@btst/stack 1.1.10 → 1.2.0

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.
@@ -2,47 +2,94 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.Cr2JoQdo.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Options for the usePosts hook
7
+ */
5
8
  interface UsePostsOptions {
9
+ /** Filter posts by tag name */
6
10
  tag?: string;
11
+ /** Filter posts by tag slug */
7
12
  tagSlug?: string;
13
+ /** Number of posts to fetch per page (default: 10) */
8
14
  limit?: number;
15
+ /** Whether to enable the query (default: true) */
9
16
  enabled?: boolean;
17
+ /** Search query to filter posts by title, content, or excerpt */
10
18
  query?: string;
19
+ /** Filter by published status */
11
20
  published?: boolean;
21
+ /** Filter by specific post slug */
12
22
  slug?: string;
13
23
  }
24
+ /**
25
+ * Result from the usePosts hook
26
+ */
14
27
  interface UsePostsResult {
28
+ /** Array of fetched posts */
15
29
  posts: SerializedPost[];
30
+ /** Whether the initial load is in progress */
16
31
  isLoading: boolean;
32
+ /** Error if the query failed */
17
33
  error: Error | null;
34
+ /** Function to load the next page of posts */
18
35
  loadMore: () => void;
36
+ /** Whether there are more posts to load */
19
37
  hasMore: boolean;
38
+ /** Whether the next page is being loaded */
20
39
  isLoadingMore: boolean;
40
+ /** Function to refetch the posts */
21
41
  refetch: () => void;
22
42
  }
43
+ /**
44
+ * Options for the usePostSearch hook
45
+ */
23
46
  interface UsePostSearchOptions {
47
+ /** Search query string to filter posts */
24
48
  query: string;
49
+ /** Whether to enable the search query (default: true) */
25
50
  enabled?: boolean;
51
+ /** Debounce delay in milliseconds (default: 300) */
26
52
  debounceMs?: number;
53
+ /** Number of results to return (default: 10) */
27
54
  limit?: number;
55
+ /** Filter by published status (default: true) */
28
56
  published?: boolean;
29
57
  }
58
+ /**
59
+ * Result from the usePostSearch hook
60
+ */
30
61
  interface UsePostSearchResult {
62
+ /** Array of posts matching the search query */
31
63
  posts: SerializedPost[];
64
+ /** Alias for posts (React Query compatibility) */
32
65
  data: SerializedPost[];
66
+ /** Whether the search is in progress */
33
67
  isLoading: boolean;
68
+ /** Error if the search failed */
34
69
  error: Error | null;
70
+ /** Function to refetch the search results */
35
71
  refetch: () => void;
72
+ /** Whether a search is currently in progress (includes debounce time) */
36
73
  isSearching: boolean;
74
+ /** The debounced search query being used */
37
75
  searchQuery: string;
38
76
  }
77
+ /**
78
+ * Result from the usePost hook
79
+ */
39
80
  interface UsePostResult {
81
+ /** The fetched post, or null if not found */
40
82
  post: SerializedPost | null;
83
+ /** Whether the post is being loaded */
41
84
  isLoading: boolean;
85
+ /** Error if the query failed */
42
86
  error: Error | null;
87
+ /** Function to refetch the post */
43
88
  refetch: () => void;
44
89
  }
90
+ /** Input type for creating a new post */
45
91
  type PostCreateInput = z.infer<typeof createPostSchema>;
92
+ /** Input type for updating an existing post */
46
93
  type PostUpdateInput = z.infer<typeof updatePostSchema>;
47
94
  /**
48
95
  * Hook for fetching paginated posts with load more functionality
@@ -114,14 +161,26 @@ declare function useDeletePost(): _tanstack_react_query.UseMutationResult<{
114
161
  * Debounces the query and preserves last successful results to avoid flicker.
115
162
  */
116
163
  declare function usePostSearch({ query, enabled, debounceMs, limit, published, }: UsePostSearchOptions): UsePostSearchResult;
