@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
@@ -4,47 +4,51 @@ let valibot = require("valibot");
4
4
  valibot = require_runtime.__toESM(valibot, 1);
5
5
  //#region src/last-edited-by.ts
6
6
  /**
7
- * Schema to extract the `last_edited_by` person object from a Notion page.
7
+ * Schema factory to extract the `last_edited_by` person object from a Notion page.
8
+ *
9
+ * This is a generic schema factory that accepts another schema as a parameter,
10
+ * allowing you to combine it with building-block schemas such as
11
+ * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.
8
12
  *
9
13
  * **Input:**
10
14
  * ```
11
15
  * {
12
16
  * last_edited_by: {
13
17
  * id: string;
14
- * object: "user" | "bot" | "group";
15
- * name: string | null;
18
+ * object: "user" | "group";
19
+ * name?: string | null;
16
20
  * ...
17
21
  * }
18
22
  * }
19
23
  * ```
20
24
  *
21
- * **Output:**
22
- * ```
23
- * {
24
- * id: string;
25
- * object: "user" | "bot" | "group";
26
- * name: string | null;
27
- * }
28
- * ```
25
+ * **Output:** The output type depends on the schema passed as a parameter.
26
+ *
27
+ * @param schema - A schema that validates the `last_edited_by` user or group object.
29
28
  *
30
29
  * @example
31
30
  * ```ts
32
31
  * import * as v from "valibot";
33
- * import { LastEditedBySchema } from "@nakanoaas/notion-valibot-schema";
32
+ * import {
33
+ * LastEditedBySchema,
34
+ * UserOrGroupSchema,
35
+ * } from "@nakanoaas/notion-valibot-schema";
34
36
  *
35
37
  * const PageSchema = v.object({
36
38
  * id: v.string(),
37
39
  * properties: v.object({
38
- * LastEditedBy: LastEditedBySchema,
40
+ * "Last Edited By": LastEditedBySchema(UserOrGroupSchema),
39
41
  * }),
40
42
  * });
41
43
  *
42
44
  * const page = await notion.pages.retrieve({ page_id: "..." });
43
45
  * const parsed = v.parse(PageSchema, page);
44
- * // parsed.properties.LastEditedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
46
+ * // parsed.properties["Last Edited By"]: { id: string; object: "user" | "group"; name: string | null }
45
47
  * ```
46
48
  */
47
- const LastEditedBySchema = valibot.pipe(valibot.object({ last_edited_by: require_people.PersonSchema }), valibot.transform((v) => v.last_edited_by));
49
+ function LastEditedBySchema(schema) {
50
+ return valibot.pipe(valibot.object({ last_edited_by: schema }), valibot.transform((v) => v.last_edited_by));
51
+ }
48
52
  /**
49
53
  * Schema to extract the `last_edited_by` person name from a Notion page.
50
54
  *
@@ -53,8 +57,8 @@ const LastEditedBySchema = valibot.pipe(valibot.object({ last_edited_by: require
53
57
  * {
54
58
  * last_edited_by: {
55
59
  * id: string;
56
- * object: "user" | "bot" | "group";
57
- * name: string | null;
60
+ * object: "user" | "group";
61
+ * name?: string | null;
58
62
  * ...
59
63
  * }
60
64
  * }
@@ -70,16 +74,16 @@ const LastEditedBySchema = valibot.pipe(valibot.object({ last_edited_by: require
70
74
  * const PageSchema = v.object({
71
75
  * id: v.string(),
72
76
  * properties: v.object({
73
- * LastEditedByName: NullableLastEditedByNameSchema,
77
+ * "Last Edited By": NullableLastEditedByNameSchema,
74
78
  * }),
75
79
  * });
76
80
  *
77
81
  * const page = await notion.pages.retrieve({ page_id: "..." });
78
82
  * const parsed = v.parse(PageSchema, page);
79
- * // parsed.properties.LastEditedByName: string | null
83
+ * // parsed.properties["Last Edited By"]: string | null
80
84
  * ```
81
85
  */
