@nakanoaas/notion-valibot-schema 0.0.3 → 0.0.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.
Files changed (138) hide show
  1. package/README.md +26 -24
  2. package/dist/checkbox.cjs +29 -0
  3. package/dist/checkbox.cjs.map +1 -1
  4. package/dist/checkbox.d.cts +30 -0
  5. package/dist/checkbox.d.mts +30 -0
  6. package/dist/checkbox.mjs +29 -0
  7. package/dist/checkbox.mjs.map +1 -1
  8. package/dist/created-by.cjs +75 -0
  9. package/dist/created-by.cjs.map +1 -1
  10. package/dist/created-by.d.cts +76 -0
  11. package/dist/created-by.d.mts +76 -0
  12. package/dist/created-by.mjs +75 -0
  13. package/dist/created-by.mjs.map +1 -1
  14. package/dist/created-time.cjs +27 -0
  15. package/dist/created-time.cjs.map +1 -1
  16. package/dist/created-time.d.cts +28 -0
  17. package/dist/created-time.d.mts +28 -0
  18. package/dist/created-time.mjs +27 -0
  19. package/dist/created-time.mjs.map +1 -1
  20. package/dist/date.cjs +203 -13
  21. package/dist/date.cjs.map +1 -1
  22. package/dist/date.d.cts +214 -6
  23. package/dist/date.d.mts +214 -6
  24. package/dist/date.mjs +201 -12
  25. package/dist/date.mjs.map +1 -1
  26. package/dist/email.cjs +58 -0
  27. package/dist/email.cjs.map +1 -1
  28. package/dist/email.d.cts +59 -0
  29. package/dist/email.d.mts +59 -0
  30. package/dist/email.mjs +58 -0
  31. package/dist/email.mjs.map +1 -1
  32. package/dist/files.cjs +39 -0
  33. package/dist/files.cjs.map +1 -1
  34. package/dist/files.d.cts +40 -0
  35. package/dist/files.d.mts +40 -0
  36. package/dist/files.mjs +39 -0
  37. package/dist/files.mjs.map +1 -1
  38. package/dist/formula.cjs +72 -0
  39. package/dist/formula.cjs.map +1 -1
  40. package/dist/formula.d.cts +73 -0
  41. package/dist/formula.d.mts +73 -0
  42. package/dist/formula.mjs +72 -0
  43. package/dist/formula.mjs.map +1 -1
  44. package/dist/index.cjs +7 -3
  45. package/dist/index.d.cts +4 -4
  46. package/dist/index.d.mts +4 -4
  47. package/dist/index.mjs +4 -4
  48. package/dist/last-edited-by.cjs +68 -0
  49. package/dist/last-edited-by.cjs.map +1 -1
  50. package/dist/last-edited-by.d.cts +69 -0
  51. package/dist/last-edited-by.d.mts +69 -0
  52. package/dist/last-edited-by.mjs +68 -0
  53. package/dist/last-edited-by.mjs.map +1 -1
  54. package/dist/last-edited-time.cjs +27 -0
  55. package/dist/last-edited-time.cjs.map +1 -1
  56. package/dist/last-edited-time.d.cts +28 -0
  57. package/dist/last-edited-time.d.mts +28 -0
  58. package/dist/last-edited-time.mjs +27 -0
  59. package/dist/last-edited-time.mjs.map +1 -1
  60. package/dist/multi-select.cjs +60 -0
  61. package/dist/multi-select.cjs.map +1 -1
  62. package/dist/multi-select.d.cts +61 -0
  63. package/dist/multi-select.d.mts +61 -0
  64. package/dist/multi-select.mjs +60 -0
  65. package/dist/multi-select.mjs.map +1 -1
  66. package/dist/number.cjs +58 -0
  67. package/dist/number.cjs.map +1 -1
  68. package/dist/number.d.cts +59 -0
  69. package/dist/number.d.mts +59 -0
  70. package/dist/number.mjs +58 -0
  71. package/dist/number.mjs.map +1 -1
  72. package/dist/people.cjs +84 -0
  73. package/dist/people.cjs.map +1 -1
  74. package/dist/people.d.cts +85 -0
  75. package/dist/people.d.mts +85 -0
  76. package/dist/people.mjs +84 -0
  77. package/dist/people.mjs.map +1 -1
  78. package/dist/phone-number.cjs +58 -0
  79. package/dist/phone-number.cjs.map +1 -1
  80. package/dist/phone-number.d.cts +59 -0
  81. package/dist/phone-number.d.mts +59 -0
  82. package/dist/phone-number.mjs +58 -0
  83. package/dist/phone-number.mjs.map +1 -1
  84. package/dist/place.cjs +128 -0
  85. package/dist/place.cjs.map +1 -1
  86. package/dist/place.d.cts +85 -0
  87. package/dist/place.d.mts +85 -0
  88. package/dist/place.mjs +128 -0
  89. package/dist/place.mjs.map +1 -1
  90. package/dist/relation.cjs +137 -1
  91. package/dist/relation.cjs.map +1 -1
  92. package/dist/relation.d.cts +113 -1
  93. package/dist/relation.d.mts +113 -1
  94. package/dist/relation.mjs +136 -2
  95. package/dist/relation.mjs.map +1 -1
  96. package/dist/rollup.cjs +203 -10
  97. package/dist/rollup.cjs.map +1 -1
  98. package/dist/rollup.d.cts +201 -0
  99. package/dist/rollup.d.mts +201 -0
  100. package/dist/rollup.mjs +203 -10
  101. package/dist/rollup.mjs.map +1 -1
  102. package/dist/select.cjs +120 -0
  103. package/dist/select.cjs.map +1 -1
  104. package/dist/select.d.cts +121 -0
  105. package/dist/select.d.mts +121 -0
  106. package/dist/select.mjs +120 -0
  107. package/dist/select.mjs.map +1 -1
  108. package/dist/status.cjs +120 -0
  109. package/dist/status.cjs.map +1 -1
  110. package/dist/status.d.cts +121 -0
  111. package/dist/status.d.mts +121 -0
  112. package/dist/status.mjs +120 -0
  113. package/dist/status.mjs.map +1 -1
  114. package/dist/text.cjs +103 -3
  115. package/dist/text.cjs.map +1 -1
  116. package/dist/text.d.cts +73 -10
  117. package/dist/text.d.mts +73 -10
  118. package/dist/text.mjs +103 -3
  119. package/dist/text.mjs.map +1 -1
  120. package/dist/unique-id.cjs +73 -2
  121. package/dist/unique-id.cjs.map +1 -1
  122. package/dist/unique-id.d.cts +81 -2
  123. package/dist/unique-id.d.mts +81 -2
  124. package/dist/unique-id.mjs +72 -2
  125. package/dist/unique-id.mjs.map +1 -1
  126. package/dist/url.cjs +58 -0
  127. package/dist/url.cjs.map +1 -1
  128. package/dist/url.d.cts +59 -0
  129. package/dist/url.d.mts +59 -0
  130. package/dist/url.mjs +58 -0
  131. package/dist/url.mjs.map +1 -1
  132. package/dist/verification.cjs +82 -5
  133. package/dist/verification.cjs.map +1 -1
  134. package/dist/verification.d.cts +81 -0
  135. package/dist/verification.d.mts +81 -0
  136. package/dist/verification.mjs +82 -5
  137. package/dist/verification.mjs.map +1 -1
  138. package/package.json +1 -1