164
+ /**
165
+ * Options for the useNextPreviousPosts hook
166
+ */
117
167
  interface UseNextPreviousPostsOptions {
168
+ /** Whether to enable the query (default: true) */
118
169
  enabled?: boolean;
119
170
  }
171
+ /**
172
+ * Result from the useNextPreviousPosts hook
173
+ */
120
174
  interface UseNextPreviousPostsResult {
175
+ /** The previous post (older), or null if none exists */
121
176
  previousPost: SerializedPost | null;
177
+ /** The next post (newer), or null if none exists */
122
178
  nextPost: SerializedPost | null;
179
+ /** Whether the query is loading */
123
180
  isLoading: boolean;
181
+ /** Error if the query failed */
124
182
  error: Error | null;
183
+ /** Function to refetch the posts */
125
184
  refetch: () => void;
126
185
  }
127
186
  /**
@@ -132,15 +191,28 @@ declare function useNextPreviousPosts(createdAt: string | Date, options?: UseNex
132
191
  ref: (node: Element | null) => void;
133
192
  inView: boolean;
134
193
  };
194
+ /**
195
+ * Options for the useRecentPosts hook
196
+ */
135
197
  interface UseRecentPostsOptions {
198
+ /** Maximum number of recent posts to fetch (default: 5) */
136
199
  limit?: number;
200
+ /** Slug of a post to exclude from results */
137
201
  excludeSlug?: string;
202
+ /** Whether to enable the query (default: true) */
138
203
  enabled?: boolean;
139
204
  }
205
+ /**
206
+ * Result from the useRecentPosts hook
207
+ */
140
208
  interface UseRecentPostsResult {
209
+ /** Array of recent posts */
141
210
  recentPosts: SerializedPost[];
211
+ /** Whether the query is loading */
142
212
  isLoading: boolean;
213
+ /** Error if the query failed */
143
214
  error: Error | null;
215
+ /** Function to refetch the posts */
144
216
  refetch: () => void;
145
217
  }
146
218
  /**
@@ -2,47 +2,94 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.Cr2JoQdo.js';
3
3
  import { z } from 'zod';
4
4
 
5
+ /**
6
+ * Options for the usePosts hook
7
+ */
5
8
  interface UsePostsOptions {
9
+ /** Filter posts by tag name */
6
10
  tag?: string;
11
+ /** Filter posts by tag slug */
7
12
  tagSlug?: string;
13
+ /** Number of posts to fetch per page (default: 10) */
8
14
  limit?: number;
15
+ /** Whether to enable the query (default: true) */
9
16
  enabled?: boolean;
17
+ /** Search query to filter posts by title, content, or excerpt */
10
18
  query?: string;
19
+ /** Filter by published status */
11
20
  published?: boolean;
21
+ /** Filter by specific post slug */
12
22
  slug?: string;
13
23
  }
24
+ /**
25
+ * Result from the usePosts hook
26
+ */
14
27
  interface UsePostsResult {
28
+ /** Array of fetched posts */
15
29
  posts: SerializedPost[];
30
+ /** Whether the initial load is in progress */
16
31
  isLoading: boolean;
32
+ /** Error if the query failed */
17
33
  error: Error | null;
34
+ /** Function to load the next page of posts */
18
35
  loadMore: () => void;
36
+ /** Whether there are more posts to load */
19
37
  hasMore: boolean;
38
+ /** Whether the next page is being loaded */
20
39
  isLoadingMore: boolean;
40
+ /** Function to refetch the posts */
21
41
  refetch: () => void;
22
42
  }
43
+ /**
44
+ * Options for the usePostSearch hook
45
+ */
23
46
  interface UsePostSearchOptions {
47
+ /** Search query string to filter posts */
24
48
  query: string;
49
+ /** Whether to enable the search query (default: true) */
25
50
  enabled?: boolean;
51
+ /** Debounce delay in milliseconds (default: 300) */
26
52
  debounceMs?: number;
53
+ /** Number of results to return (default: 10) */
27
54
  limit?: number;
55
+ /** Filter by published status (default: true) */
28
56
  published?: boolean;
29
57
  }
