@nakanoaas/notion-valibot-schema 0.3.0 → 0.7.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 (50) hide show
  1. package/README.md +95 -14
  2. package/dist/created-by.cjs +30 -26
  3. package/dist/created-by.cjs.map +1 -1
  4. package/dist/created-by.d.cts +35 -48
  5. package/dist/created-by.d.mts +35 -48
  6. package/dist/created-by.mjs +31 -27
  7. package/dist/created-by.mjs.map +1 -1
  8. package/dist/{file.cjs → files.cjs} +6 -6
  9. package/dist/files.cjs.map +1 -0
  10. package/dist/{file.d.cts → files.d.cts} +6 -6
  11. package/dist/{file.d.mts → files.d.mts} +6 -6
  12. package/dist/{file.mjs → files.mjs} +6 -6
  13. package/dist/files.mjs.map +1 -0
  14. package/dist/formula.cjs +120 -19
  15. package/dist/formula.cjs.map +1 -1
  16. package/dist/formula.d.cts +150 -41
  17. package/dist/formula.d.mts +150 -41
  18. package/dist/formula.mjs +117 -20
  19. package/dist/formula.mjs.map +1 -1
  20. package/dist/index.cjs +17 -4
  21. package/dist/index.d.cts +5 -5
  22. package/dist/index.d.mts +5 -5
  23. package/dist/index.mjs +5 -5
  24. package/dist/last-edited-by.cjs +27 -25
  25. package/dist/last-edited-by.cjs.map +1 -1
  26. package/dist/last-edited-by.d.cts +29 -44
  27. package/dist/last-edited-by.d.mts +29 -44
  28. package/dist/last-edited-by.mjs +28 -26
  29. package/dist/last-edited-by.mjs.map +1 -1
  30. package/dist/people.cjs +320 -38
  31. package/dist/people.cjs.map +1 -1
  32. package/dist/people.d.cts +331 -53
  33. package/dist/people.d.mts +331 -53
  34. package/dist/people.mjs +313 -39
  35. package/dist/people.mjs.map +1 -1
  36. package/dist/rollup.cjs +66 -0
  37. package/dist/rollup.cjs.map +1 -1
  38. package/dist/rollup.d.cts +70 -1
  39. package/dist/rollup.d.mts +70 -1
  40. package/dist/rollup.mjs +66 -1
  41. package/dist/rollup.mjs.map +1 -1
  42. package/dist/verification.cjs +7 -7
  43. package/dist/verification.cjs.map +1 -1
  44. package/dist/verification.d.cts +18 -12
  45. package/dist/verification.d.mts +18 -12
  46. package/dist/verification.mjs +8 -8
  47. package/dist/verification.mjs.map +1 -1
  48. package/package.json +3 -3
  49. package/dist/file.cjs.map +0 -1
  50. package/dist/file.mjs.map +0 -1
package/dist/people.cjs CHANGED
@@ -3,14 +3,15 @@ let valibot = require("valibot");
3
3
  valibot = require_runtime.__toESM(valibot, 1);
4
4
  //#region src/people.ts