package/dist/text.cjs CHANGED
@@ -3,9 +3,109 @@ let valibot = require("valibot");
3
3
  valibot = require_rolldown_runtime.__toESM(valibot);
4
4
 
5
5
  //#region src/text.ts
6
- const RichTextArraySchema = valibot.pipe(valibot.array(valibot.object({ plain_text: valibot.string() })), valibot.transform((v) => v.map((v$1) => v$1.plain_text).join("")));
7
- const TitleSchema = valibot.pipe(valibot.object({ title: RichTextArraySchema }), valibot.transform((v) => v.title));
8
- const RichTextSchema = valibot.pipe(valibot.object({ rich_text: RichTextArraySchema }), valibot.transform((v) => v.rich_text));
6
+ /**
7
+ * Schema for a Notion rich text array structure.
8
+ *
9
+ * **Input:**
10
+ * ```
11
+ * Array<{
12
+ * plain_text: string;
13
+ * }>
14
+ * ```
15
+ *
16
+ * **Output:**
17
+ * ```
18
+ * Array<{
19
+ * plain_text: string;
20
+ * }>
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import * as v from "valibot";
26
+ * import { RichTextArraySchema } from "@nakanoaas/notion-valibot-utils";
27
+ *
28
+ * const PageSchema = v.object({
29
+ * id: v.string(),
30
+ * properties: v.object({
31
+ * Text: v.object({
32
+ * rich_text: RichTextArraySchema,
33
+ * }),
34
+ * }),
35
+ * });
36
+ *
37
+ * const page = await notion.pages.retrieve({ page_id: "..." });
38
+ * const parsed = v.parse(PageSchema, page);
39
+ * // parsed.properties.Text.rich_text: Array<{ plain_text: string }>
40
+ * ```
41
+ *
42
+ * @internal
43
+ */
44
+ const RichTextArraySchema = valibot.array(valibot.object({ plain_text: valibot.string() }));
45
+ /**
46
+ * Schema to extract the `title` property from a Notion page property and transform it to a string.
47
+ *
48
+ * **Input:**
49
+ * ```
50
+ * {
51
+ * title: Array<{
52
+ * plain_text: string;
53
+ * }>;
54
+ * }
55
+ * ```
56
+ *
57
+ * **Output:** `string`
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { TitleSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * Title: TitleSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.Title: string
74
+ * ```
75
+ */
76
+ const TitleSchema = valibot.pipe(valibot.object({ title: RichTextArraySchema }), valibot.transform((v) => v.title.map((v$1) => v$1.plain_text).join("")));
77
+ /**
78
+ * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.
79
+ *
80
+ * **Input:**
81
+ * ```
82
+ * {
83
+ * rich_text: Array<{
84
+ * plain_text: string;
85
+ * }>;
86
+ * }
87
+ * ```
88
+ *
89
+ * **Output:** `string`
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import * as v from "valibot";
94
+ * import { RichTextSchema } from "@nakanoaas/notion-valibot-utils";
95
+ *
96
+ * const PageSchema = v.object({
97
+ * id: v.string(),
98
+ * properties: v.object({
99
+ * Description: RichTextSchema,
100
+ * }),
101
+ * });
102
+ *
103
+ * const page = await notion.pages.retrieve({ page_id: "..." });
104
+ * const parsed = v.parse(PageSchema, page);
105
+ * // parsed.properties.Description: string
106
+ * ```
107
+ */
108
+ const RichTextSchema = valibot.pipe(valibot.object({ rich_text: RichTextArraySchema }), valibot.transform((v) => v.rich_text.map((v$1) => v$1.plain_text).join("")));
9
109
 