58
+ /**
59
+ * Result from the usePostSearch hook
60
+ */
30
61
  interface UsePostSearchResult {
62
+ /** Array of posts matching the search query */
31
63
  posts: SerializedPost[];
64
+ /** Alias for posts (React Query compatibility) */
32
65
  data: SerializedPost[];
66
+ /** Whether the search is in progress */
33
67
  isLoading: boolean;
68
+ /** Error if the search failed */
34
69
  error: Error | null;
70
+ /** Function to refetch the search results */
35
71
  refetch: () => void;
72
+ /** Whether a search is currently in progress (includes debounce time) */
36
73
  isSearching: boolean;
74
+ /** The debounced search query being used */
37
75
  searchQuery: string;
38
76
  }
77
+ /**
78
+ * Result from the usePost hook
79
+ */
39
80
  interface UsePostResult {
81
+ /** The fetched post, or null if not found */
40
82
  post: SerializedPost | null;
83
+ /** Whether the post is being loaded */
41
84
  isLoading: boolean;
85
+ /** Error if the query failed */
42
86
  error: Error | null;
87
+ /** Function to refetch the post */
43
88
  refetch: () => void;
44
89
  }
90
+ /** Input type for creating a new post */
45
91
  type PostCreateInput = z.infer<typeof createPostSchema>;
92
+ /** Input type for updating an existing post */
46
93
  type PostUpdateInput = z.infer<typeof updatePostSchema>;
47
94
  /**
48
95
  * Hook for fetching paginated posts with load more functionality
@@ -114,14 +161,26 @@ declare function useDeletePost(): _tanstack_react_query.UseMutationResult<{
114
161
  * Debounces the query and preserves last successful results to avoid flicker.
115
162
  */
116
163
  declare function usePostSearch({ query, enabled, debounceMs, limit, published, }: UsePostSearchOptions): UsePostSearchResult;
164
+ /**
165
+ * Options for the useNextPreviousPosts hook
166
+ */
117
167
  interface UseNextPreviousPostsOptions {
168
+ /** Whether to enable the query (default: true) */
118
169
  enabled?: boolean;
119
170
  }
171
+ /**
172
+ * Result from the useNextPreviousPosts hook
173
+ */
120
174
  interface UseNextPreviousPostsResult {
175
+ /** The previous post (older), or null if none exists */
121
176
  previousPost: SerializedPost | null;
177
+ /** The next post (newer), or null if none exists */
122
178
  nextPost: SerializedPost | null;
179
+ /** Whether the query is loading */
123
180
  isLoading: boolean;
181
+ /** Error if the query failed */
124
182
  error: Error | null;
183
+ /** Function to refetch the posts */
125
184
  refetch: () => void;
126
185
  }
127
186
  /**
@@ -132,15 +191,28 @@ declare function useNextPreviousPosts(createdAt: string | Date, options?: UseNex
132
191
  ref: (node: Element | null) => void;
133
192
  inView: boolean;
134
193
  };
194
+ /**
195
+ * Options for the useRecentPosts hook
196
+ */
135
197
  interface UseRecentPostsOptions {
198
+ /** Maximum number of recent posts to fetch (default: 5) */
136
199
  limit?: number;
200
+ /** Slug of a post to exclude from results */
137
201
  excludeSlug?: string;
202
+ /** Whether to enable the query (default: true) */
138
203
  enabled?: boolean;
139
204
  }
205
+ /**
206
+ * Result from the useRecentPosts hook
207
+ */
140
208
  interface UseRecentPostsResult {
209
+ /** Array of recent posts */
141
210
  recentPosts: SerializedPost[];
211
+ /** Whether the query is loading */
142
212
  isLoading: boolean;
213
+ /** Error if the query failed */
143
214
  error: Error | null;
215
+ /** Function to refetch the posts */
144
216
  refetch: () => void;
145
217
  }
