@btst/stack 1.1.6 → 1.1.8

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.
Files changed (37) hide show
  1. package/dist/packages/better-stack/src/plugins/blog/api/plugin.cjs +29 -34
  2. package/dist/packages/better-stack/src/plugins/blog/api/plugin.mjs +29 -34
  3. package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +3 -3
  4. package/dist/packages/better-stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +4 -4
  5. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/default-error.cjs +1 -1
  6. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/default-error.mjs +1 -1
  7. package/dist/packages/better-stack/src/plugins/blog/client/hooks/blog-hooks.cjs +16 -16
  8. package/dist/packages/better-stack/src/plugins/blog/client/hooks/blog-hooks.mjs +16 -16
  9. package/dist/packages/better-stack/src/plugins/blog/client/plugin.cjs +50 -8
  10. package/dist/packages/better-stack/src/plugins/blog/client/plugin.mjs +50 -8
  11. package/dist/plugins/blog/api/index.d.cts +1 -1
  12. package/dist/plugins/blog/api/index.d.mts +1 -1
  13. package/dist/plugins/blog/api/index.d.ts +1 -1
  14. package/dist/plugins/blog/client/hooks/index.d.cts +3 -3
  15. package/dist/plugins/blog/client/hooks/index.d.mts +3 -3
  16. package/dist/plugins/blog/client/hooks/index.d.ts +3 -3
  17. package/dist/plugins/blog/client/index.d.cts +11 -4
  18. package/dist/plugins/blog/client/index.d.mts +11 -4
  19. package/dist/plugins/blog/client/index.d.ts +11 -4
  20. package/dist/plugins/blog/query-keys.cjs +19 -13
  21. package/dist/plugins/blog/query-keys.d.cts +6 -6
  22. package/dist/plugins/blog/query-keys.d.mts +6 -6
  23. package/dist/plugins/blog/query-keys.d.ts +6 -6
  24. package/dist/plugins/blog/query-keys.mjs +19 -13
  25. package/dist/plugins/blog/style.css +2 -5
  26. package/package.json +3 -3
  27. package/src/plugins/blog/api/plugin.ts +56 -36
  28. package/src/plugins/blog/client/components/pages/post-page.internal.tsx +4 -4
  29. package/src/plugins/blog/client/components/shared/default-error.tsx +4 -1
  30. package/src/plugins/blog/client/hooks/blog-hooks.tsx +16 -16
  31. package/src/plugins/blog/client/overrides.ts +4 -0
  32. package/src/plugins/blog/client/plugin.tsx +67 -11
  33. package/src/plugins/blog/query-keys.ts +13 -3
  34. package/src/plugins/blog/style.css +2 -5
  35. package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CoPoHVfV.d.cts} +2 -2
  36. package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CoPoHVfV.d.mts} +2 -2
  37. package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CoPoHVfV.d.ts} +2 -2
