@nakanoaas/notion-valibot-schema 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkbox.cjs +29 -0
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +30 -0
- package/dist/checkbox.d.mts +30 -0
- package/dist/checkbox.mjs +29 -0
- package/dist/checkbox.mjs.map +1 -1
- package/dist/created-by.cjs +75 -0
- package/dist/created-by.cjs.map +1 -1
- package/dist/created-by.d.cts +76 -0
- package/dist/created-by.d.mts +76 -0
- package/dist/created-by.mjs +75 -0
- package/dist/created-by.mjs.map +1 -1
- package/dist/created-time.cjs +27 -0
- package/dist/created-time.cjs.map +1 -1
- package/dist/created-time.d.cts +28 -0
- package/dist/created-time.d.mts +28 -0
- package/dist/created-time.mjs +27 -0
- package/dist/created-time.mjs.map +1 -1
- package/dist/date.cjs +188 -0
- package/dist/date.cjs.map +1 -1
- package/dist/date.d.cts +189 -0
- package/dist/date.d.mts +189 -0
- package/dist/date.mjs +188 -0
- package/dist/date.mjs.map +1 -1
- package/dist/email.cjs +58 -0
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +59 -0
- package/dist/email.d.mts +59 -0
- package/dist/email.mjs +58 -0
- package/dist/email.mjs.map +1 -1
- package/dist/files.cjs +39 -0
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.cts +40 -0
- package/dist/files.d.mts +40 -0
- package/dist/files.mjs +39 -0
- package/dist/files.mjs.map +1 -1
- package/dist/formula.cjs +72 -0
- package/dist/formula.cjs.map +1 -1
- package/dist/formula.d.cts +73 -0
- package/dist/formula.d.mts +73 -0
- package/dist/formula.mjs +72 -0
- package/dist/formula.mjs.map +1 -1
- package/dist/last-edited-by.cjs +68 -0
- package/dist/last-edited-by.cjs.map +1 -1
- package/dist/last-edited-by.d.cts +69 -0
- package/dist/last-edited-by.d.mts +69 -0
- package/dist/last-edited-by.mjs +68 -0
- package/dist/last-edited-by.mjs.map +1 -1
- package/dist/last-edited-time.cjs +27 -0
- package/dist/last-edited-time.cjs.map +1 -1
- package/dist/last-edited-time.d.cts +28 -0
- package/dist/last-edited-time.d.mts +28 -0
- package/dist/last-edited-time.mjs +27 -0
- package/dist/last-edited-time.mjs.map +1 -1
- package/dist/multi-select.cjs +60 -0
- package/dist/multi-select.cjs.map +1 -1
- package/dist/multi-select.d.cts +61 -0
- package/dist/multi-select.d.mts +61 -0
- package/dist/multi-select.mjs +60 -0
- package/dist/multi-select.mjs.map +1 -1
- package/dist/number.cjs +58 -0
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.cts +59 -0
- package/dist/number.d.mts +59 -0
- package/dist/number.mjs +58 -0
- package/dist/number.mjs.map +1 -1
- package/dist/people.cjs +84 -0
- package/dist/people.cjs.map +1 -1
- package/dist/people.d.cts +85 -0
- package/dist/people.d.mts +85 -0
- package/dist/people.mjs +84 -0
- package/dist/people.mjs.map +1 -1
- package/dist/phone-number.cjs +58 -0
- package/dist/phone-number.cjs.map +1 -1
- package/dist/phone-number.d.cts +59 -0
- package/dist/phone-number.d.mts +59 -0
- package/dist/phone-number.mjs +58 -0
- package/dist/phone-number.mjs.map +1 -1
- package/dist/place.cjs +128 -0
- package/dist/place.cjs.map +1 -1
- package/dist/place.d.cts +85 -0
- package/dist/place.d.mts +85 -0
- package/dist/place.mjs +128 -0
- package/dist/place.mjs.map +1 -1
- package/dist/relation.cjs +131 -0
- package/dist/relation.cjs.map +1 -1
- package/dist/relation.d.cts +94 -0
- package/dist/relation.d.mts +94 -0
- package/dist/relation.mjs +131 -0
- package/dist/relation.mjs.map +1 -1
- package/dist/rollup.cjs +200 -0
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +201 -0
- package/dist/rollup.d.mts +201 -0
- package/dist/rollup.mjs +200 -0
- package/dist/rollup.mjs.map +1 -1
- package/dist/select.cjs +120 -0
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +121 -0
- package/dist/select.d.mts +121 -0
- package/dist/select.mjs +120 -0
- package/dist/select.mjs.map +1 -1
- package/dist/status.cjs +120 -0
- package/dist/status.cjs.map +1 -1
- package/dist/status.d.cts +121 -0
- package/dist/status.d.mts +121 -0
- package/dist/status.mjs +120 -0
- package/dist/status.mjs.map +1 -1
- package/dist/text.cjs +100 -0
- package/dist/text.cjs.map +1 -1
- package/dist/text.d.cts +63 -0
- package/dist/text.d.mts +63 -0
- package/dist/text.mjs +100 -0
- package/dist/text.mjs.map +1 -1
- package/dist/unique-id.cjs +69 -0
- package/dist/unique-id.cjs.map +1 -1
- package/dist/unique-id.d.cts +70 -0
- package/dist/unique-id.d.mts +70 -0
- package/dist/unique-id.mjs +69 -0
- package/dist/unique-id.mjs.map +1 -1
- package/dist/url.cjs +58 -0
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.cts +59 -0
- package/dist/url.d.mts +59 -0
- package/dist/url.mjs +58 -0
- package/dist/url.mjs.map +1 -1
- package/dist/verification.cjs +80 -0
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.d.cts +81 -0
- package/dist/verification.d.mts +81 -0
- package/dist/verification.mjs +80 -0
- package/dist/verification.mjs.map +1 -1
- package/package.json +1 -1
package/dist/date.cjs
CHANGED
|
@@ -3,18 +3,206 @@ let valibot = require("valibot");
|
|
|
3
3
|
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
4
4
|
|
|
5
5
|
//#region src/date.ts
|
|
6
|
+
/**
|
|
7
|
+
* Schema for a Notion date object structure.
|
|
8
|
+
*
|
|
9
|
+
* **Input:**
|
|
10
|
+
* ```
|
|
11
|
+
* {
|
|
12
|
+
* start: string;
|
|
13
|
+
* end: string | null;
|
|
14
|
+
* time_zone: string | null;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* **Output:**
|
|
19
|
+
* ```
|
|
20
|
+
* {
|
|
21
|
+
* start: string;
|
|
22
|
+
* end: string | null;
|
|
23
|
+
* time_zone: string | null;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import * as v from "valibot";
|
|
30
|
+
* import { DateObjectSchema } from "@nakanoaas/notion-valibot-utils";
|
|
31
|
+
*
|
|
32
|
+
* const PageSchema = v.object({
|
|
33
|
+
* id: v.string(),
|
|
34
|
+
* properties: v.object({
|
|
35
|
+
* Date: v.object({
|
|
36
|
+
* date: DateObjectSchema,
|
|
37
|
+
* }),
|
|
38
|
+
* }),
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
42
|
+
* const parsed = v.parse(PageSchema, page);
|
|
43
|
+
* // parsed.properties.Date.date: { start: string; end: string | null; time_zone: string | null }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
6
48
|
const DateObjectSchema = valibot.object({
|
|
7
49
|
start: valibot.string(),
|
|
8
50
|
end: valibot.nullable(valibot.string()),
|
|
9
51
|
time_zone: valibot.nullable(valibot.string())
|
|
10
52
|
});
|
|
53
|
+
/**
|
|
54
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object.
|
|
55
|
+
*
|
|
56
|
+
* **Input:**
|
|
57
|
+
* ```
|
|
58
|
+
* {
|
|
59
|
+
* date: {
|
|
60
|
+
* start: string;
|
|
61
|
+
* end: string | null;
|
|
62
|
+
* time_zone: string | null;
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* **Output:** `Date`
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import * as v from "valibot";
|
|
72
|
+
* import { DateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
73
|
+
*
|
|
74
|
+
* const PageSchema = v.object({
|
|
75
|
+
* id: v.string(),
|
|
76
|
+
* properties: v.object({
|
|
77
|
+
* Date: DateSchema,
|
|
78
|
+
* }),
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
82
|
+
* const parsed = v.parse(PageSchema, page);
|
|
83
|
+
* // parsed.properties.Date: Date
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
11
86
|
const DateSchema = valibot.pipe(valibot.object({ date: DateObjectSchema }), valibot.transform((v) => new Date(v.date.start)));
|
|
87
|
+
/**
|
|
88
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object or `null`.
|
|
89
|
+
*
|
|
90
|
+
* **Input:**
|
|
91
|
+
* ```
|
|
92
|
+
* {
|
|
93
|
+
* date: {
|
|
94
|
+
* start: string;
|
|
95
|
+
* end: string | null;
|
|
96
|
+
* time_zone: string | null;
|
|
97
|
+
* } | null
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* **Output:** `Date | null`
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import * as v from "valibot";
|
|
106
|
+
* import { NullableDateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
107
|
+
*
|
|
108
|
+
* const PageSchema = v.object({
|
|
109
|
+
* id: v.string(),
|
|
110
|
+
* properties: v.object({
|
|
111
|
+
* Date: NullableDateSchema,
|
|
112
|
+
* }),
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
116
|
+
* const parsed = v.parse(PageSchema, page);
|
|
117
|
+
* // parsed.properties.Date: Date | null
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
12
120
|
const NullableDateSchema = valibot.pipe(valibot.object({ date: valibot.nullable(DateObjectSchema) }), valibot.transform((v) => v.date?.start ? new Date(v.date.start) : null));
|
|
121
|
+
/**
|
|
122
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object.
|
|
123
|
+
*
|
|
124
|
+
* **Input:**
|
|
125
|
+
* ```
|
|
126
|
+
* {
|
|
127
|
+
* date: {
|
|
128
|
+
* start: string;
|
|
129
|
+
* end: string | null;
|
|
130
|
+
* time_zone: string | null;
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* **Output:**
|
|
136
|
+
* ```
|
|
137
|
+
* {
|
|
138
|
+
* start: Date;
|
|
139
|
+
* end: Date | null;
|
|
140
|
+
* time_zone: string | null;
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import * as v from "valibot";
|
|
147
|
+
* import { DateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
148
|
+
*
|
|
149
|
+
* const PageSchema = v.object({
|
|
150
|
+
* id: v.string(),
|
|
151
|
+
* properties: v.object({
|
|
152
|
+
* DateRange: DateRangeSchema,
|
|
153
|
+
* }),
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
157
|
+
* const parsed = v.parse(PageSchema, page);
|
|
158
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
13
161
|
const DateRangeSchema = valibot.pipe(valibot.object({ date: DateObjectSchema }), valibot.transform((v) => ({
|
|
14
162
|
start: new Date(v.date.start),
|
|
15
163
|
end: v.date.end ? new Date(v.date.end) : null,
|
|
16
164
|
time_zone: v.date.time_zone
|
|
17
165
|
})));
|
|
166
|
+
/**
|
|
167
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object or `null`.
|
|
168
|
+
*
|
|
169
|
+
* **Input:**
|
|
170
|
+
* ```
|
|
171
|
+
* {
|
|
172
|
+
* date: {
|
|
173
|
+
* start: string;
|
|
174
|
+
* end: string | null;
|
|
175
|
+
* time_zone: string | null;
|
|
176
|
+
* } | null
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* **Output:**
|
|
181
|
+
* ```
|
|
182
|
+
* {
|
|
183
|
+
* start: Date;
|
|
184
|
+
* end: Date | null;
|
|
185
|
+
* time_zone: string | null;
|
|
186
|
+
* } | null
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* import * as v from "valibot";
|
|
192
|
+
* import { NullableDateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
193
|
+
*
|
|
194
|
+
* const PageSchema = v.object({
|
|
195
|
+
* id: v.string(),
|
|
196
|
+
* properties: v.object({
|
|
197
|
+
* DateRange: NullableDateRangeSchema,
|
|
198
|
+
* }),
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
202
|
+
* const parsed = v.parse(PageSchema, page);
|
|
203
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null } | null
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
18
206
|
const NullableDateRangeSchema = valibot.pipe(valibot.object({ date: valibot.nullable(DateObjectSchema) }), valibot.transform((v) => v.date ? {
|
|
19
207
|
start: new Date(v.date.start),
|
|
20
208
|
end: v.date.end ? new Date(v.date.end) : null,
|
package/dist/date.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.cjs","names":["v"],"sources":["../src/date.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const DateObjectSchema = v.object({\n\tstart: v.string(),\n\tend: v.nullable(v.string()),\n\ttime_zone: v.nullable(v.string()),\n});\n\nexport const DateSchema = v.pipe(\n\tv.object({\n\t\tdate: DateObjectSchema,\n\t}),\n\tv.transform((v) => new Date(v.date.start)),\n);\n\nexport const NullableDateSchema = v.pipe(\n\tv.object({\n\t\tdate: v.nullable(DateObjectSchema),\n\t}),\n\tv.transform((v) => (v.date?.start ? new Date(v.date.start) : null)),\n);\n\nexport const DateRangeSchema = v.pipe(\n\tv.object({\n\t\tdate: DateObjectSchema,\n\t}),\n\tv.transform((v) => ({\n\t\tstart: new Date(v.date.start),\n\t\tend: v.date.end ? new Date(v.date.end) : null,\n\t\ttime_zone: v.date.time_zone,\n\t})),\n);\n\nexport const NullableDateRangeSchema = v.pipe(\n\tv.object({\n\t\tdate: v.nullable(DateObjectSchema),\n\t}),\n\tv.transform((v) =>\n\t\tv.date\n\t\t\t? {\n\t\t\t\t\tstart: new Date(v.date.start),\n\t\t\t\t\tend: v.date.end ? new Date(v.date.end) : null,\n\t\t\t\t\ttime_zone: v.date.time_zone,\n\t\t\t\t}\n\t\t\t: null,\n\t),\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.cjs","names":["v"],"sources":["../src/date.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema for a Notion date object structure.\n *\n * **Input:**\n * ```\n * {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { DateObjectSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Date: v.object({\n * date: DateObjectSchema,\n * }),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Date.date: { start: string; end: string | null; time_zone: string | null }\n * ```\n *\n * @internal\n */\nexport const DateObjectSchema = v.object({\n\tstart: v.string(),\n\tend: v.nullable(v.string()),\n\ttime_zone: v.nullable(v.string()),\n});\n\n/**\n * Schema to extract the `date` property from a Notion page property and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * }\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { DateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Date: DateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Date: Date\n * ```\n */\nexport const DateSchema = v.pipe(\n\tv.object({\n\t\tdate: DateObjectSchema,\n\t}),\n\tv.transform((v) => new Date(v.date.start)),\n);\n\n/**\n * Schema to extract the `date` property from a Notion page property and transform it to a `Date` object or `null`.\n *\n * **Input:**\n * ```\n * {\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null\n * }\n * ```\n *\n * **Output:** `Date | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableDateSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Date: NullableDateSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Date: Date | null\n * ```\n */\nexport const NullableDateSchema = v.pipe(\n\tv.object({\n\t\tdate: v.nullable(DateObjectSchema),\n\t}),\n\tv.transform((v) => (v.date?.start ? new Date(v.date.start) : null)),\n);\n\n/**\n * Schema to extract the `date` property from a Notion page property and transform it to a date range object.\n *\n * **Input:**\n * ```\n * {\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * }\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * start: Date;\n * end: Date | null;\n * time_zone: string | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { DateRangeSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * DateRange: DateRangeSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null }\n * ```\n */\nexport const DateRangeSchema = v.pipe(\n\tv.object({\n\t\tdate: DateObjectSchema,\n\t}),\n\tv.transform((v) => ({\n\t\tstart: new Date(v.date.start),\n\t\tend: v.date.end ? new Date(v.date.end) : null,\n\t\ttime_zone: v.date.time_zone,\n\t})),\n);\n\n/**\n * Schema to extract the `date` property from a Notion page property and transform it to a date range object or `null`.\n *\n * **Input:**\n * ```\n * {\n * date: {\n * start: string;\n * end: string | null;\n * time_zone: string | null;\n * } | null\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * start: Date;\n * end: Date | null;\n * time_zone: string | null;\n * } | null\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableDateRangeSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * DateRange: NullableDateRangeSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null } | null\n * ```\n */\nexport const NullableDateRangeSchema = v.pipe(\n\tv.object({\n\t\tdate: v.nullable(DateObjectSchema),\n\t}),\n\tv.transform((v) =>\n\t\tv.date\n\t\t\t? {\n\t\t\t\t\tstart: new Date(v.date.start),\n\t\t\t\t\tend: v.date.end ? new Date(v.date.end) : null,\n\t\t\t\t\ttime_zone: v.date.time_zone,\n\t\t\t\t}\n\t\t\t: null,\n\t),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,mBAAmBA,QAAE,OAAO;CACxC,OAAOA,QAAE,QAAQ;CACjB,KAAKA,QAAE,SAASA,QAAE,QAAQ,CAAC;CAC3B,WAAWA,QAAE,SAASA,QAAE,QAAQ,CAAC;CACjC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCF,MAAa,aAAaA,QAAE,KAC3BA,QAAE,OAAO,EACR,MAAM,kBACN,CAAC,EACFA,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,KAAK,MAAM,CAAC,CAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,MAAa,qBAAqBA,QAAE,KACnCA,QAAE,OAAO,EACR,MAAMA,QAAE,SAAS,iBAAiB,EAClC,CAAC,EACFA,QAAE,WAAW,MAAO,EAAE,MAAM,QAAQ,IAAI,KAAK,EAAE,KAAK,MAAM,GAAG,KAAM,CACnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CD,MAAa,kBAAkBA,QAAE,KAChCA,QAAE,OAAO,EACR,MAAM,kBACN,CAAC,EACFA,QAAE,WAAW,OAAO;CACnB,OAAO,IAAI,KAAK,EAAE,KAAK,MAAM;CAC7B,KAAK,EAAE,KAAK,MAAM,IAAI,KAAK,EAAE,KAAK,IAAI,GAAG;CACzC,WAAW,EAAE,KAAK;CAClB,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CD,MAAa,0BAA0BA,QAAE,KACxCA,QAAE,OAAO,EACR,MAAMA,QAAE,SAAS,iBAAiB,EAClC,CAAC,EACFA,QAAE,WAAW,MACZ,EAAE,OACC;CACA,OAAO,IAAI,KAAK,EAAE,KAAK,MAAM;CAC7B,KAAK,EAAE,KAAK,MAAM,IAAI,KAAK,EAAE,KAAK,IAAI,GAAG;CACzC,WAAW,EAAE,KAAK;CAClB,GACA,KACH,CACD"}
|
package/dist/date.d.cts
CHANGED
|
@@ -1,11 +1,87 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/date.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for a Notion date object structure.
|
|
7
|
+
*
|
|
8
|
+
* **Input:**
|
|
9
|
+
* ```
|
|
10
|
+
* {
|
|
11
|
+
* start: string;
|
|
12
|
+
* end: string | null;
|
|
13
|
+
* time_zone: string | null;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* **Output:**
|
|
18
|
+
* ```
|
|
19
|
+
* {
|
|
20
|
+
* start: string;
|
|
21
|
+
* end: string | null;
|
|
22
|
+
* time_zone: string | null;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import * as v from "valibot";
|
|
29
|
+
* import { DateObjectSchema } from "@nakanoaas/notion-valibot-utils";
|
|
30
|
+
*
|
|
31
|
+
* const PageSchema = v.object({
|
|
32
|
+
* id: v.string(),
|
|
33
|
+
* properties: v.object({
|
|
34
|
+
* Date: v.object({
|
|
35
|
+
* date: DateObjectSchema,
|
|
36
|
+
* }),
|
|
37
|
+
* }),
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
41
|
+
* const parsed = v.parse(PageSchema, page);
|
|
42
|
+
* // parsed.properties.Date.date: { start: string; end: string | null; time_zone: string | null }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
4
47
|
declare const DateObjectSchema: v.ObjectSchema<{
|
|
5
48
|
readonly start: v.StringSchema<undefined>;
|
|
6
49
|
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
50
|
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
8
51
|
}, undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object.
|
|
54
|
+
*
|
|
55
|
+
* **Input:**
|
|
56
|
+
* ```
|
|
57
|
+
* {
|
|
58
|
+
* date: {
|
|
59
|
+
* start: string;
|
|
60
|
+
* end: string | null;
|
|
61
|
+
* time_zone: string | null;
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* **Output:** `Date`
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import * as v from "valibot";
|
|
71
|
+
* import { DateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
72
|
+
*
|
|
73
|
+
* const PageSchema = v.object({
|
|
74
|
+
* id: v.string(),
|
|
75
|
+
* properties: v.object({
|
|
76
|
+
* Date: DateSchema,
|
|
77
|
+
* }),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
81
|
+
* const parsed = v.parse(PageSchema, page);
|
|
82
|
+
* // parsed.properties.Date: Date
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
9
85
|
declare const DateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
10
86
|
readonly date: v.ObjectSchema<{
|
|
11
87
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -19,6 +95,39 @@ declare const DateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
19
95
|
time_zone: string | null;
|
|
20
96
|
};
|
|
21
97
|
}, Date>]>;
|
|
98
|
+
/**
|
|
99
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object or `null`.
|
|
100
|
+
*
|
|
101
|
+
* **Input:**
|
|
102
|
+
* ```
|
|
103
|
+
* {
|
|
104
|
+
* date: {
|
|
105
|
+
* start: string;
|
|
106
|
+
* end: string | null;
|
|
107
|
+
* time_zone: string | null;
|
|
108
|
+
* } | null
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* **Output:** `Date | null`
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import * as v from "valibot";
|
|
117
|
+
* import { NullableDateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
118
|
+
*
|
|
119
|
+
* const PageSchema = v.object({
|
|
120
|
+
* id: v.string(),
|
|
121
|
+
* properties: v.object({
|
|
122
|
+
* Date: NullableDateSchema,
|
|
123
|
+
* }),
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
127
|
+
* const parsed = v.parse(PageSchema, page);
|
|
128
|
+
* // parsed.properties.Date: Date | null
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
22
131
|
declare const NullableDateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
23
132
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
24
133
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -32,6 +141,46 @@ declare const NullableDateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
32
141
|
time_zone: string | null;
|
|
33
142
|
} | null;
|
|
34
143
|
}, Date | null>]>;
|
|
144
|
+
/**
|
|
145
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object.
|
|
146
|
+
*
|
|
147
|
+
* **Input:**
|
|
148
|
+
* ```
|
|
149
|
+
* {
|
|
150
|
+
* date: {
|
|
151
|
+
* start: string;
|
|
152
|
+
* end: string | null;
|
|
153
|
+
* time_zone: string | null;
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* **Output:**
|
|
159
|
+
* ```
|
|
160
|
+
* {
|
|
161
|
+
* start: Date;
|
|
162
|
+
* end: Date | null;
|
|
163
|
+
* time_zone: string | null;
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* import * as v from "valibot";
|
|
170
|
+
* import { DateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
171
|
+
*
|
|
172
|
+
* const PageSchema = v.object({
|
|
173
|
+
* id: v.string(),
|
|
174
|
+
* properties: v.object({
|
|
175
|
+
* DateRange: DateRangeSchema,
|
|
176
|
+
* }),
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
180
|
+
* const parsed = v.parse(PageSchema, page);
|
|
181
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
35
184
|
declare const DateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
36
185
|
readonly date: v.ObjectSchema<{
|
|
37
186
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -49,6 +198,46 @@ declare const DateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
49
198
|
end: Date | null;
|
|
50
199
|
time_zone: string | null;
|
|
51
200
|
}>]>;
|
|
201
|
+
/**
|
|
202
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object or `null`.
|
|
203
|
+
*
|
|
204
|
+
* **Input:**
|
|
205
|
+
* ```
|
|
206
|
+
* {
|
|
207
|
+
* date: {
|
|
208
|
+
* start: string;
|
|
209
|
+
* end: string | null;
|
|
210
|
+
* time_zone: string | null;
|
|
211
|
+
* } | null
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* **Output:**
|
|
216
|
+
* ```
|
|
217
|
+
* {
|
|
218
|
+
* start: Date;
|
|
219
|
+
* end: Date | null;
|
|
220
|
+
* time_zone: string | null;
|
|
221
|
+
* } | null
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* import * as v from "valibot";
|
|
227
|
+
* import { NullableDateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
228
|
+
*
|
|
229
|
+
* const PageSchema = v.object({
|
|
230
|
+
* id: v.string(),
|
|
231
|
+
* properties: v.object({
|
|
232
|
+
* DateRange: NullableDateRangeSchema,
|
|
233
|
+
* }),
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
237
|
+
* const parsed = v.parse(PageSchema, page);
|
|
238
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null } | null
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
52
241
|
declare const NullableDateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
53
242
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
54
243
|
readonly start: v.StringSchema<undefined>;
|
package/dist/date.d.mts
CHANGED
|
@@ -1,11 +1,87 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/date.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for a Notion date object structure.
|
|
7
|
+
*
|
|
8
|
+
* **Input:**
|
|
9
|
+
* ```
|
|
10
|
+
* {
|
|
11
|
+
* start: string;
|
|
12
|
+
* end: string | null;
|
|
13
|
+
* time_zone: string | null;
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* **Output:**
|
|
18
|
+
* ```
|
|
19
|
+
* {
|
|
20
|
+
* start: string;
|
|
21
|
+
* end: string | null;
|
|
22
|
+
* time_zone: string | null;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import * as v from "valibot";
|
|
29
|
+
* import { DateObjectSchema } from "@nakanoaas/notion-valibot-utils";
|
|
30
|
+
*
|
|
31
|
+
* const PageSchema = v.object({
|
|
32
|
+
* id: v.string(),
|
|
33
|
+
* properties: v.object({
|
|
34
|
+
* Date: v.object({
|
|
35
|
+
* date: DateObjectSchema,
|
|
36
|
+
* }),
|
|
37
|
+
* }),
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
41
|
+
* const parsed = v.parse(PageSchema, page);
|
|
42
|
+
* // parsed.properties.Date.date: { start: string; end: string | null; time_zone: string | null }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
4
47
|
declare const DateObjectSchema: v.ObjectSchema<{
|
|
5
48
|
readonly start: v.StringSchema<undefined>;
|
|
6
49
|
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
50
|
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
8
51
|
}, undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object.
|
|
54
|
+
*
|
|
55
|
+
* **Input:**
|
|
56
|
+
* ```
|
|
57
|
+
* {
|
|
58
|
+
* date: {
|
|
59
|
+
* start: string;
|
|
60
|
+
* end: string | null;
|
|
61
|
+
* time_zone: string | null;
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* **Output:** `Date`
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import * as v from "valibot";
|
|
71
|
+
* import { DateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
72
|
+
*
|
|
73
|
+
* const PageSchema = v.object({
|
|
74
|
+
* id: v.string(),
|
|
75
|
+
* properties: v.object({
|
|
76
|
+
* Date: DateSchema,
|
|
77
|
+
* }),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
81
|
+
* const parsed = v.parse(PageSchema, page);
|
|
82
|
+
* // parsed.properties.Date: Date
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
9
85
|
declare const DateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
10
86
|
readonly date: v.ObjectSchema<{
|
|
11
87
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -19,6 +95,39 @@ declare const DateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
19
95
|
time_zone: string | null;
|
|
20
96
|
};
|
|
21
97
|
}, Date>]>;
|
|
98
|
+
/**
|
|
99
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object or `null`.
|
|
100
|
+
*
|
|
101
|
+
* **Input:**
|
|
102
|
+
* ```
|
|
103
|
+
* {
|
|
104
|
+
* date: {
|
|
105
|
+
* start: string;
|
|
106
|
+
* end: string | null;
|
|
107
|
+
* time_zone: string | null;
|
|
108
|
+
* } | null
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* **Output:** `Date | null`
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import * as v from "valibot";
|
|
117
|
+
* import { NullableDateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
118
|
+
*
|
|
119
|
+
* const PageSchema = v.object({
|
|
120
|
+
* id: v.string(),
|
|
121
|
+
* properties: v.object({
|
|
122
|
+
* Date: NullableDateSchema,
|
|
123
|
+
* }),
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
127
|
+
* const parsed = v.parse(PageSchema, page);
|
|
128
|
+
* // parsed.properties.Date: Date | null
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
22
131
|
declare const NullableDateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
23
132
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
24
133
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -32,6 +141,46 @@ declare const NullableDateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
32
141
|
time_zone: string | null;
|
|
33
142
|
} | null;
|
|
34
143
|
}, Date | null>]>;
|
|
144
|
+
/**
|
|
145
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object.
|
|
146
|
+
*
|
|
147
|
+
* **Input:**
|
|
148
|
+
* ```
|
|
149
|
+
* {
|
|
150
|
+
* date: {
|
|
151
|
+
* start: string;
|
|
152
|
+
* end: string | null;
|
|
153
|
+
* time_zone: string | null;
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* **Output:**
|
|
159
|
+
* ```
|
|
160
|
+
* {
|
|
161
|
+
* start: Date;
|
|
162
|
+
* end: Date | null;
|
|
163
|
+
* time_zone: string | null;
|
|
164
|
+
* }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* import * as v from "valibot";
|
|
170
|
+
* import { DateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
171
|
+
*
|
|
172
|
+
* const PageSchema = v.object({
|
|
173
|
+
* id: v.string(),
|
|
174
|
+
* properties: v.object({
|
|
175
|
+
* DateRange: DateRangeSchema,
|
|
176
|
+
* }),
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
180
|
+
* const parsed = v.parse(PageSchema, page);
|
|
181
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
35
184
|
declare const DateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
36
185
|
readonly date: v.ObjectSchema<{
|
|
37
186
|
readonly start: v.StringSchema<undefined>;
|
|
@@ -49,6 +198,46 @@ declare const DateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
49
198
|
end: Date | null;
|
|
50
199
|
time_zone: string | null;
|
|
51
200
|
}>]>;
|
|
201
|
+
/**
|
|
202
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object or `null`.
|
|
203
|
+
*
|
|
204
|
+
* **Input:**
|
|
205
|
+
* ```
|
|
206
|
+
* {
|
|
207
|
+
* date: {
|
|
208
|
+
* start: string;
|
|
209
|
+
* end: string | null;
|
|
210
|
+
* time_zone: string | null;
|
|
211
|
+
* } | null
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* **Output:**
|
|
216
|
+
* ```
|
|
217
|
+
* {
|
|
218
|
+
* start: Date;
|
|
219
|
+
* end: Date | null;
|
|
220
|
+
* time_zone: string | null;
|
|
221
|
+
* } | null
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* import * as v from "valibot";
|
|
227
|
+
* import { NullableDateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
228
|
+
*
|
|
229
|
+
* const PageSchema = v.object({
|
|
230
|
+
* id: v.string(),
|
|
231
|
+
* properties: v.object({
|
|
232
|
+
* DateRange: NullableDateRangeSchema,
|
|
233
|
+
* }),
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
237
|
+
* const parsed = v.parse(PageSchema, page);
|
|
238
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null } | null
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
52
241
|
declare const NullableDateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
53
242
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
54
243
|
readonly start: v.StringSchema<undefined>;
|