5
5
  /**
6
- * Schema for a Notion person object (user, bot, or group).
6
+ * Minimal schema for a Notion user or group ID.
7
+ *
8
+ * Use this when only the `id` field is needed, such as in ID-extraction
9
+ * convenience schemas (`PeopleIdSchema`, `CreatedByIdSchema`, etc.).
7
10
  *
8
11
  * **Input:**
9
12
  * ```
10
13
  * {
11
14
  * id: string;
12
- * object: "user" | "bot" | "group";
13
- * name: string | null;
14
15
  * ...
15
16
  * }
16
17
  * ```
@@ -19,7 +20,32 @@ valibot = require_runtime.__toESM(valibot, 1);
19
20
  * ```
20
21
  * {
21
22
  * id: string;
22
- * object: "user" | "bot" | "group";
23
+ * }
24
+ * ```
25
+ */
26
+ const UserOrGroupIdSchema = valibot.object({ id: valibot.string() });
27
+ /**
28
+ * Schema for a Notion user or group object.
29
+ *
30
+ * Validates `id`, `object` (`"user"` | `"group"`), and `name`.
31
+ * Bots in the Notion API use `object: "user"` with `type: "bot"`, so they
32
+ * are accepted by this schema as well.
33
+ *
34
+ * **Input:**
35
+ * ```
36
+ * {
37
+ * id: string;
38
+ * object: "user" | "group";
39
+ * name?: string | null;
40
+ * ...
41
+ * }
42
+ * ```
43
+ *
44
+ * **Output:**
45
+ * ```
46
+ * {
47
+ * id: string;
48
+ * object: "user" | "group";
23
49
  * name: string | null;
24
50
  * }
25
51
  * ```
@@ -27,75 +53,152 @@ valibot = require_runtime.__toESM(valibot, 1);
27
53
  * @example
28
54
  * ```ts
29
55
  * import * as v from "valibot";
30
- * import { PersonSchema } from "@nakanoaas/notion-valibot-schema";
56
+ * import { PeopleSchema, UserOrGroupSchema } from "@nakanoaas/notion-valibot-schema";
31
57
  *
32
58
  * const PageSchema = v.object({
33
59
  * id: v.string(),
34
- * created_by: PersonSchema,
60
+ * properties: v.object({
61
+ * Assignees: PeopleSchema(UserOrGroupSchema),
62
+ * }),
35
63
  * });
36
64
  *
37
65
  * const page = await notion.pages.retrieve({ page_id: "..." });
38
66
  * const parsed = v.parse(PageSchema, page);
39
- * // parsed.created_by: { id: string; object: "user" | "bot" | "group"; name: string | null }
67
+ * // parsed.properties.Assignees: Array<{ id: string; object: "user" | "group"; name: string | null }>
40
68
  * ```
41
- *
42
- * @internal
43
69
  */