@@ -11,7 +11,7 @@ import { PostPageComponent } from './components/pages/post-page.mjs';
11
11
  function createPostsLoader(published, config) {
12
12
  return async () => {
13
13
  if (typeof window === "undefined") {
14
- const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
14
+ const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
15
15
  const context = {
16
16
  path: published ? "/blog" : "/blog/drafts",
17
17
  isSSR: true,
@@ -30,7 +30,7 @@ function createPostsLoader(published, config) {
30
30
  baseURL: apiBaseURL,
31
31
  basePath: apiBasePath
32
32
  });
33
- const queries = createBlogQueryKeys(client);
33
+ const queries = createBlogQueryKeys(client, headers);
34
34
  const listQuery = queries.posts.list({
35
35
  query: void 0,
36
36
  limit,
@@ -44,7 +44,14 @@ function createPostsLoader(published, config) {
44
44
  await queryClient.prefetchQuery(tagsQuery);
45
45
  if (hooks?.afterLoadPosts) {
46
46
  const posts = queryClient.getQueryData(listQuery.queryKey) || null;
47
- await hooks.afterLoadPosts(posts, { published }, context);
47
+ const canContinue = await hooks.afterLoadPosts(
48
+ posts,
49
+ { published },
50
+ context
51
+ );
52
+ if (canContinue === false) {
53
+ throw new Error("Load prevented by afterLoadPosts hook");
54
+ }
48
55
  }
49
56
  const queryState = queryClient.getQueryState(listQuery.queryKey);
50
57
  if (queryState?.error) {
@@ -64,7 +71,7 @@ function createPostsLoader(published, config) {
64
71
  function createPostLoader(slug, config) {
65
72
  return async () => {
66
73
  if (typeof window === "undefined") {
67
- const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
74
+ const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
68
75
  const context = {
69
76
  path: `/blog/${slug}`,
70
77
  params: { slug },
@@ -83,12 +90,15 @@ function createPostLoader(slug, config) {
83
90
  baseURL: apiBaseURL,
84
91
  basePath: apiBasePath
85
92
  });
86
- const queries = createBlogQueryKeys(client);
93
+ const queries = createBlogQueryKeys(client, headers);
87
94
  const postQuery = queries.posts.detail(slug);
88
95
  await queryClient.prefetchQuery(postQuery);
89
96
  if (hooks?.afterLoadPost) {
90
97
  const post = queryClient.getQueryData(postQuery.queryKey) || null;
91
- await hooks.afterLoadPost(post, slug, context);
98
+ const canContinue = await hooks.afterLoadPost(post, slug, context);
99
+ if (canContinue === false) {
100
+ throw new Error("Load prevented by afterLoadPost hook");
101
+ }
92
102
  }
93
103
  const queryState = queryClient.getQueryState(postQuery.queryKey);
94
104
  if (queryState?.error) {
@@ -105,10 +115,41 @@ function createPostLoader(slug, config) {
105
115
  }
106
116
  };
107
117
  }
118
+ function createNewPostLoader(config) {
119
+ return async () => {
120
+ if (typeof window === "undefined") {
121
+ const { apiBasePath, apiBaseURL, hooks } = config;
122
+ const context = {
123
+ path: "/blog/new",
124
+ isSSR: true,
125
+ apiBaseURL,
126
+ apiBasePath
127
+ };
128
+ try {
129
+ if (hooks?.beforeLoadNewPost) {
130
+ const canLoad = await hooks.beforeLoadNewPost(context);
131
+ if (!canLoad) {
132
+ throw new Error("Load prevented by beforeLoadNewPost hook");
133
+ }
134
+ }
135
+ if (hooks?.afterLoadNewPost) {
136
+ const canContinue = await hooks.afterLoadNewPost(context);
137
+ if (canContinue === false) {
138
+ throw new Error("Load prevented by afterLoadNewPost hook");
139
+ }
140
+ }
141
+ } catch (error) {
142
+ if (hooks?.onLoadError) {
143
+ await hooks.onLoadError(error, context);
144
+ }
145
+ }
146
+ }
147
+ };
148
+ }
108
149
  function createTagLoader(tagSlug, config) {
109
150
  return async () => {
110
151
  if (typeof window === "undefined") {
111
- const { queryClient, apiBasePath, apiBaseURL, hooks } = config;
152
+ const { queryClient, apiBasePath, apiBaseURL, hooks, headers } = config;
112
153
  const context = {
113
154
  path: `/blog/tag/${tagSlug}`,
114
155
  params: { tagSlug },
@@ -122,7 +163,7 @@ function createTagLoader(tagSlug, config) {
122
163
  baseURL: apiBaseURL,
123
164
  basePath: apiBasePath
124
165
  });
125
- const queries = createBlogQueryKeys(client);
166
+ const queries = createBlogQueryKeys(client, headers);
126
167
  const listQuery = queries.posts.list({
127
168
  query: void 0,
128
169
  limit,
@@ -380,6 +421,7 @@ const blogClientPlugin = (config) => defineClientPlugin({
380
421
  newPost: createRoute("/blog/new", () => {
381
422
  return {
382
423
  PageComponent: NewPostPageComponent,
424
+ loader: createNewPostLoader(config),
383
425
  meta: createNewPostMeta(config)
384
426
  };
385
427
  }),
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
2
2
  import '@btst/stack/plugins/api';
3
3
  import 'better-call';
4
4
  import 'zod';
5
- import '../../../shared/stack.CbuN2zVV.cjs';
5
+ import '../../../shared/stack.CoPoHVfV.cjs';
6
6
  import '@tanstack/react-query';
7
7
  import '@btst/stack/plugins/client';
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
2
2
  import '@btst/stack/plugins/api';
3
3
  import 'better-call';
4
4
  import 'zod';
5
- import '../../../shared/stack.CbuN2zVV.mjs';
5
+ import '../../../shared/stack.CoPoHVfV.mjs';
6
6
  import '@tanstack/react-query';
7
7
  import '@btst/stack/plugins/client';
@@ -2,6 +2,6 @@ export { B as BlogApiContext, c as BlogApiRouter, a as BlogBackendHooks, N as Ne
2
2
  import '@btst/stack/plugins/api';
3
3
  import 'better-call';
4
4
  import 'zod';
5
- import '../../../shared/stack.CbuN2zVV.js';
5
+ import '../../../shared/stack.CoPoHVfV.js';
6
6
  import '@tanstack/react-query';
7
7
  import '@btst/stack/plugins/client';
@@ -1,5 +1,5 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
- import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CbuN2zVV.cjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CoPoHVfV.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  interface UsePostsOptions {
@@ -81,10 +81,10 @@ declare function useSuspenseTags(): {
81
81
  };
82
82
  /** Create a new post */
83
83
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
84
+ published: boolean;
84
85
  title: string;
85
86
  content: string;
86
87
  excerpt: string;
87
- published: boolean;
88
88
  tags: ({
89
89
  name: string;
90
90
  } | {
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
93
93
  slug: string;
94
94
  })[];
95
95
  slug?: string | undefined;
96
- publishedAt?: Date | undefined;
97
96
  createdAt?: Date | undefined;
97
+ publishedAt?: Date | undefined;
98
98
  updatedAt?: Date | undefined;
99
99
  image?: string | undefined;
100
100
  }, unknown>;
@@ -1,5 +1,5 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
- import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CbuN2zVV.mjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CoPoHVfV.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  interface UsePostsOptions {
@@ -81,10 +81,10 @@ declare function useSuspenseTags(): {
81
81
  };
82
82
  /** Create a new post */
83
83
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
84
+ published: boolean;
84
85
  title: string;
85
86
  content: string;
86
87
  excerpt: string;
87
- published: boolean;
88
88
  tags: ({
89
89
  name: string;
90
90
  } | {
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
93
93
  slug: string;
94
94
  })[];
95
95
  slug?: string | undefined;
96
- publishedAt?: Date | undefined;
97
96
  createdAt?: Date | undefined;
97
+ publishedAt?: Date | undefined;
98
98
  updatedAt?: Date | undefined;
99
99
  image?: string | undefined;
100
100
  }, unknown>;
@@ -1,5 +1,5 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
- import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CbuN2zVV.js';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CoPoHVfV.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  interface UsePostsOptions {
@@ -81,10 +81,10 @@ declare function useSuspenseTags(): {
81
81
  };
82
82
  /** Create a new post */
83
83
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
84
+ published: boolean;
84
85
  title: string;
85
86
  content: string;
86
87
  excerpt: string;
87
- published: boolean;
88
88
  tags: ({
89
89
  name: string;
90
90
  } | {
@@ -93,8 +93,8 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
93
93
  slug: string;
94
94
  })[];
95
95
  slug?: string | undefined;
96
- publishedAt?: Date | undefined;
97
96
  createdAt?: Date | undefined;
97
+ publishedAt?: Date | undefined;
98
98
  updatedAt?: Date | undefined;
99
99
  image?: string | undefined;
100
100
  }, unknown>;
@@ -3,7 +3,7 @@ import * as react from 'react';
3
3
  import { ComponentType } from 'react';
4
4
  import * as _btst_yar from '@btst/yar';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
- import { P as Post, S as SerializedPost } from '../../../shared/stack.CbuN2zVV.cjs';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CoPoHVfV.cjs';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.cjs';
8
8
  import 'zod';
9
9
 
@@ -45,6 +45,7 @@ interface BlogClientConfig {
45
45
  defaultImage?: string;
46
46
  };
47
47
  hooks?: BlogClientHooks;
48
+ headers?: HeadersInit;
48
49
  }
49
50
  /**
50
51
  * Hooks for blog client plugin
@@ -56,9 +57,11 @@ interface BlogClientHooks {
56
57
  }, context: LoaderContext) => Promise<boolean> | boolean;
57
58
  afterLoadPosts?: (posts: Post[] | null, filter: {
58
59
  published: boolean;
59
- }, context: LoaderContext) => Promise<void> | void;
60
+ }, context: LoaderContext) => Promise<boolean> | boolean;
60
61
  beforeLoadPost?: (slug: string, context: LoaderContext) => Promise<boolean> | boolean;
61
- afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<void> | void;
62
+ afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<boolean> | boolean;
63
+ beforeLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
64
+ afterLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
62
65
  onLoadError?: (error: Error, context: LoaderContext) => Promise<void> | void;
63
66
  }
64
67
  /**
@@ -129,7 +132,7 @@ declare const blogClientPlugin: (config: BlogClientConfig) => _btst_stack_plugin
129
132
  PageComponent?: react.ComponentType<unknown> | undefined;
130
133
  LoadingComponent?: react.ComponentType<unknown> | undefined;
131
134
  ErrorComponent?: react.ComponentType<unknown> | undefined;
132
- loader?: (() => any) | undefined;
135
+ loader?: (() => Promise<void>) | undefined;
133
136
  meta?: (() => ({
134
137
  title: string;
135
138
  name?: undefined;
@@ -357,6 +360,10 @@ interface BlogPluginOverrides {
357
360
  * Whether to show the attribution
358
361
  */
359
362
  showAttribution?: boolean;
363
+ /**
364
+ * Optional headers to pass with API requests (e.g., for SSR auth)
365
+ */
366
+ headers?: HeadersInit;
360
367
  /**
361
368
  * Called when a route is rendered
362
369
  * @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
@@ -3,7 +3,7 @@ import * as react from 'react';
3
3
  import { ComponentType } from 'react';
4
4
  import * as _btst_yar from '@btst/yar';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
- import { P as Post, S as SerializedPost } from '../../../shared/stack.CbuN2zVV.mjs';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CoPoHVfV.mjs';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.mjs';
8
8
  import 'zod';
9
9
 
@@ -45,6 +45,7 @@ interface BlogClientConfig {
45
45
  defaultImage?: string;
46
46
  };
47
47
  hooks?: BlogClientHooks;
48
+ headers?: HeadersInit;
48
49
  }
49
50
  /**
50
51
  * Hooks for blog client plugin
@@ -56,9 +57,11 @@ interface BlogClientHooks {
56
57
  }, context: LoaderContext) => Promise<boolean> | boolean;
57
58
  afterLoadPosts?: (posts: Post[] | null, filter: {
58
59
  published: boolean;
59
- }, context: LoaderContext) => Promise<void> | void;
60
+ }, context: LoaderContext) => Promise<boolean> | boolean;
60
61
  beforeLoadPost?: (slug: string, context: LoaderContext) => Promise<boolean> | boolean;
61
- afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<void> | void;
62
+ afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<boolean> | boolean;
63
+ beforeLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
64
+ afterLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
62
65
  onLoadError?: (error: Error, context: LoaderContext) => Promise<void> | void;
63
66
  }
64
67
  /**
@@ -129,7 +132,7 @@ declare const blogClientPlugin: (config: BlogClientConfig) => _btst_stack_plugin
129
132
  PageComponent?: react.ComponentType<unknown> | undefined;
130
133
  LoadingComponent?: react.ComponentType<unknown> | undefined;
131
134
  ErrorComponent?: react.ComponentType<unknown> | undefined;
132
- loader?: (() => any) | undefined;
135
+ loader?: (() => Promise<void>) | undefined;
133
136
  meta?: (() => ({
134
137
  title: string;
135
138
  name?: undefined;
@@ -357,6 +360,10 @@ interface BlogPluginOverrides {
357
360
  * Whether to show the attribution
358
361
  */
359
362
  showAttribution?: boolean;
363
+ /**
364
+ * Optional headers to pass with API requests (e.g., for SSR auth)
365
+ */
366
+ headers?: HeadersInit;
360
367
  /**
361
368
  * Called when a route is rendered
362
369
  * @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
@@ -3,7 +3,7 @@ import * as react from 'react';
3
3
  import { ComponentType } from 'react';
4
4
  import * as _btst_yar from '@btst/yar';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
- import { P as Post, S as SerializedPost } from '../../../shared/stack.CbuN2zVV.js';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CoPoHVfV.js';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.js';
8
8
  import 'zod';
9
9
 
@@ -45,6 +45,7 @@ interface BlogClientConfig {
45
45
  defaultImage?: string;
46
46
  };
47
47
  hooks?: BlogClientHooks;
48
+ headers?: HeadersInit;
48
49
  }
49
50
  /**
50
51
  * Hooks for blog client plugin
@@ -56,9 +57,11 @@ interface BlogClientHooks {
56
57
  }, context: LoaderContext) => Promise<boolean> | boolean;
57
58
  afterLoadPosts?: (posts: Post[] | null, filter: {
58
59
  published: boolean;
59
- }, context: LoaderContext) => Promise<void> | void;
60
+ }, context: LoaderContext) => Promise<boolean> | boolean;
60
61
  beforeLoadPost?: (slug: string, context: LoaderContext) => Promise<boolean> | boolean;
61
- afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<void> | void;
62
+ afterLoadPost?: (post: Post | null, slug: string, context: LoaderContext) => Promise<boolean> | boolean;
63
+ beforeLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
64
+ afterLoadNewPost?: (context: LoaderContext) => Promise<boolean> | boolean;
62
65
  onLoadError?: (error: Error, context: LoaderContext) => Promise<void> | void;
63
66
  }
64
67
  /**
@@ -129,7 +132,7 @@ declare const blogClientPlugin: (config: BlogClientConfig) => _btst_stack_plugin
129
132
  PageComponent?: react.ComponentType<unknown> | undefined;
130
133
  LoadingComponent?: react.ComponentType<unknown> | undefined;
131
134
  ErrorComponent?: react.ComponentType<unknown> | undefined;
132
- loader?: (() => any) | undefined;
135
+ loader?: (() => Promise<void>) | undefined;
133
136
  meta?: (() => ({
134
137
  title: string;
135
138
  name?: undefined;
@@ -357,6 +360,10 @@ interface BlogPluginOverrides {
357
360
  * Whether to show the attribution
358
361
  */
359
362
  showAttribution?: boolean;
363
+ /**
364
+ * Optional headers to pass with API requests (e.g., for SSR auth)
365
+ */
366
+ headers?: HeadersInit;
360
367
  /**
361
368
  * Called when a route is rendered
362
369
  * @param routeName - Name of the route (e.g., 'posts', 'post', 'newPost')
@@ -18,13 +18,13 @@ function toError(error) {
18
18
  }
19
19
  return new Error(String(error));
20
20
  }
21
- function createBlogQueryKeys(client) {
22
- const posts = createPostsQueries(client);
23
- const drafts = createDraftsQueries(client);
24
- const tags = createTagsQueries(client);
21
+ function createBlogQueryKeys(client, headers) {
22
+ const posts = createPostsQueries(client, headers);
23
+ const drafts = createDraftsQueries(client, headers);
24
+ const tags = createTagsQueries(client, headers);
25
25
  return queryKeyFactory.mergeQueryKeys(posts, drafts, tags);
26
26
  }
27
- function createPostsQueries(client) {
27
+ function createPostsQueries(client, headers) {
28
28
  return queryKeyFactory.createQueryKeys("posts", {
29
29
  list: (params) => ({
30
30
  queryKey: [
@@ -45,7 +45,8 @@ function createPostsQueries(client) {
45
45
  limit: params?.limit ?? 10,
46
46
  published: params?.published !== void 0 ? params.published ? "true" : "false" : void 0,
47
47
  tagSlug: params?.tagSlug
48
- }
48
+ },
49
+ headers
49
50
  });
50
51
  if (isErrorResponse(response)) {
51
52
  const errorResponse = response;
@@ -65,7 +66,8 @@ function createPostsQueries(client) {
65
66
  try {
66
67
  const response = await client("/posts", {
67
68
  method: "GET",
68
- query: { slug, limit: 1 }
69
+ query: { slug, limit: 1 },
70
+ headers
69
71
  });
70
72
  if (isErrorResponse(response)) {
71
73
  const errorResponse = response;
@@ -87,7 +89,8 @@ function createPostsQueries(client) {
87
89
  method: "GET",
88
90
  query: {
89
91
  date: dateValue.toISOString()
90
- }
92
+ },
93
+ headers
91
94
  });
92
95
  if (isErrorResponse(response)) {
93
96
  const errorResponse = response;
@@ -107,7 +110,8 @@ function createPostsQueries(client) {
107
110
  query: {
108
111
  limit: params?.limit ?? 5,
109
112
  published: "true"
110
- }
113
+ },
114
+ headers
111
115
  });
112
116
  if (isErrorResponse(response)) {
113
117
  const errorResponse = response;
@@ -125,7 +129,7 @@ function createPostsQueries(client) {
125
129
  })
126
130
  });
127
131
  }
128
- function createDraftsQueries(client) {
132
+ function createDraftsQueries(client, headers) {
129
133
  return queryKeyFactory.createQueryKeys("drafts", {
130
134
  list: (params) => ({
131
135
  queryKey: [
@@ -142,7 +146,8 @@ function createDraftsQueries(client) {
142
146
  offset: pageParam ?? 0,
143
147
  limit: params?.limit ?? 10,
144
148
  published: "false"
145
- }
149
+ },
150
+ headers
146
151
  });
147
152
  if (isErrorResponse(response)) {
148
153
  const errorResponse = response;
@@ -156,14 +161,15 @@ function createDraftsQueries(client) {
156
161
  })
157
162
  });
158
163
  }
159
- function createTagsQueries(client) {
164
+ function createTagsQueries(client, headers) {
160
165
  return queryKeyFactory.createQueryKeys("tags", {
161
166
  list: () => ({
162
167
  queryKey: ["tags"],
163
168
  queryFn: async () => {
164
169
  try {
165
170
  const response = await client("/tags", {
166
- method: "GET"
171
+ method: "GET",
172
+ headers
167
173
  });
168
174
  if (isErrorResponse(response)) {
169
175
  const errorResponse = response;
@@ -1,7 +1,7 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
3
  import { z } from 'zod';
4
- import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CbuN2zVV.cjs';
4
+ import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CoPoHVfV.cjs';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { createApiClient } from '@btst/stack/plugins/client';
7
7
 
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
135
135
  content: string;
136
136
  excerpt: string;
137
137
  slug?: string | undefined;
138
- publishedAt?: unknown;
138
+ published?: boolean | undefined;
139
139
  createdAt?: unknown;
140
+ publishedAt?: unknown;
140
141
  updatedAt?: unknown;
141
142
  image?: string | undefined;
142
- published?: boolean | undefined;
143
143
  tags?: ({
144
144
  name: string;
145
145
  } | {
@@ -174,14 +174,14 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
174
174
  method: "POST";
175
175
  body: z.ZodObject<{
176
176
  slug: z.ZodOptional<z.ZodString>;
177
- publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
177
+ published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
178
178
  createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
+ publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
180
  updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
180
181
  title: z.ZodString;
181
182
  content: z.ZodString;
182
183
  excerpt: z.ZodString;
183
184
  image: z.ZodOptional<z.ZodString>;
184
- published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
185
185
  tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
186
186
  name: z.ZodString;
187
187
  }, z.core.$strip>, z.ZodObject<{
@@ -438,7 +438,7 @@ interface PostsListParams {
438
438
  published?: boolean;
439
439
  tagSlug?: string;
440
440
  }
441
- declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>): {
441
+ declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
442
442
  posts: {
443
443
  _def: readonly ["posts"];
444
444
  } & {
@@ -1,7 +1,7 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
3
  import { z } from 'zod';
4
- import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CbuN2zVV.mjs';
4
+ import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CoPoHVfV.mjs';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { createApiClient } from '@btst/stack/plugins/client';
7
7
 
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
135
135
  content: string;
136
136
  excerpt: string;
137
137
  slug?: string | undefined;
138
- publishedAt?: unknown;
138
+ published?: boolean | undefined;
139
139
  createdAt?: unknown;
140
+ publishedAt?: unknown;
140
141
  updatedAt?: unknown;
141
142
  image?: string | undefined;
142
- published?: boolean | undefined;
143
143
  tags?: ({
144
144
  name: string;
145
145
  } | {
@@ -174,14 +174,14 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
174
174
  method: "POST";
175
175
  body: z.ZodObject<{
176
176
  slug: z.ZodOptional<z.ZodString>;
177
- publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
177
+ published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
178
178
  createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
+ publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
180
  updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
180
181
  title: z.ZodString;
181
182
  content: z.ZodString;
182
183
  excerpt: z.ZodString;
183
184
  image: z.ZodOptional<z.ZodString>;
184
- published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
185
185
  tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
186
186
  name: z.ZodString;
187
187
  }, z.core.$strip>, z.ZodObject<{
@@ -438,7 +438,7 @@ interface PostsListParams {
438
438
  published?: boolean;
439
439
  tagSlug?: string;
440
440
  }
441
- declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>): {
441
+ declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
442
442
  posts: {
443
443
  _def: readonly ["posts"];
444
444
  } & {
@@ -1,7 +1,7 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
3
  import { z } from 'zod';
4
- import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CbuN2zVV.js';
4
+ import { c as createPostSchema, u as updatePostSchema, P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../shared/stack.CoPoHVfV.js';
5
5
  import * as _tanstack_react_query from '@tanstack/react-query';
6
6
  import { createApiClient } from '@btst/stack/plugins/client';
7
7
 
@@ -135,11 +135,11 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
135
135
  content: string;
136
136
  excerpt: string;
137
137
  slug?: string | undefined;
138
- publishedAt?: unknown;
138
+ published?: boolean | undefined;
139
139
  createdAt?: unknown;
140
+ publishedAt?: unknown;
140
141
  updatedAt?: unknown;
141
142
  image?: string | undefined;
142
- published?: boolean | undefined;
143
143
  tags?: ({
144
144
  name: string;
145
145
  } | {
@@ -174,14 +174,14 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
174
174
  method: "POST";
175
175
  body: z.ZodObject<{
176
176
  slug: z.ZodOptional<z.ZodString>;
177
- publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
177
+ published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
178
178
  createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
+ publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
179
180
  updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
180
181
  title: z.ZodString;
181
182
  content: z.ZodString;
182
183
  excerpt: z.ZodString;
183
184
  image: z.ZodOptional<z.ZodString>;
184
- published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
185
185
  tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
186
186
  name: z.ZodString;
187
187
  }, z.core.$strip>, z.ZodObject<{
@@ -438,7 +438,7 @@ interface PostsListParams {
438
438
  published?: boolean;
439
439
  tagSlug?: string;
440
440
  }
441
- declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>): {
441
+ declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
442
442
  posts: {
443
443
  _def: readonly ["posts"];
444
444
  } & {