rankrunners-cms 0.0.48 → 0.0.50

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rankrunners-cms",
3
3
  "type": "module",
4
- "version": "0.0.48",
4
+ "version": "0.0.50",
5
5
  "peerDependencies": {
6
6
  "@puckeditor/core": "^0.21.1",
7
7
  "@tanstack/react-router": "^1.167.0",
@@ -33,9 +33,10 @@ const isSchemaNode: IsSchemaNode<AnyNode> = (
33
33
  if (!node || typeof node !== "object") return false;
34
34
  // Delegate to the first codec whose guard approves this node.
35
35
  for (const c of Object.values(codecs)) {
36
+ const guard = (c as { isSchemaNode?: IsSchemaNode<AnyNode> }).isSchemaNode;
36
37
  if (
37
- typeof c.isSchemaNode === "function" &&
38
- c.isSchemaNode(node, {
38
+ typeof guard === "function" &&
39
+ guard(node, {
39
40
  isSchemaNode: (n) =>
40
41
  isSchemaNode(n, {
41
42
  isSchemaNode: (x) =>
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useState } from "react";
2
3
  import Image from "next/image";
3
4
  import rankrunners from "../../assets/rankrunners.webp";
package/test/test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { serializeSigned } from "hono/utils/cookie";
2
2
  import * as v from "valibot";
3
- import { fromValibot, toValibot } from "rankrunners-cms/src/libs/valibot-serialize";
3
+ import { fromValibot, toValibot } from "../src/libs/valibot-serialize";
4
4
 
5
5
  export const TestSchema = v.object({
6
6
  username: v.string(),
@@ -13,13 +13,59 @@ const deserializedValidator = toValibot(serializedSchema);
13
13
  let data: string;
14
14
 
15
15
  try {
16
- data = JSON.stringify(v.parse(deserializedValidator, {
17
- username: "testuser",
18
- fullname: "Test User"
19
- }));
16
+ data = JSON.stringify(
17
+ v.parse(deserializedValidator, {
18
+ username: "testuser",
19
+ fullname: "Test User",
20
+ }),
21
+ );
20
22
  } catch (error) {
21
- console.error("Validation failed:", error);
22
- data = "Validation failed";
23
+ console.error("Validation failed:", error);
24
+ data = "Validation failed";
23
25
  }
24
26
 
25
- console.log("Deserialized and validated data:", data);
27
+ console.log("Deserialized and validated data:", data);
28
+
29
+ const deserializedSchemaVal = toValibot({
30
+ kind: "schema",
31
+ vendor: "valibot",
32
+ version: 1,
33
+ format: 1,
34
+ node: {
35
+ type: "object",
36
+ entries: {
37
+ serviceType: { type: "string", minLength: 1 },
38
+ firstName: { type: "string", minLength: 1 },
39
+ lastName: { type: "string", minLength: 1 },
40
+ phone: {
41
+ type: "string",
42
+ minLength: 1,
43
+ maxLength: 20,
44
+ pattern: "^\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$",
45
+ },
46
+ email: { type: "string", minLength: 1, email: true },
47
+ serviceDate: { type: "optional", base: { type: "string" } },
48
+ preferredTime: { type: "optional", base: { type: "string" } },
49
+ address: { type: "string", minLength: 1 },
50
+ message: {
51
+ type: "optional",
52
+ base: { type: "string", maxLength: 50000 },
53
+ },
54
+ serviceArea: { type: "string", minLength: 1 },
55
+ consent: { type: "boolean" },
56
+ },
57
+ optionalKeys: ["serviceDate", "preferredTime", "message"],
58
+ },
59
+ });
60
+
61
+ const validatedData = v.parse(deserializedSchemaVal, {
62
+ serviceType: "Lawn Mowing",
63
+ firstName: "John",
64
+ lastName: "Doe",
65
+ phone: "123-456-7890",
66
+ email: "hey@hey.com",
67
+ address: "123 Main St",
68
+ serviceArea: "Springfield",
69
+ consent: true,
70
+ });
71
+ console.log("Validated data:", validatedData);