10
110
  //#endregion
11
111
  exports.RichTextSchema = RichTextSchema;
package/dist/text.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.cjs","names":["v"],"sources":["../src/text.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nconst RichTextArraySchema = v.pipe(\n\tv.array(\n\t\tv.object({\n\t\t\tplain_text: v.string(),\n\t\t}),\n\t),\n\tv.transform((v) => v.map((v) => v.plain_text).join(\"\")),\n);\n\nexport const TitleSchema = v.pipe(\n\tv.object({\n\t\ttitle: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.title),\n);\n\nexport const RichTextSchema = v.pipe(\n\tv.object({\n\t\trich_text: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.rich_text),\n);\n"],"mappings":";;;;;AAEA,MAAM,sBAAsBA,QAAE,KAC7BA,QAAE,MACDA,QAAE,OAAO,EACR,YAAYA,QAAE,QAAQ,EACtB,CAAC,CACF,EACDA,QAAE,WAAW,MAAM,EAAE,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CACvD;AAED,MAAa,cAAcA,QAAE,KAC5BA,QAAE,OAAO,EACR,OAAO,qBACP,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC3B;AAED,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,WAAW,qBACX,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,UAAU,CAC/B"}
1
+ {"version":3,"file":"text.cjs","names":["v"],"sources":["../src/text.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion rich text array structure.\n *\n * **Input:**\n * ```\n * Array<{\n * plain_text: string;\n * }>\n * ```\n *\n * **Output:**\n * ```\n * Array<{\n * plain_text: string;\n * }>\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RichTextArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Text: v.object({\n * rich_text: RichTextArraySchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Text.rich_text: Array<{ plain_text: string }>\n * ```\n *\n * @internal\n */\nconst RichTextArraySchema = v.array(\n\tv.object({\n\t\tplain_text: v.string(),\n\t}),\n);\n\n/**\n * Schema to extract the `title` property from a Notion page property and transform it to a string.\n *\n * **Input:**\n * ```\n * {\n * title: Array<{\n * plain_text: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { TitleSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Title: TitleSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Title: string\n * ```\n */\nexport const TitleSchema = v.pipe(\n\tv.object({\n\t\ttitle: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.title.map((v) => v.plain_text).join(\"\")),\n);\n\n/**\n * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.\n *\n * **Input:**\n * ```\n * {\n * rich_text: Array<{\n * plain_text: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RichTextSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Description: RichTextSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Description: string\n * ```\n */\nexport const RichTextSchema = v.pipe(\n\tv.object({\n\t\trich_text: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.rich_text.map((v) => v.plain_text).join(\"\")),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsBA,QAAE,MAC7BA,QAAE,OAAO,EACR,YAAYA,QAAE,QAAQ,EACtB,CAAC,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,cAAcA,QAAE,KAC5BA,QAAE,OAAO,EACR,OAAO,qBACP,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,WAAW,qBACX,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,UAAU,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CACjE"}
package/dist/text.d.cts CHANGED
@@ -1,23 +1,86 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/text.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `title` property from a Notion page property and transform it to a string.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * title: Array<{
12
+ * plain_text: string;
13
+ * }>;
14
+ * }
15
+ * ```
16
+ *
17
+ * **Output:** `string`
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import * as v from "valibot";
22
+ * import { TitleSchema } from "@nakanoaas/notion-valibot-utils";
23
+ *
24
+ * const PageSchema = v.object({
25
+ * id: v.string(),
26
+ * properties: v.object({
27
+ * Title: TitleSchema,
28
+ * }),
29
+ * });
30
+ *
31
+ * const page = await notion.pages.retrieve({ page_id: "..." });
32
+ * const parsed = v.parse(PageSchema, page);
33
+ * // parsed.properties.Title: string
34
+ * ```
35
+ */
4
36
  declare const TitleSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
- readonly title: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
37
+ readonly title: v.ArraySchema<v.ObjectSchema<{
6
38
  readonly plain_text: v.StringSchema<undefined>;
7
- }, undefined>, undefined>, v.TransformAction<{
8
- plain_text: string;
9
- }[], string>]>;
39
+ }, undefined>, undefined>;
10
40
  }, undefined>, v.TransformAction<{
11
- title: string;
41
+ title: {
42
+ plain_text: string;
43
+ }[];
12
44
  }, string>]>;