44
- const PersonSchema = valibot.object({
70
+ const UserOrGroupSchema = valibot.object({
45
71
  id: valibot.string(),
46
- object: valibot.picklist([
47
- "user",
48
- "bot",
49
- "group"
50
- ]),
72
+ object: valibot.picklist(["user", "group"]),
51
73
  name: valibot.nullish(valibot.string(), null)
52
74
  });
53
75
  /**
54
- * Schema to extract the `people` array from a Notion property.
76
+ * Schema for a Notion user object.
55
77
  *
56
78
  * **Input:**
57
79
  * ```
58
80
  * {
59
- * people: [
60
- * {
61
- * id: string;
62
- * object: "user" | "bot" | "group";
63
- * name: string | null;
64
- * ...
65
- * }
66
- * ]
81
+ * id: string;
82
+ * object: "user";
83
+ * name?: string | null;
84
+ * avatar_url?: string | null;
85
+ * ...
67
86
  * }
68
87
  * ```
69
88
  *
70
89
  * **Output:**
71
90
  * ```
72
- * [
73
- * {
74
- * id: string;
75
- * object: "user" | "bot" | "group";
76
- * name: string | null;
77
- * }
78
- * ]
91
+ * {
92
+ * id: string;
93
+ * object: "user";
94
+ * name: string | null;
95
+ * avatar_url: string | null;
96
+ * }
97
+ * ```
98
+ */
99
+ const UserSchema = valibot.object({
100
+ id: valibot.string(),
101
+ object: valibot.literal("user"),
102
+ name: valibot.nullish(valibot.string(), null),
103
+ avatar_url: valibot.nullish(valibot.string(), null)
104
+ });
105
+ /**
106
+ * Schema for a Notion person user object.
107
+ *
108
+ * Validates a user with `type: "person"` and the nested `person.email` field.
109
+ * Use with `PeopleSchema`, `SinglePeopleSchema`, or `CreatedBySchema` when
110
+ * full person details are needed.
111
+ *
112
+ * **Input:**
113
+ * ```
114
+ * {
115
+ * id: string;
116
+ * object: "user";
117
+ * name?: string | null;
118
+ * avatar_url?: string | null;
119
+ * type: "person";
120
+ * person: {
121
+ * email?: string;
122
+ * };
123
+ * ...
124
+ * }
125
+ * ```
126
+ *
127
+ * **Output:**
128
+ * ```
129
+ * {
130
+ * id: string;
131
+ * object: "user";
132
+ * name: string | null;
133
+ * avatar_url: string | null;
134
+ * type: "person";
135
+ * person: {
136
+ * email?: string;
137
+ * };
138
+ * }
79
139
  * ```
80
140
  *
81
141
  * @example
82
142
  * ```ts
83
143
  * import * as v from "valibot";
84
- * import { PeopleSchema } from "@nakanoaas/notion-valibot-schema";
144
+ * import { PeopleSchema, PersonSchema } from "@nakanoaas/notion-valibot-schema";
85
145
  *
86
146
  * const PageSchema = v.object({
87
147
  * id: v.string(),
88
148
  * properties: v.object({
89
- * People: PeopleSchema,
149
+ * People: PeopleSchema(PersonSchema),
90
150
  * }),
91
151
  * });
92
152
  *
93
153
  * const page = await notion.pages.retrieve({ page_id: "..." });
94
154
  * const parsed = v.parse(PageSchema, page);
95
- * // parsed.properties.People: Array<{ id: string; object: "user" | "bot" | "group"; name: string | null }>
155
+ * // parsed.properties.People: Array<{ id: string; object: "user"; name: string | null; ... }>
156
+ * ```
157
+ */
158
+ const PersonSchema = valibot.object({
159
+ id: valibot.string(),
160
+ object: valibot.literal("user"),
161
+ name: valibot.nullish(valibot.string(), null),
162
+ avatar_url: valibot.nullish(valibot.string(), null),
163
+ type: valibot.literal("person"),
164
+ person: valibot.object({ email: valibot.optional(valibot.string()) })
165
+ });
166
+ /**
167
+ * Schema for a Notion bot user object.
168
+ *
169
+ * **Input:**
170
+ * ```
171
+ * {
172
+ * id: string;
173
+ * object: "bot";
174
+ * name?: string | null;
175
+ * avatar_url?: string | null;
176
+ * type: "bot";
177
+ * bot: unknown;
178
+ * ...
179
+ * }
180
+ * ```
181
+ *
182
+ * **Output:**
183
+ * ```
184
+ * {
185
+ * id: string;
186
+ * object: "bot";
187
+ * name: string | null;
188
+ * avatar_url: string | null;
189
+ * type: "bot";
190
+ * bot: unknown;
191
+ * }
96
192
  * ```
97
193
  */
98
- const PeopleSchema = valibot.pipe(valibot.object({ people: valibot.array(PersonSchema) }), valibot.transform((v) => v.people));
194
+ const BotSchema = valibot.object({
195
+ id: valibot.string(),
196
+ object: valibot.literal("bot"),
197
+ name: valibot.nullish(valibot.string(), null),
198
+ avatar_url: valibot.nullish(valibot.string(), null),
199
+ type: valibot.literal("bot"),
200
+ bot: valibot.any()
201
+ });
99
202
  /**
100
203
  * Schema to extract the `people` array of IDs from a Notion property.
101
204
  *
@@ -105,8 +208,6 @@ const PeopleSchema = valibot.pipe(valibot.object({ people: valibot.array(PersonS
105
208
  * people: [
106
209
  * {
107
210
  * id: string;
108
- * object: "user" | "bot" | "group";
109
- * name: string | null;
110
211
  * ...
111
212
  * }
112
213
  * ]
@@ -135,10 +236,191 @@ const PeopleSchema = valibot.pipe(valibot.object({ people: valibot.array(PersonS
135
236
  * // parsed.properties.People: [string]
136
237
  * ```
137
238
  */
138
- const PeopleIdSchema = valibot.pipe(valibot.object({ people: valibot.array(PersonSchema) }), valibot.transform((v) => v.people.map((p) => p.id)));
239
+ const PeopleIdSchema = valibot.pipe(valibot.object({ people: valibot.array(UserOrGroupIdSchema) }), valibot.transform((v) => v.people.map((p) => p.id)));
240
+ /**
241
+ * Schema to extract a single person ID from a Notion `people` property.
242
+ *
243
+ * Expects exactly one entry in the `people` array.
244
+ *
245
+ * **Input:**
246
+ * ```
247
+ * {
248
+ * people: [{ id: string; ... }]
249
+ * }
250
+ * ```
251
+ *
252
+ * **Output:** `string`
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * import * as v from "valibot";
257
+ * import { SinglePeopleIdSchema } from "@nakanoaas/notion-valibot-schema";
258
+ *
259
+ * const PageSchema = v.object({
260
+ * id: v.string(),
261
+ * properties: v.object({
262
+ * Owner: SinglePeopleIdSchema,
263
+ * }),
264
+ * });
265
+ *
266
+ * const page = await notion.pages.retrieve({ page_id: "..." });
267
+ * const parsed = v.parse(PageSchema, page);
268
+ * // parsed.properties.Owner: string
269
+ * ```
270
+ */
271
+ const SinglePeopleIdSchema = valibot.pipe(valibot.object({ people: valibot.tuple([UserOrGroupIdSchema]) }), valibot.transform((v) => v.people[0].id));
272
+ /**
273
+ * Schema to extract a single person ID or `null` from a Notion `people` property.
274
+ *
275
+ * Returns the first entry's ID, or `null` when the array is empty.
276
+ *
277
+ * **Input:**
278
+ * ```
279
+ * {
280
+ * people: Array<{ id: string; ... }>
281
+ * }
282
+ * ```
283
+ *
284
+ * **Output:** `string | null`
285
+ *
286
+ * @example
287
+ * ```ts
288
+ * import * as v from "valibot";
289
+ * import { NullableSinglePeopleIdSchema } from "@nakanoaas/notion-valibot-schema";
290
+ *
291
+ * const PageSchema = v.object({
292
+ * id: v.string(),
293
+ * properties: v.object({
294
+ * Owner: NullableSinglePeopleIdSchema,
295
+ * }),
296
+ * });
297
+ *
298
+ * const page = await notion.pages.retrieve({ page_id: "..." });
299
+ * const parsed = v.parse(PageSchema, page);
300
+ * // parsed.properties.Owner: string | null
301
+ * ```
302
+ */
303
+ const NullableSinglePeopleIdSchema = valibot.pipe(valibot.object({ people: valibot.array(UserOrGroupIdSchema) }), valibot.transform((v) => v.people[0]?.id ?? null));
304
+ /**
305
+ * Schema factory to extract the `people` array from a Notion property.
306
+ *
307
+ * **Input:**
308
+ * ```
309
+ * {
310
+ * people: Array<InferredInput<schema>>
311
+ * }
312
+ * ```
313
+ *
314
+ * **Output:** `InferredOutput<schema>[]`
315
+ *
316
+ * @param schema - A schema that validates each person object in the `people` array.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * import * as v from "valibot";
321
+ * import { PeopleSchema, PersonSchema } from "@nakanoaas/notion-valibot-schema";
322
+ *
323
+ * const PageSchema = v.object({
324
+ * id: v.string(),
325
+ * properties: v.object({
326
+ * People: PeopleSchema(PersonSchema),
327
+ * }),
328
+ * });
329
+ *
330
+ * const page = await notion.pages.retrieve({ page_id: "..." });
331
+ * const parsed = v.parse(PageSchema, page);
332
+ * // parsed.properties.People: InferredOutput<typeof PersonSchema>[]
333
+ * ```
334
+ */
335
+ function PeopleSchema(schema) {
336
+ return valibot.pipe(valibot.object({ people: valibot.array(schema) }), valibot.transform((v) => v.people));
337
+ }
338
+ /**
339
+ * Schema factory to extract a single person from a Notion `people` property.
340
+ *
341
+ * Expects exactly one entry in the `people` array.
342
+ *
343
+ * **Input:**
344
+ * ```
345
+ * {
346
+ * people: [InferredInput<schema>]
347
+ * }
348
+ * ```
349
+ *
350
+ * **Output:** `InferredOutput<schema>`
351
+ *
352
+ * @param schema - A schema that validates the person object in the `people` array.
353
+ *
354
+ * @example
355
+ * ```ts
356
+ * import * as v from "valibot";
357
+ * import { PersonSchema, SinglePeopleSchema } from "@nakanoaas/notion-valibot-schema";
358
+ *
359
+ * const PageSchema = v.object({
360
+ * id: v.string(),
361
+ * properties: v.object({
362
+ * Owner: SinglePeopleSchema(PersonSchema),
363
+ * }),
364
+ * });
365
+ *
366
+ * const page = await notion.pages.retrieve({ page_id: "..." });
367
+ * const parsed = v.parse(PageSchema, page);
368
+ * // parsed.properties.Owner: InferredOutput<typeof PersonSchema>
369
+ * ```
370
+ */
371
+ function SinglePeopleSchema(schema) {
372
+ return valibot.pipe(valibot.object({ people: valibot.tuple([schema]) }), valibot.transform((v) => v.people[0]));
373
+ }
374
+ /**
375
+ * Schema factory to extract a single person or `null` from a Notion `people` property.
376
+ *
377
+ * Returns the first entry, or `null` when the array is empty.
378
+ *
379
+ * **Input:**
380
+ * ```
381
+ * {
382
+ * people: Array<InferredInput<schema>>
383
+ * }
384
+ * ```
385
+ *
386
+ * **Output:** `InferredOutput<schema> | null`
387
+ *
388
+ * @param schema - A schema that validates each person object in the `people` array.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * import * as v from "valibot";
393
+ * import {
394
+ * NullableSinglePeopleSchema,
395
+ * UserOrGroupSchema,
396
+ * } from "@nakanoaas/notion-valibot-schema";
397
+ *
398
+ * const PageSchema = v.object({
399
+ * id: v.string(),
400
+ * properties: v.object({
401
+ * Owner: NullableSinglePeopleSchema(UserOrGroupSchema),
402
+ * }),
403
+ * });
404
+ *
405
+ * const page = await notion.pages.retrieve({ page_id: "..." });
406
+ * const parsed = v.parse(PageSchema, page);
407
+ * // parsed.properties.Owner: { id: string; object: "user" | "group"; name: string | null } | null
408
+ * ```
409
+ */
410
+ function NullableSinglePeopleSchema(schema) {
411
+ return valibot.pipe(valibot.object({ people: valibot.array(schema) }), valibot.transform((v) => v.people[0] ?? null));
412
+ }
139
413
  //#endregion
414
+ exports.BotSchema = BotSchema;
415
+ exports.NullableSinglePeopleIdSchema = NullableSinglePeopleIdSchema;
416
+ exports.NullableSinglePeopleSchema = NullableSinglePeopleSchema;
140
417
  exports.PeopleIdSchema = PeopleIdSchema;
141
418
  exports.PeopleSchema = PeopleSchema;
142
419
  exports.PersonSchema = PersonSchema;
420
+ exports.SinglePeopleIdSchema = SinglePeopleIdSchema;
421
+ exports.SinglePeopleSchema = SinglePeopleSchema;
422
+ exports.UserOrGroupIdSchema = UserOrGroupIdSchema;
423
+ exports.UserOrGroupSchema = UserOrGroupSchema;
424
+ exports.UserSchema = UserSchema;
143
425
 
144
426
  //# sourceMappingURL=people.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"people.cjs","names":["v"],"sources":["../src/people.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion person object (user, bot, or group).\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PersonSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * created_by: PersonSchema,\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.created_by: { id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }\n * ```\n *\n * @internal\n */\nexport const PersonSchema = v.object({\n\tid: v.string(),\n\tobject: v.picklist([\"user\", \"bot\", \"group\"]),\n\tname: v.nullish(v.string(), null),\n});\n\n/**\n * Schema to extract the `people` array from a Notion property.\n *\n * **Input:**\n * ```\n * {\n * people: [\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * ]\n * }\n * ```\n *\n * **Output:**\n * ```\n * [\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * People: PeopleSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.People: Array<{ id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }>\n * ```\n */\nexport const PeopleSchema = v.pipe(\n\tv.object({\n\t\tpeople: v.array(PersonSchema),\n\t}),\n\tv.transform((v) => v.people),\n);\n\n/**\n * Schema to extract the `people` array of IDs from a Notion property.\n *\n * **Input:**\n * ```\n * {\n * people: [\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * ]\n * }\n * ```\n *\n * **Output:**\n * ```\n * [string]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * People: PeopleIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.People: [string]\n * ```\n */\nexport const PeopleIdSchema = v.pipe(\n\tv.object({\n\t\tpeople: v.array(PersonSchema),\n\t}),\n\tv.transform((v) => v.people.map((p) => p.id)),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,eAAeA,QAAE,OAAO;CACpC,IAAIA,QAAE,OAAO;CACb,QAAQA,QAAE,SAAS;EAAC;EAAQ;EAAO;CAAO,CAAC;CAC3C,MAAMA,QAAE,QAAQA,QAAE,OAAO,GAAG,IAAI;AACjC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CD,MAAa,eAAeA,QAAE,KAC7BA,QAAE,OAAO,EACR,QAAQA,QAAE,MAAM,YAAY,EAC7B,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,QAAQA,QAAE,MAAM,YAAY,EAC7B,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,OAAO,KAAK,MAAM,EAAE,EAAE,CAAC,CAC7C"}
1
+ {"version":3,"file":"people.cjs","names":["v"],"sources":["../src/people.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Minimal schema for a Notion user or group ID.\n *\n * Use this when only the `id` field is needed, such as in ID-extraction\n * convenience schemas (`PeopleIdSchema`, `CreatedByIdSchema`, etc.).\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * }\n * ```\n */\nexport const UserOrGroupIdSchema = v.object({\n\tid: v.string(),\n});\n\n/**\n * Schema for a Notion user or group object.\n *\n * Validates `id`, `object` (`\"user\"` | `\"group\"`), and `name`.\n * Bots in the Notion API use `object: \"user\"` with `type: \"bot\"`, so they\n * are accepted by this schema as well.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleSchema, UserOrGroupSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Assignees: PeopleSchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Assignees: Array<{ id: string; object: \"user\" | \"group\"; name: string | null }>\n * ```\n */\nexport const UserOrGroupSchema = v.object({\n\tid: v.string(),\n\tobject: v.picklist([\"user\", \"group\"]),\n\tname: v.nullish(v.string(), null),\n});\n\n/**\n * Schema for a Notion user object.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * object: \"user\";\n * name?: string | null;\n * avatar_url?: string | null;\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\";\n * name: string | null;\n * avatar_url: string | null;\n * }\n * ```\n */\nexport const UserSchema = v.object({\n\tid: v.string(),\n\tobject: v.literal(\"user\"),\n\tname: v.nullish(v.string(), null),\n\tavatar_url: v.nullish(v.string(), null),\n});\n\n/**\n * Schema for a Notion person user object.\n *\n * Validates a user with `type: \"person\"` and the nested `person.email` field.\n * Use with `PeopleSchema`, `SinglePeopleSchema`, or `CreatedBySchema` when\n * full person details are needed.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * object: \"user\";\n * name?: string | null;\n * avatar_url?: string | null;\n * type: \"person\";\n * person: {\n * email?: string;\n * };\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\";\n * name: string | null;\n * avatar_url: string | null;\n * type: \"person\";\n * person: {\n * email?: string;\n * };\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleSchema, PersonSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * People: PeopleSchema(PersonSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.People: Array<{ id: string; object: \"user\"; name: string | null; ... }>\n * ```\n */\nexport const PersonSchema = v.object({\n\tid: v.string(),\n\tobject: v.literal(\"user\"),\n\tname: v.nullish(v.string(), null),\n\tavatar_url: v.nullish(v.string(), null),\n\n\ttype: v.literal(\"person\"),\n\tperson: v.object({\n\t\temail: v.optional(v.string()),\n\t}),\n});\n\n/**\n * Schema for a Notion bot user object.\n *\n * **Input:**\n * ```\n * {\n * id: string;\n * object: \"bot\";\n * name?: string | null;\n * avatar_url?: string | null;\n * type: \"bot\";\n * bot: unknown;\n * ...\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"bot\";\n * name: string | null;\n * avatar_url: string | null;\n * type: \"bot\";\n * bot: unknown;\n * }\n * ```\n */\nexport const BotSchema = v.object({\n\tid: v.string(),\n\tobject: v.literal(\"bot\"),\n\tname: v.nullish(v.string(), null),\n\tavatar_url: v.nullish(v.string(), null),\n\n\ttype: v.literal(\"bot\"),\n\tbot: v.any(),\n});\n\n/**\n * Schema to extract the `people` array of IDs from a Notion property.\n *\n * **Input:**\n * ```\n * {\n * people: [\n * {\n * id: string;\n * ...\n * }\n * ]\n * }\n * ```\n *\n * **Output:**\n * ```\n * [string]\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * People: PeopleIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.People: [string]\n * ```\n */\nexport const PeopleIdSchema = v.pipe(\n\tv.object({\n\t\tpeople: v.array(UserOrGroupIdSchema),\n\t}),\n\tv.transform((v) => v.people.map((p) => p.id)),\n);\n\n/**\n * Schema to extract a single person ID from a Notion `people` property.\n *\n * Expects exactly one entry in the `people` array.\n *\n * **Input:**\n * ```\n * {\n * people: [{ id: string; ... }]\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { SinglePeopleIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Owner: SinglePeopleIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Owner: string\n * ```\n */\nexport const SinglePeopleIdSchema = v.pipe(\n\tv.object({\n\t\tpeople: v.tuple([UserOrGroupIdSchema]),\n\t}),\n\tv.transform((v) => v.people[0].id),\n);\n\n/**\n * Schema to extract a single person ID or `null` from a Notion `people` property.\n *\n * Returns the first entry's ID, or `null` when the array is empty.\n *\n * **Input:**\n * ```\n * {\n * people: Array<{ id: string; ... }>\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableSinglePeopleIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Owner: NullableSinglePeopleIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Owner: string | null\n * ```\n */\nexport const NullableSinglePeopleIdSchema = v.pipe(\n\tv.object({\n\t\tpeople: v.array(UserOrGroupIdSchema),\n\t}),\n\tv.transform((v) => v.people[0]?.id ?? null),\n);\n\n/**\n * Schema factory to extract the `people` array from a Notion property.\n *\n * **Input:**\n * ```\n * {\n * people: Array<InferredInput<schema>>\n * }\n * ```\n *\n * **Output:** `InferredOutput<schema>[]`\n *\n * @param schema - A schema that validates each person object in the `people` array.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PeopleSchema, PersonSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * People: PeopleSchema(PersonSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.People: InferredOutput<typeof PersonSchema>[]\n * ```\n */\nexport function PeopleSchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n): v.GenericSchema<{ people: v.InferInput<S>[] }, v.InferOutput<S>[]> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tpeople: v.array(schema),\n\t\t}),\n\t\tv.transform((v) => v.people),\n\t);\n}\n\n/**\n * Schema factory to extract a single person from a Notion `people` property.\n *\n * Expects exactly one entry in the `people` array.\n *\n * **Input:**\n * ```\n * {\n * people: [InferredInput<schema>]\n * }\n * ```\n *\n * **Output:** `InferredOutput<schema>`\n *\n * @param schema - A schema that validates the person object in the `people` array.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PersonSchema, SinglePeopleSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Owner: SinglePeopleSchema(PersonSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Owner: InferredOutput<typeof PersonSchema>\n * ```\n */\nexport function SinglePeopleSchema<S extends v.GenericSchema<object, unknown>>(\n\tschema: S,\n): v.GenericSchema<{ people: [v.InferInput<S>] }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tpeople: v.tuple([schema]),\n\t\t}),\n\t\tv.transform((v) => v.people[0]),\n\t);\n}\n\n/**\n * Schema factory to extract a single person or `null` from a Notion `people` property.\n *\n * Returns the first entry, or `null` when the array is empty.\n *\n * **Input:**\n * ```\n * {\n * people: Array<InferredInput<schema>>\n * }\n * ```\n *\n * **Output:** `InferredOutput<schema> | null`\n *\n * @param schema - A schema that validates each person object in the `people` array.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * NullableSinglePeopleSchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Owner: NullableSinglePeopleSchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Owner: { id: string; object: \"user\" | \"group\"; name: string | null } | null\n * ```\n */\nexport function NullableSinglePeopleSchema<\n\tS extends v.GenericSchema<object, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ people: v.InferInput<S>[] }, v.InferOutput<S> | null> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tpeople: v.array(schema),\n\t\t}),\n\t\tv.transform((v) => v.people[0] ?? null),\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,sBAAsBA,QAAE,OAAO,EAC3C,IAAIA,QAAE,OAAO,EACd,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CD,MAAa,oBAAoBA,QAAE,OAAO;CACzC,IAAIA,QAAE,OAAO;CACb,QAAQA,QAAE,SAAS,CAAC,QAAQ,OAAO,CAAC;CACpC,MAAMA,QAAE,QAAQA,QAAE,OAAO,GAAG,IAAI;AACjC,CAAC;;;;;;;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