82
- const NullableLastEditedByNameSchema = valibot.pipe(valibot.object({ last_edited_by: require_people.PersonSchema }), valibot.transform((v) => v.last_edited_by.name));
86
+ const NullableLastEditedByNameSchema = valibot.pipe(valibot.object({ last_edited_by: require_people.UserOrGroupSchema }), valibot.transform((v) => v.last_edited_by.name));
83
87
  /**
84
88
  * Schema to extract the `last_edited_by` person ID from a Notion page.
85
89
  *
@@ -88,8 +92,6 @@ const NullableLastEditedByNameSchema = valibot.pipe(valibot.object({ last_edited
88
92
  * {
89
93
  * last_edited_by: {
90
94
  * id: string;
91
- * object: "user" | "bot" | "group";
92
- * name: string | null;
93
95
  * ...
94
96
  * }
95
97
  * }
@@ -105,16 +107,16 @@ const NullableLastEditedByNameSchema = valibot.pipe(valibot.object({ last_edited
105
107
  * const PageSchema = v.object({
106
108
  * id: v.string(),
107
109
  * properties: v.object({
108
- * LastEditedById: LastEditedByIdSchema,
110
+ * "Last Edited By": LastEditedByIdSchema,
109
111
  * }),
110
112
  * });
111
113
  *
112
114
  * const page = await notion.pages.retrieve({ page_id: "..." });
113
115
  * const parsed = v.parse(PageSchema, page);
114
- * // parsed.properties.LastEditedById: string
116
+ * // parsed.properties["Last Edited By"]: string
115
117
  * ```
116
118
  */
117
- const LastEditedByIdSchema = valibot.pipe(valibot.object({ last_edited_by: require_people.PersonSchema }), valibot.transform((v) => v.last_edited_by.id));
119
+ const LastEditedByIdSchema = valibot.pipe(valibot.object({ last_edited_by: require_people.UserOrGroupIdSchema }), valibot.transform((v) => v.last_edited_by.id));
118
120
  //#endregion
119
121
  exports.LastEditedByIdSchema = LastEditedByIdSchema;
120
122
  exports.LastEditedBySchema = LastEditedBySchema;
@@ -1 +1 @@
1
- {"version":3,"file":"last-edited-by.cjs","names":["v","PersonSchema"],"sources":["../src/last-edited-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\n/**\n * Schema to extract the `last_edited_by` person object from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedBySchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedBy: LastEditedBySchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedBy: { id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }\n * ```\n */\nexport const LastEditedBySchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by),\n);\n\n/**\n * Schema to extract the `last_edited_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableLastEditedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedByName: NullableLastEditedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedByName: string | null\n * ```\n */\nexport const NullableLastEditedByNameSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.name),\n);\n\n/**\n * Schema to extract the `last_edited_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedById: LastEditedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedById: string\n * ```\n */\nexport const LastEditedByIdSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,qBAAqBA,QAAE,KACnCA,QAAE,OAAO,EACR,gBAAgBC,eAAAA,aACjB,CAAC,GACDD,QAAE,WAAW,MAAM,EAAE,cAAc,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,iCAAiCA,QAAE,KAC/CA,QAAE,OAAO,EACR,gBAAgBC,eAAAA,aACjB,CAAC,GACDD,QAAE,WAAW,MAAM,EAAE,eAAe,IAAI,CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,gBAAgBC,eAAAA,aACjB,CAAC,GACDD,QAAE,WAAW,MAAM,EAAE,eAAe,EAAE,CACvC"}
1
+ {"version":3,"file":"last-edited-by.cjs","names":["v","UserOrGroupSchema","UserOrGroupIdSchema"],"sources":["../src/last-edited-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema factory to extract the `last_edited_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @param schema - A schema that validates the `last_edited_by` user or group object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * LastEditedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": LastEditedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function LastEditedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ last_edited_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tlast_edited_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.last_edited_by),\n\t) as v.GenericSchema<{ last_edited_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n\n/**\n * Schema to extract the `last_edited_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableLastEditedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": NullableLastEditedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: string | null\n * ```\n */\nexport const NullableLastEditedByNameSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.name),\n);\n\n/**\n * Schema to extract the `last_edited_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": LastEditedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: string\n * ```\n */\nexport const LastEditedByIdSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,mBAGf,QACyE;CACzE,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,gBAAgB,OACjB,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,cAAc,CACpC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,iCAAiCA,QAAE,KAC/CA,QAAE,OAAO,EACR,gBAAgBC,eAAAA,kBACjB,CAAC,GACDD,QAAE,WAAW,MAAM,EAAE,eAAe,IAAI,CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,gBAAgBE,eAAAA,oBACjB,CAAC,GACDF,QAAE,WAAW,MAAM,EAAE,eAAe,EAAE,CACvC"}
@@ -2,63 +2,54 @@ import * as v from "valibot";
2
2
 
