@btst/stack 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -709
- package/dist/api/index.cjs +2 -1
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.mts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.mjs +1 -1
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +24 -5
- package/dist/client/index.d.cts +125 -8
- package/dist/client/index.d.mts +125 -8
- package/dist/client/index.d.ts +125 -8
- package/dist/client/index.mjs +21 -4
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/path-utils.cjs +15 -0
- package/dist/client/path-utils.mjs +13 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -63
- package/dist/context/index.d.cts +21 -24
- package/dist/context/index.d.mts +21 -24
- package/dist/context/index.d.ts +21 -24
- package/dist/context/index.mjs +1 -61
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -2
- package/dist/plugins/api/index.cjs +13 -0
- package/dist/plugins/api/index.d.cts +40 -0
- package/dist/plugins/api/index.d.mts +40 -0
- package/dist/plugins/api/index.d.ts +40 -0
- package/dist/plugins/api/index.mjs +8 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.3OUyGp_E.mjs → plugins/utils.mjs} +1 -1
- package/dist/shared/{stack.DORw_1ps.d.cts → stack.ByOugz9d.d.cts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.mts → stack.ByOugz9d.d.mts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.ts → stack.ByOugz9d.d.ts} +17 -1
- package/dist/shared/stack.CoPoHVfV.d.cts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.mts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.ts +76 -0
- package/package.json +102 -14
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +75 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +109 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/path-utils.ts +38 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +50 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -15
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DrUAVfIH.d.cts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.mts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.ts +0 -17
- /package/dist/{shared/stack.CktCg4PJ.cjs → plugins/utils.cjs} +0 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { Route, createRouter } from "@btst/yar";
|
|
2
|
+
import type { Adapter, DatabaseDefinition, DbPlugin } from "@btst/db";
|
|
3
|
+
import type { Endpoint, Router } from "better-call";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Backend plugin definition
|
|
7
|
+
* Defines API routes and data access for a feature
|
|
8
|
+
*
|
|
9
|
+
* Note: Each plugin defines its own schema using createDbPlugin().
|
|
10
|
+
* Better Stack composes all plugin schemas together at runtime using Better DB's .use() method.
|
|
11
|
+
* You can optionally provide a base schema via the dbSchema config option.
|
|
12
|
+
*
|
|
13
|
+
* @template TRoutes - The exact shape of routes this plugin provides (preserves keys and endpoint types)
|
|
14
|
+
*/
|
|
15
|
+
export interface BackendPlugin<
|
|
16
|
+
TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>,
|
|
17
|
+
> {
|
|
18
|
+
name: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create API endpoints for this plugin
|
|
22
|
+
* Returns an object with named endpoints that will be composed into the router
|
|
23
|
+
*
|
|
24
|
+
* @param adapter - Better DB adapter instance with methods:
|
|
25
|
+
* create, update, updateMany, delete, deleteMany, findOne, findMany, count
|
|
26
|
+
*/
|
|
27
|
+
routes: (adapter: Adapter) => TRoutes;
|
|
28
|
+
dbPlugin: DbPlugin;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Frontend plugin definition
|
|
33
|
+
* Defines pages, components, loaders, and React Query hooks for a feature
|
|
34
|
+
*
|
|
35
|
+
* @template TOverrides - The shape of overridable components/functions this plugin requires
|
|
36
|
+
* Example: { Link: ComponentType<{href: string}>, navigate: (path: string) => void }
|
|
37
|
+
* @template TRoutes - The exact shape of routes this plugin provides (preserves keys and route types)
|
|
38
|
+
*/
|
|
39
|
+
export interface ClientPlugin<
|
|
40
|
+
TOverrides = Record<string, never>,
|
|
41
|
+
TRoutes extends Record<string, Route> = Record<string, Route>,
|
|
42
|
+
> {
|
|
43
|
+
name: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Define routes (pages) for this plugin
|
|
47
|
+
* Returns yar routes that will be composed into the router
|
|
48
|
+
*/
|
|
49
|
+
routes: () => TRoutes;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Optional sitemap generator for this plugin. Should return absolute URLs.
|
|
53
|
+
* Implementations can call their own API endpoints to include dynamic routes.
|
|
54
|
+
*/
|
|
55
|
+
sitemap?: () => Promise<Sitemap> | Sitemap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for creating the backend library
|
|
60
|
+
*/
|
|
61
|
+
export interface BackendLibConfig<
|
|
62
|
+
TPlugins extends Record<string, BackendPlugin<any>> = Record<
|
|
63
|
+
string,
|
|
64
|
+
BackendPlugin<any>
|
|
65
|
+
>,
|
|
66
|
+
> {
|
|
67
|
+
basePath: string;
|
|
68
|
+
dbSchema?: DatabaseDefinition;
|
|
69
|
+
plugins: TPlugins;
|
|
70
|
+
adapter: (db: DatabaseDefinition) => Adapter;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Configuration for creating the client library
|
|
75
|
+
*/
|
|
76
|
+
export interface ClientLibConfig<
|
|
77
|
+
TPlugins extends Record<string, ClientPlugin<any, any>> = Record<
|
|
78
|
+
string,
|
|
79
|
+
ClientPlugin<any, any>
|
|
80
|
+
>,
|
|
81
|
+
> {
|
|
82
|
+
plugins: TPlugins;
|
|
83
|
+
baseURL?: string;
|
|
84
|
+
basePath?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Utility type to extract override types from plugins
|
|
89
|
+
* Maps plugin names to their override types
|
|
90
|
+
*/
|
|
91
|
+
export type InferPluginOverrides<
|
|
92
|
+
TPlugins extends Record<string, ClientPlugin<any, any>>,
|
|
93
|
+
> = {
|
|
94
|
+
[K in keyof TPlugins]: TPlugins[K] extends ClientPlugin<infer TOverrides, any>
|
|
95
|
+
? TOverrides
|
|
96
|
+
: never;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Type for the pluginOverrides prop in BetterStackContext
|
|
101
|
+
* Allows partial overrides per plugin
|
|
102
|
+
*/
|
|
103
|
+
export type PluginOverrides<
|
|
104
|
+
TPlugins extends Record<string, ClientPlugin<any, any>>,
|
|
105
|
+
> = {
|
|
106
|
+
[K in keyof TPlugins]?: Partial<InferPluginOverrides<TPlugins>[K]>;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Extract all routes from all client plugins, merging them into a single record
|
|
111
|
+
*/
|
|
112
|
+
export type PluginRoutes<
|
|
113
|
+
TPlugins extends Record<string, ClientPlugin<any, any>>,
|
|
114
|
+
> = MergeAllPluginRoutes<TPlugins>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Prefix all backend plugin route keys with the plugin name
|
|
118
|
+
* Example: { messages: { list: Endpoint } } => { messages_list: Endpoint }
|
|
119
|
+
*/
|
|
120
|
+
export type PrefixedPluginRoutes<
|
|
121
|
+
TPlugins extends Record<string, BackendPlugin<any>>,
|
|
122
|
+
> = UnionToIntersection<
|
|
123
|
+
{
|
|
124
|
+
[PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<
|
|
125
|
+
infer TRoutes
|
|
126
|
+
>
|
|
127
|
+
? {
|
|
128
|
+
[RouteKey in keyof TRoutes as `${PluginKey & string}_${RouteKey & string}`]: TRoutes[RouteKey];
|
|
129
|
+
}
|
|
130
|
+
: never;
|
|
131
|
+
}[keyof TPlugins]
|
|
132
|
+
> extends infer U
|
|
133
|
+
? U extends Record<string, Endpoint>
|
|
134
|
+
? U
|
|
135
|
+
: Record<string, Endpoint>
|
|
136
|
+
: Record<string, Endpoint>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Result of creating the backend library
|
|
140
|
+
*/
|
|
141
|
+
export interface BackendLib<
|
|
142
|
+
TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>,
|
|
143
|
+
> {
|
|
144
|
+
handler: (request: Request) => Promise<Response>; // API route handler
|
|
145
|
+
router: Router; // Better-call router
|
|
146
|
+
dbSchema: DatabaseDefinition; // Better-db schema
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Helper type to extract routes from a client plugin
|
|
151
|
+
*/
|
|
152
|
+
export type ExtractPluginRoutes<T> = T extends ClientPlugin<any, infer TRoutes>
|
|
153
|
+
? TRoutes
|
|
154
|
+
: never;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Helper type to merge all routes from all plugins into a single record
|
|
158
|
+
*/
|
|
159
|
+
export type MergeAllPluginRoutes<
|
|
160
|
+
TPlugins extends Record<string, ClientPlugin<any, any>>,
|
|
161
|
+
> = UnionToIntersection<
|
|
162
|
+
{
|
|
163
|
+
[K in keyof TPlugins]: ExtractPluginRoutes<TPlugins[K]>;
|
|
164
|
+
}[keyof TPlugins]
|
|
165
|
+
> extends infer U
|
|
166
|
+
? U extends Record<string, Route>
|
|
167
|
+
? U
|
|
168
|
+
: Record<string, Route>
|
|
169
|
+
: Record<string, Route>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Utility type to convert union to intersection
|
|
173
|
+
*/
|
|
174
|
+
type UnionToIntersection<U> = (
|
|
175
|
+
U extends unknown
|
|
176
|
+
? (k: U) => void
|
|
177
|
+
: never
|
|
178
|
+
) extends (k: infer I) => void
|
|
179
|
+
? I
|
|
180
|
+
: never;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Result of creating the client library
|
|
184
|
+
*/
|
|
185
|
+
export interface ClientLib<
|
|
186
|
+
TRoutes extends Record<string, Route> = Record<string, Route>,
|
|
187
|
+
> {
|
|
188
|
+
router: ReturnType<typeof createRouter<TRoutes, {}>>;
|
|
189
|
+
generateSitemap: () => Promise<Sitemap>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Minimal sitemap entry shape aligned with Next.js MetadataRoute.Sitemap
|
|
194
|
+
*/
|
|
195
|
+
export type SitemapEntry = {
|
|
196
|
+
url: string; // absolute
|
|
197
|
+
lastModified?: string | Date;
|
|
198
|
+
changeFrequency?:
|
|
199
|
+
| "always"
|
|
200
|
+
| "hourly"
|
|
201
|
+
| "daily"
|
|
202
|
+
| "weekly"
|
|
203
|
+
| "monthly"
|
|
204
|
+
| "yearly"
|
|
205
|
+
| "never";
|
|
206
|
+
priority?: number;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type Sitemap = Array<SitemapEntry>;
|
package/dist/plugins/index.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const utils = require('../shared/stack.CktCg4PJ.cjs');
|
|
4
|
-
require('better-call/client');
|
|
5
|
-
|
|
6
|
-
function defineClientPlugin(plugin) {
|
|
7
|
-
return plugin;
|
|
8
|
-
}
|
|
9
|
-
function defineBackendPlugin(plugin) {
|
|
10
|
-
return plugin;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.createApiClient = utils.createApiClient;
|
|
14
|
-
exports.defineBackendPlugin = defineBackendPlugin;
|
|
15
|
-
exports.defineClientPlugin = defineClientPlugin;
|
package/dist/plugins/index.d.cts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.cjs';
|
|
2
|
-
export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.cjs';
|
|
3
|
-
import { Endpoint } from 'better-call';
|
|
4
|
-
export { Endpoint, Router } from 'better-call';
|
|
5
|
-
export { c as createApiClient } from '../shared/stack.DrUAVfIH.cjs';
|
|
6
|
-
export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
|
|
7
|
-
export { Route } from '@btst/yar';
|
|
8
|
-
import 'better-call/client';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Plugin utilities and types for building standalone plugins
|
|
12
|
-
*
|
|
13
|
-
* This module exports everything needed to create custom plugins
|
|
14
|
-
* for Better Stack outside of this package.
|
|
15
|
-
*
|
|
16
|
-
* Note: Backend and Client plugins are separate to prevent SSR issues
|
|
17
|
-
* and enable better code splitting. Import them separately:
|
|
18
|
-
* - Backend: import type { BackendPlugin } from "@btst/stack/plugins"
|
|
19
|
-
* - Client: import type { ClientPlugin } from "@btst/stack/plugins"
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Helper to define a client plugin with full type inference
|
|
24
|
-
*
|
|
25
|
-
* Automatically infers route keys, hook names, and their types without needing casts.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const messagesPlugin = defineClientPlugin({
|
|
30
|
-
* name: "messages",
|
|
31
|
-
* routes: () => ({
|
|
32
|
-
* messagesList: createRoute("/messages", () => ({ ... }))
|
|
33
|
-
* }),
|
|
34
|
-
* hooks: () => ({
|
|
35
|
-
* useMessages: () => { ... }
|
|
36
|
-
* })
|
|
37
|
-
* });
|
|
38
|
-
* // No casts needed - route keys, hook names, and types are all preserved!
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @template TPlugin - The exact plugin definition (auto-inferred)
|
|
42
|
-
*/
|
|
43
|
-
declare function defineClientPlugin<TPlugin extends ClientPlugin<any, any>>(plugin: TPlugin): TPlugin;
|
|
44
|
-
/**
|
|
45
|
-
* Helper to define a backend plugin with full type inference
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const messagesPlugin = defineBackendPlugin({
|
|
50
|
-
* name: "messages",
|
|
51
|
-
* dbPlugin: createDbPlugin("messages", messagesSchema),
|
|
52
|
-
* routes: (adapter) => ({
|
|
53
|
-
* list: endpoint("/messages", { method: "GET" }, async () => { ... }),
|
|
54
|
-
* create: endpoint("/messages", { method: "POST" }, async () => { ... })
|
|
55
|
-
* })
|
|
56
|
-
* });
|
|
57
|
-
* // Route keys "list" and "create" are preserved in types!
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @template TRoutes - The exact shape of routes (auto-inferred from routes function)
|
|
61
|
-
*/
|
|
62
|
-
declare function defineBackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>>(plugin: BackendPlugin<TRoutes>): BackendPlugin<TRoutes>;
|
|
63
|
-
|
|
64
|
-
export { BackendPlugin, ClientPlugin, defineBackendPlugin, defineClientPlugin };
|
package/dist/plugins/index.d.mts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.mjs';
|
|
2
|
-
export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.mjs';
|
|
3
|
-
import { Endpoint } from 'better-call';
|
|
4
|
-
export { Endpoint, Router } from 'better-call';
|
|
5
|
-
export { c as createApiClient } from '../shared/stack.DrUAVfIH.mjs';
|
|
6
|
-
export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
|
|
7
|
-
export { Route } from '@btst/yar';
|
|
8
|
-
import 'better-call/client';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Plugin utilities and types for building standalone plugins
|
|
12
|
-
*
|
|
13
|
-
* This module exports everything needed to create custom plugins
|
|
14
|
-
* for Better Stack outside of this package.
|
|
15
|
-
*
|
|
16
|
-
* Note: Backend and Client plugins are separate to prevent SSR issues
|
|
17
|
-
* and enable better code splitting. Import them separately:
|
|
18
|
-
* - Backend: import type { BackendPlugin } from "@btst/stack/plugins"
|
|
19
|
-
* - Client: import type { ClientPlugin } from "@btst/stack/plugins"
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Helper to define a client plugin with full type inference
|
|
24
|
-
*
|
|
25
|
-
* Automatically infers route keys, hook names, and their types without needing casts.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const messagesPlugin = defineClientPlugin({
|
|
30
|
-
* name: "messages",
|
|
31
|
-
* routes: () => ({
|
|
32
|
-
* messagesList: createRoute("/messages", () => ({ ... }))
|
|
33
|
-
* }),
|
|
34
|
-
* hooks: () => ({
|
|
35
|
-
* useMessages: () => { ... }
|
|
36
|
-
* })
|
|
37
|
-
* });
|
|
38
|
-
* // No casts needed - route keys, hook names, and types are all preserved!
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @template TPlugin - The exact plugin definition (auto-inferred)
|
|
42
|
-
*/
|
|
43
|
-
declare function defineClientPlugin<TPlugin extends ClientPlugin<any, any>>(plugin: TPlugin): TPlugin;
|
|
44
|
-
/**
|
|
45
|
-
* Helper to define a backend plugin with full type inference
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const messagesPlugin = defineBackendPlugin({
|
|
50
|
-
* name: "messages",
|
|
51
|
-
* dbPlugin: createDbPlugin("messages", messagesSchema),
|
|
52
|
-
* routes: (adapter) => ({
|
|
53
|
-
* list: endpoint("/messages", { method: "GET" }, async () => { ... }),
|
|
54
|
-
* create: endpoint("/messages", { method: "POST" }, async () => { ... })
|
|
55
|
-
* })
|
|
56
|
-
* });
|
|
57
|
-
* // Route keys "list" and "create" are preserved in types!
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @template TRoutes - The exact shape of routes (auto-inferred from routes function)
|
|
61
|
-
*/
|
|
62
|
-
declare function defineBackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>>(plugin: BackendPlugin<TRoutes>): BackendPlugin<TRoutes>;
|
|
63
|
-
|
|
64
|
-
export { BackendPlugin, ClientPlugin, defineBackendPlugin, defineClientPlugin };
|
package/dist/plugins/index.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.js';
|
|
2
|
-
export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.js';
|
|
3
|
-
import { Endpoint } from 'better-call';
|
|
4
|
-
export { Endpoint, Router } from 'better-call';
|
|
5
|
-
export { c as createApiClient } from '../shared/stack.DrUAVfIH.js';
|
|
6
|
-
export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
|
|
7
|
-
export { Route } from '@btst/yar';
|
|
8
|
-
import 'better-call/client';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Plugin utilities and types for building standalone plugins
|
|
12
|
-
*
|
|
13
|
-
* This module exports everything needed to create custom plugins
|
|
14
|
-
* for Better Stack outside of this package.
|
|
15
|
-
*
|
|
16
|
-
* Note: Backend and Client plugins are separate to prevent SSR issues
|
|
17
|
-
* and enable better code splitting. Import them separately:
|
|
18
|
-
* - Backend: import type { BackendPlugin } from "@btst/stack/plugins"
|
|
19
|
-
* - Client: import type { ClientPlugin } from "@btst/stack/plugins"
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Helper to define a client plugin with full type inference
|
|
24
|
-
*
|
|
25
|
-
* Automatically infers route keys, hook names, and their types without needing casts.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const messagesPlugin = defineClientPlugin({
|
|
30
|
-
* name: "messages",
|
|
31
|
-
* routes: () => ({
|
|
32
|
-
* messagesList: createRoute("/messages", () => ({ ... }))
|
|
33
|
-
* }),
|
|
34
|
-
* hooks: () => ({
|
|
35
|
-
* useMessages: () => { ... }
|
|
36
|
-
* })
|
|
37
|
-
* });
|
|
38
|
-
* // No casts needed - route keys, hook names, and types are all preserved!
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @template TPlugin - The exact plugin definition (auto-inferred)
|
|
42
|
-
*/
|
|
43
|
-
declare function defineClientPlugin<TPlugin extends ClientPlugin<any, any>>(plugin: TPlugin): TPlugin;
|
|
44
|
-
/**
|
|
45
|
-
* Helper to define a backend plugin with full type inference
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const messagesPlugin = defineBackendPlugin({
|
|
50
|
-
* name: "messages",
|
|
51
|
-
* dbPlugin: createDbPlugin("messages", messagesSchema),
|
|
52
|
-
* routes: (adapter) => ({
|
|
53
|
-
* list: endpoint("/messages", { method: "GET" }, async () => { ... }),
|
|
54
|
-
* create: endpoint("/messages", { method: "POST" }, async () => { ... })
|
|
55
|
-
* })
|
|
56
|
-
* });
|
|
57
|
-
* // Route keys "list" and "create" are preserved in types!
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @template TRoutes - The exact shape of routes (auto-inferred from routes function)
|
|
61
|
-
*/
|
|
62
|
-
declare function defineBackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>>(plugin: BackendPlugin<TRoutes>): BackendPlugin<TRoutes>;
|
|
63
|
-
|
|
64
|
-
export { BackendPlugin, ClientPlugin, defineBackendPlugin, defineClientPlugin };
|
package/dist/plugins/index.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { c as createApiClient } from '../shared/stack.3OUyGp_E.mjs';
|
|
2
|
-
import 'better-call/client';
|
|
3
|
-
|
|
4
|
-
function defineClientPlugin(plugin) {
|
|
5
|
-
return plugin;
|
|
6
|
-
}
|
|
7
|
-
function defineBackendPlugin(plugin) {
|
|
8
|
-
return plugin;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { defineBackendPlugin, defineClientPlugin };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createClient } from 'better-call/client';
|
|
2
|
-
import { Router, Endpoint } from 'better-call';
|
|
3
|
-
|
|
4
|
-
interface CreateApiClientOptions {
|
|
5
|
-
baseURL?: string;
|
|
6
|
-
basePath?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a Better Call API client with proper URL handling for both server and client side
|
|
10
|
-
* @param options - Configuration options
|
|
11
|
-
* @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
|
|
12
|
-
* @param options.basePath - The API base path (defaults to '/')
|
|
13
|
-
* @template TRouter - The router type (Router or Record<string, Endpoint>)
|
|
14
|
-
*/
|
|
15
|
-
declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
|
|
16
|
-
|
|
17
|
-
export { createApiClient as c };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createClient } from 'better-call/client';
|
|
2
|
-
import { Router, Endpoint } from 'better-call';
|
|
3
|
-
|
|
4
|
-
interface CreateApiClientOptions {
|
|
5
|
-
baseURL?: string;
|
|
6
|
-
basePath?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a Better Call API client with proper URL handling for both server and client side
|
|
10
|
-
* @param options - Configuration options
|
|
11
|
-
* @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
|
|
12
|
-
* @param options.basePath - The API base path (defaults to '/')
|
|
13
|
-
* @template TRouter - The router type (Router or Record<string, Endpoint>)
|
|
14
|
-
*/
|
|
15
|
-
declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
|
|
16
|
-
|
|
17
|
-
export { createApiClient as c };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createClient } from 'better-call/client';
|
|
2
|
-
import { Router, Endpoint } from 'better-call';
|
|
3
|
-
|
|
4
|
-
interface CreateApiClientOptions {
|
|
5
|
-
baseURL?: string;
|
|
6
|
-
basePath?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a Better Call API client with proper URL handling for both server and client side
|
|
10
|
-
* @param options - Configuration options
|
|
11
|
-
* @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
|
|
12
|
-
* @param options.basePath - The API base path (defaults to '/')
|
|
13
|
-
* @template TRouter - The router type (Router or Record<string, Endpoint>)
|
|
14
|
-
*/
|
|
15
|
-
declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
|
|
16
|
-
|
|
17
|
-
export { createApiClient as c };
|
|
File without changes
|