@nakanoaas/notion-valibot-schema 0.2.1 → 0.3.0

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 (105) hide show
  1. package/README.md +2 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +7 -13
  3. package/dist/checkbox.cjs +3 -4
  4. package/dist/checkbox.cjs.map +1 -1
  5. package/dist/checkbox.mjs +1 -2
  6. package/dist/checkbox.mjs.map +1 -1
  7. package/dist/created-by.cjs +4 -5
  8. package/dist/created-by.cjs.map +1 -1
  9. package/dist/created-by.mjs +1 -2
  10. package/dist/created-by.mjs.map +1 -1
  11. package/dist/created-time.cjs +3 -4
  12. package/dist/created-time.cjs.map +1 -1
  13. package/dist/created-time.mjs +1 -2
  14. package/dist/created-time.mjs.map +1 -1
  15. package/dist/date.cjs +3 -4
  16. package/dist/date.cjs.map +1 -1
  17. package/dist/date.mjs +1 -2
  18. package/dist/date.mjs.map +1 -1
  19. package/dist/email.cjs +3 -4
  20. package/dist/email.cjs.map +1 -1
  21. package/dist/email.mjs +1 -2
  22. package/dist/email.mjs.map +1 -1
  23. package/dist/file.cjs +164 -0
  24. package/dist/file.cjs.map +1 -0
  25. package/dist/file.d.cts +198 -0
  26. package/dist/file.d.mts +198 -0
  27. package/dist/file.mjs +160 -0
  28. package/dist/file.mjs.map +1 -0
  29. package/dist/formula.cjs +3 -4
  30. package/dist/formula.cjs.map +1 -1
  31. package/dist/formula.mjs +1 -2
  32. package/dist/formula.mjs.map +1 -1
  33. package/dist/index.cjs +27 -26
  34. package/dist/index.d.cts +2 -2
  35. package/dist/index.d.mts +2 -2
  36. package/dist/index.mjs +2 -3
  37. package/dist/last-edited-by.cjs +4 -5
  38. package/dist/last-edited-by.cjs.map +1 -1
  39. package/dist/last-edited-by.mjs +1 -2
  40. package/dist/last-edited-by.mjs.map +1 -1
  41. package/dist/last-edited-time.cjs +3 -4
  42. package/dist/last-edited-time.cjs.map +1 -1
  43. package/dist/last-edited-time.mjs +1 -2
  44. package/dist/last-edited-time.mjs.map +1 -1
  45. package/dist/multi-select.cjs +3 -4
  46. package/dist/multi-select.cjs.map +1 -1
  47. package/dist/multi-select.mjs +1 -2
  48. package/dist/multi-select.mjs.map +1 -1
  49. package/dist/number.cjs +4 -8
  50. package/dist/number.cjs.map +1 -1
  51. package/dist/number.d.cts +0 -2
  52. package/dist/number.d.mts +0 -2
  53. package/dist/number.mjs +2 -6
  54. package/dist/number.mjs.map +1 -1
  55. package/dist/people.cjs +3 -4
  56. package/dist/people.cjs.map +1 -1
  57. package/dist/people.mjs +1 -2
  58. package/dist/people.mjs.map +1 -1
  59. package/dist/phone-number.cjs +3 -4
  60. package/dist/phone-number.cjs.map +1 -1
  61. package/dist/phone-number.mjs +1 -2
  62. package/dist/phone-number.mjs.map +1 -1
  63. package/dist/place.cjs +3 -4
  64. package/dist/place.cjs.map +1 -1
  65. package/dist/place.mjs +1 -2
  66. package/dist/place.mjs.map +1 -1
  67. package/dist/relation.cjs +3 -4
  68. package/dist/relation.cjs.map +1 -1
  69. package/dist/relation.mjs +1 -2
  70. package/dist/relation.mjs.map +1 -1
  71. package/dist/rollup.cjs +5 -6
  72. package/dist/rollup.cjs.map +1 -1
  73. package/dist/rollup.mjs +2 -3
  74. package/dist/rollup.mjs.map +1 -1
  75. package/dist/select.cjs +3 -4
  76. package/dist/select.cjs.map +1 -1
  77. package/dist/select.mjs +1 -2
  78. package/dist/select.mjs.map +1 -1
  79. package/dist/status.cjs +3 -4
  80. package/dist/status.cjs.map +1 -1
  81. package/dist/status.mjs +1 -2
  82. package/dist/status.mjs.map +1 -1
  83. package/dist/text.cjs +3 -4
  84. package/dist/text.cjs.map +1 -1
  85. package/dist/text.mjs +1 -2
  86. package/dist/text.mjs.map +1 -1
  87. package/dist/unique-id.cjs +3 -4
  88. package/dist/unique-id.cjs.map +1 -1
  89. package/dist/unique-id.mjs +1 -2
  90. package/dist/unique-id.mjs.map +1 -1
  91. package/dist/url.cjs +3 -4
  92. package/dist/url.cjs.map +1 -1
  93. package/dist/url.mjs +1 -2
  94. package/dist/url.mjs.map +1 -1
  95. package/dist/verification.cjs +5 -6
  96. package/dist/verification.cjs.map +1 -1
  97. package/dist/verification.mjs +1 -2
  98. package/dist/verification.mjs.map +1 -1
  99. package/package.json +2 -2
  100. package/dist/files.cjs +0 -55
  101. package/dist/files.cjs.map +0 -1
  102. package/dist/files.d.cts +0 -70
  103. package/dist/files.d.mts +0 -70
  104. package/dist/files.mjs +0 -53
  105. package/dist/files.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"phone-number.mjs","names":[],"sources":["../src/phone-number.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `phone_number` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * phone_number: string;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PhoneNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Phone: PhoneNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Phone: string\n * ```\n */\nexport const PhoneNumberSchema = v.pipe(\n\tv.object({\n\t\tphone_number: v.string(),\n\t}),\n\tv.transform((v) => v.phone_number),\n);\n\n/**\n * Schema to extract the `phone_number` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * phone_number: string | null;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePhoneNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Phone: NullablePhoneNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Phone: string | null\n * ```\n */\nexport const NullablePhoneNumberSchema = v.pipe(\n\tv.object({\n\t\tphone_number: v.nullable(v.string()),\n\t}),\n\tv.transform((v) => v.phone_number),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,cAAc,EAAE,QAAQ,EACxB,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,aAAa,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BD,MAAa,4BAA4B,EAAE,KAC1C,EAAE,OAAO,EACR,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,EACpC,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,aAAa,CAClC"}