45
+ /**
46
+ * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.
47
+ *
48
+ * **Input:**
49
+ * ```
50
+ * {
51
+ * rich_text: Array<{
52
+ * plain_text: string;
53
+ * }>;
54
+ * }
55
+ * ```
56
+ *
57
+ * **Output:** `string`
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { RichTextSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * Description: RichTextSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.Description: string
74
+ * ```
75
+ */
13
76
  declare const RichTextSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
14
- readonly rich_text: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
77
+ readonly rich_text: v.ArraySchema<v.ObjectSchema<{
15
78
  readonly plain_text: v.StringSchema<undefined>;
16
- }, undefined>, undefined>, v.TransformAction<{
17
- plain_text: string;
18
- }[], string>]>;
79
+ }, undefined>, undefined>;
19
80
  }, undefined>, v.TransformAction<{
20
- rich_text: string;
81
+ rich_text: {
82
+ plain_text: string;
83
+ }[];
21
84
  }, string>]>;
22
85
  //#endregion
23
86
  export { RichTextSchema, TitleSchema };
package/dist/text.d.mts CHANGED
@@ -1,23 +1,86 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/text.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `title` property from a Notion page property and transform it to a string.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * title: Array<{
12
+ * plain_text: string;
13
+ * }>;
14
+ * }
15
+ * ```
16
+ *
17
+ * **Output:** `string`
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import * as v from "valibot";
22
+ * import { TitleSchema } from "@nakanoaas/notion-valibot-utils";
23
+ *
24
+ * const PageSchema = v.object({
25
+ * id: v.string(),
26
+ * properties: v.object({
27
+ * Title: TitleSchema,
28
+ * }),
29
+ * });
30
+ *
31
+ * const page = await notion.pages.retrieve({ page_id: "..." });
32
+ * const parsed = v.parse(PageSchema, page);
33
+ * // parsed.properties.Title: string
34
+ * ```
35
+ */
4
36
  declare const TitleSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
