@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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Notion Valibot Schema
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/%40nakanoaas%2Fnotion-valibot-schema)](https://www.npmjs.com/package/@nakanoaas/notion-valibot-schema) [![JSR](https://jsr.io/badges/@nakanoaas/notion-valibot-schema)](https://jsr.io/@nakanoaas/notion-valibot-schema)
4
+
3
5
  A small collection of **[Valibot](https://github.com/fabian-hiller/valibot)** schemas for the Notion API.
4
6
 
5
7
  It helps you **validate and transform** Notion `properties` into plain JavaScript values (e.g. `string`, `number`, `Date`, `string[]`) so you can work with the results without dealing with Notion’s nested property shapes.
@@ -30,38 +32,38 @@ deno add @nakanoaas/notion-valibot-schema @valibot/valibot
30
32
 
31
33
  ### Parse a Notion database page (common pattern)
32
34
 
33
- This example shows how to parse a page returned by `notion.pages.retrieve()` (or an item from `notion.databases.query().results`) and turn its `properties` into plain values.
35
+ This example shows how to parse a page returned by `notion.pages.retrieve()` (or an item from `notion.dataSources.query().results`) and turn its `properties` into plain values.
34
36
 
35
37
  ```ts
36
38
  import * as v from "valibot";
37
39
  import {
38
- CheckboxSchema,
39
- FilesSchema,
40
- MultiSelectSchema,
41
- NullableDateSchema,
42
- NullableNumberSchema,
43
- NullableStatusSchema,
44
- NullableUrlSchema,
45
- RelationSchema,
46
- RichTextSchema,
47
- TitleSchema,
40
+ CheckboxSchema,
41
+ FilesSchema,
42
+ MultiSelectSchema,
43
+ NullableDateSchema,
44
+ NullableNumberSchema,
45
+ NullableUrlSchema,
46
+ RelationSchema,
47
+ RichTextSchema,
48
+ StatusSchema,
49
+ TitleSchema,
48
50
  } from "@nakanoaas/notion-valibot-schema";
49
51
 
50
52
  // Property keys must match your database property names exactly.
51
53
  const NotionTaskPageSchema = v.object({
52
- id: v.string(),
53
- properties: v.object({
54
- Name: TitleSchema, // -> string
55
- Notes: RichTextSchema, // -> string
56
- Status: NullableStatusSchema(v.string()), // -> string | null
57
- Tags: MultiSelectSchema(v.string()), // -> string[]
58
- Due: NullableDateSchema, // -> Date | null
59
- Points: NullableNumberSchema, // -> number | null
60
- Done: CheckboxSchema, // -> boolean
61
- Website: NullableUrlSchema, // -> string | null
62
- Attachments: FilesSchema, // -> string[] (URLs)
63
- Related: RelationSchema, // -> string[] (page IDs)
64
- }),
54
+ id: v.string(),
55
+ properties: v.object({
56
+ Name: TitleSchema, // -> string
57
+ Notes: RichTextSchema, // -> string
58
+ Status: StatusSchema(v.picklist(["ToDo", "In Progress", "Done"])), // -> "ToDo" | "In Progress" | "Done"
59
+ Tags: MultiSelectSchema(v.string()), // -> string[]
60
+ Due: NullableDateSchema, // -> Date | null
61
+ Points: NullableNumberSchema, // -> number | null
62
+ Done: CheckboxSchema, // -> boolean
63
+ Website: NullableUrlSchema, // -> string | null
64
+ Attachments: FilesSchema, // -> string[] (URLs)
65
+ Related: RelationSchema, // -> string[] (page IDs)
66
+ }),
65
67
  });
66
68
 
67
69
  // Fetch a page with the Notion SDK
package/dist/checkbox.cjs CHANGED
@@ -3,6 +3,35 @@ let valibot = require("valibot");
3
3
  valibot = require_rolldown_runtime.__toESM(valibot);
4
4
 
5
5
  //#region src/checkbox.ts
6
+ /**
7
+ * Schema to extract the `checkbox` property from a Notion page property.
8
+ *
9
+ * **Input:**
10
+ * ```
11
+ * {
12
+ * checkbox: boolean;
13
+ * }
14
+ * ```
15
+ *
16
+ * **Output:** `boolean`
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import * as v from "valibot";
21
+ * import { CheckboxSchema } from "@nakanoaas/notion-valibot-utils";
22
+ *
23
+ * const PageSchema = v.object({
24
+ * id: v.string(),
25
+ * properties: v.object({
26
+ * Checkbox: CheckboxSchema,
27
+ * }),
28
+ * });
29
+ *
30
+ * const page = await notion.pages.retrieve({ page_id: "..." });
31
+ * const parsed = v.parse(PageSchema, page);
32
+ * // parsed.properties.Checkbox: boolean
33
+ * ```
34
+ */
6
35
  const CheckboxSchema = valibot.pipe(valibot.object({ checkbox: valibot.boolean() }), valibot.transform((v) => v.checkbox));
7
36
 
8
37
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.cjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;;;AAEA,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,UAAUA,QAAE,SAAS,EACrB,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,SAAS,CAC9B"}
1
+ {"version":3,"file":"checkbox.cjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Checkbox: CheckboxSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Checkbox: boolean\n * ```\n */\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,UAAUA,QAAE,SAAS,EACrB,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,SAAS,CAC9B"}
@@ -1,6 +1,36 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/checkbox.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `checkbox` property from a Notion page property.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * checkbox: boolean;
12
+ * }
13
+ * ```
14
+ *
15
+ * **Output:** `boolean`
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import * as v from "valibot";
20
+ * import { CheckboxSchema } from "@nakanoaas/notion-valibot-utils";
21
+ *
22
+ * const PageSchema = v.object({
23
+ * id: v.string(),
24
+ * properties: v.object({
25
+ * Checkbox: CheckboxSchema,
26
+ * }),
27
+ * });
28
+ *
29
+ * const page = await notion.pages.retrieve({ page_id: "..." });
30
+ * const parsed = v.parse(PageSchema, page);
31
+ * // parsed.properties.Checkbox: boolean
32
+ * ```
33
+ */
4
34
  declare const CheckboxSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
35
  readonly checkbox: v.BooleanSchema<undefined>;
6
36
  }, undefined>, v.TransformAction<{
@@ -1,6 +1,36 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/checkbox.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `checkbox` property from a Notion page property.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * checkbox: boolean;
12
+ * }
13
+ * ```
14
+ *
15
+ * **Output:** `boolean`
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import * as v from "valibot";
20
+ * import { CheckboxSchema } from "@nakanoaas/notion-valibot-utils";
21
+ *
22
+ * const PageSchema = v.object({
23
+ * id: v.string(),
24
+ * properties: v.object({
25
+ * Checkbox: CheckboxSchema,
26
+ * }),
27
+ * });
28
+ *
29
+ * const page = await notion.pages.retrieve({ page_id: "..." });
30
+ * const parsed = v.parse(PageSchema, page);
31
+ * // parsed.properties.Checkbox: boolean
32
+ * ```
33
+ */
4
34
  declare const CheckboxSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