1
+ {"version":3,"file":"phone-number.mjs","names":[],"sources":["../src/phone-number.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `phone_number` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * phone_number: string;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PhoneNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Phone: PhoneNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Phone: string\n * ```\n */\nexport const PhoneNumberSchema = v.pipe(\n\tv.object({\n\t\tphone_number: v.string(),\n\t}),\n\tv.transform((v) => v.phone_number),\n);\n\n/**\n * Schema to extract the `phone_number` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * phone_number: string | null;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePhoneNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Phone: NullablePhoneNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Phone: string | null\n * ```\n */\nexport const NullablePhoneNumberSchema = v.pipe(\n\tv.object({\n\t\tphone_number: v.nullable(v.string()),\n\t}),\n\tv.transform((v) => v.phone_number),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,cAAc,EAAE,OAAO,EACxB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,YAAY,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,4BAA4B,EAAE,KAC1C,EAAE,OAAO,EACR,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,EACpC,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,YAAY,CAClC"}
package/dist/place.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  let valibot = require("valibot");
3
- valibot = require_runtime.__toESM(valibot);
4
-
3
+ valibot = require_runtime.__toESM(valibot, 1);
5
4
  //#region src/place.ts
6
5
  /**
7
6
  * Schema for a Notion place object structure.
@@ -139,8 +138,8 @@ const PlaceSchema = valibot.pipe(valibot.object({ place: PlaceObjectSchema }), v
139
138
  * ```
140
139
  */
141
140
  const NullablePlaceSchema = valibot.pipe(valibot.object({ place: valibot.nullable(PlaceObjectSchema) }), valibot.transform((v) => v.place));
142
-
143
141
  //#endregion
144
142
  exports.NullablePlaceSchema = NullablePlaceSchema;
145
143
  exports.PlaceSchema = PlaceSchema;
144
+
146
145
  //# sourceMappingURL=place.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"place.cjs","names":["v"],"sources":["../src/place.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion place object structure.\n *\n * **Input:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceObjectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: v.object({\n * place: PlaceObjectSchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location.place: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n *\n * @internal\n */\nconst PlaceObjectSchema = v.object({\n\tlat: v.number(),\n\tlon: v.number(),\n\tname: v.nullish(v.string()),\n\taddress: v.nullish(v.string()),\n});\n\n/**\n * Schema to extract the `place` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: PlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n */\nexport const PlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: PlaceObjectSchema,\n\t}),\n\tv.transform((v) => v.place),\n);\n\n/**\n * Schema to extract the `place` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: NullablePlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null } | null\n * ```\n */\nexport const NullablePlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: v.nullable(PlaceObjectSchema),\n\t}),\n\tv.transform((v) => v.place),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,oBAAoBA,QAAE,OAAO;CAClC,KAAKA,QAAE,QAAQ;CACf,KAAKA,QAAE,QAAQ;CACf,MAAMA,QAAE,QAAQA,QAAE,QAAQ,CAAC;CAC3B,SAASA,QAAE,QAAQA,QAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CF,MAAa,cAAcA,QAAE,KAC5BA,QAAE,OAAO,EACR,OAAO,mBACP,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CD,MAAa,sBAAsBA,QAAE,KACpCA,QAAE,OAAO,EACR,OAAOA,QAAE,SAAS,kBAAkB,EACpC,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC3B"}
1
+ {"version":3,"file":"place.cjs","names":["v"],"sources":["../src/place.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion place object structure.\n *\n * **Input:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceObjectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: v.object({\n * place: PlaceObjectSchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location.place: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n *\n * @internal\n */\nconst PlaceObjectSchema = v.object({\n\tlat: v.number(),\n\tlon: v.number(),\n\tname: v.nullish(v.string()),\n\taddress: v.nullish(v.string()),\n});\n\n/**\n * Schema to extract the `place` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: PlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n */\nexport const PlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: PlaceObjectSchema,\n\t}),\n\tv.transform((v) => v.place),\n);\n\n/**\n * Schema to extract the `place` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: NullablePlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null } | null\n * ```\n */\nexport const NullablePlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: v.nullable(PlaceObjectSchema),\n\t}),\n\tv.transform((v) => v.place),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,oBAAoBA,QAAE,OAAO;CAClC,KAAKA,QAAE,OAAO;CACd,KAAKA,QAAE,OAAO;CACd,MAAMA,QAAE,QAAQA,QAAE,OAAO,CAAC;CAC1B,SAASA,QAAE,QAAQA,QAAE,OAAO,CAAC;AAC9B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CD,MAAa,cAAcA,QAAE,KAC5BA,QAAE,OAAO,EACR,OAAO,kBACR,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,KAAK,CAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,sBAAsBA,QAAE,KACpCA,QAAE,OAAO,EACR,OAAOA,QAAE,SAAS,iBAAiB,EACpC,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,KAAK,CAC3B"}
package/dist/place.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as v from "valibot";
2
-
3
2
  //#region src/place.ts
4
3
  /**
5
4
  * Schema for a Notion place object structure.
@@ -137,7 +136,7 @@ const PlaceSchema = v.pipe(v.object({ place: PlaceObjectSchema }), v.transform((
137
136
  * ```
138
137
  */
139
138
  const NullablePlaceSchema = v.pipe(v.object({ place: v.nullable(PlaceObjectSchema) }), v.transform((v) => v.place));
140
-
141
139
  //#endregion
142
140
  export { NullablePlaceSchema, PlaceSchema };
141
+
143
142
  //# sourceMappingURL=place.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"place.mjs","names":[],"sources":["../src/place.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion place object structure.\n *\n * **Input:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceObjectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: v.object({\n * place: PlaceObjectSchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location.place: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n *\n * @internal\n */\nconst PlaceObjectSchema = v.object({\n\tlat: v.number(),\n\tlon: v.number(),\n\tname: v.nullish(v.string()),\n\taddress: v.nullish(v.string()),\n});\n\n/**\n * Schema to extract the `place` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: PlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n */\nexport const PlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: PlaceObjectSchema,\n\t}),\n\tv.transform((v) => v.place),\n);\n\n/**\n * Schema to extract the `place` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: NullablePlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null } | null\n * ```\n */\nexport const NullablePlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: v.nullable(PlaceObjectSchema),\n\t}),\n\tv.transform((v) => v.place),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,oBAAoB,EAAE,OAAO;CAClC,KAAK,EAAE,QAAQ;CACf,KAAK,EAAE,QAAQ;CACf,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC;CAC3B,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC;CAC9B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CF,MAAa,cAAc,EAAE,KAC5B,EAAE,OAAO,EACR,OAAO,mBACP,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,MAAM,CAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CD,MAAa,sBAAsB,EAAE,KACpC,EAAE,OAAO,EACR,OAAO,EAAE,SAAS,kBAAkB,EACpC,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,MAAM,CAC3B"}
1
+ {"version":3,"file":"place.mjs","names":[],"sources":["../src/place.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion place object structure.\n *\n * **Input:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceObjectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: v.object({\n * place: PlaceObjectSchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location.place: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n *\n * @internal\n */\nconst PlaceObjectSchema = v.object({\n\tlat: v.number(),\n\tlon: v.number(),\n\tname: v.nullish(v.string()),\n\taddress: v.nullish(v.string()),\n});\n\n/**\n * Schema to extract the `place` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: PlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null }\n * ```\n */\nexport const PlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: PlaceObjectSchema,\n\t}),\n\tv.transform((v) => v.place),\n);\n\n/**\n * Schema to extract the `place` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * place: {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * lat: number;\n * lon: number;\n * name?: string | null;\n * address?: string | null;\n * } | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullablePlaceSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Location: NullablePlaceSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Location: { lat: number; lon: number; name?: string | null; address?: string | null } | null\n * ```\n */\nexport const NullablePlaceSchema = v.pipe(\n\tv.object({\n\t\tplace: v.nullable(PlaceObjectSchema),\n\t}),\n\tv.transform((v) => v.place),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,oBAAoB,EAAE,OAAO;CAClC,KAAK,EAAE,OAAO;CACd,KAAK,EAAE,OAAO;CACd,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC;CAC1B,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC;AAC9B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CD,MAAa,cAAc,EAAE,KAC5B,EAAE,OAAO,EACR,OAAO,kBACR,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,KAAK,CAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,sBAAsB,EAAE,KACpC,EAAE,OAAO,EACR,OAAO,EAAE,SAAS,iBAAiB,EACpC,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,KAAK,CAC3B"}
package/dist/relation.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  let valibot = require("valibot");
3
- valibot = require_runtime.__toESM(valibot);
4
-
3
+ valibot = require_runtime.__toESM(valibot, 1);
5
4
  //#region src/relation.ts
6
5
  /**
7
6
  * Schema for a Notion relation object structure.
@@ -138,9 +137,9 @@ const SingleRelationSchema = valibot.pipe(valibot.object({ relation: valibot.tup
138
137
  * ```
139
138
  */
140
139
  const NullableSingleRelationSchema = valibot.pipe(valibot.object({ relation: valibot.array(InnerRelationSchema) }), valibot.transform((v) => v.relation[0]?.id ?? null));
141
-
142
140
  //#endregion
143
141
  exports.NullableSingleRelationSchema = NullableSingleRelationSchema;
144
142
  exports.RelationSchema = RelationSchema;
145
143
  exports.SingleRelationSchema = SingleRelationSchema;
144
+
146
145
  //# sourceMappingURL=relation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"relation.cjs","names":["v"],"sources":["../src/relation.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion relation object structure.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { InnerRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Relation: v.object({\n * relation: v.array(InnerRelationSchema),\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Relation.relation: Array<{ id: string }>\n * ```\n *\n * @internal\n */\nconst InnerRelationSchema = v.object({ id: v.string() });\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to an array of page IDs.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string[]`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RelatedPages: RelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RelatedPages: string[]\n * ```\n */\nexport const RelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation.map((r) => r.id)),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID.\n *\n * **Input:**\n * ```\n * {\n * relation: [{\n * id: string;\n * }];\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: SingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string\n * ```\n */\nexport const SingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.tuple([InnerRelationSchema]),\n\t}),\n\tv.transform((v) => v.relation[0].id),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID or `null`.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: NullableSingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string | null\n * ```\n */\nexport const NullableSingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation[0]?.id ?? null),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsBA,QAAE,OAAO,EAAE,IAAIA,QAAE,QAAQ,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCxD,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,oBAAoB,EACtC,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,SAAS,KAAK,MAAM,EAAE,GAAG,CAAC,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,CAAC,oBAAoB,CAAC,EACxC,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,SAAS,GAAG,GAAG,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,+BAA+BA,QAAE,KAC7CA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,oBAAoB,EACtC,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,SAAS,IAAI,MAAM,KAAK,CAC7C"}
1
+ {"version":3,"file":"relation.cjs","names":["v"],"sources":["../src/relation.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion relation object structure.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { InnerRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Relation: v.object({\n * relation: v.array(InnerRelationSchema),\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Relation.relation: Array<{ id: string }>\n * ```\n *\n * @internal\n */\nconst InnerRelationSchema = v.object({ id: v.string() });\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to an array of page IDs.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string[]`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RelatedPages: RelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RelatedPages: string[]\n * ```\n */\nexport const RelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation.map((r) => r.id)),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID.\n *\n * **Input:**\n * ```\n * {\n * relation: [{\n * id: string;\n * }];\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: SingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string\n * ```\n */\nexport const SingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.tuple([InnerRelationSchema]),\n\t}),\n\tv.transform((v) => v.relation[0].id),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID or `null`.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: NullableSingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string | null\n * ```\n */\nexport const NullableSingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation[0]?.id ?? null),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsBA,QAAE,OAAO,EAAE,IAAIA,QAAE,OAAO,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCvD,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,mBAAmB,EACtC,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,SAAS,KAAK,MAAM,EAAE,EAAE,CAAC,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,CAAC,mBAAmB,CAAC,EACxC,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,+BAA+BA,QAAE,KAC7CA,QAAE,OAAO,EACR,UAAUA,QAAE,MAAM,mBAAmB,EACtC,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,IAAI,CAC7C"}
package/dist/relation.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as v from "valibot";
2
-
3
2
  //#region src/relation.ts
4
3
  /**
5
4
  * Schema for a Notion relation object structure.
@@ -136,7 +135,7 @@ const SingleRelationSchema = v.pipe(v.object({ relation: v.tuple([InnerRelationS
136
135
  * ```
137
136
  */
138
137
  const NullableSingleRelationSchema = v.pipe(v.object({ relation: v.array(InnerRelationSchema) }), v.transform((v) => v.relation[0]?.id ?? null));
139
-
140
138
  //#endregion
141
139
  export { NullableSingleRelationSchema, RelationSchema, SingleRelationSchema };
140
+
142
141
  //# sourceMappingURL=relation.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"relation.mjs","names":[],"sources":["../src/relation.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion relation object structure.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { InnerRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Relation: v.object({\n * relation: v.array(InnerRelationSchema),\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Relation.relation: Array<{ id: string }>\n * ```\n *\n * @internal\n */\nconst InnerRelationSchema = v.object({ id: v.string() });\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to an array of page IDs.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string[]`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RelatedPages: RelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RelatedPages: string[]\n * ```\n */\nexport const RelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation.map((r) => r.id)),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID.\n *\n * **Input:**\n * ```\n * {\n * relation: [{\n * id: string;\n * }];\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: SingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string\n * ```\n */\nexport const SingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.tuple([InnerRelationSchema]),\n\t}),\n\tv.transform((v) => v.relation[0].id),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID or `null`.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: NullableSingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string | null\n * ```\n */\nexport const NullableSingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation[0]?.id ?? null),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCxD,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,oBAAoB,EACtC,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,SAAS,KAAK,MAAM,EAAE,GAAG,CAAC,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,EACxC,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,SAAS,GAAG,GAAG,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCD,MAAa,+BAA+B,EAAE,KAC7C,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,oBAAoB,EACtC,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,SAAS,IAAI,MAAM,KAAK,CAC7C"}
1
+ {"version":3,"file":"relation.mjs","names":[],"sources":["../src/relation.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion relation object structure.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { InnerRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Relation: v.object({\n * relation: v.array(InnerRelationSchema),\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Relation.relation: Array<{ id: string }>\n * ```\n *\n * @internal\n */\nconst InnerRelationSchema = v.object({ id: v.string() });\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to an array of page IDs.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string[]`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RelatedPages: RelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RelatedPages: string[]\n * ```\n */\nexport const RelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation.map((r) => r.id)),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID.\n *\n * **Input:**\n * ```\n * {\n * relation: [{\n * id: string;\n * }];\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: SingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string\n * ```\n */\nexport const SingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.tuple([InnerRelationSchema]),\n\t}),\n\tv.transform((v) => v.relation[0].id),\n);\n\n/**\n * Schema to extract the `relation` property from a Notion page property and transform it to a single page ID or `null`.\n *\n * **Input:**\n * ```\n * {\n * relation: Array<{\n * id: string;\n * }>;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRelationSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ParentPage: NullableSingleRelationSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ParentPage: string | null\n * ```\n */\nexport const NullableSingleRelationSchema = v.pipe(\n\tv.object({\n\t\trelation: v.array(InnerRelationSchema),\n\t}),\n\tv.transform((v) => v.relation[0]?.id ?? null),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,sBAAsB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCvD,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,mBAAmB,EACtC,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,SAAS,KAAK,MAAM,EAAE,EAAE,CAAC,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,CAAC,mBAAmB,CAAC,EACxC,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,+BAA+B,EAAE,KAC7C,EAAE,OAAO,EACR,UAAU,EAAE,MAAM,mBAAmB,EACtC,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,IAAI,CAC7C"}
package/dist/rollup.cjs CHANGED
@@ -1,8 +1,7 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_date = require('./date.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_date = require("./date.cjs");
3
3
  let valibot = require("valibot");
4
- valibot = require_runtime.__toESM(valibot);
5
-
4
+ valibot = require_runtime.__toESM(valibot, 1);
6
5
  //#region src/rollup.ts
7
6
  /**
8
7
  * Schema to extract the `rollup` property with number type from a Notion page property or `null`.
@@ -291,7 +290,7 @@ function RollupArraySchema(schema) {
291
290
  function SingleRollupArraySchema(schema) {
292
291
  return valibot.pipe(valibot.object({ rollup: valibot.object({
293
292
  type: valibot.literal("array"),
294
- array: valibot.array(schema)
293
+ array: valibot.tuple([schema])
295
294
  }) }), valibot.transform((v) => v.rollup.array[0]));
296
295
  }
297
296
  /**
@@ -361,7 +360,6 @@ function NullableSingleRollupArraySchema(schema) {
361
360
  array: valibot.array(schema)
362
361
  }) }), valibot.transform((v) => v.rollup.array[0] ?? null));
363
362
  }
364
-
365
363
  //#endregion
366
364
  exports.NullableRollupDateSchema = NullableRollupDateSchema;
367
365
  exports.NullableRollupNumberSchema = NullableRollupNumberSchema;
@@ -370,4 +368,5 @@ exports.RollupArraySchema = RollupArraySchema;
370
368
  exports.RollupDateSchema = RollupDateSchema;
371
369
  exports.RollupNumberSchema = RollupNumberSchema;
372
370
  exports.SingleRollupArraySchema = SingleRollupArraySchema;
371
+
373
372
  //# sourceMappingURL=rollup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.cjs","names":["v","DateObjectSchema"],"sources":["../src/rollup.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { DateObjectSchema } from \"./date\";\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:** `number | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: NullableRollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number | null\n * ```\n */\nexport const NullableRollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: RollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number\n * ```\n */\nexport const RollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null;\n * };\n * }\n * ```\n *\n * **Output:** `Date | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: NullableRollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date | null\n * ```\n */\nexport const NullableRollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: v.nullable(DateObjectSchema),\n\t\t}),\n\t}),\n\tv.transform((v) => (v.rollup.date ? new Date(v.rollup.date.start) : null)),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * };\n * };\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: RollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date\n * ```\n */\nexport const RollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: DateObjectSchema,\n\t\t}),\n\t}),\n\tv.transform((v) => new Date(v.rollup.date.start)),\n);\n\n/**\n * Schema factory to extract the `rollup` property with array type from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed rollup array results. The rollup property in Notion can return an\n * array of different types of values depending on the rollup configuration.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<{ type: string; ... }>;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if a schema for number properties is passed, the output will be `Array<number>`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupNumbers: RollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupNumbers: number[]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for relation rollup\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupRelations: RollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupRelations: Array<{ type: \"relation\"; relation: Array<{ id: string }> }>\n * ```\n */\nexport function RollupArraySchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type.\n *\n * This is similar to {@link RollupArraySchema} but expects exactly one element in the array\n * and returns that element directly instead of an array. Useful when the rollup is configured\n * to return a single value (e.g., `show_unique_values` with one relation).\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: [T]; // exactly one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter (single element, not array).\n * For example, if a schema for number properties is passed, the output will be `number`.\n *\n * @param schema - A schema that validates the single element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: SingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: SingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> }\n * ```\n */\nexport function SingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S>\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array[0] as v.InferOutput<S>),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type, or `null` when the array is empty.\n *\n * This is similar to {@link SingleRollupArraySchema} but accepts empty arrays and returns `null` instead of requiring\n * exactly one element. Useful when the rollup may return zero or one value.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<T>; // zero or one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter, or `null`.\n * For example, if a schema for number properties is passed, the output will be `number | null`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: NullableSingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: NullableSingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> } | null\n * ```\n */\nexport function NullableSingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S> | null\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => (v.rollup.array[0] ?? null) as v.InferOutput<S> | null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,6BAA6BA,QAAE,KAC3CA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,SAAS;CACzB,QAAQA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC9B,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,OAAO,OAAO,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCD,MAAa,qBAAqBA,QAAE,KACnCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,SAAS;CACzB,QAAQA,QAAE,QAAQ;CAClB,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,OAAO,OAAO,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCD,MAAa,2BAA2BA,QAAE,KACzCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,OAAO;CACvB,MAAMA,QAAE,SAASC,8BAAiB;CAClC,CAAC,EACF,CAAC,EACFD,QAAE,WAAW,MAAO,EAAE,OAAO,OAAO,IAAI,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,KAAM,CAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCD,MAAa,mBAAmBA,QAAE,KACjCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,OAAO;CACvB,MAAMC;CACN,CAAC,EACF,CAAC,EACFD,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,CACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkED,SAAgB,kBACf,QACC;AACD,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,QAAQ;EACxB,OAAOA,QAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEF,SAAgB,wBAGf,QASC;AACD,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,QAAQ;EACxB,OAAOA,QAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,OAAO,MAAM,GAAuB,CACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEF,SAAgB,gCAGf,QASC;AACD,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,QAAQ;EACxB,OAAOA,QAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACFA,QAAE,WAAW,MAAO,EAAE,OAAO,MAAM,MAAM,KAAiC,CAC1E"}