- readonly title: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
37
+ readonly title: v.ArraySchema<v.ObjectSchema<{
6
38
  readonly plain_text: v.StringSchema<undefined>;
7
- }, undefined>, undefined>, v.TransformAction<{
8
- plain_text: string;
9
- }[], string>]>;
39
+ }, undefined>, undefined>;
10
40
  }, undefined>, v.TransformAction<{
11
- title: string;
41
+ title: {
42
+ plain_text: string;
43
+ }[];
12
44
  }, string>]>;
45
+ /**
46
+ * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.
47
+ *
48
+ * **Input:**
49
+ * ```
50
+ * {
51
+ * rich_text: Array<{
52
+ * plain_text: string;
53
+ * }>;
54
+ * }
55
+ * ```
56
+ *
57
+ * **Output:** `string`
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { RichTextSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * Description: RichTextSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.Description: string
74
+ * ```
75
+ */
13
76
  declare const RichTextSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
14
- readonly rich_text: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
77
+ readonly rich_text: v.ArraySchema<v.ObjectSchema<{
15
78
  readonly plain_text: v.StringSchema<undefined>;
16
- }, undefined>, undefined>, v.TransformAction<{
17
- plain_text: string;
18
- }[], string>]>;
79
+ }, undefined>, undefined>;
19
80
  }, undefined>, v.TransformAction<{
20
- rich_text: string;
81
+ rich_text: {
82
+ plain_text: string;
83
+ }[];
21
84
  }, string>]>;
22
85
  //#endregion
23
86
  export { RichTextSchema, TitleSchema };