35
  readonly checkbox: v.BooleanSchema<undefined>;
6
36
  }, undefined>, v.TransformAction<{
package/dist/checkbox.mjs CHANGED
@@ -1,6 +1,35 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/checkbox.ts
4
+ /**
5
+ * Schema to extract the `checkbox` property from a Notion page property.
6
+ *
7
+ * **Input:**
8
+ * ```
9
+ * {
10
+ * checkbox: boolean;
11
+ * }
12
+ * ```
13
+ *
14
+ * **Output:** `boolean`
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import * as v from "valibot";
19
+ * import { CheckboxSchema } from "@nakanoaas/notion-valibot-utils";
20
+ *
21
+ * const PageSchema = v.object({
22
+ * id: v.string(),
23
+ * properties: v.object({
24
+ * Checkbox: CheckboxSchema,
25
+ * }),
26
+ * });
27
+ *
28
+ * const page = await notion.pages.retrieve({ page_id: "..." });
29
+ * const parsed = v.parse(PageSchema, page);
30
+ * // parsed.properties.Checkbox: boolean
31
+ * ```
32
+ */
4
33
  const CheckboxSchema = v.pipe(v.object({ checkbox: v.boolean() }), v.transform((v$1) => v$1.checkbox));
5
34
 
6
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.mjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;AAEA,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,UAAU,EAAE,SAAS,EACrB,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,SAAS,CAC9B"}
1
+ {"version":3,"file":"checkbox.mjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Checkbox: CheckboxSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Checkbox: boolean\n * ```\n */\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,UAAU,EAAE,SAAS,EACrB,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,SAAS,CAC9B"}
@@ -4,7 +4,82 @@ let valibot = require("valibot");
4
4
  valibot = require_rolldown_runtime.__toESM(valibot);
5
5
 
6
6
  //#region src/created-by.ts
7
+ /**
8
+ * Schema to extract the `created_by` person object from a Notion page.
9
+ *
10
+ * **Input:**
11
+ * ```
12
+ * {
13
+ * created_by: {
14
+ * id: string;
15
+ * object: "user" | "bot" | "group";
16
+ * name: string | null;
17
+ * ...
18
+ * }
19
+ * }
20
+ * ```
21
+ *
22
+ * **Output:**
23
+ * ```
24
+ * {
25
+ * id: string;
26
+ * object: "user" | "bot" | "group";
27
+ * name: string | null;
28
+ * }
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import * as v from "valibot";
34
+ * import { CreatedBySchema } from "@nakanoaas/notion-valibot-schema";
35
+ *
36
+ * const PageSchema = v.object({
37
+ * id: v.string(),
38
+ * properties: v.object({
39
+ * CreatedBy: CreatedBySchema,
40
+ * }),
41
+ * });
42
+ *
43
+ * const page = await notion.pages.retrieve({ page_id: "..." });
44
+ * const parsed = v.parse(PageSchema, page);
45
+ * // parsed.properties.CreatedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
46
+ * ```
47
+ */
7
48
  const CreatedBySchema = valibot.pipe(valibot.object({ created_by: require_people.PersonSchema }), valibot.transform((v) => v.created_by));
49
+ /**
50
+ * Schema to extract the `created_by` person ID from a Notion page.
51
+ *
52
+ * **Input:**
53
+ * ```
54
+ * {
55
+ * created_by: {
56
+ * id: string;
57
+ * object: "user" | "bot" | "group";
58
+ * name: string | null;
59
+ * ...
60
+ * }
61
+ * }
62
+ * ```
63
+ *
64
+ * **Output:** `string`
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import * as v from "valibot";
69
+ * import { CreatedByIdSchema } from "@nakanoaas/notion-valibot-schema";
70
+ *
71
+ * const PageSchema = v.object({
72
+ * id: v.string(),
73
+ * properties: v.object({
74
+ * CreatedById: CreatedByIdSchema,
75
+ * }),
76
+ * });
77
+ *
78
+ * const page = await notion.pages.retrieve({ page_id: "..." });
79
+ * const parsed = v.parse(PageSchema, page);
80
+ * // parsed.properties.CreatedById: string
81
+ * ```
82
+ */
8
83
  const CreatedByIdSchema = valibot.pipe(valibot.object({ created_by: require_people.PersonSchema }), valibot.transform((v) => v.created_by.id));
9
84
 
10
85
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"created-by.cjs","names":["v","PersonSchema"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\nexport const CreatedBySchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by),\n);\n\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n"],"mappings":";;;;;;AAIA,MAAa,kBAAkBA,QAAE,KAChCA,QAAE,OAAO,EACR,YAAYC,6BACZ,CAAC,EACFD,QAAE,WAAW,MAAM,EAAE,WAAW,CAChC;AAED,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,YAAYC,6BACZ,CAAC,EACFD,QAAE,WAAW,MAAM,EAAE,WAAW,GAAG,CACnC"}
1
+ {"version":3,"file":"created-by.cjs","names":["v","PersonSchema"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person object from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedBySchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * CreatedBy: CreatedBySchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.CreatedBy: { id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }\n * ```\n */\nexport const CreatedBySchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by),\n);\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * CreatedById: CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.CreatedById: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,kBAAkBA,QAAE,KAChCA,QAAE,OAAO,EACR,YAAYC,6BACZ,CAAC,EACFD,QAAE,WAAW,MAAM,EAAE,WAAW,CAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCD,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,YAAYC,6BACZ,CAAC,EACFD,QAAE,WAAW,MAAM,EAAE,WAAW,GAAG,CACnC"}
@@ -1,6 +1,48 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/created-by.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `created_by` person object from a Notion page.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * created_by: {
12
+ * id: string;
13
+ * object: "user" | "bot" | "group";
14
+ * name: string | null;
15
+ * ...
16
+ * }
17
+ * }
18
+ * ```
19
+ *
20
+ * **Output:**
21
+ * ```
22
+ * {
23
+ * id: string;
24
+ * object: "user" | "bot" | "group";
25
+ * name: string | null;
26
+ * }
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import * as v from "valibot";
32
+ * import { CreatedBySchema } from "@nakanoaas/notion-valibot-schema";
33
+ *
34
+ * const PageSchema = v.object({
35
+ * id: v.string(),
36
+ * properties: v.object({
37
+ * CreatedBy: CreatedBySchema,
38
+ * }),
39
+ * });
40
+ *
41
+ * const page = await notion.pages.retrieve({ page_id: "..." });
42
+ * const parsed = v.parse(PageSchema, page);
43
+ * // parsed.properties.CreatedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * ```
45
+ */
4
46
  declare const CreatedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
47
  readonly created_by: v.ObjectSchema<{
6
48
  readonly id: v.StringSchema<undefined>;
@@ -18,6 +60,40 @@ declare const CreatedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
18
60
  object: "user" | "bot" | "group";
19
61
  name: string | null;
20
62
  }>]>;
63
+ /**
64
+ * Schema to extract the `created_by` person ID from a Notion page.
65
+ *
66
+ * **Input:**
67
+ * ```
68
+ * {
69
+ * created_by: {
70
+ * id: string;
71
+ * object: "user" | "bot" | "group";
72
+ * name: string | null;
73
+ * ...
74
+ * }
75
+ * }
76
+ * ```
77
+ *
78
+ * **Output:** `string`
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import * as v from "valibot";
83
+ * import { CreatedByIdSchema } from "@nakanoaas/notion-valibot-schema";
84
+ *
85
+ * const PageSchema = v.object({
86
+ * id: v.string(),
87
+ * properties: v.object({
88
+ * CreatedById: CreatedByIdSchema,
89
+ * }),
90
+ * });
91
+ *
92
+ * const page = await notion.pages.retrieve({ page_id: "..." });
93
+ * const parsed = v.parse(PageSchema, page);
94
+ * // parsed.properties.CreatedById: string
95
+ * ```
96
+ */
21
97
  declare const CreatedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
22
98
  readonly created_by: v.ObjectSchema<{
23
99
  readonly id: v.StringSchema<undefined>;
@@ -1,6 +1,48 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/created-by.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `created_by` person object from a Notion page.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * created_by: {
12
+ * id: string;
13
+ * object: "user" | "bot" | "group";
14
+ * name: string | null;
15
+ * ...
16
+ * }
17
+ * }
18
+ * ```
19
+ *
20
+ * **Output:**
21
+ * ```
22
+ * {
23
+ * id: string;
24
+ * object: "user" | "bot" | "group";
25
+ * name: string | null;
26
+ * }
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import * as v from "valibot";
32
+ * import { CreatedBySchema } from "@nakanoaas/notion-valibot-schema";
33
+ *
34
+ * const PageSchema = v.object({
35
+ * id: v.string(),
36
+ * properties: v.object({
37
+ * CreatedBy: CreatedBySchema,
38
+ * }),
39
+ * });
40
+ *
41
+ * const page = await notion.pages.retrieve({ page_id: "..." });
42
+ * const parsed = v.parse(PageSchema, page);
43
+ * // parsed.properties.CreatedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * ```
45
+ */
4
46
  declare const CreatedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
47
  readonly created_by: v.ObjectSchema<{
6
48
  readonly id: v.StringSchema<undefined>;
@@ -18,6 +60,40 @@ declare const CreatedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
18
60
  object: "user" | "bot" | "group";
19
61
  name: string | null;
20
62
  }>]>;