1
+ {"version":3,"file":"rollup.cjs","names":["v","DateObjectSchema"],"sources":["../src/rollup.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { DateObjectSchema } from \"./date\";\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:** `number | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: NullableRollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number | null\n * ```\n */\nexport const NullableRollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: RollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number\n * ```\n */\nexport const RollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null;\n * };\n * }\n * ```\n *\n * **Output:** `Date | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: NullableRollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date | null\n * ```\n */\nexport const NullableRollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: v.nullable(DateObjectSchema),\n\t\t}),\n\t}),\n\tv.transform((v) => (v.rollup.date ? new Date(v.rollup.date.start) : null)),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * };\n * };\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: RollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date\n * ```\n */\nexport const RollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: DateObjectSchema,\n\t\t}),\n\t}),\n\tv.transform((v) => new Date(v.rollup.date.start)),\n);\n\n/**\n * Schema factory to extract the `rollup` property with array type from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed rollup array results. The rollup property in Notion can return an\n * array of different types of values depending on the rollup configuration.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<{ type: string; ... }>;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if a schema for number properties is passed, the output will be `Array<number>`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupNumbers: RollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupNumbers: number[]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for relation rollup\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupRelations: RollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupRelations: Array<{ type: \"relation\"; relation: Array<{ id: string }> }>\n * ```\n */\nexport function RollupArraySchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type.\n *\n * This is similar to {@link RollupArraySchema} but expects exactly one element in the array\n * and returns that element directly instead of an array. Useful when the rollup is configured\n * to return a single value (e.g., `show_unique_values` with one relation).\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: [T]; // exactly one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter (single element, not array).\n * For example, if a schema for number properties is passed, the output will be `number`.\n *\n * @param schema - A schema that validates the single element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: SingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: SingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> }\n * ```\n */\nexport function SingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S>\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.tuple([schema]),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array[0]),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type, or `null` when the array is empty.\n *\n * This is similar to {@link SingleRollupArraySchema} but accepts empty arrays and returns `null` instead of requiring\n * exactly one element. Useful when the rollup may return zero or one value.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<T>; // zero or one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter, or `null`.\n * For example, if a schema for number properties is passed, the output will be `number | null`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: NullableSingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: NullableSingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> } | null\n * ```\n */\nexport function NullableSingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S> | null\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => (v.rollup.array[0] ?? null) as v.InferOutput<S> | null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,6BAA6BA,QAAE,KAC3CA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,QAAQ;CACxB,QAAQA,QAAE,SAASA,QAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,qBAAqBA,QAAE,KACnCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,QAAQ;CACxB,QAAQA,QAAE,OAAO;AAClB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,2BAA2BA,QAAE,KACzCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,MAAM;CACtB,MAAMA,QAAE,SAASC,aAAAA,gBAAgB;AAClC,CAAC,EACF,CAAC,GACDD,QAAE,WAAW,MAAO,EAAE,OAAO,OAAO,IAAI,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,IAAK,CAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,mBAAmBA,QAAE,KACjCA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;CAChB,MAAMA,QAAE,QAAQ,MAAM;CACtB,MAAMC,aAAAA;AACP,CAAC,EACF,CAAC,GACDD,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC,CACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAgB,kBACf,QACC;CACD,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,OAAO;EACvB,OAAOA,QAAE,MAAM,MAAM;CACtB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,OAAO,KAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,wBAGf,QASC;CACD,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,OAAO;EACvB,OAAOA,QAAE,MAAM,CAAC,MAAM,CAAC;CACxB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,OAAO,MAAM,EAAE,CACrC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAgB,gCAGf,QASC;CACD,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO;EAChB,MAAMA,QAAE,QAAQ,OAAO;EACvB,OAAOA,QAAE,MAAM,MAAM;CACtB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAO,EAAE,OAAO,MAAM,MAAM,IAAgC,CAC1E;AACD"}
package/dist/rollup.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { DateObjectSchema } from "./date.mjs";
2
2
  import * as v from "valibot";
3
-
4
3
  //#region src/rollup.ts
5
4
  /**
6
5
  * Schema to extract the `rollup` property with number type from a Notion page property or `null`.
@@ -289,7 +288,7 @@ function RollupArraySchema(schema) {
289
288
  function SingleRollupArraySchema(schema) {
290
289
  return v.pipe(v.object({ rollup: v.object({
291
290
  type: v.literal("array"),
292
- array: v.array(schema)
291
+ array: v.tuple([schema])
293
292
  }) }), v.transform((v) => v.rollup.array[0]));
294
293
  }
295
294
  /**
@@ -359,7 +358,7 @@ function NullableSingleRollupArraySchema(schema) {
359
358
  array: v.array(schema)
360
359
  }) }), v.transform((v) => v.rollup.array[0] ?? null));
361
360
  }
362
-
363
361
  //#endregion
364
362
  export { NullableRollupDateSchema, NullableRollupNumberSchema, NullableSingleRollupArraySchema, RollupArraySchema, RollupDateSchema, RollupNumberSchema, SingleRollupArraySchema };
363
+
365
364
  //# sourceMappingURL=rollup.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.mjs","names":[],"sources":["../src/rollup.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { DateObjectSchema } from \"./date\";\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:** `number | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: NullableRollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number | null\n * ```\n */\nexport const NullableRollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: RollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number\n * ```\n */\nexport const RollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null;\n * };\n * }\n * ```\n *\n * **Output:** `Date | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: NullableRollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date | null\n * ```\n */\nexport const NullableRollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: v.nullable(DateObjectSchema),\n\t\t}),\n\t}),\n\tv.transform((v) => (v.rollup.date ? new Date(v.rollup.date.start) : null)),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * };\n * };\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: RollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date\n * ```\n */\nexport const RollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: DateObjectSchema,\n\t\t}),\n\t}),\n\tv.transform((v) => new Date(v.rollup.date.start)),\n);\n\n/**\n * Schema factory to extract the `rollup` property with array type from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed rollup array results. The rollup property in Notion can return an\n * array of different types of values depending on the rollup configuration.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<{ type: string; ... }>;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if a schema for number properties is passed, the output will be `Array<number>`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupNumbers: RollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupNumbers: number[]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for relation rollup\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupRelations: RollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupRelations: Array<{ type: \"relation\"; relation: Array<{ id: string }> }>\n * ```\n */\nexport function RollupArraySchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type.\n *\n * This is similar to {@link RollupArraySchema} but expects exactly one element in the array\n * and returns that element directly instead of an array. Useful when the rollup is configured\n * to return a single value (e.g., `show_unique_values` with one relation).\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: [T]; // exactly one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter (single element, not array).\n * For example, if a schema for number properties is passed, the output will be `number`.\n *\n * @param schema - A schema that validates the single element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: SingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: SingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> }\n * ```\n */\nexport function SingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S>\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array[0] as v.InferOutput<S>),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type, or `null` when the array is empty.\n *\n * This is similar to {@link SingleRollupArraySchema} but accepts empty arrays and returns `null` instead of requiring\n * exactly one element. Useful when the rollup may return zero or one value.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<T>; // zero or one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter, or `null`.\n * For example, if a schema for number properties is passed, the output will be `number | null`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: NullableSingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: NullableSingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> } | null\n * ```\n */\nexport function NullableSingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S> | null\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => (v.rollup.array[0] ?? null) as v.InferOutput<S> | null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,6BAA6B,EAAE,KAC3C,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,SAAS;CACzB,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,OAAO,OAAO,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCD,MAAa,qBAAqB,EAAE,KACnC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,SAAS;CACzB,QAAQ,EAAE,QAAQ;CAClB,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,OAAO,OAAO,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCD,MAAa,2BAA2B,EAAE,KACzC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,OAAO;CACvB,MAAM,EAAE,SAAS,iBAAiB;CAClC,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAO,EAAE,OAAO,OAAO,IAAI,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,KAAM,CAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCD,MAAa,mBAAmB,EAAE,KACjC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,OAAO;CACvB,MAAM;CACN,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAM,IAAI,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,CACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkED,SAAgB,kBACf,QACC;AACD,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,QAAQ;EACxB,OAAO,EAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEF,SAAgB,wBAGf,QASC;AACD,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,QAAQ;EACxB,OAAO,EAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,GAAuB,CACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEF,SAAgB,gCAGf,QASC;AACD,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,QAAQ;EACxB,OAAO,EAAE,MAAM,OAAO;EACtB,CAAC,EACF,CAAC,EACF,EAAE,WAAW,MAAO,EAAE,OAAO,MAAM,MAAM,KAAiC,CAC1E"}
