@chat-de-hp/site 0.3.3 → 0.3.5
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/check-core.d.ts +27 -0
- package/dist/check-core.d.ts.map +1 -0
- package/dist/check-core.js +638 -0
- package/dist/check.d.ts +2 -17
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +18 -529
- package/dist/control-plane.d.ts +28 -28
- package/dist/control-plane.d.ts.map +1 -1
- package/dist/control-plane.js +31 -34
- package/dist/internal/forms-plugin-runtime.d.ts +5 -0
- package/dist/internal/forms-plugin-runtime.d.ts.map +1 -0
- package/dist/internal/forms-plugin-runtime.js +42 -0
- package/package.json +5 -2
package/dist/control-plane.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { array, enum as enumSchema, int, literal, looseObject, minLength, number, positive, string, } from "zod/mini";
|
|
2
2
|
import packageJson from "../package.json" with { type: "json" };
|
|
3
3
|
export const SITE_RUNTIME_NAME = "@chat-de-hp/site";
|
|
4
4
|
export const SITE_RUNTIME_VERSION = packageJson.version;
|
|
5
5
|
export const SITE_RUNTIME_PROTOCOL_VERSION = 1;
|
|
6
|
-
export const siteRuntimeBindingSchema =
|
|
7
|
-
.
|
|
8
|
-
|
|
9
|
-
type: z.enum([
|
|
6
|
+
export const siteRuntimeBindingSchema = looseObject({
|
|
7
|
+
name: string().check(minLength(1)),
|
|
8
|
+
type: enumSchema([
|
|
10
9
|
"d1",
|
|
11
10
|
"images",
|
|
12
11
|
"kv_namespace",
|
|
@@ -14,34 +13,32 @@ export const siteRuntimeBindingSchema = z
|
|
|
14
13
|
"send_email",
|
|
15
14
|
"worker_loader",
|
|
16
15
|
]),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.object({
|
|
37
|
-
name: z.literal(SITE_RUNTIME_NAME),
|
|
38
|
-
protocolVersion: z.literal(SITE_RUNTIME_PROTOCOL_VERSION),
|
|
39
|
-
version: z.string().min(1),
|
|
40
|
-
})
|
|
41
|
-
.passthrough(),
|
|
42
|
-
schemaVersion: z.literal(1),
|
|
43
|
-
})
|
|
44
|
-
.passthrough();
|
|
16
|
+
});
|
|
17
|
+
export const siteRuntimeManifestSchema = looseObject({
|
|
18
|
+
capabilities: array(looseObject({
|
|
19
|
+
id: string().check(minLength(1)),
|
|
20
|
+
provider: string().check(minLength(1)),
|
|
21
|
+
schemaVersion: number().check(int(), positive()),
|
|
22
|
+
})),
|
|
23
|
+
primitives: array(looseObject({
|
|
24
|
+
id: string().check(minLength(1)),
|
|
25
|
+
schemaVersion: number().check(int(), positive()),
|
|
26
|
+
})),
|
|
27
|
+
requiredBindings: array(siteRuntimeBindingSchema),
|
|
28
|
+
runtime: looseObject({
|
|
29
|
+
name: literal(SITE_RUNTIME_NAME),
|
|
30
|
+
protocolVersion: literal(SITE_RUNTIME_PROTOCOL_VERSION),
|
|
31
|
+
version: string().check(minLength(1)),
|
|
32
|
+
}),
|
|
33
|
+
schemaVersion: literal(1),
|
|
34
|
+
});
|
|
45
35
|
export function parseSiteRuntimeManifest(value) {
|
|
46
|
-
|
|
36
|
+
try {
|
|
37
|
+
return siteRuntimeManifestSchema.parse(value);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error("Invalid input: site runtime manifest failed validation.", {
|
|
41
|
+
cause: error,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
47
44
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type FormsPluginOptions } from "@emdash-cms/plugin-forms";
|
|
2
|
+
import type { ResolvedPlugin } from "emdash";
|
|
3
|
+
export declare function createPlugin(options?: FormsPluginOptions): ResolvedPlugin;
|
|
4
|
+
export default createPlugin;
|
|
5
|
+
//# sourceMappingURL=forms-plugin-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms-plugin-runtime.d.ts","sourceRoot":"","sources":["../../src/internal/forms-plugin-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAqB7C,wBAAgB,YAAY,CAAC,OAAO,GAAE,kBAAuB,GAAG,cAAc,CAuB7E;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createPlugin as createUpstreamFormsPlugin, } from "@emdash-cms/plugin-forms";
|
|
2
|
+
import { z } from "astro/zod";
|
|
3
|
+
import { siteFormInputSchema } from "../contracts/forms.js";
|
|
4
|
+
const HTTP_SCHEME_RE = /^https?:\/\//iu;
|
|
5
|
+
const httpUrlSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.url()
|
|
8
|
+
.refine((url) => HTTP_SCHEME_RE.test(url), "URL must use http or https");
|
|
9
|
+
const formSettingsSchema = siteFormInputSchema.shape.settings.unwrap().extend({
|
|
10
|
+
redirectUrl: httpUrlSchema.optional().or(z.literal("")),
|
|
11
|
+
webhookUrl: httpUrlSchema.optional().or(z.literal("")),
|
|
12
|
+
});
|
|
13
|
+
const formCreateSchema = siteFormInputSchema.extend({
|
|
14
|
+
settings: formSettingsSchema,
|
|
15
|
+
});
|
|
16
|
+
const formUpdateSchema = formCreateSchema.partial().extend({
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
status: z.enum(["active", "paused"]).optional(),
|
|
19
|
+
});
|
|
20
|
+
export function createPlugin(options = {}) {
|
|
21
|
+
const plugin = createUpstreamFormsPlugin(options);
|
|
22
|
+
const createRoute = plugin.routes["forms/create"];
|
|
23
|
+
const updateRoute = plugin.routes["forms/update"];
|
|
24
|
+
if (!(createRoute && updateRoute)) {
|
|
25
|
+
throw new Error("EmDash forms plugin routes are unavailable");
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...plugin,
|
|
29
|
+
routes: {
|
|
30
|
+
...plugin.routes,
|
|
31
|
+
"forms/create": {
|
|
32
|
+
...createRoute,
|
|
33
|
+
input: formCreateSchema,
|
|
34
|
+
},
|
|
35
|
+
"forms/update": {
|
|
36
|
+
...updateRoute,
|
|
37
|
+
input: formUpdateSchema,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export default createPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chat-de-hp/site",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Managed Astro site runtime and primitive composition for Chat de HP",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./dist/primitives/forms-styles.css"
|
|
18
|
+
],
|
|
16
19
|
"exports": {
|
|
17
20
|
".": {
|
|
18
21
|
"types": "./dist/index.d.ts",
|
|
@@ -68,7 +71,7 @@
|
|
|
68
71
|
"@emdash-cms/cloudflare": "0.32.0",
|
|
69
72
|
"@emdash-cms/plugin-forms": "0.2.4",
|
|
70
73
|
"jsonc-parser": "3.3.1",
|
|
71
|
-
"zod": "4.
|
|
74
|
+
"zod": "4.5.2"
|
|
72
75
|
},
|
|
73
76
|
"devDependencies": {
|
|
74
77
|
"@types/node": "20",
|