@btst/stack 2.2.0 → 2.3.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.
Files changed (159) hide show
  1. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +52 -1
  2. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +52 -1
  3. package/dist/packages/stack/src/plugins/blog/api/query-key-defs.cjs +18 -0
  4. package/dist/packages/stack/src/plugins/blog/api/query-key-defs.mjs +15 -0
  5. package/dist/packages/stack/src/plugins/blog/api/serializers.cjs +21 -0
  6. package/dist/packages/stack/src/plugins/blog/api/serializers.mjs +18 -0
  7. package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +15 -0
  8. package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +16 -1
  9. package/dist/packages/stack/src/plugins/cms/api/getters.cjs +10 -0
  10. package/dist/packages/stack/src/plugins/cms/api/getters.mjs +10 -1
  11. package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +70 -1
  12. package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +71 -2
  13. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +29 -0
  14. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +26 -0
  15. package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +15 -0
  16. package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +16 -1
  17. package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
  18. package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
  19. package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +62 -1
  20. package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +63 -2
  21. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +37 -0
  22. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +33 -0
  23. package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +15 -0
  24. package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +16 -1
  25. package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +29 -1
  26. package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +29 -1
  27. package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.cjs +26 -0
  28. package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.mjs +23 -0
  29. package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +30 -0
  30. package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +26 -0
  31. package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +10 -0
  32. package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +11 -1
  33. package/dist/packages/stack/src/plugins/utils.cjs +6 -0
  34. package/dist/packages/stack/src/plugins/utils.mjs +6 -1
  35. package/dist/plugins/blog/api/index.cjs +5 -0
  36. package/dist/plugins/blog/api/index.d.cts +19 -4
  37. package/dist/plugins/blog/api/index.d.mts +19 -4
  38. package/dist/plugins/blog/api/index.d.ts +19 -4
  39. package/dist/plugins/blog/api/index.mjs +2 -0
  40. package/dist/plugins/blog/client/hooks/index.d.cts +4 -4
  41. package/dist/plugins/blog/client/hooks/index.d.mts +4 -4
  42. package/dist/plugins/blog/client/hooks/index.d.ts +4 -4
  43. package/dist/plugins/blog/client/index.d.cts +1 -1
  44. package/dist/plugins/blog/client/index.d.mts +1 -1
  45. package/dist/plugins/blog/client/index.d.ts +1 -1
  46. package/dist/plugins/blog/query-keys.cjs +6 -5
  47. package/dist/plugins/blog/query-keys.d.cts +8 -387
  48. package/dist/plugins/blog/query-keys.d.mts +8 -387
  49. package/dist/plugins/blog/query-keys.d.ts +8 -387
  50. package/dist/plugins/blog/query-keys.mjs +6 -5
  51. package/dist/plugins/client/index.cjs +1 -0
  52. package/dist/plugins/client/index.d.cts +8 -1
  53. package/dist/plugins/client/index.d.mts +8 -1
  54. package/dist/plugins/client/index.d.ts +8 -1
  55. package/dist/plugins/client/index.mjs +1 -1
  56. package/dist/plugins/cms/api/index.cjs +6 -0
  57. package/dist/plugins/cms/api/index.d.cts +7 -219
  58. package/dist/plugins/cms/api/index.d.mts +7 -219
  59. package/dist/plugins/cms/api/index.d.ts +7 -219
  60. package/dist/plugins/cms/api/index.mjs +2 -1
  61. package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
  62. package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
  63. package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
  64. package/dist/plugins/cms/query-keys.cjs +2 -1
  65. package/dist/plugins/cms/query-keys.d.cts +5 -9
  66. package/dist/plugins/cms/query-keys.d.mts +5 -9
  67. package/dist/plugins/cms/query-keys.d.ts +5 -9
  68. package/dist/plugins/cms/query-keys.mjs +2 -1
  69. package/dist/plugins/form-builder/api/index.cjs +6 -0
  70. package/dist/plugins/form-builder/api/index.d.cts +7 -211
  71. package/dist/plugins/form-builder/api/index.d.mts +7 -211
  72. package/dist/plugins/form-builder/api/index.d.ts +7 -211
  73. package/dist/plugins/form-builder/api/index.mjs +2 -1
  74. package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
  75. package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
  76. package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
  77. package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
  78. package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
  79. package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
  80. package/dist/plugins/form-builder/query-keys.cjs +3 -2
  81. package/dist/plugins/form-builder/query-keys.d.cts +6 -6
  82. package/dist/plugins/form-builder/query-keys.d.mts +6 -6
  83. package/dist/plugins/form-builder/query-keys.d.ts +6 -6
  84. package/dist/plugins/form-builder/query-keys.mjs +3 -2
  85. package/dist/plugins/kanban/api/index.cjs +6 -0
  86. package/dist/plugins/kanban/api/index.d.cts +17 -392
  87. package/dist/plugins/kanban/api/index.d.mts +17 -392
  88. package/dist/plugins/kanban/api/index.d.ts +17 -392
  89. package/dist/plugins/kanban/api/index.mjs +2 -0
  90. package/dist/plugins/kanban/client/components/index.d.cts +1 -1
  91. package/dist/plugins/kanban/client/components/index.d.mts +1 -1
  92. package/dist/plugins/kanban/client/components/index.d.ts +1 -1
  93. package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
  94. package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
  95. package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
  96. package/dist/plugins/kanban/client/index.d.cts +1 -1
  97. package/dist/plugins/kanban/client/index.d.mts +1 -1
  98. package/dist/plugins/kanban/client/index.d.ts +1 -1
  99. package/dist/plugins/kanban/query-keys.cjs +2 -9
  100. package/dist/plugins/kanban/query-keys.d.cts +4 -16
  101. package/dist/plugins/kanban/query-keys.d.mts +4 -16
  102. package/dist/plugins/kanban/query-keys.d.ts +4 -16
  103. package/dist/plugins/kanban/query-keys.mjs +2 -9
  104. package/dist/plugins/ui-builder/index.d.cts +1 -1
  105. package/dist/plugins/ui-builder/index.d.mts +1 -1
  106. package/dist/plugins/ui-builder/index.d.ts +1 -1
  107. package/dist/shared/stack.B1EeBt1b.d.ts +297 -0
  108. package/dist/shared/stack.BIXEI6v_.d.mts +419 -0
  109. package/dist/shared/stack.BKfolAyK.d.ts +419 -0
  110. package/dist/shared/stack.BpolpQpf.d.cts +445 -0
  111. package/dist/shared/stack.C5dtIncc.d.mts +293 -0
  112. package/dist/shared/stack.CIP6QS9l.d.ts +293 -0
  113. package/dist/shared/stack.CP68pFEH.d.mts +297 -0
  114. package/dist/shared/{stack.CXjzTMsb.d.mts → stack.CVDTkMoO.d.cts} +7 -1
  115. package/dist/shared/{stack.CXjzTMsb.d.ts → stack.CVDTkMoO.d.mts} +7 -1
  116. package/dist/shared/{stack.CXjzTMsb.d.cts → stack.CVDTkMoO.d.ts} +7 -1
  117. package/dist/shared/{stack.QD1y_7NY.d.mts → stack.DJaKVY7v.d.cts} +1 -1
  118. package/dist/shared/{stack.QD1y_7NY.d.ts → stack.DJaKVY7v.d.mts} +1 -1
  119. package/dist/shared/{stack.QD1y_7NY.d.cts → stack.DJaKVY7v.d.ts} +1 -1
  120. package/dist/shared/{stack.CIrIsc-A.d.mts → stack.DdI5W6MB.d.cts} +7 -1
  121. package/dist/shared/{stack.CIrIsc-A.d.ts → stack.DdI5W6MB.d.mts} +7 -1
  122. package/dist/shared/{stack.CIrIsc-A.d.cts → stack.DdI5W6MB.d.ts} +7 -1
  123. package/dist/shared/stack.Dw0Ly2TM.d.cts +293 -0
  124. package/dist/shared/stack.IdtKDRka.d.cts +297 -0
  125. package/dist/shared/stack.TIBF2AOx.d.ts +445 -0
  126. package/dist/shared/stack.rTy7-wQU.d.mts +445 -0
  127. package/dist/shared/stack.snB1EDP7.d.cts +419 -0
  128. package/package.json +3 -3
  129. package/src/plugins/blog/api/index.ts +2 -0
  130. package/src/plugins/blog/api/plugin.ts +85 -0
  131. package/src/plugins/blog/api/query-key-defs.ts +46 -0
  132. package/src/plugins/blog/api/serializers.ts +27 -0
  133. package/src/plugins/blog/client/plugin.tsx +19 -0
  134. package/src/plugins/blog/query-keys.ts +5 -7
  135. package/src/plugins/client/index.ts +1 -1
  136. package/src/plugins/cms/api/getters.ts +24 -0
  137. package/src/plugins/cms/api/index.ts +10 -1
  138. package/src/plugins/cms/api/plugin.ts +105 -0
  139. package/src/plugins/cms/api/query-key-defs.ts +53 -0
  140. package/src/plugins/cms/api/serializers.ts +12 -0
  141. package/src/plugins/cms/client/plugin.tsx +19 -0
  142. package/src/plugins/cms/query-keys.ts +2 -1
  143. package/src/plugins/form-builder/api/getters.ts +23 -0
  144. package/src/plugins/form-builder/api/index.ts +15 -2
  145. package/src/plugins/form-builder/api/plugin.ts +91 -0
  146. package/src/plugins/form-builder/api/query-key-defs.ts +79 -0
  147. package/src/plugins/form-builder/api/serializers.ts +12 -0
  148. package/src/plugins/form-builder/client/plugin.tsx +19 -0
  149. package/src/plugins/form-builder/query-keys.ts +6 -2
  150. package/src/plugins/kanban/api/index.ts +3 -0
  151. package/src/plugins/kanban/api/plugin.ts +49 -0
  152. package/src/plugins/kanban/api/query-key-defs.ts +54 -0
  153. package/src/plugins/kanban/api/serializers.ts +49 -0
  154. package/src/plugins/kanban/client/plugin.tsx +13 -0
  155. package/src/plugins/kanban/query-keys.ts +2 -9
  156. package/src/plugins/utils.ts +19 -0
  157. package/dist/shared/{stack.BkYlUT_8.d.cts → stack.CBON0dWL.d.cts} +6 -6
  158. package/dist/shared/{stack.BkYlUT_8.d.mts → stack.CBON0dWL.d.mts} +6 -6
  159. package/dist/shared/{stack.BkYlUT_8.d.ts → stack.CBON0dWL.d.ts} +6 -6