146
218
  /**
@@ -11,21 +11,32 @@ import 'zod';
11
11
  * Context passed to route hooks
12
12
  */
13
13
  interface RouteContext$1 {
14
+ /** Current route path */
14
15
  path: string;
16
+ /** Route parameters (e.g., { slug: "my-post" }) */
15
17
  params?: Record<string, string>;
18
+ /** Whether rendering on server (true) or client (false) */
16
19
  isSSR: boolean;
20
+ /** Additional context properties */
17
21
  [key: string]: any;
18
22
  }
19
23
  /**
20
24
  * Context passed to loader hooks
21
25
  */
22
26
  interface LoaderContext {
27
+ /** Current route path */
23
28
  path: string;
29
+ /** Route parameters (e.g., { slug: "my-post" }) */
24
30
  params?: Record<string, string>;
31
+ /** Whether rendering on server (true) or client (false) */
25
32
  isSSR: boolean;
33
+ /** Base URL for API calls */
26
34
  apiBaseURL: string;
35
+ /** Path where the API is mounted */
27
36
  apiBasePath: string;
37
+ /** Optional headers for the request */
28
38
  headers?: Headers;
39
+ /** Additional context properties */
29
40
  [key: string]: any;
30
41
  }
31
42
  /**
@@ -33,19 +44,32 @@ interface LoaderContext {
33
44
  * Note: queryClient is passed at runtime to both loader and meta (for SSR isolation)
34
45
  */
35
46
  interface BlogClientConfig {
47
+ /** Base URL for API calls (e.g., "http://localhost:3000") */
36
48
  apiBaseURL: string;
49
+ /** Path where the API is mounted (e.g., "/api/data") */
37
50
  apiBasePath: string;
51
+ /** Base URL of your site for SEO meta tags */
38
52
  siteBaseURL: string;
53
+ /** Path where pages are mounted (e.g., "/pages") */
39
54
  siteBasePath: string;
55
+ /** React Query client instance for caching */
40
56
  queryClient: QueryClient;
57
+ /** Optional SEO configuration for meta tags */
41
58
  seo?: {
59
+ /** Site name for Open Graph tags */
42
60
  siteName?: string;
61
+ /** Default author name */
43
62
  author?: string;
63
+ /** Twitter handle (e.g., "@yourhandle") */
44
64
  twitterHandle?: string;
65
+ /** Locale for Open Graph (e.g., "en_US") */
45
66
  locale?: string;
67
+ /** Default image URL for social sharing */
46
68
  defaultImage?: string;
47
69
  };
70
+ /** Optional hooks for customizing behavior */
48
71
  hooks?: BlogClientHooks;
72
+ /** Optional headers for SSR (e.g., forwarding cookies) */
49
73
  headers?: Headers;
50
74
  }
51
75
  /**
@@ -53,16 +77,51 @@ interface BlogClientConfig {
53
77
  * All hooks are optional and allow consumers to customize behavior
54
78
  */
55
79
  interface BlogClientHooks {
80
+ /**
81
+ * Called before loading posts list. Return false to cancel loading.
82
+ * @param filter - Filter parameters including published status
83
+ * @param context - Loader context with path, params, etc.
84
+ */
56
85
  beforeLoadPosts?: (filter: {
57
86
  published: boolean;
58
87
  }, context: LoaderContext) => Promise<boolean> | boolean;
88
+ /**
89
+ * Called after posts are loaded. Return false to cancel further processing.
90
+ * @param posts - Array of loaded posts or null
91
+ * @param filter - Filter parameters used
92
+ * @param context - Loader context
93
+ */
59
94
  afterLoadPosts?: (posts: Post[] | null, filter: {
60
95
  published: boolean;
61
96
  }, context: LoaderContext) => Promise<boolean> | boolean;
97
+ /**
98
+ * Called before loading a single post. Return false to cancel loading.
99
+ * @param slug - Post slug being loaded
100
+ * @param context - Loader context
101
+ */
62
102
  beforeLoadPost?: (slug: string, context: LoaderContext) => Promise<boolean> | boolean;
103
+ /**
104
+ * Called after a post is loaded. Return false to cancel further processing.
105
+ * @param post - Loaded post or null if not found
106
+ * @param slug - Post slug that was requested
107
+ * @param context - Loader context
108
+ */
63
109
  afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<boolean> | boolean;
110
+ /**
111
+ * Called before loading the new post page. Return false to cancel.
112
+ * @param context - Loader context
113
+ */
64
114
  beforeLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
115
+ /**
116
+ * Called after the new post page is loaded. Return false to cancel.
117
+ * @param context - Loader context
118
+ */
65
119
  afterLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
120
+ /**
121
+ * Called when a loading error occurs
122
+ * @param error - The error that occurred
123
+ * @param context - Loader context
124
+ */
66
125
  onLoadError?: (error: Error, context: LoaderContext) => Promise<void> | void;
67
126
  }
