@btst/stack 2.11.1 → 2.11.2

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 (40) hide show
  1. package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +170 -0
  2. package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +166 -0
  3. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +34 -157
  4. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +40 -163
  5. package/dist/plugins/blog/api/index.cjs +4 -0
  6. package/dist/plugins/blog/api/index.d.cts +2 -2
  7. package/dist/plugins/blog/api/index.d.mts +2 -2
  8. package/dist/plugins/blog/api/index.d.ts +2 -2
  9. package/dist/plugins/blog/api/index.mjs +1 -0
  10. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  11. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  12. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  13. package/dist/plugins/blog/client/index.d.cts +2 -2
  14. package/dist/plugins/blog/client/index.d.mts +2 -2
  15. package/dist/plugins/blog/client/index.d.ts +2 -2
  16. package/dist/plugins/blog/query-keys.d.cts +2 -2
  17. package/dist/plugins/blog/query-keys.d.mts +2 -2
  18. package/dist/plugins/blog/query-keys.d.ts +2 -2
  19. package/dist/plugins/kanban/api/index.d.cts +1 -1
  20. package/dist/plugins/kanban/api/index.d.mts +1 -1
  21. package/dist/plugins/kanban/api/index.d.ts +1 -1
  22. package/dist/plugins/kanban/query-keys.d.cts +1 -1
  23. package/dist/plugins/kanban/query-keys.d.mts +1 -1
  24. package/dist/plugins/kanban/query-keys.d.ts +1 -1
  25. package/dist/shared/{stack.DvMUCTTl.d.mts → stack.D0p6oNme.d.ts} +96 -13
  26. package/dist/shared/{stack.DGsFF5qb.d.cts → stack.DOZ1EXjM.d.mts} +5 -5
  27. package/dist/shared/{stack.qta0-CPq.d.ts → stack.DWipT53I.d.cts} +96 -13
  28. package/dist/shared/{stack.NtflNnnH.d.mts → stack.DX-tQ93o.d.cts} +5 -5
  29. package/dist/shared/{stack.DEW8EtFu.d.cts → stack.E17kSK1W.d.mts} +96 -13
  30. package/dist/shared/{stack.QrBE0Bc8.d.ts → stack.VF6FhyZw.d.ts} +5 -5
  31. package/package.json +1 -1
  32. package/src/plugins/blog/api/index.ts +7 -0
  33. package/src/plugins/blog/api/mutations.ts +287 -0
  34. package/src/plugins/blog/api/plugin.ts +43 -184
  35. package/dist/shared/{stack.BOokfhZD.d.cts → stack.B6S3cgwN.d.cts} +16 -16
  36. package/dist/shared/{stack.Sod_PZhB.d.cts → stack.BWp0hcm9.d.cts} +7 -7
  37. package/dist/shared/{stack.Sod_PZhB.d.mts → stack.BWp0hcm9.d.mts} +7 -7
  38. package/dist/shared/{stack.Sod_PZhB.d.ts → stack.BWp0hcm9.d.ts} +7 -7
  39. package/dist/shared/{stack.CWxAl9K3.d.mts → stack.Bzfx-_lq.d.mts} +16 -16
  40. package/dist/shared/{stack.BvCR4-9H.d.ts → stack.j5SFLC1d.d.ts} +16 -16
@@ -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 './stack.Sod_PZhB.cjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from './stack.BWp0hcm9.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,10 +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
- published: boolean;
132
- title: string;
133
- content: string;
134
- excerpt: string;
135
131
  tags: ({
136
132
  name: string;
137
133
  } | {
@@ -139,6 +135,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
139
135
  name: string;
140
136
  slug: string;
141
137
  })[];
138
+ published: boolean;
139
+ title: string;
140
+ content: string;
141
+ excerpt: string;
142
142
  slug?: string | undefined;
143
143
  publishedAt?: Date | undefined;
144
144
  createdAt?: Date | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
  import { createApiClient } from '@btst/stack/plugins/client';