package/dist/text.mjs CHANGED
@@ -1,9 +1,109 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/text.ts
4
- const RichTextArraySchema = v.pipe(v.array(v.object({ plain_text: v.string() })), v.transform((v$1) => v$1.map((v$2) => v$2.plain_text).join("")));
5
- const TitleSchema = v.pipe(v.object({ title: RichTextArraySchema }), v.transform((v$1) => v$1.title));
6
- const RichTextSchema = v.pipe(v.object({ rich_text: RichTextArraySchema }), v.transform((v$1) => v$1.rich_text));
4
+ /**
5
+ * Schema for a Notion rich text array structure.
6
+ *
7
+ * **Input:**
8
+ * ```
9
+ * Array<{
10
+ * plain_text: string;
11
+ * }>
12
+ * ```
13
+ *
14
+ * **Output:**
15
+ * ```
16
+ * Array<{
17
+ * plain_text: string;
18
+ * }>
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import * as v from "valibot";
24
+ * import { RichTextArraySchema } from "@nakanoaas/notion-valibot-utils";
25
+ *
26
+ * const PageSchema = v.object({
27
+ * id: v.string(),
28
+ * properties: v.object({
29
+ * Text: v.object({
30
+ * rich_text: RichTextArraySchema,
31
+ * }),
32
+ * }),
33
+ * });
34
+ *
35
+ * const page = await notion.pages.retrieve({ page_id: "..." });
36
+ * const parsed = v.parse(PageSchema, page);
37
+ * // parsed.properties.Text.rich_text: Array<{ plain_text: string }>
38
+ * ```
39
+ *
40
+ * @internal
41
+ */
42
+ const RichTextArraySchema = v.array(v.object({ plain_text: v.string() }));
43
+ /**
44
+ * Schema to extract the `title` property from a Notion page property and transform it to a string.
45
+ *
46
+ * **Input:**
47
+ * ```
48
+ * {
49
+ * title: Array<{
50
+ * plain_text: string;
51
+ * }>;
52
+ * }
53
+ * ```
54
+ *
55
+ * **Output:** `string`
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import * as v from "valibot";
60
+ * import { TitleSchema } from "@nakanoaas/notion-valibot-utils";
61
+ *
62
+ * const PageSchema = v.object({
63
+ * id: v.string(),
64
+ * properties: v.object({
65
+ * Title: TitleSchema,
66
+ * }),
67
+ * });
68
+ *
69
+ * const page = await notion.pages.retrieve({ page_id: "..." });
70
+ * const parsed = v.parse(PageSchema, page);
71
+ * // parsed.properties.Title: string
72
+ * ```
73
+ */
74
+ const TitleSchema = v.pipe(v.object({ title: RichTextArraySchema }), v.transform((v$1) => v$1.title.map((v$2) => v$2.plain_text).join("")));
75
+ /**
76
+ * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.
77
+ *
78
+ * **Input:**
79
+ * ```
80
+ * {
81
+ * rich_text: Array<{
82
+ * plain_text: string;
83
+ * }>;
84
+ * }
85
+ * ```
86
+ *
87
+ * **Output:** `string`
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import * as v from "valibot";
92
+ * import { RichTextSchema } from "@nakanoaas/notion-valibot-utils";
93
+ *
94
+ * const PageSchema = v.object({
95
+ * id: v.string(),
96
+ * properties: v.object({
97
+ * Description: RichTextSchema,
98
+ * }),
99
+ * });
100
+ *
101
+ * const page = await notion.pages.retrieve({ page_id: "..." });
102
+ * const parsed = v.parse(PageSchema, page);
103
+ * // parsed.properties.Description: string
104
+ * ```
105
+ */
106
+ const RichTextSchema = v.pipe(v.object({ rich_text: RichTextArraySchema }), v.transform((v$1) => v$1.rich_text.map((v$2) => v$2.plain_text).join("")));
7
107
 
8
108
  //#endregion
9
109
  export { RichTextSchema, TitleSchema };