3
3
  //#region src/last-edited-by.d.ts
4
4
  /**
5
- * Schema to extract the `last_edited_by` person object from a Notion page.
5
+ * Schema factory to extract the `last_edited_by` person object from a Notion page.
6
+ *
7
+ * This is a generic schema factory that accepts another schema as a parameter,
8
+ * allowing you to combine it with building-block schemas such as
9
+ * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.
6
10
  *
7
11
  * **Input:**
8
12
  * ```
9
13
  * {
10
14
  * last_edited_by: {
11
15
  * id: string;
12
- * object: "user" | "bot" | "group";
13
- * name: string | null;
16
+ * object: "user" | "group";
17
+ * name?: string | null;
14
18
  * ...
15
19
  * }
16
20
  * }
17
21
  * ```
18
22
  *
19
- * **Output:**
20
- * ```
21
- * {
22
- * id: string;
23
- * object: "user" | "bot" | "group";
24
- * name: string | null;
25
- * }
26
- * ```
23
+ * **Output:** The output type depends on the schema passed as a parameter.
24
+ *
25
+ * @param schema - A schema that validates the `last_edited_by` user or group object.
27
26
  *
28
27
  * @example
29
28
  * ```ts
30
29
  * import * as v from "valibot";
31
- * import { LastEditedBySchema } from "@nakanoaas/notion-valibot-schema";
30
+ * import {
31
+ * LastEditedBySchema,
32
+ * UserOrGroupSchema,
33
+ * } from "@nakanoaas/notion-valibot-schema";
32
34
  *
33
35
  * const PageSchema = v.object({
34
36
  * id: v.string(),
35
37
  * properties: v.object({
36
- * LastEditedBy: LastEditedBySchema,
38
+ * "Last Edited By": LastEditedBySchema(UserOrGroupSchema),
37
39
  * }),
38
40
  * });
39
41
  *
40
42
  * const page = await notion.pages.retrieve({ page_id: "..." });
41
43
  * const parsed = v.parse(PageSchema, page);
42
- * // parsed.properties.LastEditedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * // parsed.properties["Last Edited By"]: { id: string; object: "user" | "group"; name: string | null }
43
45
  * ```
44
46
  */
45
- declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
46
- readonly last_edited_by: v.ObjectSchema<{
47
- readonly id: v.StringSchema<undefined>;
48
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
49
- readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
50
- }, undefined>;
51
- }, undefined>, v.TransformAction<{
52
- last_edited_by: {
53
- id: string;
54
- object: "user" | "bot" | "group";
55
- name: string | null;
56
- };
57
- }, {
47
+ declare function LastEditedBySchema<S extends v.GenericSchema<{
58
48
  id: string;
59
- object: "user" | "bot" | "group";
60
- name: string | null;
61
- }>]>;
49
+ object: "user" | "group";
50
+ }, unknown>>(schema: S): v.GenericSchema<{
51
+ last_edited_by: v.InferInput<S>;
52
+ }, v.InferOutput<S>>;
62
53
  /**
63
54
  * Schema to extract the `last_edited_by` person name from a Notion page.
64
55
  *
@@ -67,8 +58,8 @@ declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
67
58
  * {
68
59
  * last_edited_by: {
69
60
  * id: string;
70
- * object: "user" | "bot" | "group";
71
- * name: string | null;
61
+ * object: "user" | "group";
62
+ * name?: string | null;
72
63
  * ...
73
64
  * }
74
65
  * }
@@ -84,25 +75,25 @@ declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
84
75
  * const PageSchema = v.object({
85
76
  * id: v.string(),
86
77
  * properties: v.object({
87
- * LastEditedByName: NullableLastEditedByNameSchema,
78
+ * "Last Edited By": NullableLastEditedByNameSchema,
88
79
  * }),
89
80
  * });
90
81
  *
91
82
  * const page = await notion.pages.retrieve({ page_id: "..." });
92
83
  * const parsed = v.parse(PageSchema, page);
93
- * // parsed.properties.LastEditedByName: string | null
84
+ * // parsed.properties["Last Edited By"]: string | null
94
85
  * ```
95
86
  */