4
- import { P as Post, T as Tag, c as createPostSchema, u as updatePostSchema, S as SerializedPost, a as SerializedTag } from './stack.Sod_PZhB.js';
4
+ import { P as Post, T as Tag, c as createPostSchema, u as updatePostSchema, S as SerializedPost, a as SerializedTag } from './stack.BWp0hcm9.cjs';
5
5
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
6
6
  import { DBAdapter } from '@btst/db';
7
7
  import * as better_call from 'better-call';
@@ -67,6 +67,86 @@ declare function getPostBySlug(adapter: DBAdapter, slug: string): Promise<(Post
67
67
  */
68
68
  declare function getAllTags(adapter: DBAdapter): Promise<Tag[]>;
69
69
 
70
+ type TagInput = {
71
+ name: string;
72
+ } | {
73
+ id: string;
74
+ name: string;
75
+ slug: string;
76
+ };
77
+ /**
78
+ * Input for creating a new blog post.
79
+ * `slug` must already be slugified by the caller.
80
+ */
81
+ interface CreatePostInput {
82
+ title: string;
83
+ content: string;
84
+ excerpt: string;
85
+ /** Pre-slugified URL slug — use {@link slugify} before passing. */
86
+ slug: string;
87
+ image?: string;
88
+ published?: boolean;
89
+ publishedAt?: Date;
90
+ createdAt?: Date;
91
+ updatedAt?: Date;
92
+ tags?: TagInput[];
93
+ }
94
+ /**
95
+ * Input for updating an existing blog post.
96
+ * If `slug` is provided it must already be slugified by the caller.
97
+ */
98
+ interface UpdatePostInput {
99
+ title?: string;
100
+ content?: string;
101
+ excerpt?: string;
102
+ /** Pre-slugified URL slug — use {@link slugify} before passing. */
103
+ slug?: string;
104
+ image?: string;
105
+ published?: boolean;
106
+ publishedAt?: Date;
107
+ createdAt?: Date;
108
+ updatedAt?: Date;
109
+ tags?: TagInput[];
110
+ }
111
+ /**
112
+ * Create a new blog post with optional tag associations.
113
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side and SSG use.
114
+ *
115
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeCreatePost`) are NOT
116
+ * called. The caller is responsible for any access-control checks before
117
+ * invoking this function.
118
+ *
119
+ * @param adapter - The database adapter
120
+ * @param input - Post data; `slug` must be pre-slugified
121
+ */
122
+ declare function createPost(adapter: DBAdapter, input: CreatePostInput): Promise<Post>;
123
+ /**
124
+ * Update an existing blog post and reconcile its tag associations.
125
+ * Returns `null` if no post with the given `id` exists.
126
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side use.
127
+ *
128
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeUpdatePost`) are NOT
129
+ * called. The caller is responsible for any access-control checks before
130
+ * invoking this function.
131
+ *
132
+ * @param adapter - The database adapter
133
+ * @param id - The post ID to update
134
+ * @param input - Partial post data to apply; `slug` must be pre-slugified if provided
135
+ */
136
+ declare function updatePost(adapter: DBAdapter, id: string, input: UpdatePostInput): Promise<Post | null>;
137
+ /**
138
+ * Delete a blog post by ID.
139
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side use.
140
+ *
141
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeDeletePost`) are NOT
142
+ * called. The caller is responsible for any access-control checks before
143
+ * invoking this function.
144
+ *
145
+ * @param adapter - The database adapter
146
+ * @param id - The post ID to delete
147
+ */
148
+ declare function deletePost(adapter: DBAdapter, id: string): Promise<void>;
149
+
70
150
  /**
71
151
  * Route keys for the blog plugin — matches the keys returned by
72
152
  * `stackClient.router.getRoute(path).routeKey`.
@@ -236,12 +316,6 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
236
316
  title: string;
237
317
  content: string;
238
318
  excerpt: string;
239
- slug?: string | undefined;
240
- published?: boolean | undefined;
241
- publishedAt?: unknown;
242
- createdAt?: unknown;
243
- updatedAt?: unknown;
244
- image?: string | undefined;
245
319
  tags?: ({
246
320
  name: string;
247
321
  } | {
@@ -249,16 +323,16 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
249
323
  name: string;
250
324
  slug: string;
251
325
  })[] | undefined;
252
- }, {
253
- title: string;
254
- content: string;
255
- excerpt: string;
256
326
  slug?: string | undefined;
257
327
  published?: boolean | undefined;
258
328
  publishedAt?: unknown;
259
329
  createdAt?: unknown;
260
330
  updatedAt?: unknown;
261
331
  image?: string | undefined;
332
+ }, {
333
+ title: string;
334
+ content: string;
335
+ excerpt: string;
262
336
  tags?: ({
263
337
  name: string;
264
338
  } | {
@@ -266,6 +340,12 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
266
340
  name: string;
267
341
  slug: string;
268
342
  })[] | undefined;
343
+ slug?: string | undefined;
344
+ published?: boolean | undefined;
345
+ publishedAt?: unknown;
346
+ createdAt?: unknown;
347
+ updatedAt?: unknown;
348
+ image?: string | undefined;
269
349
  }>;
270
350
  }, Post>;
271
351
  readonly updatePost: better_call.StrictEndpoint<"/posts/:id", {} & {
@@ -366,6 +446,9 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
366
446
  }) | null>;
367
447
  getAllTags: () => Promise<Tag[]>;
368
448
  prefetchForRoute: BlogPrefetchForRoute;
449
+ createPost: (input: CreatePostInput) => Promise<Post>;
450
+ updatePost: (id: string, input: UpdatePostInput) => Promise<Post | null>;
451
+ deletePost: (id: string) => Promise<void>;
369
452
  }>;
370
453
  type BlogApiRouter = ReturnType<ReturnType<typeof blogBackendPlugin>["routes"]>;
371
454
 
@@ -476,5 +559,5 @@ declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<B
476
559
  };
477
560
  };
478
561
 
479
- export { BLOG_QUERY_KEYS as B, NextPreviousPostsQuerySchema as N, getPostBySlug as a, getAllTags as b, createBlogQueryKeys as d, PostListQuerySchema as f, getAllPosts as g, blogBackendPlugin as j };
480
- export type { PostListParams as P, PostListResult as c, BlogRouteKey as e, BlogApiContext as h, BlogBackendHooks as i, BlogApiRouter as k };
562
+ export { BLOG_QUERY_KEYS as B, NextPreviousPostsQuerySchema as N, getPostBySlug as a, getAllTags as b, createPost as d, deletePost as e, createBlogQueryKeys as f, getAllPosts as g, PostListQuerySchema as i, blogBackendPlugin as l, updatePost as u };
563
+ export type { CreatePostInput as C, PostListParams as P, UpdatePostInput as U, PostListResult as c, BlogRouteKey as h, BlogApiContext as j, BlogBackendHooks as k, BlogApiRouter as m };
@@ -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 './stack.Sod_PZhB.mjs';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from './stack.BWp0hcm9.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,10 +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
- published: boolean;
132
- title: string;
133
- content: string;
134
- excerpt: string;
135
131
  tags: ({
136
132
  name: string;
137
133
  } | {
@@ -139,6 +135,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
139
135
  name: string;
140
136
  slug: string;
141
137
  })[];
138
+ published: boolean;
139
+ title: string;
140
+ content: string;
141
+ excerpt: string;
142
142
  slug?: string | undefined;
143
143
  publishedAt?: Date | undefined;
144
144
  createdAt?: Date | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
  import { createApiClient } from '@btst/stack/plugins/client';
4
- import { P as Post, T as Tag, c as createPostSchema, u as updatePostSchema, S as SerializedPost, a as SerializedTag } from './stack.Sod_PZhB.cjs';
4
+ import { P as Post, T as Tag, c as createPostSchema, u as updatePostSchema, S as SerializedPost, a as SerializedTag } from './stack.BWp0hcm9.mjs';
5
5
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
6
6
  import { DBAdapter } from '@btst/db';
7
7
  import * as better_call from 'better-call';
@@ -67,6 +67,86 @@ declare function getPostBySlug(adapter: DBAdapter, slug: string): Promise<(Post
67
67
  */
68
68
  declare function getAllTags(adapter: DBAdapter): Promise<Tag[]>;
69
69
 
70
+ type TagInput = {
71
+ name: string;
72
+ } | {
73
+ id: string;
74
+ name: string;
75
+ slug: string;
76
+ };
77
+ /**
78
+ * Input for creating a new blog post.
79
+ * `slug` must already be slugified by the caller.
80
+ */
81
+ interface CreatePostInput {
82
+ title: string;
83
+ content: string;
84
+ excerpt: string;
85
+ /** Pre-slugified URL slug — use {@link slugify} before passing. */
86
+ slug: string;
87
+ image?: string;
88
+ published?: boolean;
89
+ publishedAt?: Date;
90
+ createdAt?: Date;
91
+ updatedAt?: Date;
92
+ tags?: TagInput[];
93
+ }
94
+ /**
95
+ * Input for updating an existing blog post.
96
+ * If `slug` is provided it must already be slugified by the caller.
97
+ */
98
+ interface UpdatePostInput {
99
+ title?: string;
100
+ content?: string;
101
+ excerpt?: string;
102
+ /** Pre-slugified URL slug — use {@link slugify} before passing. */
103
+ slug?: string;
104
+ image?: string;
105
+ published?: boolean;
106
+ publishedAt?: Date;
107
+ createdAt?: Date;
108
+ updatedAt?: Date;
109
+ tags?: TagInput[];
110
+ }
111
+ /**
112
+ * Create a new blog post with optional tag associations.
113
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side and SSG use.
114
+ *
115
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeCreatePost`) are NOT
116
+ * called. The caller is responsible for any access-control checks before
117
+ * invoking this function.
118
+ *
119
+ * @param adapter - The database adapter
120
+ * @param input - Post data; `slug` must be pre-slugified
121
+ */
122
+ declare function createPost(adapter: DBAdapter, input: CreatePostInput): Promise<Post>;
123
+ /**
124
+ * Update an existing blog post and reconcile its tag associations.
125
+ * Returns `null` if no post with the given `id` exists.
126
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side use.
127
+ *
128
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeUpdatePost`) are NOT
129
+ * called. The caller is responsible for any access-control checks before
130
+ * invoking this function.
131
+ *
132
+ * @param adapter - The database adapter
133
+ * @param id - The post ID to update
134
+ * @param input - Partial post data to apply; `slug` must be pre-slugified if provided
135
+ */
136
+ declare function updatePost(adapter: DBAdapter, id: string, input: UpdatePostInput): Promise<Post | null>;
137
+ /**
138
+ * Delete a blog post by ID.
139
+ * Pure DB function — no hooks, no HTTP context. Safe for server-side use.
140
+ *
141
+ * @remarks **Security:** Authorization hooks (e.g. `onBeforeDeletePost`) are NOT
142
+ * called. The caller is responsible for any access-control checks before
143
+ * invoking this function.
144
+ *
145
+ * @param adapter - The database adapter
146
+ * @param id - The post ID to delete
147
+ */
148
+ declare function deletePost(adapter: DBAdapter, id: string): Promise<void>;
149
+
70
150
  /**
71
151
  * Route keys for the blog plugin — matches the keys returned by
72
152
  * `stackClient.router.getRoute(path).routeKey`.
@@ -236,12 +316,6 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
236
316
  title: string;
237
317
  content: string;
238
318
  excerpt: string;
239
- slug?: string | undefined;
240
- published?: boolean | undefined;
241
- publishedAt?: unknown;
242
- createdAt?: unknown;
243
- updatedAt?: unknown;
244
- image?: string | undefined;
245
319
  tags?: ({
246
320
  name: string;
247
321
  } | {
@@ -249,16 +323,16 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
249
323
  name: string;
250
324
  slug: string;
251
325
  })[] | undefined;
252
- }, {
253
- title: string;
254
- content: string;
255
- excerpt: string;
256
326
  slug?: string | undefined;
257
327
  published?: boolean | undefined;
258
328
  publishedAt?: unknown;
259
329
  createdAt?: unknown;
260
330
  updatedAt?: unknown;
261
331
  image?: string | undefined;
332
+ }, {
333
+ title: string;
334
+ content: string;
335
+ excerpt: string;
262
336
  tags?: ({
263
337
  name: string;
264
338
  } | {
@@ -266,6 +340,12 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
266
340
  name: string;
267
341
  slug: string;
268
342
  })[] | undefined;
343
+ slug?: string | undefined;
344
+ published?: boolean | undefined;
345
+ publishedAt?: unknown;
346
+ createdAt?: unknown;
347
+ updatedAt?: unknown;
348
+ image?: string | undefined;
269
349
  }>;
270
350
  }, Post>;
271
351
  readonly updatePost: better_call.StrictEndpoint<"/posts/:id", {} & {
@@ -366,6 +446,9 @@ declare const blogBackendPlugin: (hooks?: BlogBackendHooks) => _btst_stack_plugi
366
446
  }) | null>;
367
447
  getAllTags: () => Promise<Tag[]>;
368
448
  prefetchForRoute: BlogPrefetchForRoute;
449
+ createPost: (input: CreatePostInput) => Promise<Post>;
450
+ updatePost: (id: string, input: UpdatePostInput) => Promise<Post | null>;
451
+ deletePost: (id: string) => Promise<void>;
369
452
  }>;
370
453
  type BlogApiRouter = ReturnType<ReturnType<typeof blogBackendPlugin>["routes"]>;
371
454
 
@@ -476,5 +559,5 @@ declare function createBlogQueryKeys(client: ReturnType<typeof createApiClient<B
476
559
  };
477
560
  };
478
561
 
479
- export { BLOG_QUERY_KEYS as B, NextPreviousPostsQuerySchema as N, getPostBySlug as a, getAllTags as b, createBlogQueryKeys as d, PostListQuerySchema as f, getAllPosts as g, blogBackendPlugin as j };
480
- export type { PostListParams as P, PostListResult as c, BlogRouteKey as e, BlogApiContext as h, BlogBackendHooks as i, BlogApiRouter as k };
562
+ export { BLOG_QUERY_KEYS as B, NextPreviousPostsQuerySchema as N, getPostBySlug as a, getAllTags as b, createPost as d, deletePost as e, createBlogQueryKeys as f, getAllPosts as g, PostListQuerySchema as i, blogBackendPlugin as l, updatePost as u };
563
+ export type { CreatePostInput as C, PostListParams as P, UpdatePostInput as U, PostListResult as c, BlogRouteKey as h, BlogApiContext as j, BlogBackendHooks as k, BlogApiRouter as m };
@@ -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 './stack.Sod_PZhB.js';
2
+ import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from './stack.BWp0hcm9.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -128,10 +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
- published: boolean;
132
- title: string;
133
- content: string;
134
- excerpt: string;
135
131
  tags: ({
136
132
  name: string;
137
133
  } | {
@@ -139,6 +135,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
139
135
  name: string;
140
136
  slug: string;
141
137
  })[];
138
+ published: boolean;
139
+ title: string;
140
+ content: string;
141
+ excerpt: string;
142
142
  slug?: string | undefined;
143
143
  publishedAt?: Date | undefined;
144
144
  createdAt?: Date | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btst/stack",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "A composable, plugin-based library for building full-stack applications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,6 +6,13 @@ export {
6
6
  type PostListParams,
7
7
  type PostListResult,
8
8
  } from "./getters";
9
+ export {
10
+ createPost,
11
+ updatePost,
12
+ deletePost,
13
+ type CreatePostInput,
14
+ type UpdatePostInput,
15
+ } from "./mutations";
9
16
  export { serializePost, serializeTag } from "./serializers";
10
17
  export { BLOG_QUERY_KEYS } from "./query-key-defs";
11
18
  export { createBlogQueryKeys } from "../query-keys";