@@ -1,8 +1,23 @@
1
- export { B as BlogApiContext, h as BlogApiRouter, e as BlogBackendHooks, N as NextPreviousPostsQuerySchema, P as PostListParams, d as PostListQuerySchema, c as PostListResult, f as blogBackendPlugin, createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../query-keys.cjs';
1
+ export { B as BLOG_QUERY_KEYS, h as BlogApiContext, k as BlogApiRouter, i as BlogBackendHooks, e as BlogRouteKey, N as NextPreviousPostsQuerySchema, P as PostListParams, f as PostListQuerySchema, c as PostListResult, j as blogBackendPlugin, d as createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../../../shared/stack.snB1EDP7.cjs';
2
+ import { P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../../shared/stack.CBON0dWL.cjs';
3
+ import '@tanstack/react-query';
4
+ import '@btst/stack/plugins/client';
2
5
  import '@btst/stack/plugins/api';
3
6
  import 'better-call';
4
7
  import '@btst/db';
5
- import '../../../shared/stack.BkYlUT_8.cjs';
6
8
  import 'zod';
7
- import '@tanstack/react-query';
8
- import '@btst/stack/plugins/client';
9
+
10
+ /**
11
+ * Serialize a Tag for SSR/SSG use (convert dates to strings).
12
+ * Pure function — no DB access, no hooks.
13
+ */
14
+ declare function serializeTag(tag: Tag): SerializedTag;
15
+ /**
16
+ * Serialize a Post (with tags) for SSR/SSG use (convert dates to strings).
17
+ * Pure function — no DB access, no hooks.
18
+ */
19
+ declare function serializePost(post: Post & {
20
+ tags: Tag[];
21
+ }): SerializedPost;
22
+
23
+ export { serializePost, serializeTag };
@@ -1,8 +1,23 @@
1
- export { B as BlogApiContext, h as BlogApiRouter, e as BlogBackendHooks, N as NextPreviousPostsQuerySchema, P as PostListParams, d as PostListQuerySchema, c as PostListResult, f as blogBackendPlugin, createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../query-keys.mjs';
1
+ export { B as BLOG_QUERY_KEYS, h as BlogApiContext, k as BlogApiRouter, i as BlogBackendHooks, e as BlogRouteKey, N as NextPreviousPostsQuerySchema, P as PostListParams, f as PostListQuerySchema, c as PostListResult, j as blogBackendPlugin, d as createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../../../shared/stack.BIXEI6v_.mjs';
2
+ import { P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../../shared/stack.CBON0dWL.mjs';
3
+ import '@tanstack/react-query';
4
+ import '@btst/stack/plugins/client';
2
5
  import '@btst/stack/plugins/api';
3
6
  import 'better-call';
4
7
  import '@btst/db';
5
- import '../../../shared/stack.BkYlUT_8.mjs';
6
8
  import 'zod';
7
- import '@tanstack/react-query';
8
- import '@btst/stack/plugins/client';
9
+
10
+ /**
11
+ * Serialize a Tag for SSR/SSG use (convert dates to strings).
12
+ * Pure function — no DB access, no hooks.
13
+ */
14
+ declare function serializeTag(tag: Tag): SerializedTag;
15
+ /**
16
+ * Serialize a Post (with tags) for SSR/SSG use (convert dates to strings).
17
+ * Pure function — no DB access, no hooks.
18
+ */
19
+ declare function serializePost(post: Post & {
20
+ tags: Tag[];
21
+ }): SerializedPost;
22
+
23
+ export { serializePost, serializeTag };
@@ -1,8 +1,23 @@
1
- export { B as BlogApiContext, h as BlogApiRouter, e as BlogBackendHooks, N as NextPreviousPostsQuerySchema, P as PostListParams, d as PostListQuerySchema, c as PostListResult, f as blogBackendPlugin, createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../query-keys.js';
1
+ export { B as BLOG_QUERY_KEYS, h as BlogApiContext, k as BlogApiRouter, i as BlogBackendHooks, e as BlogRouteKey, N as NextPreviousPostsQuerySchema, P as PostListParams, f as PostListQuerySchema, c as PostListResult, j as blogBackendPlugin, d as createBlogQueryKeys, g as getAllPosts, b as getAllTags, a as getPostBySlug } from '../../../shared/stack.BKfolAyK.js';
2
+ import { P as Post, T as Tag, S as SerializedPost, a as SerializedTag } from '../../../shared/stack.CBON0dWL.js';
3
+ import '@tanstack/react-query';
4
+ import '@btst/stack/plugins/client';
2
5
  import '@btst/stack/plugins/api';
3
6
  import 'better-call';
4
7
  import '@btst/db';
5
- import '../../../shared/stack.BkYlUT_8.js';
6
8
  import 'zod';
7
- import '@tanstack/react-query';
8
- import '@btst/stack/plugins/client';
9
+
10
+ /**
11
+ * Serialize a Tag for SSR/SSG use (convert dates to strings).
12
+ * Pure function — no DB access, no hooks.
13
+ */
14
+ declare function serializeTag(tag: Tag): SerializedTag;
15
+ /**
16
+ * Serialize a Post (with tags) for SSR/SSG use (convert dates to strings).
17
+ * Pure function — no DB access, no hooks.
18
+ */
19
+ declare function serializePost(post: Post & {
20
+ tags: Tag[];
21
+ }): SerializedPost;
22
+
23
+ export { serializePost, serializeTag };
@@ -1,3 +1,5 @@
1
1
  export { NextPreviousPostsQuerySchema, PostListQuerySchema, blogBackendPlugin } from '../../../packages/stack/src/plugins/blog/api/plugin.mjs';
2
2
  export { getAllPosts, getAllTags, getPostBySlug } from '../../../packages/stack/src/plugins/blog/api/getters.mjs';
3
+ export { serializePost, serializeTag } from '../../../packages/stack/src/plugins/blog/api/serializers.mjs';
4
+ export { BLOG_QUERY_KEYS } from '../../../packages/stack/src/plugins/blog/api/query-key-defs.mjs';
3
5
  export { createBlogQueryKeys } from '../query-keys.mjs';
@@ -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.BkYlUT_8.cjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CBON0dWL.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,8 +128,6 @@ declare function useSuspenseTags(): {
128
128
  };
129
129
  /** Create a new post */
130
130
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
131
- title: string;
132
- published: boolean;
133
131
  tags: ({
134
132
  name: string;
135
133
  } | {
@@ -137,12 +135,14 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
137
135
  name: string;
138
136
  slug: string;
139
137
  })[];
138
+ title: string;
140
139
  content: string;
141
140
  excerpt: string;
141
+ published: boolean;
142
142
  slug?: string | undefined;
143
+ publishedAt?: Date | undefined;
143
144
  createdAt?: Date | undefined;
144
145
  updatedAt?: Date | undefined;
145
- publishedAt?: Date | undefined;
146
146
  image?: string | undefined;
147
147
  }, unknown>;
148
148
  /** Update an existing post by id */
@@ -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.BkYlUT_8.mjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CBON0dWL.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,8 +128,6 @@ declare function useSuspenseTags(): {
128
128
  };
129
129
  /** Create a new post */
130
130
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
131
- title: string;
132
- published: boolean;
133
131
  tags: ({
134
132
  name: string;
135
133
  } | {
@@ -137,12 +135,14 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
137
135
  name: string;
138
136
  slug: string;
139
137
  })[];
138
+ title: string;
140
139
  content: string;
141
140
  excerpt: string;
141
+ published: boolean;
142
142
  slug?: string | undefined;
143
+ publishedAt?: Date | undefined;
143
144
  createdAt?: Date | undefined;
144
145
  updatedAt?: Date | undefined;
145
- publishedAt?: Date | undefined;
146
146
  image?: string | undefined;
147
147
  }, unknown>;
148
148
  /** Update an existing post by id */
@@ -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.BkYlUT_8.js';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from '../../../../shared/stack.CBON0dWL.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,8 +128,6 @@ declare function useSuspenseTags(): {
128
128
  };
129
129
  /** Create a new post */
130
130
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
131
- title: string;
132
- published: boolean;
133
131
  tags: ({
134
132
  name: string;
135
133
  } | {
@@ -137,12 +135,14 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
137
135
  name: string;
138
136
  slug: string;
139
137
  })[];
138
+ title: string;
140
139
  content: string;
141
140
  excerpt: string;
141
+ published: boolean;
142
142
  slug?: string | undefined;
143
+ publishedAt?: Date | undefined;
143
144
  createdAt?: Date | undefined;
144
145
  updatedAt?: Date | undefined;
145
- publishedAt?: Date | undefined;
146
146
  image?: string | undefined;
147
147
  }, unknown>;
148
148
  /** Update an existing post by id */
@@ -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.BkYlUT_8.cjs';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CBON0dWL.cjs';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.cjs';
8
8
  import 'zod';
9
9
 
@@ -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.BkYlUT_8.mjs';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CBON0dWL.mjs';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.mjs';
8
8
  import 'zod';
9
9
 
@@ -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.BkYlUT_8.js';
6
+ import { P as Post, S as SerializedPost } from '../../../shared/stack.CBON0dWL.js';
7
7
  export { UsePostsOptions, UsePostsResult } from './hooks/index.js';
8
8
  import 'zod';
9
9
 
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const queryKeyFactory = require('@lukemorales/query-key-factory');
4
+ const queryKeyDefs = require('../../packages/stack/src/plugins/blog/api/query-key-defs.cjs');
4
5
 
5
6
  function isErrorResponse(response) {
6
7
  return typeof response === "object" && response !== null && "error" in response && response.error !== null && response.error !== void 0;
@@ -28,12 +29,12 @@ function createPostsQueries(client, headers) {
28
29
  return queryKeyFactory.createQueryKeys("posts", {
29
30
  list: (params) => ({
30
31
  queryKey: [
31
- {
32
- query: params?.query !== void 0 && params?.query?.trim() === "" ? void 0 : params?.query,
33
- limit: params?.limit ?? 10,
32
+ queryKeyDefs.postsListDiscriminator({
34
33
  published: params?.published ?? true,
35
- tagSlug: params?.tagSlug
36
- }
34
+ limit: params?.limit ?? 10,
35
+ tagSlug: params?.tagSlug,
36
+ query: params?.query
37
+ })
37
38
  ],
38
39
  queryFn: async ({ pageParam }) => {
39
40
  try {
@@ -1,387 +1,8 @@
1
- import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
- import * as better_call from 'better-call';
3
- import { Adapter } from '@btst/db';
4
- import { P as Post, T as Tag, c as createPostSchema, u as updatePostSchema, S as SerializedPost, a as SerializedTag } from '../../shared/stack.BkYlUT_8.cjs';
5
- import { z } from 'zod';
6
- import * as _tanstack_react_query from '@tanstack/react-query';
7
- import { createApiClient } from '@btst/stack/plugins/client';
8
-
9
- /**
10
- * Parameters for filtering/paginating posts.
11
- * Mirrors the shape of the list API query schema.
12
- */
13
- interface PostListParams {
14
- slug?: string;
15
- tagSlug?: string;
16
- offset?: number;
17
- limit?: number;
18
- query?: string;
19
- published?: boolean;
20
- }
21
- /**
22
- * Paginated result returned by {@link getAllPosts}.
23
- */
24
- interface PostListResult {
25
- items: Array<Post & {
26
- tags: Tag[];
27
- }>;
28
- total: number;
29
- limit?: number;
30
- offset?: number;
31
- }
32
- /**
33
- * Retrieve all posts matching optional filter criteria.
34
- * Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
35
- *
36
- * @remarks **Security:** Authorization hooks (e.g. `onBeforeListPosts`) are NOT
37
- * called. The caller is responsible for any access-control checks before
38
- * invoking this function.
39
- *
40
- * @param adapter - The database adapter
41
- * @param params - Optional filter/pagination parameters (same shape as the list API query)
42
- */
43
- declare function getAllPosts(adapter: Adapter, params?: PostListParams): Promise<PostListResult>;
44
- /**
45
- * Retrieve a single post by its slug, including associated tags.
46
- * Returns null if no post is found.
47
- * Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
48
- *
49
- * @remarks **Security:** Authorization hooks are NOT called. The caller is
50
- * responsible for any access-control checks before invoking this function.
51
- *
52
- * @param adapter - The database adapter
53
- * @param slug - The post slug
54
- */
55
- declare function getPostBySlug(adapter: Adapter, slug: string): Promise<(Post & {
56
- tags: Tag[];
57
- }) | null>;
58
- /**
59
- * Retrieve all tags, sorted alphabetically by name.
60
- * Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
61
- *
62
- * @remarks **Security:** Authorization hooks are NOT called. The caller is
63
- * responsible for any access-control checks before invoking this function.
64
- *
65
- * @param adapter - The database adapter
66
- */
67
- declare function getAllTags(adapter: Adapter): Promise<Tag[]>;
68
-
69
- declare const PostListQuerySchema: z.ZodObject<{
70
- slug: z.ZodOptional<z.ZodString>;
71
- tagSlug: z.ZodOptional<z.ZodString>;
72
- offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
73
- limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
74
- query: z.ZodOptional<z.ZodString>;
75
- published: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<boolean | undefined, string | undefined>>;
76
- }, z.core.$strip>;
77
- declare const NextPreviousPostsQuerySchema: z.ZodObject<{
78
- date: z.ZodCoercedDate<unknown>;
79
- }, z.core.$strip>;
80
- /**
81
- * Context passed to blog API hooks
82
- */
83
- interface BlogApiContext<TBody = any, TParams = any, TQuery = any> {
84
- body?: TBody;
85
- params?: TParams;
86
- query?: TQuery;
87
- request?: Request;
88
- headers?: Headers;
89
- [key: string]: any;
90
- }
91
- /**
92
- * Configuration hooks for blog backend plugin
93
- * All hooks are optional and allow consumers to customize behavior
94
- */
95
- interface BlogBackendHooks {
96
- /**
97
- * Called before listing posts. Return false to deny access.
98
- * @param filter - Query parameters for filtering posts
99
- * @param context - Request context with headers, etc.
100
- */
101
- onBeforeListPosts?: (filter: z.infer<typeof PostListQuerySchema>, context: BlogApiContext) => Promise<boolean> | boolean;
102
- /**
103
- * Called before creating a post. Return false to deny access.
104
- * @param data - Post data being created
105
- * @param context - Request context with headers, etc.
106
- */
107
- onBeforeCreatePost?: (data: z.infer<typeof createPostSchema>, context: BlogApiContext) => Promise<boolean> | boolean;
108
- /**
109
- * Called before updating a post. Return false to deny access.
110
- * @param postId - ID of the post being updated
111
- * @param data - Updated post data
112
- * @param context - Request context with headers, etc.
113
- */
114
- onBeforeUpdatePost?: (postId: string, data: z.infer<typeof updatePostSchema>, context: BlogApiContext) => Promise<boolean> | boolean;
115
- /**
116
- * Called before deleting a post. Return false to deny access.
117
- * @param postId - ID of the post being deleted
118
- * @param context - Request context with headers, etc.
119
- */
120
- onBeforeDeletePost?: (postId: string, context: BlogApiContext) => Promise<boolean> | boolean;
121
- /**
122
- * Called after posts are read successfully
123
- * @param posts - The list of posts returned by the query
124
- * @param filter - Query parameters used for filtering
125
- * @param context - Request context
126
- */
127
- onPostsRead?: (posts: Array<Post & {
128
- tags: Tag[];
129
- }>, filter: z.infer<typeof PostListQuerySchema>, context: BlogApiContext) => Promise<void> | void;
130
- /**
131
- * Called after a post is created successfully
132
- * @param post - The created post
133
- * @param context - Request context
134
- */
135
- onPostCreated?: (post: Post, context: BlogApiContext) => Promise<void> | void;
136
- /**
137
- * Called after a post is updated successfully
138
- * @param post - The updated post
139
- * @param context - Request context
140
- */
141
- onPostUpdated?: (post: Post, context: BlogApiContext) => Promise<void> | void;
142
- /**
143
- * Called after a post is deleted successfully
144
- * @param postId - ID of the deleted post
145
- * @param context - Request context
146
- */
147
- onPostDeleted?: (postId: string, context: BlogApiContext) => Promise<void> | void;
148
- /**
149
- * Called when listing posts fails
150
- * @param error - The error that occurred
151
- * @param context - Request context
152
- */
153
- onListPostsError?: (error: Error, context: BlogApiContext) => Promise<void> | void;
154
- /**
155
- * Called when creating a post fails
156
- * @param error - The error that occurred
157
- * @param context - Request context
158
- */
159
- onCreatePostError?: (error: Error, context: BlogApiContext) => Promise<void> | void;
160
- /**
161
- * Called when updating a post fails
162
- * @param error - The error that occurred
163
- * @param context - Request context
164
- */
165
- onUpdatePostError?: (error: Error, context: BlogApiContext) => Promise<void> | void;
166
- /**
167
- * Called when deleting a post fails
168
- * @param error - The error that occurred
169
- * @param context - Request context
170
- */
171
- onDeletePostError?: (error: Error, context: BlogApiContext) => Promise<void> | void;
172
- }
173
- /**
174
- * Blog backend plugin
175
- * Provides API endpoints for managing blog posts
176
- * Uses better-db adapter for database operations
177
- *
178
- * @param hooks - Optional configuration hooks for customizing plugin behavior
179
- */
180
- declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugins_api.BackendPlugin<{
181
- readonly listPosts: better_call.StrictEndpoint<"/posts", {
182
- method: "GET";
183
- query: z.ZodObject<{
184
- slug: z.ZodOptional<z.ZodString>;
185
- tagSlug: z.ZodOptional<z.ZodString>;
186
- offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
187
- limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
188
- query: z.ZodOptional<z.ZodString>;
189
- published: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<boolean | undefined, string | undefined>>;
190
- }, z.core.$strip>;
191
- }, PostListResult>;
192
- readonly createPost: better_call.StrictEndpoint<"/posts", {
193
- method: "POST";
194
- body: z.ZodObject<{
195
- title: z.ZodString;
196
- slug: z.ZodOptional<z.ZodString>;
197
- published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
198
- createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
199
- updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
200
- publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
201
- tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
202
- name: z.ZodString;
203
- }, z.core.$strip>, z.ZodObject<{
204
- id: z.ZodString;
205
- name: z.ZodString;
206
- slug: z.ZodString;
207
- }, z.core.$strip>]>>>>;
208
- content: z.ZodString;
209
- excerpt: z.ZodString;
210
- image: z.ZodOptional<z.ZodString>;
211
- }, z.core.$strip>;
212
- }, Post>;
213
- readonly updatePost: better_call.StrictEndpoint<"/posts/:id", {
214
- method: "PUT";
215
- body: z.ZodObject<{
216
- publishedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
217
- createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
218
- updatedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
219
- title: z.ZodString;
220
- content: z.ZodString;
221
- excerpt: z.ZodString;
222
- image: z.ZodOptional<z.ZodString>;
223
- published: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
224
- slug: z.ZodString;
225
- tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
226
- name: z.ZodString;
227
- }, z.core.$strip>, z.ZodObject<{
228
- id: z.ZodString;
229
- name: z.ZodString;
230
- slug: z.ZodString;
231
- }, z.core.$strip>]>>>>;
232
- id: z.ZodString;
233
- }, z.core.$strip>;
234
- }, Post>;
235
- readonly deletePost: better_call.StrictEndpoint<"/posts/:id", {
236
- method: "DELETE";
237
- }, {
238
- success: boolean;
239
- }>;
240
- readonly getNextPreviousPosts: better_call.StrictEndpoint<"/posts/next-previous", {
241
- method: "GET";
242
- query: z.ZodObject<{
243
- date: z.ZodCoercedDate<unknown>;
244
- }, z.core.$strip>;
245
- }, {
246
- previous: {
247
- tags: Tag[];
248
- id: string;
249
- authorId?: string;
250
- defaultLocale?: string;
251
- slug: string;
252
- title: string;
253
- content: string;
254
- excerpt: string;
255
- image?: string;
256
- published: boolean;
257
- status?: "DRAFT" | "PUBLISHED";
258
- publishedAt?: Date;
259
- createdAt: Date;
260
- updatedAt: Date;
261
- } | null;
262
- next: {
263
- tags: Tag[];
264
- id: string;
265
- authorId?: string;
266
- defaultLocale?: string;
267
- slug: string;
268
- title: string;
269
- content: string;
270
- excerpt: string;
271
- image?: string;
272
- published: boolean;
273
- status?: "DRAFT" | "PUBLISHED";
274
- publishedAt?: Date;
275
- createdAt: Date;
276
- updatedAt: Date;
277
- } | null;
278
- }>;
279
- readonly listTags: better_call.StrictEndpoint<"/tags", {
280
- method: "GET";
281
- }, Tag[]>;
282
- }, {
283
- getAllPosts: (params?: Parameters<typeof getAllPosts>[1]) => Promise<PostListResult>;
284
- getPostBySlug: (slug: string) => Promise<(Post & {
285
- tags: Tag[];
286
- }) | null>;
287
- getAllTags: () => Promise<Tag[]>;
288
- }>;
289
- type BlogApiRouter = ReturnType<ReturnType<typeof blogBackendPlugin>["routes"]>;
290
-
291
- interface PostsListParams {
292
- query?: string;
293
- limit?: number;
294
- published?: boolean;
295
- tagSlug?: string;
296
- }
297
- declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<BlogApiRouter>>, headers?: HeadersInit): {
298
- posts: {
299
- _def: readonly ["posts"];
300
- } & {
301
- list: ((params?: PostsListParams | undefined) => Omit<Omit<{
302
- queryKey: readonly ["posts", "list", {
303
- query: string | undefined;
304
- limit: number;
305
- published: boolean;
306
- tagSlug: string | undefined;
307
- }];
308
- queryFn: _tanstack_react_query.QueryFunction<unknown, readonly ["posts", "list", {
309
- query: string | undefined;
310
- limit: number;
311
- published: boolean;
312
- tagSlug: string | undefined;
313
- }]>;
314
- }, "queryFn"> & {
315
- _def: readonly ["posts", "list"];
316
- }, "_def">) & {
317
- _def: readonly ["posts", "list"];
318
- };
319
- detail: ((slug: string) => Omit<{
320
- queryKey: readonly ["posts", "detail", string];
321
- queryFn: _tanstack_react_query.QueryFunction<SerializedPost | null, readonly ["posts", "detail", string]>;
322
- } & {
323
- _def: readonly ["posts", "detail"];
324
- }, "_def">) & {
325
- _def: readonly ["posts", "detail"];
326
- };
327
- nextPrevious: ((date: string | Date) => Omit<{
328
- queryKey: readonly ["posts", "nextPrevious", string, string | Date];
329
- queryFn: _tanstack_react_query.QueryFunction<{
330
- previous: SerializedPost | null;
331
- next: SerializedPost | null;
332
- }, readonly ["posts", "nextPrevious", string, string | Date]>;
333
- } & {
334
- _def: readonly ["posts", "nextPrevious"];
335
- }, "_def">) & {
336
- _def: readonly ["posts", "nextPrevious"];
337
- };
338
- recent: ((params?: {
339
- limit?: number;
340
- excludeSlug?: string;
341
- } | undefined) => Omit<{
342
- queryKey: readonly ["posts", "recent", string, {
343
- limit?: number;
344
- excludeSlug?: string;
345
- } | undefined];
346
- queryFn: _tanstack_react_query.QueryFunction<SerializedPost[], readonly ["posts", "recent", string, {
347
- limit?: number;
348
- excludeSlug?: string;
349
- } | undefined]>;
350
- } & {
351
- _def: readonly ["posts", "recent"];
352
- }, "_def">) & {
353
- _def: readonly ["posts", "recent"];
354
- };
355
- };
356
- drafts: {
357
- _def: readonly ["drafts"];
358
- } & {
359
- list: ((params?: PostsListParams | undefined) => Omit<Omit<{
360
- queryKey: readonly ["drafts", "list", {
361
- limit?: number | undefined;
362
- }];
363
- queryFn: _tanstack_react_query.QueryFunction<unknown, readonly ["drafts", "list", {
364
- limit?: number | undefined;
365
- }]>;
366
- }, "queryFn"> & {
367
- _def: readonly ["drafts", "list"];
368
- }, "_def">) & {
369
- _def: readonly ["drafts", "list"];
370
- };
371
- };
372
- tags: {
373
- _def: readonly ["tags"];
374
- } & {
375
- list: (() => Omit<{
376
- queryKey: readonly ["tags", "list", string];
377
- queryFn: _tanstack_react_query.QueryFunction<SerializedTag[], readonly ["tags", "list", string]>;
378
- } & {
379
- _def: readonly ["tags", "list"];
380
- }, "_def">) & {
381
- _def: readonly ["tags", "list"];
382
- };
383
- };
384
- };
385
-
386
- export { NextPreviousPostsQuerySchema as N, getPostBySlug as a, getAllTags as b, createBlogQueryKeys, PostListQuerySchema as d, blogBackendPlugin as f, getAllPosts as g };
387
- export type { BlogApiContext as B, PostListParams as P, PostListResult as c, BlogBackendHooks as e, BlogApiRouter as h };
1
+ import '@tanstack/react-query';
2
+ export { d as createBlogQueryKeys } from '../../shared/stack.snB1EDP7.cjs';
3
+ import '@btst/stack/plugins/client';
4
+ import '../../shared/stack.CBON0dWL.cjs';
5
+ import '@btst/stack/plugins/api';
6
+ import 'better-call';
7
+ import '@btst/db';
8
+ import 'zod';