1
+ {"version":3,"file":"rollup.mjs","names":[],"sources":["../src/rollup.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { DateObjectSchema } from \"./date\";\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:** `number | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: NullableRollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number | null\n * ```\n */\nexport const NullableRollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with number type from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"number\";\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Sum: RollupNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Sum: number\n * ```\n */\nexport const RollupNumberSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"number\"),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.rollup.number),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object or `null`.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null;\n * };\n * }\n * ```\n *\n * **Output:** `Date | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableRollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: NullableRollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date | null\n * ```\n */\nexport const NullableRollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: v.nullable(DateObjectSchema),\n\t\t}),\n\t}),\n\tv.transform((v) => (v.rollup.date ? new Date(v.rollup.date.start) : null)),\n);\n\n/**\n * Schema to extract the `rollup` property with date type from a Notion page property and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"date\";\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * };\n * };\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LatestDate: RollupDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LatestDate: Date\n * ```\n */\nexport const RollupDateSchema = v.pipe(\n\tv.object({\n\t\trollup: v.object({\n\t\t\ttype: v.literal(\"date\"),\n\t\t\tdate: DateObjectSchema,\n\t\t}),\n\t}),\n\tv.transform((v) => new Date(v.rollup.date.start)),\n);\n\n/**\n * Schema factory to extract the `rollup` property with array type from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed rollup array results. The rollup property in Notion can return an\n * array of different types of values depending on the rollup configuration.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<{ type: string; ... }>;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if a schema for number properties is passed, the output will be `Array<number>`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupNumbers: RollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupNumbers: number[]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { RollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for relation rollup\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * RollupRelations: RollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.RollupRelations: Array<{ type: \"relation\"; relation: Array<{ id: string }> }>\n * ```\n */\nexport function RollupArraySchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type.\n *\n * This is similar to {@link RollupArraySchema} but expects exactly one element in the array\n * and returns that element directly instead of an array. Useful when the rollup is configured\n * to return a single value (e.g., `show_unique_values` with one relation).\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: [T]; // exactly one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter (single element, not array).\n * For example, if a schema for number properties is passed, the output will be `number`.\n *\n * @param schema - A schema that validates the single element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: SingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: SingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> }\n * ```\n */\nexport function SingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S>\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.tuple([schema]),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => v.rollup.array[0]),\n\t);\n}\n\n/**\n * Schema factory to extract the single element from the `rollup` property with array type, or `null` when the array is empty.\n *\n * This is similar to {@link SingleRollupArraySchema} but accepts empty arrays and returns `null` instead of requiring\n * exactly one element. Useful when the rollup may return zero or one value.\n *\n * **Input:**\n * ```\n * {\n * rollup: {\n * type: \"array\";\n * array: Array<T>; // zero or one element\n * };\n * }\n * ```\n *\n * **Output:** The output type of the schema passed as a parameter, or `null`.\n * For example, if a schema for number properties is passed, the output will be `number | null`.\n *\n * @param schema - A schema that validates each element in the rollup array.\n * Must accept an object with a `type` field.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema, NumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRollupNumber: NullableSingleRollupArraySchema(NumberSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRollupNumber: number | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSingleRollupArraySchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const RelationItemSchema = v.object({\n * type: v.literal(\"relation\"),\n * relation: v.array(v.object({ id: v.string() })),\n * });\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * SingleRelation: NullableSingleRollupArraySchema(RelationItemSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.SingleRelation: { type: \"relation\"; relation: Array<{ id: string }> } | null\n * ```\n */\nexport function NullableSingleRollupArraySchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<\n\t{\n\t\trollup: {\n\t\t\ttype: \"array\";\n\t\t\tarray: v.InferInput<S>[];\n\t\t};\n\t},\n\tv.InferOutput<S> | null\n> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\trollup: v.object({\n\t\t\t\ttype: v.literal(\"array\"),\n\t\t\t\tarray: v.array(schema),\n\t\t\t}),\n\t\t}),\n\t\tv.transform((v) => (v.rollup.array[0] ?? null) as v.InferOutput<S> | null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,6BAA6B,EAAE,KAC3C,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,QAAQ;CACxB,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,qBAAqB,EAAE,KACnC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,QAAQ;CACxB,QAAQ,EAAE,OAAO;AAClB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,2BAA2B,EAAE,KACzC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,MAAM;CACtB,MAAM,EAAE,SAAS,gBAAgB;AAClC,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAO,EAAE,OAAO,OAAO,IAAI,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,IAAK,CAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,mBAAmB,EAAE,KACjC,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;CAChB,MAAM,EAAE,QAAQ,MAAM;CACtB,MAAM;AACP,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,IAAI,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC,CACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAgB,kBACf,QACC;CACD,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,OAAO;EACvB,OAAO,EAAE,MAAM,MAAM;CACtB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,OAAO,KAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,wBAGf,QASC;CACD,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,OAAO;EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;CACxB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,EAAE,CACrC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAgB,gCAGf,QASC;CACD,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO;EAChB,MAAM,EAAE,QAAQ,OAAO;EACvB,OAAO,EAAE,MAAM,MAAM;CACtB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAO,EAAE,OAAO,MAAM,MAAM,IAAgC,CAC1E;AACD"}
package/dist/select.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  let valibot = require("valibot");
3
- valibot = require_runtime.__toESM(valibot);
4
-
3
+ valibot = require_runtime.__toESM(valibot, 1);
5
4
  //#region src/select.ts
6
5
  /**
7
6
  * Schema factory to extract the `select` property from a Notion page property.
@@ -129,8 +128,8 @@ function SelectSchema(schema) {
129
128
  function NullableSelectSchema(schema) {
130
129
  return valibot.pipe(valibot.object({ select: valibot.nullable(valibot.object({ name: schema })) }), valibot.transform((v) => v.select?.name ?? null));
131
130
  }
132
-
133
131
  //#endregion
134
132
  exports.NullableSelectSchema = NullableSelectSchema;
135
133
  exports.SelectSchema = SelectSchema;
134
+
136
135
  //# sourceMappingURL=select.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.cjs","names":["v"],"sources":["../src/select.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `select` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\"\n * ```\n */\nexport function SelectSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.select.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `select` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\" | null\n * ```\n */\nexport function NullableSelectSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.select?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;AAC1E,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO,EAChB,MAAM,QACN,CAAC,EACF,CAAC,EAEFA,QAAE,WAAW,MAAM,EAAE,OAAO,KAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DF,SAAgB,qBACf,QACC;AACD,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,SACTA,QAAE,OAAO,EACR,MAAM,QACN,CAAC,CACF,EACD,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,KAAK,CAC1C"}
