@btst/stack 2.1.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.
- package/dist/api/index.cjs +9 -1
- package/dist/api/index.d.cts +4 -4
- package/dist/api/index.d.mts +4 -4
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.mjs +9 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.cjs +42 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.mjs +39 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +5 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +5 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.cjs +131 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.mjs +127 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.cjs +18 -0
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.mjs +18 -0
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +16 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +17 -2
- package/dist/packages/stack/src/plugins/cms/api/getters.cjs +156 -0
- package/dist/packages/stack/src/plugins/cms/api/getters.mjs +147 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +624 -617
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +623 -616
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +29 -0
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +120 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +112 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +75 -86
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +71 -82
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +37 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +33 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +84 -0
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +81 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.cjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.mjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +30 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +11 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +12 -2
- package/dist/packages/stack/src/plugins/utils.cjs +6 -0
- package/dist/packages/stack/src/plugins/utils.mjs +6 -1
- package/dist/plugins/ai-chat/api/index.cjs +3 -0
- package/dist/plugins/ai-chat/api/index.d.cts +27 -4
- package/dist/plugins/ai-chat/api/index.d.mts +27 -4
- package/dist/plugins/ai-chat/api/index.d.ts +27 -4
- package/dist/plugins/ai-chat/api/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
- package/dist/plugins/ai-chat/query-keys.d.cts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.mts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.ts +9 -284
- package/dist/plugins/api/index.d.cts +4 -3
- package/dist/plugins/api/index.d.mts +4 -3
- package/dist/plugins/api/index.d.ts +4 -3
- package/dist/plugins/blog/api/index.cjs +9 -0
- package/dist/plugins/blog/api/index.d.cts +20 -4
- package/dist/plugins/blog/api/index.d.mts +20 -4
- package/dist/plugins/blog/api/index.d.ts +20 -4
- package/dist/plugins/blog/api/index.mjs +3 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.mts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.ts +5 -5
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.cjs +13 -9
- package/dist/plugins/blog/query-keys.d.cts +8 -333
- package/dist/plugins/blog/query-keys.d.mts +8 -333
- package/dist/plugins/blog/query-keys.d.ts +8 -333
- package/dist/plugins/blog/query-keys.mjs +13 -9
- package/dist/plugins/client/index.cjs +1 -0
- package/dist/plugins/client/index.d.cts +10 -3
- package/dist/plugins/client/index.d.mts +10 -3
- package/dist/plugins/client/index.d.ts +10 -3
- package/dist/plugins/client/index.mjs +1 -1
- package/dist/plugins/cms/api/index.cjs +10 -0
- package/dist/plugins/cms/api/index.d.cts +7 -163
- package/dist/plugins/cms/api/index.d.mts +7 -163
- package/dist/plugins/cms/api/index.d.ts +7 -163
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/query-keys.cjs +2 -1
- package/dist/plugins/cms/query-keys.d.cts +6 -9
- package/dist/plugins/cms/query-keys.d.mts +6 -9
- package/dist/plugins/cms/query-keys.d.ts +6 -9
- package/dist/plugins/cms/query-keys.mjs +2 -1
- package/dist/plugins/form-builder/api/index.cjs +10 -0
- package/dist/plugins/form-builder/api/index.d.cts +7 -141
- package/dist/plugins/form-builder/api/index.d.mts +7 -141
- package/dist/plugins/form-builder/api/index.d.ts +7 -141
- package/dist/plugins/form-builder/api/index.mjs +2 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
- package/dist/plugins/form-builder/query-keys.cjs +3 -2
- package/dist/plugins/form-builder/query-keys.d.cts +7 -6
- package/dist/plugins/form-builder/query-keys.d.mts +7 -6
- package/dist/plugins/form-builder/query-keys.d.ts +7 -6
- package/dist/plugins/form-builder/query-keys.mjs +3 -2
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +17 -395
- package/dist/plugins/kanban/api/index.d.mts +17 -395
- package/dist/plugins/kanban/api/index.d.ts +17 -395
- package/dist/plugins/kanban/api/index.mjs +3 -0
- package/dist/plugins/kanban/client/components/index.d.cts +1 -1
- package/dist/plugins/kanban/client/components/index.d.mts +1 -1
- package/dist/plugins/kanban/client/components/index.d.ts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
- package/dist/plugins/kanban/client/index.d.cts +1 -1
- package/dist/plugins/kanban/client/index.d.mts +1 -1
- package/dist/plugins/kanban/client/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.cjs +6 -12
- package/dist/plugins/kanban/query-keys.d.cts +5 -16
- package/dist/plugins/kanban/query-keys.d.mts +5 -16
- package/dist/plugins/kanban/query-keys.d.ts +5 -16
- package/dist/plugins/kanban/query-keys.mjs +6 -12
- package/dist/plugins/open-api/api/index.d.cts +2 -2
- package/dist/plugins/open-api/api/index.d.mts +2 -2
- package/dist/plugins/open-api/api/index.d.ts +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +1 -1
- package/dist/plugins/route-docs/client/index.d.mts +1 -1
- package/dist/plugins/route-docs/client/index.d.ts +1 -1
- package/dist/plugins/ui-builder/index.d.cts +1 -1
- package/dist/plugins/ui-builder/index.d.mts +1 -1
- package/dist/plugins/ui-builder/index.d.ts +1 -1
- package/dist/shared/{stack.BoA0xkJv.d.cts → stack.7n9Y_u7N.d.cts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.mts → stack.7n9Y_u7N.d.mts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.ts → stack.7n9Y_u7N.d.ts} +33 -7
- package/dist/shared/stack.B1EeBt1b.d.ts +297 -0
- package/dist/shared/stack.BIXEI6v_.d.mts +419 -0
- package/dist/shared/stack.BKfolAyK.d.ts +419 -0
- package/dist/shared/stack.BeSm90va.d.ts +289 -0
- package/dist/shared/stack.BpolpQpf.d.cts +445 -0
- package/dist/shared/stack.C5dtIncc.d.mts +293 -0
- package/dist/shared/stack.CIP6QS9l.d.ts +293 -0
- package/dist/shared/stack.CMh_EdxW.d.cts +289 -0
- package/dist/shared/stack.CP68pFEH.d.mts +297 -0
- package/dist/shared/{stack.BsXokfNh.d.mts → stack.CVDTkMoO.d.cts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.ts → stack.CVDTkMoO.d.mts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.cts → stack.CVDTkMoO.d.ts} +8 -2
- package/dist/shared/{stack.DKDMI-QO.d.mts → stack.DJaKVY7v.d.cts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.ts → stack.DJaKVY7v.d.mts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.cts → stack.DJaKVY7v.d.ts} +7 -1
- package/dist/shared/{stack.DzH_wcvr.d.mts → stack.DdI5W6MB.d.cts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.ts → stack.DdI5W6MB.d.mts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.cts → stack.DdI5W6MB.d.ts} +9 -3
- package/dist/shared/stack.Dg09R0oB.d.mts +289 -0
- package/dist/shared/stack.Dw0Ly2TM.d.cts +293 -0
- package/dist/shared/stack.IdtKDRka.d.cts +297 -0
- package/dist/shared/stack.TIBF2AOx.d.ts +445 -0
- package/dist/shared/stack.rTy7-wQU.d.mts +445 -0
- package/dist/shared/stack.snB1EDP7.d.cts +419 -0
- package/package.json +3 -3
- package/src/__tests__/stack-api.test.ts +118 -0
- package/src/api/index.ts +15 -1
- package/src/plugins/ai-chat/__tests__/getters.test.ts +109 -0
- package/src/plugins/ai-chat/api/getters.ts +71 -0
- package/src/plugins/ai-chat/api/index.ts +1 -0
- package/src/plugins/ai-chat/api/plugin.ts +8 -0
- package/src/plugins/api/index.ts +3 -1
- package/src/plugins/blog/__tests__/getters.test.ts +540 -0
- package/src/plugins/blog/api/getters.ts +243 -0
- package/src/plugins/blog/api/index.ts +9 -0
- package/src/plugins/blog/api/plugin.ts +98 -141
- package/src/plugins/blog/api/query-key-defs.ts +46 -0
- package/src/plugins/blog/api/serializers.ts +27 -0
- package/src/plugins/blog/client/plugin.tsx +21 -1
- package/src/plugins/blog/query-keys.ts +21 -20
- package/src/plugins/client/index.ts +1 -1
- package/src/plugins/cms/__tests__/getters.test.ts +206 -0
- package/src/plugins/cms/api/getters.ts +268 -0
- package/src/plugins/cms/api/index.ts +15 -1
- package/src/plugins/cms/api/plugin.ts +151 -150
- package/src/plugins/cms/api/query-key-defs.ts +53 -0
- package/src/plugins/cms/api/serializers.ts +12 -0
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +1 -1
- package/src/plugins/cms/client/hooks/cms-hooks.tsx +3 -0
- package/src/plugins/cms/client/plugin.tsx +19 -0
- package/src/plugins/cms/query-keys.ts +2 -1
- package/src/plugins/cms/types.ts +1 -1
- package/src/plugins/form-builder/__tests__/getters.test.ts +159 -0
- package/src/plugins/form-builder/api/getters.ts +226 -0
- package/src/plugins/form-builder/api/index.ts +15 -1
- package/src/plugins/form-builder/api/plugin.ts +107 -109
- package/src/plugins/form-builder/api/query-key-defs.ts +79 -0
- package/src/plugins/form-builder/api/serializers.ts +12 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +1 -1
- package/src/plugins/form-builder/client/plugin.tsx +19 -0
- package/src/plugins/form-builder/query-keys.ts +6 -2
- package/src/plugins/form-builder/types.ts +2 -2
- package/src/plugins/kanban/__tests__/getters.test.ts +172 -0
- package/src/plugins/kanban/api/getters.ts +149 -0
- package/src/plugins/kanban/api/index.ts +4 -0
- package/src/plugins/kanban/api/plugin.ts +65 -146
- package/src/plugins/kanban/api/query-key-defs.ts +54 -0
- package/src/plugins/kanban/api/serializers.ts +49 -0
- package/src/plugins/kanban/client/plugin.tsx +15 -1
- package/src/plugins/kanban/query-keys.ts +10 -14
- package/src/plugins/utils.ts +19 -0
- package/src/types.ts +44 -5
- package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CBON0dWL.d.cts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CBON0dWL.d.mts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CBON0dWL.d.ts} +7 -7
package/dist/api/index.cjs
CHANGED
|
@@ -24,13 +24,21 @@ function stack(config) {
|
|
|
24
24
|
allRoutes[compositeKey] = endpoint;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
const pluginApis = {};
|
|
28
|
+
for (const [pluginKey, plugin] of Object.entries(plugins)) {
|
|
29
|
+
if (plugin.api) {
|
|
30
|
+
pluginApis[pluginKey] = plugin.api(adapterInstance);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
27
33
|
const router = betterCall.createRouter(allRoutes, {
|
|
28
34
|
basePath
|
|
29
35
|
});
|
|
30
36
|
return {
|
|
31
37
|
handler: router.handler,
|
|
32
38
|
router,
|
|
33
|
-
dbSchema: betterDbSchema
|
|
39
|
+
dbSchema: betterDbSchema,
|
|
40
|
+
adapter: adapterInstance,
|
|
41
|
+
api: pluginApis
|
|
34
42
|
};
|
|
35
43
|
}
|
|
36
44
|
|
package/dist/api/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib } from '../shared/stack.
|
|
2
|
-
export { B as BackendPlugin, S as StackContext } from '../shared/stack.
|
|
1
|
+
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib, j as PluginApis } from '../shared/stack.7n9Y_u7N.cjs';
|
|
2
|
+
export { B as BackendPlugin, S as StackContext } from '../shared/stack.7n9Y_u7N.cjs';
|
|
3
3
|
export { toNodeHandler } from 'better-call/node';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
@@ -25,6 +25,6 @@ import 'better-call';
|
|
|
25
25
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
26
26
|
* @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
|
|
27
27
|
*/
|
|
28
|
-
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes
|
|
28
|
+
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes, PluginApis<TPlugins>>;
|
|
29
29
|
|
|
30
|
-
export { BackendLib, BackendLibConfig, stack };
|
|
30
|
+
export { BackendLib, BackendLibConfig, PluginApis, stack };
|
package/dist/api/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib } from '../shared/stack.
|
|
2
|
-
export { B as BackendPlugin, S as StackContext } from '../shared/stack.
|
|
1
|
+
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib, j as PluginApis } from '../shared/stack.7n9Y_u7N.mjs';
|
|
2
|
+
export { B as BackendPlugin, S as StackContext } from '../shared/stack.7n9Y_u7N.mjs';
|
|
3
3
|
export { toNodeHandler } from 'better-call/node';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
@@ -25,6 +25,6 @@ import 'better-call';
|
|
|
25
25
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
26
26
|
* @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
|
|
27
27
|
*/
|
|
28
|
-
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes
|
|
28
|
+
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes, PluginApis<TPlugins>>;
|
|
29
29
|
|
|
30
|
-
export { BackendLib, BackendLibConfig, stack };
|
|
30
|
+
export { BackendLib, BackendLibConfig, PluginApis, stack };
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib } from '../shared/stack.
|
|
2
|
-
export { B as BackendPlugin, S as StackContext } from '../shared/stack.
|
|
1
|
+
import { g as PrefixedPluginRoutes, h as BackendLibConfig, i as BackendLib, j as PluginApis } from '../shared/stack.7n9Y_u7N.js';
|
|
2
|
+
export { B as BackendPlugin, S as StackContext } from '../shared/stack.7n9Y_u7N.js';
|
|
3
3
|
export { toNodeHandler } from 'better-call/node';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
@@ -25,6 +25,6 @@ import 'better-call';
|
|
|
25
25
|
* @template TPlugins - The exact plugins map (inferred from config)
|
|
26
26
|
* @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
|
|
27
27
|
*/
|
|
28
|
-
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes
|
|
28
|
+
declare function stack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes, PluginApis<TPlugins>>;
|
|
29
29
|
|
|
30
|
-
export { BackendLib, BackendLibConfig, stack };
|
|
30
|
+
export { BackendLib, BackendLibConfig, PluginApis, stack };
|
package/dist/api/index.mjs
CHANGED
|
@@ -22,13 +22,21 @@ function stack(config) {
|
|
|
22
22
|
allRoutes[compositeKey] = endpoint;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
const pluginApis = {};
|
|
26
|
+
for (const [pluginKey, plugin] of Object.entries(plugins)) {
|
|
27
|
+
if (plugin.api) {
|
|
28
|
+
pluginApis[pluginKey] = plugin.api(adapterInstance);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
25
31
|
const router = createRouter(allRoutes, {
|
|
26
32
|
basePath
|
|
27
33
|
});
|
|
28
34
|
return {
|
|
29
35
|
handler: router.handler,
|
|
30
36
|
router,
|
|
31
|
-
dbSchema: betterDbSchema
|
|
37
|
+
dbSchema: betterDbSchema,
|
|
38
|
+
adapter: adapterInstance,
|
|
39
|
+
api: pluginApis
|
|
32
40
|
};
|
|
33
41
|
}
|
|
34
42
|
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.
|
|
2
|
-
export { b as ClientStackContext } from '../shared/stack.
|
|
1
|
+
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.7n9Y_u7N.cjs';
|
|
2
|
+
export { b as ClientStackContext } from '../shared/stack.7n9Y_u7N.cjs';
|
|
3
3
|
import '@btst/yar';
|
|
4
4
|
import '@btst/db';
|
|
5
5
|
import 'better-call';
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.
|
|
2
|
-
export { b as ClientStackContext } from '../shared/stack.
|
|
1
|
+
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.7n9Y_u7N.mjs';
|
|
2
|
+
export { b as ClientStackContext } from '../shared/stack.7n9Y_u7N.mjs';
|
|
3
3
|
import '@btst/yar';
|
|
4
4
|
import '@btst/db';
|
|
5
5
|
import 'better-call';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.
|
|
2
|
-
export { b as ClientStackContext } from '../shared/stack.
|
|
1
|
+
import { c as Sitemap, C as ClientPlugin, d as PluginRoutes, e as ClientLibConfig, f as ClientLib } from '../shared/stack.7n9Y_u7N.js';
|
|
2
|
+
export { b as ClientStackContext } from '../shared/stack.7n9Y_u7N.js';
|
|
3
3
|
import '@btst/yar';
|
|
4
4
|
import '@btst/db';
|
|
5
5
|
import 'better-call';
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { stack } from './api/index.cjs';
|
|
2
2
|
export { toNodeHandler } from 'better-call/node';
|
|
3
|
-
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, S as StackContext } from './shared/stack.
|
|
3
|
+
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, j as PluginApis, S as StackContext } from './shared/stack.7n9Y_u7N.cjs';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
6
6
|
import 'better-call';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { stack } from './api/index.mjs';
|
|
2
2
|
export { toNodeHandler } from 'better-call/node';
|
|
3
|
-
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, S as StackContext } from './shared/stack.
|
|
3
|
+
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, j as PluginApis, S as StackContext } from './shared/stack.7n9Y_u7N.mjs';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
6
6
|
import 'better-call';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { stack } from './api/index.js';
|
|
2
2
|
export { toNodeHandler } from 'better-call/node';
|
|
3
|
-
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, S as StackContext } from './shared/stack.
|
|
3
|
+
export { i as BackendLib, h as BackendLibConfig, B as BackendPlugin, j as PluginApis, S as StackContext } from './shared/stack.7n9Y_u7N.js';
|
|
4
4
|
import '@btst/yar';
|
|
5
5
|
import '@btst/db';
|
|
6
6
|
import 'better-call';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
async function getAllConversations(adapter, userId) {
|
|
4
|
+
const whereConditions = [];
|
|
5
|
+
if (userId) {
|
|
6
|
+
whereConditions.push({
|
|
7
|
+
field: "userId",
|
|
8
|
+
value: userId,
|
|
9
|
+
operator: "eq"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return adapter.findMany({
|
|
13
|
+
model: "conversation",
|
|
14
|
+
where: whereConditions.length > 0 ? whereConditions : void 0,
|
|
15
|
+
sortBy: { field: "updatedAt", direction: "desc" }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function getConversationById(adapter, id) {
|
|
19
|
+
const conversations = await adapter.findMany({
|
|
20
|
+
model: "conversation",
|
|
21
|
+
where: [{ field: "id", value: id, operator: "eq" }],
|
|
22
|
+
limit: 1,
|
|
23
|
+
join: {
|
|
24
|
+
message: true
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (!conversations.length) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const conversation = conversations[0];
|
|
31
|
+
const messages = (conversation.message || []).sort(
|
|
32
|
+
(a, b) => a.createdAt.getTime() - b.createdAt.getTime()
|
|
33
|
+
);
|
|
34
|
+
const { message: _, ...conversationWithoutJoin } = conversation;
|
|
35
|
+
return {
|
|
36
|
+
...conversationWithoutJoin,
|
|
37
|
+
messages
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.getAllConversations = getAllConversations;
|
|
42
|
+
exports.getConversationById = getConversationById;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
async function getAllConversations(adapter, userId) {
|
|
2
|
+
const whereConditions = [];
|
|
3
|
+
if (userId) {
|
|
4
|
+
whereConditions.push({
|
|
5
|
+
field: "userId",
|
|
6
|
+
value: userId,
|
|
7
|
+
operator: "eq"
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return adapter.findMany({
|
|
11
|
+
model: "conversation",
|
|
12
|
+
where: whereConditions.length > 0 ? whereConditions : void 0,
|
|
13
|
+
sortBy: { field: "updatedAt", direction: "desc" }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function getConversationById(adapter, id) {
|
|
17
|
+
const conversations = await adapter.findMany({
|
|
18
|
+
model: "conversation",
|
|
19
|
+
where: [{ field: "id", value: id, operator: "eq" }],
|
|
20
|
+
limit: 1,
|
|
21
|
+
join: {
|
|
22
|
+
message: true
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (!conversations.length) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const conversation = conversations[0];
|
|
29
|
+
const messages = (conversation.message || []).sort(
|
|
30
|
+
(a, b) => a.createdAt.getTime() - b.createdAt.getTime()
|
|
31
|
+
);
|
|
32
|
+
const { message: _, ...conversationWithoutJoin } = conversation;
|
|
33
|
+
return {
|
|
34
|
+
...conversationWithoutJoin,
|
|
35
|
+
messages
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { getAllConversations, getConversationById };
|
|
@@ -4,11 +4,16 @@ const api = require('@btst/stack/plugins/api');
|
|
|
4
4
|
const ai = require('ai');
|
|
5
5
|
const db = require('../db.cjs');
|
|
6
6
|
const schemas = require('../schemas.cjs');
|
|
7
|
+
const getters = require('./getters.cjs');
|
|
7
8
|
|
|
8
9
|
const aiChatBackendPlugin = (config) => api.defineBackendPlugin({
|
|
9
10
|
name: "ai-chat",
|
|
10
11
|
// Always include db schema - in public mode we just don't use it
|
|
11
12
|
dbPlugin: db.aiChatSchema,
|
|
13
|
+
api: (adapter) => ({
|
|
14
|
+
getAllConversations: (userId) => getters.getAllConversations(adapter, userId),
|
|
15
|
+
getConversationById: (id) => getters.getConversationById(adapter, id)
|
|
16
|
+
}),
|
|
12
17
|
routes: (adapter) => {
|
|
13
18
|
const mode = config.mode ?? "authenticated";
|
|
14
19
|
const isPublicMode = mode === "public";
|
|
@@ -2,11 +2,16 @@ import { defineBackendPlugin, createEndpoint } from '@btst/stack/plugins/api';
|
|
|
2
2
|
import { convertToModelMessages, streamText, stepCountIs } from 'ai';
|
|
3
3
|
import { aiChatSchema } from '../db.mjs';
|
|
4
4
|
import { chatRequestSchema, createConversationSchema, updateConversationSchema } from '../schemas.mjs';
|
|
5
|
+
import { getConversationById, getAllConversations } from './getters.mjs';
|
|
5
6
|
|
|
6
7
|
const aiChatBackendPlugin = (config) => defineBackendPlugin({
|
|
7
8
|
name: "ai-chat",
|
|
8
9
|
// Always include db schema - in public mode we just don't use it
|
|
9
10
|
dbPlugin: aiChatSchema,
|
|
11
|
+
api: (adapter) => ({
|
|
12
|
+
getAllConversations: (userId) => getAllConversations(adapter, userId),
|
|
13
|
+
getConversationById: (id) => getConversationById(adapter, id)
|
|
14
|
+
}),
|
|
10
15
|
routes: (adapter) => {
|
|
11
16
|
const mode = config.mode ?? "authenticated";
|
|
12
17
|
const isPublicMode = mode === "public";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
async function getAllPosts(adapter, params) {
|
|
4
|
+
const query = params ?? {};
|
|
5
|
+
const whereConditions = [];
|
|
6
|
+
if (query.tagSlug) {
|
|
7
|
+
const tag = await adapter.findOne({
|
|
8
|
+
model: "tag",
|
|
9
|
+
where: [{ field: "slug", value: query.tagSlug, operator: "eq" }]
|
|
10
|
+
});
|
|
11
|
+
if (!tag) {
|
|
12
|
+
return { items: [], total: 0, limit: query.limit, offset: query.offset };
|
|
13
|
+
}
|
|
14
|
+
const postTags = await adapter.findMany({
|
|
15
|
+
model: "postTag",
|
|
16
|
+
where: [{ field: "tagId", value: tag.id, operator: "eq" }]
|
|
17
|
+
});
|
|
18
|
+
const taggedPostIds = postTags.map((pt) => pt.postId);
|
|
19
|
+
if (taggedPostIds.length === 0) {
|
|
20
|
+
return { items: [], total: 0, limit: query.limit, offset: query.offset };
|
|
21
|
+
}
|
|
22
|
+
whereConditions.push({
|
|
23
|
+
field: "id",
|
|
24
|
+
value: taggedPostIds,
|
|
25
|
+
operator: "in"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (query.published !== void 0) {
|
|
29
|
+
whereConditions.push({
|
|
30
|
+
field: "published",
|
|
31
|
+
value: query.published,
|
|
32
|
+
operator: "eq"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (query.slug) {
|
|
36
|
+
whereConditions.push({
|
|
37
|
+
field: "slug",
|
|
38
|
+
value: query.slug,
|
|
39
|
+
operator: "eq"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const needsInMemoryFilter = !!query.query;
|
|
43
|
+
const dbWhere = whereConditions.length > 0 ? whereConditions : void 0;
|
|
44
|
+
const dbTotal = !needsInMemoryFilter ? await adapter.count({ model: "post", where: dbWhere }) : void 0;
|
|
45
|
+
const posts = await adapter.findMany({
|
|
46
|
+
model: "post",
|
|
47
|
+
limit: !needsInMemoryFilter ? query.limit : void 0,
|
|
48
|
+
offset: !needsInMemoryFilter ? query.offset : void 0,
|
|
49
|
+
where: dbWhere,
|
|
50
|
+
sortBy: { field: "createdAt", direction: "desc" },
|
|
51
|
+
join: { postTag: true }
|
|
52
|
+
});
|
|
53
|
+
const tagIds = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const post of posts) {
|
|
55
|
+
if (post.postTag) {
|
|
56
|
+
for (const pt of post.postTag) {
|
|
57
|
+
tagIds.add(pt.tagId);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const tags = tagIds.size > 0 ? await adapter.findMany({
|
|
62
|
+
model: "tag",
|
|
63
|
+
where: [
|
|
64
|
+
{
|
|
65
|
+
field: "id",
|
|
66
|
+
value: Array.from(tagIds),
|
|
67
|
+
operator: "in"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}) : [];
|
|
71
|
+
const tagMap = new Map(tags.map((t) => [t.id, t]));
|
|
72
|
+
let result = posts.map((post) => {
|
|
73
|
+
const postTags = (post.postTag || []).map((pt) => {
|
|
74
|
+
const tag = tagMap.get(pt.tagId);
|
|
75
|
+
return tag ? { ...tag } : void 0;
|
|
76
|
+
}).filter((tag) => tag !== void 0);
|
|
77
|
+
const { postTag: _, ...postWithoutJoin } = post;
|
|
78
|
+
return { ...postWithoutJoin, tags: postTags };
|
|
79
|
+
});
|
|
80
|
+
if (query.query) {
|
|
81
|
+
const searchLower = query.query.toLowerCase();
|
|
82
|
+
result = result.filter(
|
|
83
|
+
(post) => post.title?.toLowerCase().includes(searchLower) || post.content?.toLowerCase().includes(searchLower) || post.excerpt?.toLowerCase().includes(searchLower)
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (needsInMemoryFilter) {
|
|
87
|
+
const total = result.length;
|
|
88
|
+
const offset = query.offset ?? 0;
|
|
89
|
+
const limit = query.limit;
|
|
90
|
+
result = result.slice(
|
|
91
|
+
offset,
|
|
92
|
+
limit !== void 0 ? offset + limit : void 0
|
|
93
|
+
);
|
|
94
|
+
return { items: result, total, limit: query.limit, offset: query.offset };
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
items: result,
|
|
98
|
+
total: dbTotal ?? result.length,
|
|
99
|
+
limit: query.limit,
|
|
100
|
+
offset: query.offset
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function getPostBySlug(adapter, slug) {
|
|
104
|
+
const posts = await adapter.findMany({
|
|
105
|
+
model: "post",
|
|
106
|
+
where: [{ field: "slug", value: slug, operator: "eq" }],
|
|
107
|
+
limit: 1,
|
|
108
|
+
join: { postTag: true }
|
|
109
|
+
});
|
|
110
|
+
if (posts.length === 0) return null;
|
|
111
|
+
const post = posts[0];
|
|
112
|
+
const tagIds = (post.postTag || []).map((pt) => pt.tagId);
|
|
113
|
+
const tags = tagIds.length > 0 ? await adapter.findMany({
|
|
114
|
+
model: "tag",
|
|
115
|
+
where: [{ field: "id", value: tagIds, operator: "in" }]
|
|
116
|
+
}) : [];
|
|
117
|
+
const tagMap = new Map(tags.map((t) => [t.id, t]));
|
|
118
|
+
const resolvedTags = (post.postTag || []).map((pt) => tagMap.get(pt.tagId)).filter((t) => t !== void 0);
|
|
119
|
+
const { postTag: _, ...postWithoutJoin } = post;
|
|
120
|
+
return { ...postWithoutJoin, tags: resolvedTags };
|
|
121
|
+
}
|
|
122
|
+
async function getAllTags(adapter) {
|
|
123
|
+
return adapter.findMany({
|
|
124
|
+
model: "tag",
|
|
125
|
+
sortBy: { field: "name", direction: "asc" }
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.getAllPosts = getAllPosts;
|
|
130
|
+
exports.getAllTags = getAllTags;
|
|
131
|
+
exports.getPostBySlug = getPostBySlug;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
async function getAllPosts(adapter, params) {
|
|
2
|
+
const query = params ?? {};
|
|
3
|
+
const whereConditions = [];
|
|
4
|
+
if (query.tagSlug) {
|
|
5
|
+
const tag = await adapter.findOne({
|
|
6
|
+
model: "tag",
|
|
7
|
+
where: [{ field: "slug", value: query.tagSlug, operator: "eq" }]
|
|
8
|
+
});
|
|
9
|
+
if (!tag) {
|
|
10
|
+
return { items: [], total: 0, limit: query.limit, offset: query.offset };
|
|
11
|
+
}
|
|
12
|
+
const postTags = await adapter.findMany({
|
|
13
|
+
model: "postTag",
|
|
14
|
+
where: [{ field: "tagId", value: tag.id, operator: "eq" }]
|
|
15
|
+
});
|
|
16
|
+
const taggedPostIds = postTags.map((pt) => pt.postId);
|
|
17
|
+
if (taggedPostIds.length === 0) {
|
|
18
|
+
return { items: [], total: 0, limit: query.limit, offset: query.offset };
|
|
19
|
+
}
|
|
20
|
+
whereConditions.push({
|
|
21
|
+
field: "id",
|
|
22
|
+
value: taggedPostIds,
|
|
23
|
+
operator: "in"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (query.published !== void 0) {
|
|
27
|
+
whereConditions.push({
|
|
28
|
+
field: "published",
|
|
29
|
+
value: query.published,
|
|
30
|
+
operator: "eq"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (query.slug) {
|
|
34
|
+
whereConditions.push({
|
|
35
|
+
field: "slug",
|
|
36
|
+
value: query.slug,
|
|
37
|
+
operator: "eq"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const needsInMemoryFilter = !!query.query;
|
|
41
|
+
const dbWhere = whereConditions.length > 0 ? whereConditions : void 0;
|
|
42
|
+
const dbTotal = !needsInMemoryFilter ? await adapter.count({ model: "post", where: dbWhere }) : void 0;
|
|
43
|
+
const posts = await adapter.findMany({
|
|
44
|
+
model: "post",
|
|
45
|
+
limit: !needsInMemoryFilter ? query.limit : void 0,
|
|
46
|
+
offset: !needsInMemoryFilter ? query.offset : void 0,
|
|
47
|
+
where: dbWhere,
|
|
48
|
+
sortBy: { field: "createdAt", direction: "desc" },
|
|
49
|
+
join: { postTag: true }
|
|
50
|
+
});
|
|
51
|
+
const tagIds = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const post of posts) {
|
|
53
|
+
if (post.postTag) {
|
|
54
|
+
for (const pt of post.postTag) {
|
|
55
|
+
tagIds.add(pt.tagId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const tags = tagIds.size > 0 ? await adapter.findMany({
|
|
60
|
+
model: "tag",
|
|
61
|
+
where: [
|
|
62
|
+
{
|
|
63
|
+
field: "id",
|
|
64
|
+
value: Array.from(tagIds),
|
|
65
|
+
operator: "in"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}) : [];
|
|
69
|
+
const tagMap = new Map(tags.map((t) => [t.id, t]));
|
|
70
|
+
let result = posts.map((post) => {
|
|
71
|
+
const postTags = (post.postTag || []).map((pt) => {
|
|
72
|
+
const tag = tagMap.get(pt.tagId);
|
|
73
|
+
return tag ? { ...tag } : void 0;
|
|
74
|
+
}).filter((tag) => tag !== void 0);
|
|
75
|
+
const { postTag: _, ...postWithoutJoin } = post;
|
|
76
|
+
return { ...postWithoutJoin, tags: postTags };
|
|
77
|
+
});
|
|
78
|
+
if (query.query) {
|
|
79
|
+
const searchLower = query.query.toLowerCase();
|
|
80
|
+
result = result.filter(
|
|
81
|
+
(post) => post.title?.toLowerCase().includes(searchLower) || post.content?.toLowerCase().includes(searchLower) || post.excerpt?.toLowerCase().includes(searchLower)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (needsInMemoryFilter) {
|
|
85
|
+
const total = result.length;
|
|
86
|
+
const offset = query.offset ?? 0;
|
|
87
|
+
const limit = query.limit;
|
|
88
|
+
result = result.slice(
|
|
89
|
+
offset,
|
|
90
|
+
limit !== void 0 ? offset + limit : void 0
|
|
91
|
+
);
|
|
92
|
+
return { items: result, total, limit: query.limit, offset: query.offset };
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
items: result,
|
|
96
|
+
total: dbTotal ?? result.length,
|
|
97
|
+
limit: query.limit,
|
|
98
|
+
offset: query.offset
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function getPostBySlug(adapter, slug) {
|
|
102
|
+
const posts = await adapter.findMany({
|
|
103
|
+
model: "post",
|
|
104
|
+
where: [{ field: "slug", value: slug, operator: "eq" }],
|
|
105
|
+
limit: 1,
|
|
106
|
+
join: { postTag: true }
|
|
107
|
+
});
|
|
108
|
+
if (posts.length === 0) return null;
|
|
109
|
+
const post = posts[0];
|
|
110
|
+
const tagIds = (post.postTag || []).map((pt) => pt.tagId);
|
|
111
|
+
const tags = tagIds.length > 0 ? await adapter.findMany({
|
|
112
|
+
model: "tag",
|
|
113
|
+
where: [{ field: "id", value: tagIds, operator: "in" }]
|
|
114
|
+
}) : [];
|
|
115
|
+
const tagMap = new Map(tags.map((t) => [t.id, t]));
|
|
116
|
+
const resolvedTags = (post.postTag || []).map((pt) => tagMap.get(pt.tagId)).filter((t) => t !== void 0);
|
|
117
|
+
const { postTag: _, ...postWithoutJoin } = post;
|
|
118
|
+
return { ...postWithoutJoin, tags: resolvedTags };
|
|
119
|
+
}
|
|
120
|
+
async function getAllTags(adapter) {
|
|
121
|
+
return adapter.findMany({
|
|
122
|
+
model: "tag",
|
|
123
|
+
sortBy: { field: "name", direction: "asc" }
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { getAllPosts, getAllTags, getPostBySlug };
|