96
87
  declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
97
88
  readonly last_edited_by: v.ObjectSchema<{
98
89
  readonly id: v.StringSchema<undefined>;
99
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
90
+ readonly object: v.PicklistSchema<["user", "group"], undefined>;
100
91
  readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
101
92
  }, undefined>;
102
93
  }, undefined>, v.TransformAction<{
103
94
  last_edited_by: {
104
95
  id: string;
105
- object: "user" | "bot" | "group";
96
+ object: "user" | "group";
106
97
  name: string | null;
107
98
  };
108
99
  }, string | null>]>;
@@ -114,8 +105,6 @@ declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.Objec
114
105
  * {
115
106
  * last_edited_by: {
116
107
  * id: string;
117
- * object: "user" | "bot" | "group";
118
- * name: string | null;
119
108
  * ...
120
109
  * }
121
110
  * }
@@ -131,26 +120,22 @@ declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.Objec
131
120
  * const PageSchema = v.object({
132
121
  * id: v.string(),
133
122
  * properties: v.object({
134
- * LastEditedById: LastEditedByIdSchema,
123
+ * "Last Edited By": LastEditedByIdSchema,
135
124
  * }),
136
125
  * });
137
126
  *
138
127
  * const page = await notion.pages.retrieve({ page_id: "..." });
139
128
  * const parsed = v.parse(PageSchema, page);
140
- * // parsed.properties.LastEditedById: string
129
+ * // parsed.properties["Last Edited By"]: string
141
130
  * ```
142
131
  */
143
132
  declare const LastEditedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
144
133
  readonly last_edited_by: v.ObjectSchema<{
145
134
  readonly id: v.StringSchema<undefined>;
146
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
147
- readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
148
135
  }, undefined>;
149
136
  }, undefined>, v.TransformAction<{
150
137
  last_edited_by: {
151
138
  id: string;
152
- object: "user" | "bot" | "group";
153
- name: string | null;
154
139
  };
155
140
  }, string>]>;
156
141
  //#endregion
@@ -2,63 +2,54 @@ import * as v from "valibot";
2
2
 
3
3
  //#region src/last-edited-by.d.ts
4
4
  /**
5
- * Schema to extract the `last_edited_by` person object from a Notion page.
5
+ * Schema factory to extract the `last_edited_by` person object from a Notion page.
6
+ *
7
+ * This is a generic schema factory that accepts another schema as a parameter,
8
+ * allowing you to combine it with building-block schemas such as
9
+ * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.
6
10
  *
7
11
  * **Input:**
8
12
  * ```
9
13
  * {
10
14
  * last_edited_by: {
11
15
  * id: string;
12
- * object: "user" | "bot" | "group";
13
- * name: string | null;
16
+ * object: "user" | "group";
17
+ * name?: string | null;
14
18
  * ...
15
19
  * }
16
20
  * }
17
21
  * ```
18
22
  *
19
- * **Output:**
20
- * ```
21
- * {
22
- * id: string;
23
- * object: "user" | "bot" | "group";
24
- * name: string | null;
25
- * }
26
- * ```
23
+ * **Output:** The output type depends on the schema passed as a parameter.
24
+ *
25
+ * @param schema - A schema that validates the `last_edited_by` user or group object.
27
26
  *
28
27
  * @example
29
28
  * ```ts
30
29
  * import * as v from "valibot";
31
- * import { LastEditedBySchema } from "@nakanoaas/notion-valibot-schema";
30
+ * import {
31
+ * LastEditedBySchema,
32
+ * UserOrGroupSchema,
33
+ * } from "@nakanoaas/notion-valibot-schema";
32
34
  *
33
35
  * const PageSchema = v.object({
34
36
  * id: v.string(),
35
37
  * properties: v.object({
36
- * LastEditedBy: LastEditedBySchema,
38
+ * "Last Edited By": LastEditedBySchema(UserOrGroupSchema),
37
39
  * }),
38
40
  * });
39
41
  *
40
42
  * const page = await notion.pages.retrieve({ page_id: "..." });
41
43
  * const parsed = v.parse(PageSchema, page);