1
+ {"version":3,"file":"select.cjs","names":["v"],"sources":["../src/select.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `select` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\"\n * ```\n */\nexport function SelectSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.select.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `select` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\" | null\n * ```\n */\nexport function NullableSelectSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.select?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;CAC1E,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO,EAChB,MAAM,OACP,CAAC,EACF,CAAC,GAEDA,QAAE,WAAW,MAAM,EAAE,OAAO,IAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBACf,QACC;CACD,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,SACTA,QAAE,OAAO,EACR,MAAM,OACP,CAAC,CACF,EACD,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,IAAI,CAC1C;AACD"}
package/dist/select.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as v from "valibot";
2
-
3
2
  //#region src/select.ts
4
3
  /**
5
4
  * Schema factory to extract the `select` property from a Notion page property.
@@ -127,7 +126,7 @@ function SelectSchema(schema) {
127
126
  function NullableSelectSchema(schema) {
128
127
  return v.pipe(v.object({ select: v.nullable(v.object({ name: schema })) }), v.transform((v) => v.select?.name ?? null));
129
128
  }
130
-
131
129
  //#endregion
132
130
  export { NullableSelectSchema, SelectSchema };
131
+
133
132
  //# sourceMappingURL=select.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.mjs","names":[],"sources":["../src/select.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `select` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\"\n * ```\n */\nexport function SelectSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.select.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `select` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\" | null\n * ```\n */\nexport function NullableSelectSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.select?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;AAC1E,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO,EAChB,MAAM,QACN,CAAC,EACF,CAAC,EAEF,EAAE,WAAW,MAAM,EAAE,OAAO,KAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DF,SAAgB,qBACf,QACC;AACD,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,SACT,EAAE,OAAO,EACR,MAAM,QACN,CAAC,CACF,EACD,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,KAAK,CAC1C"}