63
+ /**
64
+ * Schema to extract the `created_by` person ID from a Notion page.
65
+ *
66
+ * **Input:**
67
+ * ```
68
+ * {
69
+ * created_by: {
70
+ * id: string;
71
+ * object: "user" | "bot" | "group";
72
+ * name: string | null;
73
+ * ...
74
+ * }
75
+ * }
76
+ * ```
77
+ *
78
+ * **Output:** `string`
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import * as v from "valibot";
83
+ * import { CreatedByIdSchema } from "@nakanoaas/notion-valibot-schema";
84
+ *
85
+ * const PageSchema = v.object({
86
+ * id: v.string(),
87
+ * properties: v.object({
88
+ * CreatedById: CreatedByIdSchema,
89
+ * }),
90
+ * });
91
+ *
92
+ * const page = await notion.pages.retrieve({ page_id: "..." });
93
+ * const parsed = v.parse(PageSchema, page);
94
+ * // parsed.properties.CreatedById: string
95
+ * ```
96
+ */
21
97
  declare const CreatedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
22
98
  readonly created_by: v.ObjectSchema<{
23
99
  readonly id: v.StringSchema<undefined>;
@@ -2,7 +2,82 @@ import { PersonSchema } from "./people.mjs";
2
2
  import * as v from "valibot";
3
3
 
4
4
  //#region src/created-by.ts
5
+ /**
6
+ * Schema to extract the `created_by` person object from a Notion page.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * created_by: {
12
+ * id: string;
13
+ * object: "user" | "bot" | "group";
14
+ * name: string | null;
15
+ * ...
16
+ * }
17
+ * }
18
+ * ```
19
+ *
20
+ * **Output:**
21
+ * ```
22
+ * {
23
+ * id: string;
24
+ * object: "user" | "bot" | "group";
25
+ * name: string | null;
26
+ * }
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import * as v from "valibot";
32
+ * import { CreatedBySchema } from "@nakanoaas/notion-valibot-schema";
33
+ *
34
+ * const PageSchema = v.object({
35
+ * id: v.string(),
36
+ * properties: v.object({
37
+ * CreatedBy: CreatedBySchema,
38
+ * }),
39
+ * });
40
+ *
41
+ * const page = await notion.pages.retrieve({ page_id: "..." });
42
+ * const parsed = v.parse(PageSchema, page);
43
+ * // parsed.properties.CreatedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * ```
45
+ */
5
46
  const CreatedBySchema = v.pipe(v.object({ created_by: PersonSchema }), v.transform((v$1) => v$1.created_by));
47
+ /**
48
+ * Schema to extract the `created_by` person ID from a Notion page.
49
+ *
50
+ * **Input:**
51
+ * ```
52
+ * {
53
+ * created_by: {
54
+ * id: string;
55
+ * object: "user" | "bot" | "group";
56
+ * name: string | null;
57
+ * ...
58
+ * }
59
+ * }
60
+ * ```
61
+ *
62
+ * **Output:** `string`
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import * as v from "valibot";
67
+ * import { CreatedByIdSchema } from "@nakanoaas/notion-valibot-schema";
68
+ *
69
+ * const PageSchema = v.object({
70
+ * id: v.string(),
71
+ * properties: v.object({
72
+ * CreatedById: CreatedByIdSchema,
73
+ * }),
74
+ * });
75
+ *
76
+ * const page = await notion.pages.retrieve({ page_id: "..." });
77
+ * const parsed = v.parse(PageSchema, page);
78
+ * // parsed.properties.CreatedById: string
79
+ * ```
80
+ */
6
81
  const CreatedByIdSchema = v.pipe(v.object({ created_by: PersonSchema }), v.transform((v$1) => v$1.created_by.id));
7
82
 
8
83
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"created-by.mjs","names":["v"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\nexport const CreatedBySchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by),\n);\n\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n"],"mappings":";;;;AAIA,MAAa,kBAAkB,EAAE,KAChC,EAAE,OAAO,EACR,YAAY,cACZ,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,WAAW,CAChC;AAED,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,YAAY,cACZ,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,WAAW,GAAG,CACnC"}
1
+ {"version":3,"file":"created-by.mjs","names":["v"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person object from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedBySchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * CreatedBy: CreatedBySchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.CreatedBy: { id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }\n * ```\n */\nexport const CreatedBySchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by),\n);\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * CreatedById: CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.CreatedById: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,kBAAkB,EAAE,KAChC,EAAE,OAAO,EACR,YAAY,cACZ,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,WAAW,CAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCD,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,YAAY,cACZ,CAAC,EACF,EAAE,WAAW,QAAMA,IAAE,WAAW,GAAG,CACnC"}
@@ -3,6 +3,33 @@ let valibot = require("valibot");
3
3
  valibot = require_rolldown_runtime.__toESM(valibot);
4
4
 
5
5
  //#region src/created-time.ts
6
+ /**
7
+ * Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.
8
+ *
9
+ * **Input:**
10
+ * ```
11
+ * {
12
+ * created_time: string;
13
+ * }
14
+ * ```
15
+ *
16
+ * **Output:** `Date`
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import * as v from "valibot";
21
+ * import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-utils";
22
+ *
23
+ * const PageSchema = v.object({
24
+ * id: v.string(),
25
+ * created_time: CreatedTimeSchema,
26
+ * });
27
+ *
28
+ * const page = await notion.pages.retrieve({ page_id: "..." });
29
+ * const parsed = v.parse(PageSchema, page);
30
+ * // parsed.created_time: Date
31
+ * ```
32
+ */
6
33
  const CreatedTimeSchema = valibot.pipe(valibot.object({ created_time: valibot.string() }), valibot.transform((v) => new Date(v.created_time)));
7
34
 
8
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"created-time.cjs","names":["v"],"sources":["../src/created-time.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const CreatedTimeSchema = v.pipe(\n\tv.object({\n\t\tcreated_time: v.string(),\n\t}),\n\tv.transform((v) => new Date(v.created_time)),\n);\n"],"mappings":";;;;;AAEA,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,cAAcA,QAAE,QAAQ,EACxB,CAAC,EACFA,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,aAAa,CAAC,CAC5C"}
1
+ {"version":3,"file":"created-time.cjs","names":["v"],"sources":["../src/created-time.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * created_time: string;\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedTimeSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * created_time: CreatedTimeSchema,\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.created_time: Date\n * ```\n */\nexport const CreatedTimeSchema = v.pipe(\n\tv.object({\n\t\tcreated_time: v.string(),\n\t}),\n\tv.transform((v) => new Date(v.created_time)),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,cAAcA,QAAE,QAAQ,EACxB,CAAC,EACFA,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,aAAa,CAAC,CAC5C"}
@@ -1,6 +1,34 @@
1
1
  import * as v from "valibot";
2
2
 
3
3
  //#region src/created-time.d.ts
4
+
5
+ /**
6
+ * Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.
7
+ *
8
+ * **Input:**
9
+ * ```
10
+ * {
11
+ * created_time: string;
12
+ * }
13
+ * ```
14
+ *
15
+ * **Output:** `Date`
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import * as v from "valibot";
20
+ * import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-utils";
21
+ *
22
+ * const PageSchema = v.object({
23
+ * id: v.string(),
24
+ * created_time: CreatedTimeSchema,
25
+ * });
26
+ *
27
+ * const page = await notion.pages.retrieve({ page_id: "..." });
28
+ * const parsed = v.parse(PageSchema, page);
29
+ * // parsed.created_time: Date
30
+ * ```
31
+ */
4
32
  declare const CreatedTimeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
5
33
  readonly created_time: v.StringSchema<undefined>;
6
34
  }, undefined>, v.TransformAction<{