42
- * // parsed.properties.LastEditedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * // parsed.properties["Last Edited By"]: { id: string; object: "user" | "group"; name: string | null }
43
45
  * ```
44
46
  */
45
- declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
46
- readonly last_edited_by: v.ObjectSchema<{
47
- readonly id: v.StringSchema<undefined>;
48
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
49
- readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
50
- }, undefined>;
51
- }, undefined>, v.TransformAction<{
52
- last_edited_by: {
53
- id: string;
54
- object: "user" | "bot" | "group";
55
- name: string | null;
56
- };
57
- }, {
47
+ declare function LastEditedBySchema<S extends v.GenericSchema<{
58
48
  id: string;
59
- object: "user" | "bot" | "group";
60
- name: string | null;
61
- }>]>;
49
+ object: "user" | "group";
50
+ }, unknown>>(schema: S): v.GenericSchema<{
51
+ last_edited_by: v.InferInput<S>;
52
+ }, v.InferOutput<S>>;
62
53
  /**
63
54
  * Schema to extract the `last_edited_by` person name from a Notion page.
64
55
  *
@@ -67,8 +58,8 @@ declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
67
58
  * {
68
59
  * last_edited_by: {
69
60
  * id: string;
70
- * object: "user" | "bot" | "group";
71
- * name: string | null;
61
+ * object: "user" | "group";
62
+ * name?: string | null;
72
63
  * ...
73
64
  * }
74
65
  * }
@@ -84,25 +75,25 @@ declare const LastEditedBySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
84
75
  * const PageSchema = v.object({
85
76
  * id: v.string(),
86
77
  * properties: v.object({
87
- * LastEditedByName: NullableLastEditedByNameSchema,
78
+ * "Last Edited By": NullableLastEditedByNameSchema,
88
79
  * }),
89
80
  * });
90
81
  *
91
82
  * const page = await notion.pages.retrieve({ page_id: "..." });
92
83
  * const parsed = v.parse(PageSchema, page);
93
- * // parsed.properties.LastEditedByName: string | null
84
+ * // parsed.properties["Last Edited By"]: string | null
94
85
  * ```
95
86
  */
96
87
  declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
97
88
  readonly last_edited_by: v.ObjectSchema<{
98
89
  readonly id: v.StringSchema<undefined>;
99
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
90
+ readonly object: v.PicklistSchema<["user", "group"], undefined>;
100
91
  readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
101
92
  }, undefined>;
102
93
  }, undefined>, v.TransformAction<{
103
94
  last_edited_by: {
104
95
  id: string;
105
- object: "user" | "bot" | "group";
96
+ object: "user" | "group";
106
97
  name: string | null;
107
98
  };
108
99
  }, string | null>]>;
@@ -114,8 +105,6 @@ declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.Objec
114
105
  * {
115
106
  * last_edited_by: {
116
107
  * id: string;
117
- * object: "user" | "bot" | "group";
118
- * name: string | null;
119
108
  * ...
120
109
  * }
121
110
  * }