1
+ {"version":3,"file":"select.mjs","names":[],"sources":["../src/select.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `select` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: SelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\"\n * ```\n */\nexport function SelectSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.select.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `select` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed select values. The select property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * select: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the select option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSelectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusSchema = v.picklist([\"todo\", \"in-progress\", \"done\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableSelectSchema(StatusSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"todo\" | \"in-progress\" | \"done\" | null\n * ```\n */\nexport function NullableSelectSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tselect: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.select?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;CAC1E,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO,EAChB,MAAM,OACP,CAAC,EACF,CAAC,GAED,EAAE,WAAW,MAAM,EAAE,OAAO,IAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBACf,QACC;CACD,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,SACT,EAAE,OAAO,EACR,MAAM,OACP,CAAC,CACF,EACD,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,IAAI,CAC1C;AACD"}
package/dist/status.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  let valibot = require("valibot");
3
- valibot = require_runtime.__toESM(valibot);
4
-
3
+ valibot = require_runtime.__toESM(valibot, 1);
5
4
  //#region src/status.ts
6
5
  /**
7
6
  * Schema factory to extract the `status` property from a Notion page property.
@@ -129,8 +128,8 @@ function StatusSchema(schema) {
129
128
  function NullableStatusSchema(schema) {
130
129
  return valibot.pipe(valibot.object({ status: valibot.nullable(valibot.object({ name: schema })) }), valibot.transform((v) => v.status?.name ?? null));
131
130
  }
132
-
133
131
  //#endregion
134
132
  exports.NullableStatusSchema = NullableStatusSchema;
135
133
  exports.StatusSchema = StatusSchema;
134
+
136
135
  //# sourceMappingURL=status.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.cjs","names":["v"],"sources":["../src/status.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `status` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\"\n * ```\n */\nexport function StatusSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.status.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `status` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\" | null\n * ```\n */\nexport function NullableStatusSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.status?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;AAC1E,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO,EAChB,MAAM,QACN,CAAC,EACF,CAAC,EAEFA,QAAE,WAAW,MAAM,EAAE,OAAO,KAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DF,SAAgB,qBACf,QACC;AACD,QAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,SACTA,QAAE,OAAO,EACR,MAAM,QACN,CAAC,CACF,EACD,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,KAAK,CAC1C"}