68
127
  /**
@@ -313,9 +372,13 @@ type BlogLocalization = typeof BLOG_LOCALIZATION;
313
372
  * Context passed to lifecycle hooks
314
373
  */
315
374
  interface RouteContext {
375
+ /** Current route path */
316
376
  path: string;
377
+ /** Route parameters (e.g., { slug: "my-post" }) */
317
378
  params?: Record<string, string>;
379
+ /** Whether rendering on server (true) or client (false) */
318
380
  isSSR: boolean;
381
+ /** Additional context properties */
319
382
  [key: string]: any;
320
383
  }
321
384
  /**
@@ -325,7 +388,13 @@ interface RouteContext {
325
388
  * to customize the behavior for their framework (Next.js, React Router, etc.)
326
389
  */
327
390
  interface BlogPluginOverrides {
391
+ /**
392
+ * Link component for navigation
393
+ */
328
394
  Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
395
+ /**
396
+ * Post card component for displaying a post
397
+ */
329
398
  PostCard?: ComponentType<{
330
399
  post: SerializedPost;
331
400
  }>;
@@ -11,21 +11,32 @@ import 'zod';
11
11
  * Context passed to route hooks
12
12
  */
13
13
  interface RouteContext$1 {
14
+ /** Current route path */
14
15
  path: string;
16
+ /** Route parameters (e.g., { slug: "my-post" }) */
15
17
  params?: Record<string, string>;
18
+ /** Whether rendering on server (true) or client (false) */
16
19
  isSSR: boolean;
20
+ /** Additional context properties */
17
21
  [key: string]: any;
18
22
  }
19
23
  /**
20
24
  * Context passed to loader hooks
21
25
  */
22
26
  interface LoaderContext {
27
+ /** Current route path */
23
28
  path: string;
29
+ /** Route parameters (e.g., { slug: "my-post" }) */
24
30
  params?: Record<string, string>;
31
+ /** Whether rendering on server (true) or client (false) */
25
32
  isSSR: boolean;
33
+ /** Base URL for API calls */
26
34
  apiBaseURL: string;
35
+ /** Path where the API is mounted */
27
36
  apiBasePath: string;
37
+ /** Optional headers for the request */
28
38
  headers?: Headers;
39
+ /** Additional context properties */
29
40
  [key: string]: any;
30
41
  }
31
42
  /**
@@ -33,19 +44,32 @@ interface LoaderContext {
33
44
  * Note: queryClient is passed at runtime to both loader and meta (for SSR isolation)
34
45
  */
35
46
  interface BlogClientConfig {
47
+ /** Base URL for API calls (e.g., "http://localhost:3000") */
36
48
  apiBaseURL: string;
49
+ /** Path where the API is mounted (e.g., "/api/data") */
37
50
  apiBasePath: string;
51
+ /** Base URL of your site for SEO meta tags */
38
52
  siteBaseURL: string;
53
+ /** Path where pages are mounted (e.g., "/pages") */
39
54
  siteBasePath: string;
55
+ /** React Query client instance for caching */
40
56
  queryClient: QueryClient;
57
+ /** Optional SEO configuration for meta tags */
41
58
  seo?: {
59
+ /** Site name for Open Graph tags */
42
60
  siteName?: string;
61
+ /** Default author name */
43
62
  author?: string;
63
+ /** Twitter handle (e.g., "@yourhandle") */
44
64
  twitterHandle?: string;
65
+ /** Locale for Open Graph (e.g., "en_US") */
45
66
  locale?: string;
67
+ /** Default image URL for social sharing */
46
68
  defaultImage?: string;
47
69
  };
70
+ /** Optional hooks for customizing behavior */
48
71
  hooks?: BlogClientHooks;
72
+ /** Optional headers for SSR (e.g., forwarding cookies) */
49
73
  headers?: Headers;
50
74
  }
51
75
  /**
@@ -53,16 +77,51 @@ interface BlogClientConfig {
53
77
  * All hooks are optional and allow consumers to customize behavior
54
78
  */
55
79
  interface BlogClientHooks {
80
+ /**
81
+ * Called before loading posts list. Return false to cancel loading.
82
+ * @param filter - Filter parameters including published status
83
+ * @param context - Loader context with path, params, etc.
84
+ */
56
85
  beforeLoadPosts?: (filter: {
57
86
  published: boolean;
58
87
  }, context: LoaderContext) => Promise<boolean> | boolean;
88
+ /**
89
+ * Called after posts are loaded. Return false to cancel further processing.
90
+ * @param posts - Array of loaded posts or null
91
+ * @param filter - Filter parameters used
92
+ * @param context - Loader context
93
+ */
59
94
  afterLoadPosts?: (posts: Post[] | null, filter: {
60
95
  published: boolean;
61
96
  }, context: LoaderContext) => Promise<boolean> | boolean;
97
+ /**
98
+ * Called before loading a single post. Return false to cancel loading.
99
+ * @param slug - Post slug being loaded
100
+ * @param context - Loader context
101
+ */
62
102
  beforeLoadPost?: (slug: string, context: LoaderContext) => Promise<boolean> | boolean;
103
+ /**
104
+ * Called after a post is loaded. Return false to cancel further processing.
105
+ * @param post - Loaded post or null if not found
106
+ * @param slug - Post slug that was requested
107
+ * @param context - Loader context
108
+ */
63
109
  afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<boolean> | boolean;
110
+ /**
111
+ * Called before loading the new post page. Return false to cancel.
112
+ * @param context - Loader context
113
+ */
64
114
  beforeLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
115
+ /**
116
+ * Called after the new post page is loaded. Return false to cancel.
117
+ * @param context - Loader context
118
+ */
65
119
  afterLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
120
+ /**
121
+ * Called when a loading error occurs
122
+ * @param error - The error that occurred
123
+ * @param context - Loader context
124
+ */
66
125
  onLoadError?: (error: Error, context: LoaderContext) => Promise<void> | void;
67
126
  }
68
127
  /**
@@ -313,9 +372,13 @@ type BlogLocalization = typeof BLOG_LOCALIZATION;
313
372
  * Context passed to lifecycle hooks
314
373
  */
315
374
  interface RouteContext {
375
+ /** Current route path */
316
376
  path: string;
377
+ /** Route parameters (e.g., { slug: "my-post" }) */
317
378
  params?: Record<string, string>;
379
+ /** Whether rendering on server (true) or client (false) */
318
380
  isSSR: boolean;
381
+ /** Additional context properties */
319
382
  [key: string]: any;
320
383
  }
321
384
  /**
@@ -325,7 +388,13 @@ interface RouteContext {
325
388
  * to customize the behavior for their framework (Next.js, React Router, etc.)
326
389
  */
327
390
  interface BlogPluginOverrides {
391
+ /**
392
+ * Link component for navigation
393
+ */
328
394
  Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
395
+ /**
396
+ * Post card component for displaying a post
397
+ */
329
398
  PostCard?: ComponentType<{
330
399
  post: SerializedPost;
331
400
  }>;