@@ -131,26 +120,22 @@ declare const NullableLastEditedByNameSchema: v.SchemaWithPipe<readonly [v.Objec
131
120
  * const PageSchema = v.object({
132
121
  * id: v.string(),
133
122
  * properties: v.object({
134
- * LastEditedById: LastEditedByIdSchema,
123
+ * "Last Edited By": LastEditedByIdSchema,
135
124
  * }),
136
125
  * });
137
126
  *
138
127
  * const page = await notion.pages.retrieve({ page_id: "..." });
139
128
  * const parsed = v.parse(PageSchema, page);
140
- * // parsed.properties.LastEditedById: string
129
+ * // parsed.properties["Last Edited By"]: string
141
130
  * ```
142
131
  */
143
132
  declare const LastEditedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
144
133
  readonly last_edited_by: v.ObjectSchema<{
145
134
  readonly id: v.StringSchema<undefined>;
146
- readonly object: v.PicklistSchema<["user", "bot", "group"], undefined>;
147
- readonly name: v.NullishSchema<v.StringSchema<undefined>, null>;
148
135
  }, undefined>;
149
136
  }, undefined>, v.TransformAction<{
150
137
  last_edited_by: {
151
138
  id: string;
152
- object: "user" | "bot" | "group";
153
- name: string | null;
154
139
  };
155
140
  }, string>]>;
156
141
  //#endregion
@@ -1,48 +1,52 @@
1
- import { PersonSchema } from "./people.mjs";
1
+ import { UserOrGroupIdSchema, UserOrGroupSchema } from "./people.mjs";
2
2
  import * as v from "valibot";
3
3
  //#region src/last-edited-by.ts
4
4
  /**
5
- * Schema to extract the `last_edited_by` person object from a Notion page.
5
+ * Schema factory to extract the `last_edited_by` person object from a Notion page.
6
+ *
7
+ * This is a generic schema factory that accepts another schema as a parameter,
8
+ * allowing you to combine it with building-block schemas such as
9
+ * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.
6
10
  *
7
11
  * **Input:**
8
12
  * ```
9
13
  * {
10
14
  * last_edited_by: {
11
15
  * id: string;
12
- * object: "user" | "bot" | "group";
13
- * name: string | null;
16
+ * object: "user" | "group";
17
+ * name?: string | null;
14
18
  * ...
15
19
  * }
16
20
  * }
17
21
  * ```
18
22
  *
19
- * **Output:**
20
- * ```
21
- * {
22
- * id: string;
23
- * object: "user" | "bot" | "group";
24
- * name: string | null;
25
- * }
26
- * ```
23
+ * **Output:** The output type depends on the schema passed as a parameter.
24
+ *
25
+ * @param schema - A schema that validates the `last_edited_by` user or group object.
27
26
  *
28
27
  * @example
29
28
  * ```ts
30
29
  * import * as v from "valibot";
31
- * import { LastEditedBySchema } from "@nakanoaas/notion-valibot-schema";
30
+ * import {
31
+ * LastEditedBySchema,
32
+ * UserOrGroupSchema,
33
+ * } from "@nakanoaas/notion-valibot-schema";
32
34
  *
33
35
  * const PageSchema = v.object({
34
36
  * id: v.string(),
35
37
  * properties: v.object({
36
- * LastEditedBy: LastEditedBySchema,
38
+ * "Last Edited By": LastEditedBySchema(UserOrGroupSchema),
37
39
  * }),
38
40
  * });
39
41
  *
40
42
  * const page = await notion.pages.retrieve({ page_id: "..." });
41
43
  * const parsed = v.parse(PageSchema, page);
42
- * // parsed.properties.LastEditedBy: { id: string; object: "user" | "bot" | "group"; name: string | null }
44
+ * // parsed.properties["Last Edited By"]: { id: string; object: "user" | "group"; name: string | null }
43
45
  * ```
44
46
  */
45
- const LastEditedBySchema = v.pipe(v.object({ last_edited_by: PersonSchema }), v.transform((v) => v.last_edited_by));
47
+ function LastEditedBySchema(schema) {
48
+ return v.pipe(v.object({ last_edited_by: schema }), v.transform((v) => v.last_edited_by));
49
+ }
46
50
  /**
47
51
  * Schema to extract the `last_edited_by` person name from a Notion page.
48
52
  *
@@ -51,8 +55,8 @@ const LastEditedBySchema = v.pipe(v.object({ last_edited_by: PersonSchema }), v.
51
55
  * {
52
56
  * last_edited_by: {
53
57
  * id: string;
54
- * object: "user" | "bot" | "group";
55
- * name: string | null;
58
+ * object: "user" | "group";
59
+ * name?: string | null;
56
60
  * ...
57
61
  * }
58
62
  * }
@@ -68,16 +72,16 @@ const LastEditedBySchema = v.pipe(v.object({ last_edited_by: PersonSchema }), v.
68
72
  * const PageSchema = v.object({
69
73
  * id: v.string(),
70
74
  * properties: v.object({
71
- * LastEditedByName: NullableLastEditedByNameSchema,
75
+ * "Last Edited By": NullableLastEditedByNameSchema,
72
76
  * }),
73
77
  * });
74
78
  *
75
79
  * const page = await notion.pages.retrieve({ page_id: "..." });
76
80
  * const parsed = v.parse(PageSchema, page);
77
- * // parsed.properties.LastEditedByName: string | null
81
+ * // parsed.properties["Last Edited By"]: string | null
78
82
  * ```
79
83
  */
80
- const NullableLastEditedByNameSchema = v.pipe(v.object({ last_edited_by: PersonSchema }), v.transform((v) => v.last_edited_by.name));
84
+ const NullableLastEditedByNameSchema = v.pipe(v.object({ last_edited_by: UserOrGroupSchema }), v.transform((v) => v.last_edited_by.name));
81
85
  /**
82
86
  * Schema to extract the `last_edited_by` person ID from a Notion page.
83
87
  *
@@ -86,8 +90,6 @@ const NullableLastEditedByNameSchema = v.pipe(v.object({ last_edited_by: PersonS
86
90
  * {
87
91
  * last_edited_by: {
88
92
  * id: string;
89
- * object: "user" | "bot" | "group";
90
- * name: string | null;
91
93
  * ...
92
94
  * }
93
95
  * }
@@ -103,16 +105,16 @@ const NullableLastEditedByNameSchema = v.pipe(v.object({ last_edited_by: PersonS
103
105
  * const PageSchema = v.object({
104
106
  * id: v.string(),
105
107
  * properties: v.object({
106
- * LastEditedById: LastEditedByIdSchema,
108
+ * "Last Edited By": LastEditedByIdSchema,
107
109
  * }),
108
110
  * });
109
111
  *
110
112
  * const page = await notion.pages.retrieve({ page_id: "..." });
111
113
  * const parsed = v.parse(PageSchema, page);
112
- * // parsed.properties.LastEditedById: string
114
+ * // parsed.properties["Last Edited By"]: string
113
115
  * ```
114
116
  */
115
- const LastEditedByIdSchema = v.pipe(v.object({ last_edited_by: PersonSchema }), v.transform((v) => v.last_edited_by.id));
117
+ const LastEditedByIdSchema = v.pipe(v.object({ last_edited_by: UserOrGroupIdSchema }), v.transform((v) => v.last_edited_by.id));
116
118
  //#endregion
117
119
  export { LastEditedByIdSchema, LastEditedBySchema, NullableLastEditedByNameSchema };
118
120
 
@@ -1 +1 @@
1
- {"version":3,"file":"last-edited-by.mjs","names":[],"sources":["../src/last-edited-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { PersonSchema } from \"./people\";\n\n/**\n * Schema to extract the `last_edited_by` person object from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedBySchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedBy: LastEditedBySchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedBy: { id: string; object: \"user\" | \"bot\" | \"group\"; name: string | null }\n * ```\n */\nexport const LastEditedBySchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by),\n);\n\n/**\n * Schema to extract the `last_edited_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableLastEditedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedByName: NullableLastEditedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedByName: string | null\n * ```\n */\nexport const NullableLastEditedByNameSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.name),\n);\n\n/**\n * Schema to extract the `last_edited_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"bot\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * LastEditedById: LastEditedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.LastEditedById: string\n * ```\n */\nexport const LastEditedByIdSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: PersonSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,qBAAqB,EAAE,KACnC,EAAE,OAAO,EACR,gBAAgB,aACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,cAAc,CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,iCAAiC,EAAE,KAC/C,EAAE,OAAO,EACR,gBAAgB,aACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,eAAe,IAAI,CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,gBAAgB,aACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,CACvC"}
1
+ {"version":3,"file":"last-edited-by.mjs","names":[],"sources":["../src/last-edited-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema factory to extract the `last_edited_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @param schema - A schema that validates the `last_edited_by` user or group object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * LastEditedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": LastEditedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function LastEditedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ last_edited_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tlast_edited_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.last_edited_by),\n\t) as v.GenericSchema<{ last_edited_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n\n/**\n * Schema to extract the `last_edited_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableLastEditedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": NullableLastEditedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: string | null\n * ```\n */\nexport const NullableLastEditedByNameSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.name),\n);\n\n/**\n * Schema to extract the `last_edited_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * last_edited_by: {\n * id: string;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { LastEditedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Last Edited By\": LastEditedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Last Edited By\"]: string\n * ```\n */\nexport const LastEditedByIdSchema = v.pipe(\n\tv.object({\n\t\tlast_edited_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.last_edited_by.id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,mBAGf,QACyE;CACzE,OAAO,EAAE,KACR,EAAE,OAAO,EACR,gBAAgB,OACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,cAAc,CACpC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,iCAAiC,EAAE,KAC/C,EAAE,OAAO,EACR,gBAAgB,kBACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,eAAe,IAAI,CACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,gBAAgB,oBACjB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,CACvC"}