1
+ {"version":3,"file":"status.cjs","names":["v"],"sources":["../src/status.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `status` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\"\n * ```\n */\nexport function StatusSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.status.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `status` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\" | null\n * ```\n */\nexport function NullableStatusSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.status?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;CAC1E,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,OAAO,EAChB,MAAM,OACP,CAAC,EACF,CAAC,GAEDA,QAAE,WAAW,MAAM,EAAE,OAAO,IAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBACf,QACC;CACD,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,QAAQA,QAAE,SACTA,QAAE,OAAO,EACR,MAAM,OACP,CAAC,CACF,EACD,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,IAAI,CAC1C;AACD"}
package/dist/status.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as v from "valibot";
2
-
3
2
  //#region src/status.ts
4
3
  /**
5
4
  * Schema factory to extract the `status` property from a Notion page property.
@@ -127,7 +126,7 @@ function StatusSchema(schema) {
127
126
  function NullableStatusSchema(schema) {
128
127
  return v.pipe(v.object({ status: v.nullable(v.object({ name: schema })) }), v.transform((v) => v.status?.name ?? null));
129
128
  }
130
-
131
129
  //#endregion
132
130
  export { NullableStatusSchema, StatusSchema };
131
+
133
132
  //# sourceMappingURL=status.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.mjs","names":[],"sources":["../src/status.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `status` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\"\n * ```\n */\nexport function StatusSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.status.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `status` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\" | null\n * ```\n */\nexport function NullableStatusSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.status?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;AAC1E,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO,EAChB,MAAM,QACN,CAAC,EACF,CAAC,EAEF,EAAE,WAAW,MAAM,EAAE,OAAO,KAAM,CAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DF,SAAgB,qBACf,QACC;AACD,QAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,SACT,EAAE,OAAO,EACR,MAAM,QACN,CAAC,CACF,EACD,CAAC,EACF,EAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,KAAK,CAC1C"}
