@kidecms/core 0.14.1 → 0.14.3
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 +26 -0
- package/admin/lib/edit-data.ts +1 -1
- package/middleware/auth.ts +7 -1
- package/package.json +11 -1
- package/routes/admin/login.astro +5 -1
- package/routes/api/forms/submit/[slug].ts +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @kidecms/core
|
|
2
|
+
|
|
3
|
+
The runtime behind [Kide CMS](https://github.com/mhernesniemi/kide-cms) — a code-first CMS built for Astro. Define collections in TypeScript, get a generated admin UI and typed content API.
|
|
4
|
+
|
|
5
|
+
You normally don't install this package directly. Scaffold a project with:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpx create-kide-app
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
and choose **Package** mode when asked how you want the CMS runtime — `create-kide-app` adds `@kidecms/core` as a dependency and wires everything up. **Embedded** mode vendors this same source into your project instead, no npm dependency involved.
|
|
12
|
+
|
|
13
|
+
## Links
|
|
14
|
+
|
|
15
|
+
- [Docs](https://docs.kide.dev/)
|
|
16
|
+
- [Live demo](https://demo.kide.dev/admin)
|
|
17
|
+
- [Source & issues](https://github.com/mhernesniemi/kide-cms)
|
|
18
|
+
- [Changelog](https://github.com/mhernesniemi/kide-cms/blob/main/CHANGELOG.md)
|
|
19
|
+
|
|
20
|
+
## What's in the box
|
|
21
|
+
|
|
22
|
+
Admin UI, typed local API, auth, assets, search, webhooks, background tasks, collaboration workflow, and the `kide` CLI (`kide generate|push|seed|admin|upgrade|eject|mcp`). See the [full feature list and quick start](https://github.com/mhernesniemi/kide-cms#readme) in the main repo.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
package/admin/lib/edit-data.ts
CHANGED
|
@@ -436,7 +436,7 @@ export async function loadParentFormTitle(
|
|
|
436
436
|
runtimeContext: RuntimeContext,
|
|
437
437
|
): Promise<string | null> {
|
|
438
438
|
try {
|
|
439
|
-
const parentForm = (await cmsRuntime.forms.findOne({
|
|
439
|
+
const parentForm = (await cmsRuntime.forms.findOne({ _id: formId }, runtimeContext)) as Record<
|
|
440
440
|
string,
|
|
441
441
|
unknown
|
|
442
442
|
> | null;
|
package/middleware/auth.ts
CHANGED
|
@@ -33,7 +33,13 @@ export const onRequest = defineMiddleware(async (context, next) => {
|
|
|
33
33
|
const scope: RequestScope = cfContext?.waitUntil
|
|
34
34
|
? { defer: (task) => cfContext.waitUntil!(task) }
|
|
35
35
|
: { defer: () => {} };
|
|
36
|
-
return runWithRequestScope(scope, () =>
|
|
36
|
+
return runWithRequestScope(scope, async () => {
|
|
37
|
+
const response = await handle(context, next);
|
|
38
|
+
// Draft responses must never enter the shared cache. Runs after the page
|
|
39
|
+
// rendered because a page-level cache.set() would re-enable caching.
|
|
40
|
+
if (context.url.searchParams.has("preview")) context.cache?.set(false);
|
|
41
|
+
return response;
|
|
42
|
+
});
|
|
37
43
|
});
|
|
38
44
|
|
|
39
45
|
const handle = async (context: APIContext, next: MiddlewareNext) => {
|
package/package.json
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kidecms/core",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "Kide CMS runtime — core library, admin UI, routes, and middleware for Astro. Shipped as TypeScript source.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cms",
|
|
7
|
+
"astro",
|
|
8
|
+
"headless-cms",
|
|
9
|
+
"content-management",
|
|
10
|
+
"typescript",
|
|
11
|
+
"admin-panel"
|
|
12
|
+
],
|
|
5
13
|
"type": "module",
|
|
6
14
|
"license": "MIT",
|
|
15
|
+
"homepage": "https://docs.kide.dev/",
|
|
7
16
|
"repository": {
|
|
8
17
|
"type": "git",
|
|
9
18
|
"url": "https://github.com/mhernesniemi/kide-cms.git"
|
|
10
19
|
},
|
|
20
|
+
"bugs": "https://github.com/mhernesniemi/kide-cms/issues",
|
|
11
21
|
"engines": {
|
|
12
22
|
"node": ">=22.12.0"
|
|
13
23
|
},
|
package/routes/admin/login.astro
CHANGED
|
@@ -18,7 +18,11 @@ const errorMessage =
|
|
|
18
18
|
? "Email and password are required."
|
|
19
19
|
: error === "disabled"
|
|
20
20
|
? "Password login is disabled."
|
|
21
|
-
:
|
|
21
|
+
: error === "rate-limited"
|
|
22
|
+
? "Too many attempts. Try again in a few minutes."
|
|
23
|
+
: error
|
|
24
|
+
? "Sign-in failed. Try again."
|
|
25
|
+
: null;
|
|
22
26
|
const auth = resolveAdminAuth(config);
|
|
23
27
|
---
|
|
24
28
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { APIRoute } from "astro";
|
|
2
2
|
import { cms } from "virtual:kide/api";
|
|
3
3
|
import { sendFormSubmissionEmail, isEmailConfigured } from "virtual:kide/email";
|
|
4
|
-
import { hitRateLimit, PayloadTooLargeError, readLimitedFormData } from "../../../../core";
|
|
4
|
+
import { hitRateLimit, PayloadTooLargeError, readLimitedFormData, safeUrl } from "../../../../core";
|
|
5
5
|
|
|
6
6
|
export const prerender = false;
|
|
7
7
|
|
|
@@ -58,7 +58,7 @@ export const POST: APIRoute = async ({ request, params, redirect, clientAddress
|
|
|
58
58
|
return redirect(buildRedirectUrl(request, null, true), 303);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const form = await cms.forms.findOne({
|
|
61
|
+
const form = await cms.forms.findOne({ slug }, { _system: true });
|
|
62
62
|
if (!form) return new Response("Form not found", { status: 404 });
|
|
63
63
|
|
|
64
64
|
const fieldConfigs = Array.isArray(form.fields) ? (form.fields as FormFieldConfig[]) : [];
|
|
@@ -125,8 +125,9 @@ export const POST: APIRoute = async ({ request, params, redirect, clientAddress
|
|
|
125
125
|
await sendFormSubmissionEmail(String(form.notificationEmail), String(form.title), data);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
const submitRedirect = form.submitRedirect ? safeUrl(String(form.submitRedirect)) : null;
|
|
129
|
+
if (submitRedirect) {
|
|
130
|
+
return redirect(submitRedirect, 303);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
return redirect(buildRedirectUrl(request, null, true), 303);
|