package/dist/text.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.mjs","names":["v"],"sources":["../src/text.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nconst RichTextArraySchema = v.pipe(\n\tv.array(\n\t\tv.object({\n\t\t\tplain_text: v.string(),\n\t\t}),\n\t),\n\tv.transform((v) => v.map((v) => v.plain_text).join(\"\")),\n);\n\nexport const TitleSchema = v.pipe(\n\tv.object({\n\t\ttitle: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.title),\n);\n\nexport const RichTextSchema = v.pipe(\n\tv.object({\n\t\trich_text: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.rich_text),\n);\n"],"mappings":";;;AAEA,MAAM,sBAAsB,EAAE,KAC7B,EAAE,MACD,EAAE,OAAO,EACR,YAAY,EAAE,QAAQ,EACtB,CAAC,CACF,EACD,EAAE,WAAW,QAAMA,IAAE,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CACvD;AAED,MAAa,cAAc,EAAE,KAC5B,EAAE,OAAO,EACR,OAAO,qBACP,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,MAAM,CAC3B;AAED,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,WAAW,qBACX,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,UAAU,CAC/B"}
1
+ {"version":3,"file":"text.mjs","names":["v"],"sources":["../src/text.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion rich text array structure.\n *\n * **Input:**\n * ```\n * Array<{\n * plain_text: string;\n * }>\n * ```\n *\n * **Output:**\n * ```\n * Array<{\n * plain_text: string;\n * }>\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RichTextArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Text: v.object({\n * rich_text: RichTextArraySchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Text.rich_text: Array<{ plain_text: string }>\n * ```\n *\n * @internal\n */\nconst RichTextArraySchema = v.array(\n\tv.object({\n\t\tplain_text: v.string(),\n\t}),\n);\n\n/**\n * Schema to extract the `title` property from a Notion page property and transform it to a string.\n *\n * **Input:**\n * ```\n * {\n * title: Array<{\n * plain_text: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { TitleSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Title: TitleSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Title: string\n * ```\n */\nexport const TitleSchema = v.pipe(\n\tv.object({\n\t\ttitle: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.title.map((v) => v.plain_text).join(\"\")),\n);\n\n/**\n * Schema to extract the `rich_text` property from a Notion page property and transform it to a string.\n *\n * **Input:**\n * ```\n * {\n * rich_text: Array<{\n * plain_text: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RichTextSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Description: RichTextSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Description: string\n * ```\n */\nexport const RichTextSchema = v.pipe(\n\tv.object({\n\t\trich_text: RichTextArraySchema,\n\t}),\n\tv.transform((v) => v.rich_text.map((v) => v.plain_text).join(\"\")),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsB,EAAE,MAC7B,EAAE,OAAO,EACR,YAAY,EAAE,QAAQ,EACtB,CAAC,CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,cAAc,EAAE,KAC5B,EAAE,OAAO,EACR,OAAO,qBACP,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,MAAM,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,WAAW,qBACX,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,UAAU,KAAK,QAAMA,IAAE,WAAW,CAAC,KAAK,GAAG,CAAC,CACjE"}
@@ -3,11 +3,82 @@ let valibot = require("valibot");
3
3
  valibot = require_rolldown_runtime.__toESM(valibot);
4
4
 
5
5
  //#region src/unique-id.ts
6
- const UniqueIdSchema = valibot.pipe(valibot.object({ unique_id: valibot.object({
6
+ /**
7
+ * Schema to extract the `unique_id` property number from a Notion page property.
8
+ *
9
+ * **Input:**
10
+ * ```
11
+ * {
12
+ * unique_id: {
13
+ * number: number;
14
+ * };
15
+ * }
16
+ * ```
17
+ *
18
+ * **Output:** `number`
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import * as v from "valibot";
23
+ * import { UniqueIdNumberSchema } from "@nakanoaas/notion-valibot-utils";
24
+ *
25
+ * const PageSchema = v.object({
26
+ * id: v.string(),
27
+ * properties: v.object({
28
+ * ID: UniqueIdNumberSchema,
29
+ * }),
30
+ * });
31
+ *
32
+ * const page = await notion.pages.retrieve({ page_id: "..." });
33
+ * const parsed = v.parse(PageSchema, page);
34
+ * // parsed.properties.ID: number
35
+ * ```
36
+ */
37
+ const UniqueIdNumberSchema = valibot.pipe(valibot.object({ unique_id: valibot.object({ number: valibot.number() }) }), valibot.transform((v) => v.unique_id.number));
38
+ /**
39
+ * Schema to extract the `unique_id` property from a Notion page property.
40
+ *
41
+ * **Input:**
42
+ * ```
43
+ * {
44
+ * unique_id: {
45
+ * prefix: string | null;
46
+ * number: number | null;
47
+ * };
48
+ * }
49
+ * ```
50
+ *
51
+ * **Output:**
52
+ * ```
53
+ * {
54
+ * prefix: string | null;
55
+ * number: number | null;
56
+ * }
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { NullableUniqueIdSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * ID: NullableUniqueIdSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.ID: { prefix: string | null; number: number | null }
74
+ * ```
75
+ */
76
+ const NullableUniqueIdSchema = valibot.pipe(valibot.object({ unique_id: valibot.object({
7
77
  prefix: valibot.nullable(valibot.string()),
8
78
  number: valibot.nullable(valibot.number())
9
79
  }) }), valibot.transform((v) => v.unique_id));
10
80
 
11
81
  //#endregion
12
- exports.UniqueIdSchema = UniqueIdSchema;
82
+ exports.NullableUniqueIdSchema = NullableUniqueIdSchema;
83
+ exports.UniqueIdNumberSchema = UniqueIdNumberSchema;
13
84
  //# sourceMappingURL=unique-id.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"unique-id.cjs","names":["v"],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const UniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;AAEA,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO;CACnB,QAAQA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC9B,QAAQA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC9B,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,UAAU,CAC/B"}
1
+ {"version":3,"file":"unique-id.cjs","names":["v"],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `unique_id` property number from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { UniqueIdNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: UniqueIdNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: number\n * ```\n */\nexport const UniqueIdNumberSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id.number),\n);\n\n/**\n * Schema to extract the `unique_id` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string | null;\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * prefix: string | null;\n * number: number | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableUniqueIdSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: NullableUniqueIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: { prefix: string | null; number: number | null }\n * ```\n */\nexport const NullableUniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO,EACnB,QAAQA,QAAE,QAAQ,EAClB,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,UAAU,OAAO,CACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCD,MAAa,yBAAyBA,QAAE,KACvCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO;CACnB,QAAQA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC9B,QAAQA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC9B,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,UAAU,CAC/B"}
@@ -1,7 +1,86 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/unique-id.d.ts
4
- declare const UniqueIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
4
+
5
+ /**
6
+ * Schema to extract the `unique_id` property number from a Notion page property.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * unique_id: {
12
+ * number: number;
13
+ * };
14
+ * }
15
+ * ```
16
+ *
17
+ * **Output:** `number`
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import * as v from "valibot";
22
+ * import { UniqueIdNumberSchema } from "@nakanoaas/notion-valibot-utils";
23
+ *
24
+ * const PageSchema = v.object({
25
+ * id: v.string(),
26
+ * properties: v.object({
27
+ * ID: UniqueIdNumberSchema,
28
+ * }),
29
+ * });
30
+ *
31
+ * const page = await notion.pages.retrieve({ page_id: "..." });
32
+ * const parsed = v.parse(PageSchema, page);
33
+ * // parsed.properties.ID: number
34
+ * ```
35
+ */
36
+ declare const UniqueIdNumberSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
37
+ readonly unique_id: v.ObjectSchema<{
38
+ readonly number: v.NumberSchema<undefined>;
39
+ }, undefined>;
40
+ }, undefined>, v.TransformAction<{
41
+ unique_id: {
42
+ number: number;
43
+ };
44
+ }, number>]>;
45
+ /**
46
+ * Schema to extract the `unique_id` property from a Notion page property.
47
+ *
48
+ * **Input:**
49
+ * ```
50
+ * {
51
+ * unique_id: {
52
+ * prefix: string | null;
53
+ * number: number | null;
54
+ * };
55
+ * }
56
+ * ```
57
+ *
58
+ * **Output:**
59
+ * ```
60
+ * {
61
+ * prefix: string | null;
62
+ * number: number | null;
63
+ * }
64
+ * ```
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import * as v from "valibot";
69
+ * import { NullableUniqueIdSchema } from "@nakanoaas/notion-valibot-utils";
70
+ *
71
+ * const PageSchema = v.object({
72
+ * id: v.string(),
73
+ * properties: v.object({
74
+ * ID: NullableUniqueIdSchema,
75
+ * }),
76
+ * });
77
+ *
78
+ * const page = await notion.pages.retrieve({ page_id: "..." });
79
+ * const parsed = v.parse(PageSchema, page);
80
+ * // parsed.properties.ID: { prefix: string | null; number: number | null }
81
+ * ```
82
+ */
83
+ declare const NullableUniqueIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
84
  readonly unique_id: v.ObjectSchema<{
6
85
  readonly prefix: v.NullableSchema<v.StringSchema<undefined>, undefined>;
7
86
  readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
@@ -16,5 +95,5 @@ declare const UniqueIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
16
95
  number: number | null;
17
96
  }>]>;
18
97
  //#endregion
19
- export { UniqueIdSchema };
98
+ export { NullableUniqueIdSchema, UniqueIdNumberSchema };
20
99
  //# sourceMappingURL=unique-id.d.cts.map