1
+ {"version":3,"file":"status.mjs","names":[],"sources":["../src/status.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema factory to extract the `status` property from a Notion page property.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * };\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n * For example, if `v.string()` is passed, the output will be `string`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { StatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: StatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\"\n * ```\n */\nexport function StatusSchema<S extends v.GenericSchema<string>>(schema: S) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.object({\n\t\t\t\tname: schema,\n\t\t\t}),\n\t\t}),\n\t\t// biome-ignore lint/style/noNonNullAssertion: valibot inference is not working correctly\n\t\tv.transform((v) => v.status.name!),\n\t);\n}\n\n/**\n * Schema factory to extract the `status` property from a Notion page property or `null`.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with other schemas in this library to extract\n * typed status values. The status property in Notion contains an object with\n * a `name` field that can be validated using the provided schema, or `null` if not set.\n *\n * **Input:**\n * ```\n * {\n * status: {\n * name: string;\n * } | null;\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter, or `null`.\n * For example, if `v.string()` is passed, the output will be `string | null`.\n *\n * @param schema - A schema that validates the status option name.\n * Must accept a string value.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(v.string()),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: string | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableStatusSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * // Custom schema for enum values\n * const StatusOptionSchema = v.picklist([\"not-started\", \"in-progress\", \"completed\"]);\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Status: NullableStatusSchema(StatusOptionSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Status: \"not-started\" | \"in-progress\" | \"completed\" | null\n * ```\n */\nexport function NullableStatusSchema<S extends v.GenericSchema<string>>(\n\tschema: S,\n) {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tstatus: v.nullable(\n\t\t\t\tv.object({\n\t\t\t\t\tname: schema,\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\tv.transform((v) => v.status?.name ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,aAAgD,QAAW;CAC1E,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,OAAO,EAChB,MAAM,OACP,CAAC,EACF,CAAC,GAED,EAAE,WAAW,MAAM,EAAE,OAAO,IAAK,CAClC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,qBACf,QACC;CACD,OAAO,EAAE,KACR,EAAE,OAAO,EACR,QAAQ,EAAE,SACT,EAAE,OAAO,EACR,MAAM,OACP,CAAC,CACF,EACD,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,QAAQ,QAAQ,IAAI,CAC1C;AACD"}
package/dist/text.cjs CHANGED
@@ -1,7 +1,6 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
2
  let valibot = require("valibot");
3
- valibot = require_runtime.__toESM(valibot);
4
-
3
+ valibot = require_runtime.__toESM(valibot, 1);
5
4
  //#region src/text.ts
6
5
  /**
7
6
  * Schema for a Notion rich text array structure.
@@ -178,10 +177,10 @@ const RichTextSchema = valibot.pipe(valibot.object({ rich_text: RichTextItemArra
178
177
  * ```
179
178
  */
180
179
  const NullableRichTextSchema = valibot.pipe(valibot.object({ rich_text: RichTextItemArraySchema }), valibot.transform((v) => v.rich_text.map((v) => v.plain_text).join("") || null));
181
-
182
180
  //#endregion
183
181
  exports.NullableRichTextSchema = NullableRichTextSchema;
184
182
  exports.NullableTitleSchema = NullableTitleSchema;
185
183
  exports.RichTextSchema = RichTextSchema;
186
184
  exports.TitleSchema = TitleSchema;
185
+
187
186
  //# sourceMappingURL=text.cjs.map