@stacksjs/cms 0.70.86 → 0.70.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/cms",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.70.86",
5
+ "version": "0.70.88",
6
6
  "description": "Stacks cms utilities.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -1,15 +0,0 @@
1
- /**
2
- * Delete an author by ID
3
- *
4
- * @param id The ID of the author to delete
5
- * @returns The deleted author record
6
- */
7
- export declare function destroy(id: number): Promise<AuthorJsonResponse>;
8
- /**
9
- * Delete multiple authors by IDs
10
- *
11
- * @param ids Array of author IDs to delete
12
- * @returns The number of deleted authors
13
- */
14
- export declare function destroyMany(ids: number[]): Promise<number>;
15
- declare type AuthorJsonResponse = ModelRow<typeof Author>;
@@ -1,25 +0,0 @@
1
- /**
2
- * Fetch an author by ID
3
- */
4
- export declare function fetchById(id: number): Promise<AuthorJsonResponse | undefined>;
5
- /**
6
- * Fetch all authors
7
- */
8
- export declare function fetchAll(): Promise<AuthorJsonResponse[]>;
9
- /**
10
- * Fetch authors by name
11
- */
12
- export declare function findByName(name: string): Promise<AuthorJsonResponse | undefined>;
13
- /**
14
- * Fetch authors by email
15
- */
16
- export declare function findByEmail(email: string): Promise<AuthorJsonResponse | undefined>;
17
- /**
18
- * Fetch author by UUID
19
- */
20
- export declare function findByUuid(uuid: string): Promise<AuthorJsonResponse | undefined>;
21
- /**
22
- * Fetch authors by user ID
23
- */
24
- export declare function findByUserId(userId: number): Promise<AuthorJsonResponse | undefined>;
25
- declare type AuthorJsonResponse = ModelRow<typeof Author>;
@@ -1,18 +0,0 @@
1
- export {
2
- destroy,
3
- } from './destroy';
4
- export {
5
- fetchAll,
6
- fetchById,
7
- findByEmail,
8
- findByName,
9
- findByUserId,
10
- findByUuid,
11
- } from './fetch';
12
- export {
13
- findOrCreate,
14
- store,
15
- } from './store';
16
- export {
17
- update,
18
- } from './update';
@@ -1,20 +0,0 @@
1
- /**
2
- * Find an existing author by name or email, or create a new one if not found
3
- *
4
- * @param data The author data to find or create
5
- * @returns The found or created author record
6
- */
7
- export declare function findOrCreate(data: AuthorData): Promise<AuthorJsonResponse>;
8
- /**
9
- * Find or create an author by name or email
10
- *
11
- * @param data The author data to find or create
12
- * @returns The found or created author record
13
- */
14
- export declare function store(data: NewAuthor): Promise<AuthorJsonResponse>;
15
- declare interface AuthorData {
16
- name: string
17
- email: string
18
- }
19
- declare type AuthorJsonResponse = ModelRow<typeof Author>;
20
- declare type NewAuthor = NewModelData<typeof Author>;
@@ -1,10 +0,0 @@
1
- /**
2
- * Update an existing author
3
- *
4
- * @param id The ID of the author to update
5
- * @param data The author data to update
6
- * @returns The updated author record
7
- */
8
- export declare function update(id: number, data: Partial<NewAuthor>): Promise<AuthorJsonResponse | undefined>;
9
- declare type AuthorJsonResponse = ModelRow<typeof Author>;
10
- declare type NewAuthor = NewModelData<typeof Author>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Delete a category by ID
3
- *
4
- * @param id The ID of the category to delete
5
- * @returns True if the deletion was successful, false otherwise
6
- */
7
- export declare function destroy(id: number): Promise<boolean>;
8
- /**
9
- * Bulk delete multiple categories
10
- *
11
- * @param ids Array of category IDs to delete
12
- * @returns Number of categories successfully deleted
13
- */
14
- export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -1,30 +0,0 @@
1
- import type { CategorizableTable } from '@stacksjs/orm';
2
- /**
3
- * Fetch a category by ID
4
- */
5
- export declare function fetchById(id: number): Promise<CategorizableTable | undefined>;
6
- /**
7
- * Fetch all categories
8
- */
9
- export declare function fetchAll(): Promise<CategorizableTable[]>;
10
- /**
11
- * Fetch categories by name
12
- */
13
- export declare function fetchByName(name: string): Promise<CategorizableTable[]>;
14
- /**
15
- * Fetch category by slug
16
- */
17
- export declare function fetchBySlug(slug: string): Promise<CategorizableTable | undefined>;
18
- /**
19
- * Fetch categories with posts
20
- */
21
- export declare function fetchWithPosts(id: number): Promise<CategorizableTable | undefined>;
22
- /**
23
- * Find a category by name or create it if it doesn't exist
24
- *
25
- * @param name The name of the category to find or create
26
- * @param categorizableType Type of the categorizable entity
27
- * @param description Optional description for the category
28
- * @returns The existing or newly created category
29
- */
30
- export declare function firstOrCreate(name: string, categorizableType: string, description?: string): Promise<CategorizableTable>;
@@ -1,19 +0,0 @@
1
- export {
2
- bulkDestroy,
3
- destroy,
4
- } from './destroy';
5
- export {
6
- fetchAll,
7
- fetchById,
8
- fetchByName,
9
- fetchBySlug,
10
- fetchWithPosts,
11
- } from './fetch';
12
- export {
13
- bulkStore,
14
- store,
15
- storeCategorizableModel,
16
- } from './store';
17
- export {
18
- update,
19
- } from './update';
@@ -1,32 +0,0 @@
1
- import type { CategorizableModelsTable, CategorizableTable } from '@stacksjs/orm';
2
- /**
3
- * Create a new category and its pivot table entry
4
- *
5
- * @param data The category data to create
6
- * @returns The created category record
7
- */
8
- export declare function store(data: CategoryData): Promise<CategorizableTable>;
9
- /**
10
- * Create a new categorizable model relationship
11
- *
12
- * @param data The categorizable model data to create
13
- * @returns The created categorizable model record
14
- */
15
- export declare function storeCategorizableModel(data: CategorizableModelData): Promise<CategorizableModelsTable>;
16
- /**
17
- * Create multiple categories and their pivot table entries in a single transaction
18
- *
19
- * @param data Array of category data to create
20
- * @returns Array of created category records
21
- */
22
- export declare function bulkStore(data: CategoryData[]): Promise<CategorizableTable[]>;
23
- declare interface CategoryData {
24
- name: string
25
- description?: string
26
- categorizable_type: string
27
- is_active?: boolean
28
- }
29
- declare interface CategorizableModelData {
30
- category_id: number
31
- categorizable_type: string
32
- }
@@ -1,16 +0,0 @@
1
- import type { CategorizableTable } from '@stacksjs/orm';
2
- /**
3
- * Update a category
4
- *
5
- * @param data The category data to update (must include id)
6
- * @returns The updated category record
7
- */
8
- export declare function update(data: UpdateCategoryData): Promise<CategorizableTable>;
9
- declare interface UpdateCategoryData {
10
- id: number
11
- name?: string
12
- description?: string
13
- categorizable_type?: string
14
- is_active?: boolean
15
- slug?: string
16
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Delete a comment by ID
3
- *
4
- * @param id The ID of the comment to delete
5
- * @returns True if the deletion was successful, false otherwise
6
- */
7
- export declare function destroy(id: number): Promise<boolean>;
8
- /**
9
- * Bulk delete multiple comments
10
- *
11
- * @param ids Array of comment IDs to delete
12
- * @returns Number of comments successfully deleted
13
- */
14
- export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -1,62 +0,0 @@
1
- export declare function fetchComments(options?: {
2
- status?: Commentable['status']
3
- commentables_id?: number
4
- commentables_type?: string
5
- limit?: number
6
- offset?: number
7
- }): Promise<Commentable[]>;
8
- export declare function fetchCommentById(id: number): Promise<Commentable | undefined>;
9
- export declare function fetchCommentsByCommentables(commentables_id: number, commentables_type: string, options?: { status?: Commentable['status'], limit?: number, offset?: number }): Promise<Commentable[]>;
10
- /**
11
- * Fetch comment counts for different time periods
12
- *
13
- * @param days The number of days to look back (e.g., 7, 14, 30, 60, 90)
14
- * @returns The count of comments within the specified time period
15
- */
16
- export declare function fetchCommentCountByPeriod(days: number): Promise<number>;
17
- export declare function fetchCommentsByStatus(status: CommentStatus, options?: { limit?: number, offset?: number }): Promise<Commentable[]>;
18
- export declare function calculateApprovalRate(): Promise<{ approved: number, total: number, rate: number }>;
19
- export declare function fetchPostsWithMostComments(dateRange: DateRange, options?: { limit?: number }): Promise<PostWithCommentCount[]>;
20
- export declare function fetchCommentCountBarGraph(dateRange: DateRange, options?: { limit?: number }): Promise<BarGraphData>;
21
- export declare function fetchStatusDistributionDonut(dateRange: DateRange): Promise<DonutGraphData>;
22
- export declare function fetchMonthlyCommentCounts(dateRange: DateRange): Promise<LineGraphData>;
23
- export declare interface Commentable {
24
- id?: number
25
- title: string
26
- body: string
27
- status: string
28
- approved_at: number | null
29
- rejected_at: number | null
30
- commentables_id: number
31
- commentables_type: string
32
- reports_count?: number
33
- reported_at?: number | null
34
- upvotes_count?: number
35
- downvotes_count?: number
36
- user_id: number | null
37
- created_at?: string
38
- updated_at?: string | null
39
- }
40
- export declare interface PostWithCommentCount {
41
- id: number
42
- title: string
43
- comment_count: number
44
- }
45
- export declare interface DateRange {
46
- startDate: Date
47
- endDate: Date
48
- }
49
- export declare interface BarGraphData {
50
- labels: string[]
51
- values: number[]
52
- }
53
- export declare interface DonutGraphData {
54
- labels: string[]
55
- values: number[]
56
- percentages: number[]
57
- }
58
- export declare interface LineGraphData {
59
- labels: string[]
60
- values: number[]
61
- }
62
- export type CommentStatus = 'approved' | 'pending' | 'spam';
@@ -1,22 +0,0 @@
1
- export {
2
- bulkDestroy,
3
- destroy,
4
- } from './destroy';
5
- export {
6
- calculateApprovalRate,
7
- fetchCommentById,
8
- fetchCommentCountBarGraph,
9
- fetchCommentCountByPeriod,
10
- fetchComments,
11
- fetchCommentsByCommentables,
12
- fetchCommentsByStatus,
13
- fetchMonthlyCommentCounts,
14
- fetchPostsWithMostComments,
15
- fetchStatusDistributionDonut,
16
- } from './fetch';
17
- export {
18
- store,
19
- } from './store';
20
- export {
21
- update,
22
- } from './update';
@@ -1,35 +0,0 @@
1
- import type { CommentablesTable } from '@stacksjs/orm';
2
- export declare function createComment(data: CreateCommentInput): Promise<CommentablesTable>;
3
- export declare function updateComment(id: number, input: UpdateCommentInput): Promise<CommentablesTable>;
4
- export declare function approveComment(id: number): Promise<CommentablesTable>;
5
- export declare function rejectComment(id: number): Promise<CommentablesTable>;
6
- export declare function deleteComment(id: number): Promise<void>;
7
- /**
8
- * Create a new comment
9
- *
10
- * @param data The comment data to store
11
- * @returns The newly created comment record
12
- */
13
- export declare function store(data: CommentStore): Promise<CommentablesTable>;
14
- export declare interface CreateCommentInput {
15
- title: string
16
- body: string
17
- commentables_id: number
18
- commentables_type: string
19
- }
20
- export declare interface UpdateCommentInput {
21
- title?: string
22
- body?: string
23
- status?: string
24
- }
25
- declare interface CommentStore {
26
- title: string
27
- body: string
28
- status: string
29
- user_id: number
30
- commentables_id: number
31
- commentables_type: string
32
- is_active?: boolean | null
33
- approved_at?: number | null
34
- rejected_at?: number | null
35
- }
@@ -1,20 +0,0 @@
1
- import type { CommentablesTable } from '@stacksjs/orm';
2
- /**
3
- * Update a comment by ID
4
- *
5
- * @param id The ID of the comment to update
6
- * @param data The updated comment data
7
- * @returns The updated comment record
8
- */
9
- export declare function update(id: number, data: CommentUpdate): Promise<CommentablesTable | undefined>;
10
- declare interface CommentUpdate {
11
- title?: string
12
- body?: string
13
- status?: string
14
- approved_at?: number | null
15
- rejected_at?: number | null
16
- commentables_id?: number
17
- commentables_type?: string
18
- user_id?: number | null
19
- updated_at?: string | null
20
- }
@@ -1,2 +0,0 @@
1
- export declare function getDb(): Promise<StacksDatabase>;
2
- declare type StacksDatabase = typeof import('@stacksjs/database').db;
package/dist/index.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import * as authors from './authors/index';
2
- import * as comments from './commentables/index';
3
- import * as pages from './pages/index';
4
- import * as postCategories from './categorizables/index';
5
- import * as posts from './posts/index';
6
- import * as tags from './taggables/index';
7
- export declare const cms: CmsNamespace;
8
- export declare interface CmsNamespace {
9
- posts: PostsModule
10
- postCategories: PostCategoriesModule
11
- tags: TagsModule
12
- comments: CommentsModule
13
- authors: AuthorsModule
14
- pages: PagesModule
15
- }
16
- declare type PostsModule = typeof posts;
17
- declare type PostCategoriesModule = typeof postCategories;
18
- declare type TagsModule = typeof tags;
19
- declare type CommentsModule = typeof comments;
20
- declare type AuthorsModule = typeof authors;
21
- declare type PagesModule = typeof pages;
22
- export {
23
- authors,
24
- postCategories as categorizable,
25
- comments,
26
- pages,
27
- posts,
28
- tags,
29
- };
30
- export default cms;
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- // @bun
2
- var Df=Object.defineProperty;var uf=(f)=>f;function lf(f,M){this[f]=uf.bind(null,M)}var Q=(f,M)=>{for(var B in M)Df(f,B,{get:M[B],enumerable:!0,configurable:!0,set:lf.bind(M,B)})};var nf=import.meta.require;var V={};Q(V,{update:()=>u,store:()=>p,findOrCreate:()=>m,findByUuid:()=>q,findByUserId:()=>c,findByName:()=>I,findByEmail:()=>T,fetchById:()=>R,fetchAll:()=>v,destroy:()=>N});var h;async function x(){return h??=import("@stacksjs/database").then((f)=>f.db),h}async function N(f){let M=await x();try{let B=await M.deleteFrom("authors").where("id","=",f).returningAll().executeTakeFirst();if(!B)throw Error(`Author with ID ${f} not found`);return B}catch(B){if(B instanceof Error)throw TypeError(`Author with ID ${f} not found`);throw B}}async function R(f){return await(await x()).selectFrom("authors").where("id","=",f).selectAll().executeTakeFirst()}async function v(){return await(await x()).selectFrom("authors").selectAll().execute()}async function I(f){return await(await x()).selectFrom("authors").where("name","=",f).selectAll().executeTakeFirst()}async function T(f){return await(await x()).selectFrom("authors").where("email","=",f).selectAll().executeTakeFirst()}async function q(f){return await(await x()).selectFrom("authors").where("uuid","=",f).selectAll().executeTakeFirst()}async function c(f){return await(await x()).selectFrom("authors").where("user_id","=",f).selectAll().executeTakeFirst()}var{randomUUIDv7:w}=globalThis.Bun;import{HttpError as Z}from"@stacksjs/error-handling";import{formatDate as X,isUniqueViolation as y}from"@stacksjs/orm";async function m(f){let M=await x();try{let B=await M.selectFrom("authors").where((S)=>S.or([S("email","=",f.email),S("name","=",f.name)])).selectAll().executeTakeFirst();if(B)return B;let P=await M.selectFrom("users").where("email","=",f.email).selectAll().executeTakeFirst();if(!P){let S=await M.insertInto("users").values({email:f.email,name:f.name,password:w(),uuid:w(),created_at:X(new Date),updated_at:X(new Date)}).returningAll().executeTakeFirst();if(!S)throw Error("Failed to create user");P=S}let C={user_id:P.id,name:f.name,email:f.email,created_at:X(new Date),updated_at:X(new Date)},G=await M.insertInto("authors").values(C).returningAll().executeTakeFirst();if(!G)throw Error("Failed to create author");return G}catch(B){if(B instanceof Z)throw B;if(y(B))throw new Z(409,"An author with this email already exists");if(B instanceof Error)throw TypeError(`Failed to find or create author: ${B.message}`);throw B}}async function p(f){let M=await x();try{let B=await M.selectFrom("authors").where((G)=>G.or([G("email","=",f.email),G("name","=",f.name)])).selectAll().executeTakeFirst();if(B)return B;let P={user_id:f.user_id,name:f.name,email:f.email,created_at:X(new Date),updated_at:X(new Date)},C=await M.insertInto("authors").values(P).returningAll().executeTakeFirst();if(!C)throw Error("Failed to create author");return C}catch(B){if(B instanceof Z)throw B;if(y(B))throw new Z(409,"An author with this email already exists");if(B instanceof Error)throw TypeError(`Failed to find or create author: ${B.message}`);throw B}}import{HttpError as D}from"@stacksjs/error-handling";import{formatDate as gf,isUniqueViolation as bf}from"@stacksjs/orm";async function u(f,M){let B=await x();try{let P={...M,updated_at:gf(new Date)};return await B.updateTable("authors").set(P).where("id","=",f).returningAll().executeTakeFirst()}catch(P){if(P instanceof D)throw P;if(bf(P))throw new D(409,"An author with this email already exists");if(P instanceof Error)throw TypeError(`Failed to update author: ${P.message}`);throw P}}var E={};Q(E,{update:()=>t,storeCategorizableModel:()=>r,store:()=>d,fetchWithPosts:()=>b,fetchBySlug:()=>g,fetchByName:()=>n,fetchById:()=>$,fetchAll:()=>l,destroy:()=>s,bulkStore:()=>e,bulkDestroy:()=>i});import{slugify as EB}from"ts-slug";async function $(f){return await(await x()).selectFrom("categorizables").where("id","=",f).where("is_active","=",!0).selectAll().executeTakeFirst()}async function l(){return await(await x()).selectFrom("categorizables").selectAll().execute()}async function n(f){return await(await x()).selectFrom("categorizables").where("name","=",f).where("is_active","=",!0).selectAll().execute()}async function g(f){return await(await x()).selectFrom("categorizables").where("slug","=",f).where("is_active","=",!0).selectAll().executeTakeFirst()}async function b(f){return await(await x()).selectFrom("categorizables").where("id","=",f).where("is_active","=",!0).selectAll().executeTakeFirst()}async function s(f){let M=await x();try{if(!await $(f))throw Error(`Category with ID ${f} not found`);return(await M.deleteFrom("categorizables").where("id","=",f).executeTakeFirst()).numDeletedRows>0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete category: ${B.message}`);throw B}}async function i(f){let M=await x();if(!f.length)return 0;try{let B=await M.deleteFrom("categorizables").where("id","in",f).executeTakeFirst();return Number(B.numDeletedRows)||0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete categories in bulk: ${B.message}`);throw B}}import{slugify as o}from"ts-slug";async function d(f){let M=await x();try{if(!f.name||f.name.trim()==="")throw Error("Category name is required");if(!f.categorizable_type||f.categorizable_type.trim()==="")throw Error("Category categorizable_type is required");let B={name:f.name,slug:o(f.name),description:f.description,categorizable_type:f.categorizable_type,is_active:f.is_active??!0},P=await M.insertInto("categorizables").values(B).returningAll().executeTakeFirst();if(!P)throw Error("Failed to create category");return P}catch(B){if(B instanceof Error)throw TypeError(`Failed to create category: ${B.message}`);throw B}}async function r(f){let M=await x();try{let B={category_id:f.category_id,categorizable_type:f.categorizable_type},P=await M.insertInto("categorizable_models").values(B).returningAll().executeTakeFirst();if(!P)throw Error("Failed to create categorizable model relationship");return P}catch(B){if(B instanceof Error)throw TypeError(`Failed to create categorizable model relationship: ${B.message}`);throw B}}async function e(f){let M=await x();try{return await M.transaction(async(P)=>{let C=[];for(let G of f){let S={name:G.name,slug:o(G.name),description:G.description,categorizable_type:G.categorizable_type,is_active:G.is_active??!0},A=await P.insertInto("categorizables").values(S).returningAll().executeTakeFirst();if(!A)throw Error(`Failed to create category: ${G.name}`);C.push(A)}return C})}catch(B){if(B instanceof Error)throw TypeError(`Failed to create categories: ${B.message}`);throw B}}import{slugify as sf}from"ts-slug";async function t(f){let M=await x();try{let B=f.id;if(!B)throw Error("Category ID is required for update");if(f.name!==void 0){if(f.name.trim()==="")throw Error("Category name cannot be empty");f.slug=sf(f.name)}let{id:P,...C}=f,G=await M.updateTable("categorizables").set(C).where("id","=",B).returningAll().executeTakeFirst();if(!G)throw Error("Failed to update category");return G}catch(B){if(B instanceof Error)throw TypeError(`Failed to update category: ${B.message}`);throw B}}var _={};Q(_,{update:()=>Jf,store:()=>Af,fetchStatusDistributionDonut:()=>Cf,fetchPostsWithMostComments:()=>H,fetchMonthlyCommentCounts:()=>Gf,fetchCommentsByStatus:()=>Mf,fetchCommentsByCommentables:()=>ff,fetchComments:()=>a,fetchCommentCountByPeriod:()=>Bf,fetchCommentCountBarGraph:()=>xf,fetchCommentById:()=>z,destroy:()=>Sf,calculateApprovalRate:()=>Pf,bulkDestroy:()=>Wf});import{formatDate as Y}from"@stacksjs/orm";async function a(f={}){let B=(await x()).selectFrom("commentables");if(f.status)B=B.where("status","=",f.status);if(f.commentables_id)B=B.where("commentables_id","=",f.commentables_id);if(f.commentables_type)B=B.where("commentables_type","=",f.commentables_type);if(f.limit)B=B.limit(f.limit);if(f.offset)B=B.offset(f.offset);return B.selectAll().execute()}async function z(f){return(await x()).selectFrom("commentables").where("id","=",f).selectAll().executeTakeFirst()}async function ff(f,M,B={}){let C=(await x()).selectFrom("commentables").where("commentables_id","=",f).where("commentables_type","=",M);if(B.status)C=C.where("status","=",B.status);if(B.limit)C=C.limit(B.limit);if(B.offset)C=C.offset(B.offset);return C.selectAll().execute()}async function Bf(f){let M=await x();try{let B=await M.selectFrom("commentables").where("created_at",">=",new Date(Date.now()-f*24*60*60*1000).toISOString()).count();return Number(B)||0}catch(B){if(B instanceof Error)throw TypeError(`Failed to fetch comment count: ${B.message}`);throw B}}async function Mf(f,M={}){let B=await x();try{let P=B.selectFrom("commentables").where("status","=",f);if(M.limit)P=P.limit(M.limit);if(M.offset)P=P.offset(M.offset);return P.selectAll().execute()}catch(P){if(P instanceof Error)throw TypeError(`Failed to fetch comments by status: ${P.message}`);throw P}}async function Pf(){let f=await x();try{let[M,B]=await Promise.all([f.selectFrom("commentables").where("status","=","approved").count(),f.selectFrom("commentables").count()]),P=Number(M||0),C=Number(B||0),G=C>0?P/C*100:0;return{approved:P,total:C,rate:G}}catch(M){if(M instanceof Error)throw TypeError(`Failed to calculate approval rate: ${M.message}`);throw M}}async function H(f,M={}){let B=await x();try{let P=B.selectFrom("posts").leftJoin("commentables","posts.id","=","commentables.commentables_id").where("commentables.created_at",">=",Y(f.startDate)).where("commentables.created_at","<=",Y(f.endDate)).select(["posts.id","posts.title"]).groupBy("posts.id","posts.title").orderBy("posts.id","desc");if(M.limit)P=P.limit(M.limit);return(await P.execute()).map((G)=>({id:Number(G.id),title:String(G.title),comment_count:Number(G.comment_count||0)}))}catch(P){if(P instanceof Error)throw TypeError(`Failed to fetch posts with most comments: ${P.message}`);throw P}}async function xf(f,M={}){try{let B=await H(f,M);return{labels:B.map((P)=>P.title),values:B.map((P)=>P.comment_count)}}catch(B){if(B instanceof Error)throw TypeError(`Failed to fetch bar graph data: ${B.message}`);throw B}}async function Cf(f){let M=await x();try{let P=await M.selectFrom("commentables").where("created_at",">=",Y(f.startDate)).where("created_at","<=",Y(f.endDate)).select(["status"]).groupBy("status").execute(),C=P.reduce((W,L)=>W+Number(L.count||0),0),G=P.map((W)=>String(W.status)),S=P.map((W)=>Number(W.count||0)),A=S.map((W)=>C>0?W/C*100:0);return{labels:G,values:S,percentages:A}}catch(B){if(B instanceof Error)throw TypeError(`Failed to fetch status distribution: ${B.message}`);throw B}}async function Gf(f){let M=await x();try{let B=await M.selectFrom("commentables").where("created_at",">=",Y(f.startDate)).where("created_at","<=",Y(f.endDate)).select(["created_at"]).groupBy("created_at").orderBy("created_at","asc").execute(),P=new Map;B.forEach((S)=>{if(!S.created_at)return;let A=new Date(S.created_at),W=`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}`;P.set(W,(P.get(W)||0)+Number(S.count||0))});let C=[],G=[];return P.forEach((S,A)=>{let[W,L]=A.split("-");C.push(new Date(Number(W),Number(L)-1).toLocaleString("default",{month:"short",year:"numeric"})),G.push(S)}),{labels:C,values:G}}catch(B){if(B instanceof Error)throw TypeError(`Failed to fetch monthly comment counts: ${B.message}`);throw B}}async function Sf(f){let M=await x();try{if(!await z(f))throw Error(`Comment with ID ${f} not found`);return(await M.deleteFrom("commentables").where("id","=",f).executeTakeFirst()).numDeletedRows>0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete comment: ${B.message}`);throw B}}async function Wf(f){let M=await x();if(!f.length)return 0;try{let B=await M.deleteFrom("commentables").where("id","in",f).executeTakeFirst();return Number(B.numDeletedRows)||0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete comments in bulk: ${B.message}`);throw B}}async function Af(f){let M=await x();try{if(!f.title||f.title.trim()==="")throw Error("Comment title is required");if(!f.body||f.body.trim()==="")throw Error("Comment body is required");if(!f.commentables_type||f.commentables_type.trim()==="")throw Error("Comment commentables_type is required");let B=["pending","approved","rejected"];if(f.status&&!B.includes(f.status))throw Error(`Invalid comment status: ${f.status}`);let P={title:f.title,body:f.body,status:f.status,commentables_id:f.commentables_id,commentables_type:f.commentables_type,user_id:f.user_id,is_active:f.is_active},C=await M.insertInto("commentables").values(P).returningAll().executeTakeFirst();if(!C)throw Error("Failed to create comment");return C}catch(B){if(B instanceof Error)throw TypeError(`Failed to store comment: ${B.message}`);throw B}}import{formatDate as of}from"@stacksjs/orm";async function Jf(f,M){let B=await x();try{if(M.title!==void 0&&M.title.trim()==="")throw Error("Comment title cannot be empty");if(M.body!==void 0&&M.body.trim()==="")throw Error("Comment body cannot be empty");let P=["pending","approved","rejected"];if(M.status!==void 0&&!P.includes(M.status))throw Error(`Invalid comment status: ${M.status}`);let C={updated_at:of(new Date)};if(M.title!==void 0)C.title=M.title;if(M.body!==void 0)C.body=M.body;if(M.status!==void 0)C.status=M.status;if(M.commentables_id!==void 0)C.commentables_id=M.commentables_id;if(M.commentables_type!==void 0)C.commentables_type=M.commentables_type;if(M.approved_at!==void 0)C.approved_at=M.approved_at;if(M.rejected_at!==void 0)C.rejected_at=M.rejected_at;return await B.updateTable("commentables").set(C).where("id","=",f).execute(),await B.selectFrom("commentables").where("id","=",f).selectAll().executeTakeFirst()}catch(P){if(P instanceof Error)throw TypeError(`Failed to update comment: ${P.message}`);throw P}}var j={};Q(j,{update:()=>Kf,store:()=>kf,fetchPublishedAfter:()=>Zf,fetchByMinViews:()=>Xf,fetchByMinConversions:()=>Yf,fetchById:()=>O,fetchByAuthor:()=>Qf,fetchAll:()=>Lf,destroy:()=>$f,bulkDestroy:()=>zf});async function O(f){return await(await x()).selectFrom("pages").where("id","=",f).selectAll().executeTakeFirst()}async function Lf(){return await(await x()).selectFrom("pages").selectAll().execute()}async function Qf(f){return await(await x()).selectFrom("pages").where("author_id","=",f).selectAll().execute()}async function Xf(f){return await(await x()).selectFrom("pages").where("views",">=",f).selectAll().execute()}async function Yf(f){return await(await x()).selectFrom("pages").where("conversions",">=",f).selectAll().execute()}async function Zf(f){return await(await x()).selectFrom("pages").where("published_at",">",f).selectAll().execute()}async function $f(f){let M=await x();try{if(!await O(f))throw Error(`Page with ID ${f} not found`);return(await M.deleteFrom("pages").where("id","=",f).executeTakeFirst()).numDeletedRows>0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete page: ${B.message}`);throw B}}async function zf(f){let M=await x();if(!f.length)return 0;try{let B=await M.deleteFrom("pages").where("id","in",f).executeTakeFirst();return Number(B.numDeletedRows)||0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete pages in bulk: ${B.message}`);throw B}}import{formatDate as Of}from"@stacksjs/orm";async function kf(f){let M=await x();try{let B={author_id:f.author_id,title:f.title,template:f.template,views:f.views||0,conversions:f.conversions||0,created_at:Of(new Date),updated_at:Of(new Date)},P=await M.insertInto("pages").values(B).returningAll().executeTakeFirst();if(!P)throw Error("Failed to create page");return P}catch(B){if(B instanceof Error)throw TypeError(`Failed to create page: ${B.message}`);throw B}}import{formatDate as df}from"@stacksjs/orm";async function Kf(f,M){let B=await x();try{let P={...M,updated_at:df(new Date)},C=await B.updateTable("pages").set(P).where("id","=",f).returningAll().executeTakeFirst();if(!C)throw Error("Failed to update page");return C}catch(P){if(P instanceof Error)throw TypeError(`Failed to update page: ${P.message}`);throw P}}var U={};Q(U,{update:()=>Tf,sync:()=>If,store:()=>Nf,fetchPublishedAfter:()=>Uf,fetchByStatus:()=>Ef,fetchByMinViews:()=>jf,fetchById:()=>k,fetchByCategory:()=>Hf,fetchByAuthor:()=>_f,fetchAll:()=>Vf,detach:()=>vf,destroy:()=>Ff,bulkDestroy:()=>hf,attach:()=>Rf});async function k(f){return await(await x()).selectFrom("posts").where("id","=",f).selectAll().executeTakeFirst()}async function Vf(){return await(await x()).selectFrom("posts").selectAll().execute()}async function Ef(f){return await(await x()).selectFrom("posts").where("status","=",f).selectAll().execute()}async function Hf(f){return await(await x()).selectFrom("posts").where("category","=",f).selectAll().execute()}async function _f(f){return await(await x()).selectFrom("posts").where("author","=",f).selectAll().execute()}async function jf(f){return await(await x()).selectFrom("posts").where("views",">=",f).selectAll().execute()}async function Uf(f){return await(await x()).selectFrom("posts").where("published_at",">",f).selectAll().execute()}async function Ff(f){let M=await x();try{if(!await k(f))throw Error(`Post with ID ${f} not found`);await M.deleteFrom("categorizable_models").where("categorizable_id","=",f).where("categorizable_type","=","posts").execute();let P=await M.deleteFrom("posts").where("id","=",f).executeTakeFirst();return P?.numDeletedRows?P.numDeletedRows>0:!1}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete post: ${B.message}`);throw B}}async function hf(f){let M=await x();if(!f.length)return 0;try{let P=(await M.selectFrom("posts").select(["id"]).where("id","in",f).execute()).map((G)=>G.id);if(!P.length)return 0;await M.deleteFrom("categorizable_models").where("categorizable_id","in",P).where("categorizable_type","=","posts").execute();let C=await M.deleteFrom("posts").where("id","in",P).executeTakeFirst();return Number(C?.numDeletedRows)||0}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete posts in bulk: ${B.message}`);throw B}}var{randomUUIDv7:rf}=globalThis.Bun;import{formatDate as K}from"@stacksjs/orm";var ef="Draft";async function Nf(f){let M=await x();try{if(!f.title||typeof f.title==="string"&&f.title.trim()==="")throw Error("Post title is required");let B=f.content||f.body,P=f,C={author_id:P.author_id,uuid:rf(),title:f.title,poster:f.poster,content:B,body:f.body,category:f.category,excerpt:f.excerpt,is_featured:P.is_featured?Date.now():void 0,views:f.views||0,published_at:P.published_at||Date.now(),status:f.status||ef},G=await M.insertInto("posts").values(C).returningAll().executeTakeFirst();if(!G)throw Error("Failed to create post");return G}catch(B){if(B instanceof Error)throw TypeError(`Failed to create post: ${B.message}`);throw B}}async function Rf(f,M,B){let P=await x();try{let C=M==="categorizable_models"?"categorizable_id":"taggable_id",G=M==="categorizable_models"?"categorizable_type":"taggable_type",S=M==="categorizable_models"?"category_id":"tag_id",A=B.map((W)=>({[S]:W,[C]:f,[G]:"posts",created_at:K(new Date),updated_at:K(new Date)}));for(let W of A)await P.insertInto(M).values(W).execute()}catch(C){if(C instanceof Error)throw TypeError(`Failed to attach records: ${C.message}`);throw C}}async function vf(f,M,B){let P=await x();try{let C=M==="categorizable_models"?"categorizable_id":"taggable_id",G=M==="categorizable_models"?"categorizable_type":"taggable_type",S=P.deleteFrom(M).where(C,"=",f).where(G,"=","posts");if(B)S=S.where("id","in",B);await S.execute()}catch(C){if(C instanceof Error)throw TypeError(`Failed to detach records: ${C.message}`);throw C}}async function If(f,M,B){let P=await x();try{let C=M==="categorizable_models"?"categorizable_id":"taggable_id",G=M==="categorizable_models"?"categorizable_type":"taggable_type",A=(await P.selectFrom(M).select(["id"]).where(C,"=",f).where(G,"=","posts").execute()).map((J)=>J.id),W=A.filter((J)=>!B.includes(J)),L=B.filter((J)=>!A.includes(J));if(W.length>0)await P.deleteFrom(M).where(C,"=",f).where(G,"=","posts").where("id","in",W).execute();if(L.length>0){let J=L.map(()=>({[C]:f,[G]:"posts",created_at:K(new Date),updated_at:K(new Date)}));await P.insertInto(M).values(J).execute()}}catch(C){if(C instanceof Error)throw TypeError(`Failed to sync records: ${C.message}`);throw C}}async function Tf(f,M){let B=await x();try{if(M.title!==void 0&&typeof M.title==="string"&&M.title.trim()==="")throw Error("Post title cannot be empty");let P=["published","draft","archived"];if(M.status!==void 0&&typeof M.status==="string"&&!P.includes(M.status))throw Error(`Invalid post status: ${M.status}`);if(M.views!==void 0&&typeof M.views==="number"&&M.views<0)throw Error("Views count cannot be negative");let C=await B.updateTable("posts").set(M).where("id","=",f).returningAll().executeTakeFirst();if(!C)throw Error("Failed to update post");return C}catch(P){if(P instanceof Error)throw TypeError(`Failed to update post: ${P.message}`);throw P}}var F={};Q(F,{update:()=>pf,store:()=>wf,fetchTags:()=>mf,fetchTagById:()=>yf,destroy:()=>qf,bulkDestroy:()=>cf});async function qf(f){let M=await x();if(!await M.selectFrom("taggables").where("id","=",f).selectAll().executeTakeFirst())throw Error(`Tag with ID ${f} not found`);await M.deleteFrom("taggables").where("id","=",f).executeTakeFirst()}async function cf(f){let M=await x();try{await M.deleteFrom("taggables").where("id","in",f).execute()}catch(B){if(B instanceof Error)throw TypeError(`Failed to delete tags: ${B.message}`);throw B}}import{slugify as tf}from"ts-slug";async function wf(f){let M=await x();try{if(!f.name||f.name.trim()==="")throw Error("Tag name is required");if(!f.taggable_type||f.taggable_type.trim()==="")throw Error("Tag taggable_type is required");let B=tf(f.name);if(await M.selectFrom("taggables").selectAll().where("slug","=",B).executeTakeFirst())throw Error(`Tag with unique slug "${B}" already exists`);let C={name:f.name,slug:B,description:f.description,is_active:f.is_active??!0,taggable_type:f.taggable_type};if(f.taggable_id!==void 0)C.taggable_id=f.taggable_id;let G=await M.insertInto("taggables").values(C).returningAll().executeTakeFirst();if(!G)throw Error("Failed to create tag");return G}catch(B){if(B instanceof Error)throw TypeError(`Failed to store tag: ${B.message}`);throw B}}async function yf(f){let M=await x();try{let B=await M.selectFrom("taggables").where("id","=",f).selectAll().executeTakeFirst();if(!B)return;return B}catch(B){if(B instanceof Error)throw TypeError(`Failed to fetch tag: ${B.message}`);throw B}}async function mf(){let f=await x();try{return await f.selectFrom("taggables").where("is_active","=",!0).selectAll().execute()}catch(M){if(M instanceof Error)throw TypeError(`Failed to fetch tags: ${M.message}`);throw M}}import{uniqueSlug as af}from"@stacksjs/slug";async function pf(f){let M=await x();try{let B=f.id;if(!B)throw Error("Tag ID is required for update");if(f.name!==void 0){if(f.name.trim()==="")throw Error("Tag name cannot be empty");let S=await af(f.name,{table:"taggables",column:"slug"});if(await M.selectFrom("taggables").selectAll().where("slug","=",S).where("id","!=",B).executeTakeFirst())throw Error(`Tag with unique slug "${S}" already exists`);f.slug=S}let{id:P,...C}=f,G=await M.updateTable("taggables").set(C).where("id","=",B).returningAll().executeTakeFirst();if(!G)throw Error("Failed to update tag");return G}catch(B){if(B instanceof Error)throw TypeError(`Failed to update tag: ${B.message}`);throw B}}var fB={posts:U,postCategories:E,tags:F,comments:_,authors:V,pages:j},nM=fB;export{F as tags,U as posts,j as pages,nM as default,_ as comments,fB as cms,E as categorizable,V as authors};
@@ -1,14 +0,0 @@
1
- /**
2
- * Delete a page by ID
3
- *
4
- * @param id The ID of the page to delete
5
- * @returns True if the deletion was successful, false otherwise
6
- */
7
- export declare function destroy(id: number): Promise<boolean>;
8
- /**
9
- * Bulk delete multiple pages
10
- *
11
- * @param ids Array of page IDs to delete
12
- * @returns Number of pages successfully deleted
13
- */
14
- export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -1,29 +0,0 @@
1
- /**
2
- * Fetch a page by ID
3
- */
4
- export declare function fetchById(id: number): Promise<PageJsonResponse | undefined>;
5
- /**
6
- * Fetch all pages
7
- */
8
- export declare function fetchAll(): Promise<PageJsonResponse[]>;
9
- /**
10
- * Fetch pages by template
11
- */
12
- export declare function fetchByTemplate(template: string): Promise<PageJsonResponse[]>;
13
- /**
14
- * Fetch pages by author
15
- */
16
- export declare function fetchByAuthor(authorId: number): Promise<PageJsonResponse[]>;
17
- /**
18
- * Fetch pages with minimum views
19
- */
20
- export declare function fetchByMinViews(minViews: number): Promise<PageJsonResponse[]>;
21
- /**
22
- * Fetch pages with minimum conversions
23
- */
24
- export declare function fetchByMinConversions(minConversions: number): Promise<PageJsonResponse[]>;
25
- /**
26
- * Fetch pages published after a specific date
27
- */
28
- export declare function fetchPublishedAfter(timestamp: number): Promise<PageJsonResponse[]>;
29
- declare type PageJsonResponse = ModelRow<typeof Page>;
@@ -1,18 +0,0 @@
1
- export {
2
- bulkDestroy,
3
- destroy,
4
- } from './destroy';
5
- export {
6
- fetchAll,
7
- fetchByAuthor,
8
- fetchById,
9
- fetchByMinConversions,
10
- fetchByMinViews,
11
- fetchPublishedAfter,
12
- } from './fetch';
13
- export {
14
- store,
15
- } from './store';
16
- export {
17
- update,
18
- } from './update';
@@ -1,9 +0,0 @@
1
- /**
2
- * Create a new page
3
- *
4
- * @param data The page data to create
5
- * @returns The created page record
6
- */
7
- export declare function store(data: NewPage): Promise<PageJsonResponse>;
8
- declare type PageJsonResponse = ModelRow<typeof Page>;
9
- declare type NewPage = NewModelData<typeof Page>;
@@ -1,10 +0,0 @@
1
- /**
2
- * Update a page
3
- *
4
- * @param id The id of the page to update
5
- * @param data The page data to update
6
- * @returns The updated page record
7
- */
8
- export declare function update(id: number, data: Partial<PageUpdate>): Promise<PageJsonResponse>;
9
- declare type PageJsonResponse = ModelRow<typeof Page>;
10
- declare type PageUpdate = UpdateModelData<typeof Page>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Delete a post by ID
3
- *
4
- * @param id The ID of the post to delete
5
- * @returns True if the deletion was successful, false otherwise
6
- */
7
- export declare function destroy(id: number): Promise<boolean>;
8
- /**
9
- * Bulk delete multiple posts
10
- *
11
- * @param ids Array of post IDs to delete
12
- * @returns Number of posts successfully deleted
13
- */
14
- export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -1,29 +0,0 @@
1
- /**
2
- * Fetch a post by ID
3
- */
4
- export declare function fetchById(id: number): Promise<PostJsonResponse | undefined>;
5
- /**
6
- * Fetch all posts
7
- */
8
- export declare function fetchAll(): Promise<PostJsonResponse[]>;
9
- /**
10
- * Fetch posts by status
11
- */
12
- export declare function fetchByStatus(status: 'published' | 'draft' | 'archived'): Promise<PostJsonResponse[]>;
13
- /**
14
- * Fetch posts by category
15
- */
16
- export declare function fetchByCategory(category: string): Promise<PostJsonResponse[]>;
17
- /**
18
- * Fetch posts by author
19
- */
20
- export declare function fetchByAuthor(author: string): Promise<PostJsonResponse[]>;
21
- /**
22
- * Fetch posts with minimum views
23
- */
24
- export declare function fetchByMinViews(minViews: number): Promise<PostJsonResponse[]>;
25
- /**
26
- * Fetch posts published after a specific date
27
- */
28
- export declare function fetchPublishedAfter(timestamp: number): Promise<PostJsonResponse[]>;
29
- declare type PostJsonResponse = ModelRow<typeof Post>;
@@ -1,22 +0,0 @@
1
- export {
2
- bulkDestroy,
3
- destroy,
4
- } from './destroy';
5
- export {
6
- fetchAll,
7
- fetchByAuthor,
8
- fetchByCategory,
9
- fetchById,
10
- fetchByMinViews,
11
- fetchByStatus,
12
- fetchPublishedAfter,
13
- } from './fetch';
14
- export {
15
- attach,
16
- detach,
17
- store,
18
- sync,
19
- } from './store';
20
- export {
21
- update,
22
- } from './update';
@@ -1,40 +0,0 @@
1
- /**
2
- * Create a new post
3
- *
4
- * @param data The post data to create
5
- * @returns The created post record
6
- */
7
- export declare function store(data: NewPost & { body?: string, category?: string }): Promise<PostJsonResponse & { body?: string, category?: string }>;
8
- /**
9
- * Attach related records to a post through a pivot table
10
- *
11
- * @param postId The ID of the post to attach records to
12
- * @param tableName The name of the pivot table (e.g., 'categorizable_models', 'taggable')
13
- * @param ids Array of IDs to attach
14
- * @returns Promise<void>
15
- */
16
- export declare function attach(postId: number, tableName: 'categorizable_models' | 'taggable_models', ids: number[]): Promise<void>;
17
- /**
18
- * Detach related records from a post through a pivot table
19
- *
20
- * @param postId The ID of the post to detach records from
21
- * @param tableName The name of the pivot table (e.g., 'categorizable_models', 'taggable')
22
- * @param ids Optional array of IDs to detach. If not provided, all related records will be detached
23
- * @returns Promise<void>
24
- */
25
- export declare function detach(postId: number, tableName: 'categorizable_models' | 'taggable_models', ids?: number[]): Promise<void>;
26
- /**
27
- * Synchronize related records for a post through a pivot table
28
- * This will detach relationships not in the new set and attach only new relationships
29
- *
30
- * @param postId The ID of the post to sync records for
31
- * @param tableName The name of the pivot table (e.g., 'categorizable_models', 'taggable')
32
- * @param ids Array of IDs to sync
33
- * @returns Promise<void>
34
- */
35
- export declare function sync(postId: number, tableName: 'categorizable_models' | 'taggable_models', ids: number[]): Promise<void>;
36
- export declare const POST_STATUS_DRAFT: 'Draft';
37
- export declare const POST_STATUS_PUBLISHED: 'Published';
38
- export declare const POST_STATUS_ARCHIVED: 'Archived';
39
- declare type PostJsonResponse = ModelRow<typeof Post>;
40
- declare type NewPost = NewModelData<typeof Post>;
@@ -1,10 +0,0 @@
1
- /**
2
- * Update a post
3
- *
4
- * @param id The id of the post to update
5
- * @param data The post data to update
6
- * @returns The updated post record
7
- */
8
- export declare function update(id: number, data: Partial<PostUpdate>): Promise<PostJsonResponse>;
9
- declare type PostJsonResponse = ModelRow<typeof Post>;
10
- declare type PostUpdate = UpdateModelData<typeof Post>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Delete a tag by its ID
3
- *
4
- * @param id The ID of the tag to delete
5
- * @returns void
6
- */
7
- export declare function destroy(id: number): Promise<void>;
8
- /**
9
- * Delete multiple tags by their IDs
10
- *
11
- * @param ids An array of tag IDs to delete
12
- * @returns void
13
- */
14
- export declare function bulkDestroy(ids: number[]): Promise<void>;
@@ -1,61 +0,0 @@
1
- import type { TaggableTable } from '@stacksjs/orm';
2
- /**
3
- * Fetch a tag by its ID
4
- *
5
- * @param id The ID of the tag to fetch
6
- * @returns The tag record if found
7
- */
8
- export declare function fetchTagById(id: number): Promise<TaggableTable | undefined>;
9
- /**
10
- * Fetch all tags
11
- *
12
- * @returns An array of tag records
13
- */
14
- export declare function fetchTags(): Promise<TaggableTable[]>;
15
- /**
16
- * Find a tag by name or create it if it doesn't exist
17
- *
18
- * @param name The name of the tag to find or create
19
- * @param taggableType Type of the taggable entity
20
- * @param description Optional description for the tag
21
- * @returns The existing or newly created tag
22
- */
23
- export declare function firstOrCreate(name: string, taggableType: string, description?: string): Promise<TaggableTable>;
24
- /**
25
- * Count the number of posts that have been tagged
26
- *
27
- * @param taggableType The type of entity to count (e.g. 'posts')
28
- * @returns The count of tagged posts
29
- */
30
- export declare function countTaggedPosts(taggableType: string): Promise<number>;
31
- /**
32
- * Count the total number of tags in the system
33
- *
34
- * @returns The total count of tags
35
- */
36
- export declare function countTotalTags(): Promise<number>;
37
- /**
38
- * Find the most used tag in the system
39
- *
40
- * @param taggableType Optional type to filter by (e.g. 'posts', 'articles')
41
- * @returns The most used tag name and its count
42
- */
43
- export declare function findMostUsedTag(taggableType?: string): Promise<{ name: string, count: number } | null>;
44
- /**
45
- * Find the least used tag in the system
46
- *
47
- * @returns The least used tag name and its count
48
- */
49
- export declare function findLeastUsedTag(): Promise<{ name: string, count: number } | null>;
50
- /**
51
- * Fetch tags with their post counts
52
- *
53
- * @returns Array of tags with their post counts
54
- */
55
- export declare function fetchTagsWithPostCounts(): Promise<Array<{ name: string, postCount: number }>>;
56
- /**
57
- * Fetch tag distribution data for a donut graph
58
- *
59
- * @returns Array of tags with their counts and percentages
60
- */
61
- export declare function fetchTagDistribution(): Promise<Array<{ name: string, count: number, percentage: number }>>;
@@ -1,14 +0,0 @@
1
- export {
2
- bulkDestroy,
3
- destroy,
4
- } from './destroy';
5
- export {
6
- fetchTagById,
7
- fetchTags,
8
- } from './fetch';
9
- export {
10
- store,
11
- } from './store';
12
- export {
13
- update,
14
- } from './update';
@@ -1,30 +0,0 @@
1
- import type { TaggableTable } from '@stacksjs/orm';
2
- /**
3
- * Find or create multiple tags by their names
4
- *
5
- * @param names Array of tag names to process
6
- * @param taggableType The type of model these tags belong to
7
- * @returns Array of tag IDs
8
- */
9
- export declare function findOrCreateMany(names: string[], taggableType: string): Promise<number[]>;
10
- /**
11
- * Find or create a single tag
12
- *
13
- * @param data The tag data
14
- * @returns The found or created tag
15
- */
16
- export declare function findOrCreate(data: TagData): Promise<TaggableTable>;
17
- /**
18
- * Create a new tag
19
- *
20
- * @param data The tag data to store
21
- * @returns The newly created tag record
22
- */
23
- export declare function store(data: TagData): Promise<TaggableTable>;
24
- declare interface TagData {
25
- name: string
26
- description?: string
27
- is_active?: boolean
28
- taggable_id?: number
29
- taggable_type: string
30
- }
@@ -1,18 +0,0 @@
1
- import type { TaggableTable } from '@stacksjs/orm';
2
- /**
3
- * Update a tag
4
- *
5
- * @param id The tag id
6
- * @param data The tag data to update
7
- * @returns The updated tag record
8
- */
9
- export declare function update(data: UpdateTagData): Promise<TaggableTable>;
10
- declare interface UpdateTagData {
11
- id: number
12
- name?: string
13
- slug?: string
14
- description?: string
15
- is_active?: boolean
16
- taggable_id?: number
17
- taggable_type?: string
18
- }