@nakanoaas/notion-valibot-schema 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -24
- 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 +203 -13
- package/dist/date.cjs.map +1 -1
- package/dist/date.d.cts +214 -6
- package/dist/date.d.mts +214 -6
- package/dist/date.mjs +201 -12
- 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/index.cjs +7 -3
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- 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 +137 -1
- package/dist/relation.cjs.map +1 -1
- package/dist/relation.d.cts +113 -1
- package/dist/relation.d.mts +113 -1
- package/dist/relation.mjs +136 -2
- package/dist/relation.mjs.map +1 -1
- package/dist/rollup.cjs +203 -10
- 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 +203 -10
- 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 +103 -3
- package/dist/text.cjs.map +1 -1
- package/dist/text.d.cts +73 -10
- package/dist/text.d.mts +73 -10
- package/dist/text.mjs +103 -3
- package/dist/text.mjs.map +1 -1
- package/dist/unique-id.cjs +73 -2
- package/dist/unique-id.cjs.map +1 -1
- package/dist/unique-id.d.cts +81 -2
- package/dist/unique-id.d.mts +81 -2
- package/dist/unique-id.mjs +72 -2
- 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 +82 -5
- 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 +82 -5
- package/dist/verification.mjs.map +1 -1
- package/package.json +1 -1
package/dist/created-time.d.mts
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/created-time.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.
|
|
7
|
+
*
|
|
8
|
+
* **Input:**
|
|
9
|
+
* ```
|
|
10
|
+
* {
|
|
11
|
+
* created_time: string;
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* **Output:** `Date`
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import * as v from "valibot";
|
|
20
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
21
|
+
*
|
|
22
|
+
* const PageSchema = v.object({
|
|
23
|
+
* id: v.string(),
|
|
24
|
+
* created_time: CreatedTimeSchema,
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
28
|
+
* const parsed = v.parse(PageSchema, page);
|
|
29
|
+
* // parsed.created_time: Date
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
4
32
|
declare const CreatedTimeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
33
|
readonly created_time: v.StringSchema<undefined>;
|
|
6
34
|
}, undefined>, v.TransformAction<{
|
package/dist/created-time.mjs
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/created-time.ts
|
|
4
|
+
/**
|
|
5
|
+
* Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.
|
|
6
|
+
*
|
|
7
|
+
* **Input:**
|
|
8
|
+
* ```
|
|
9
|
+
* {
|
|
10
|
+
* created_time: string;
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **Output:** `Date`
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import * as v from "valibot";
|
|
19
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
20
|
+
*
|
|
21
|
+
* const PageSchema = v.object({
|
|
22
|
+
* id: v.string(),
|
|
23
|
+
* created_time: CreatedTimeSchema,
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
27
|
+
* const parsed = v.parse(PageSchema, page);
|
|
28
|
+
* // parsed.created_time: Date
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
4
31
|
const CreatedTimeSchema = v.pipe(v.object({ created_time: v.string() }), v.transform((v$1) => new Date(v$1.created_time)));
|
|
5
32
|
|
|
6
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created-time.mjs","names":["v"],"sources":["../src/created-time.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const CreatedTimeSchema = v.pipe(\n\tv.object({\n\t\tcreated_time: v.string(),\n\t}),\n\tv.transform((v) => new Date(v.created_time)),\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"created-time.mjs","names":["v"],"sources":["../src/created-time.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `created_time` property from a Notion page and transform it to a `Date` object.\n *\n * **Input:**\n * ```\n * {\n * created_time: string;\n * }\n * ```\n *\n * **Output:** `Date`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedTimeSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * created_time: CreatedTimeSchema,\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.created_time: Date\n * ```\n */\nexport const CreatedTimeSchema = v.pipe(\n\tv.object({\n\t\tcreated_time: v.string(),\n\t}),\n\tv.transform((v) => new Date(v.created_time)),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,cAAc,EAAE,QAAQ,EACxB,CAAC,EACF,EAAE,WAAW,QAAM,IAAI,KAAKA,IAAE,aAAa,CAAC,CAC5C"}
|
package/dist/date.cjs
CHANGED
|
@@ -3,26 +3,216 @@ let valibot = require("valibot");
|
|
|
3
3
|
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
4
4
|
|
|
5
5
|
//#region src/date.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
*/
|
|
48
|
+
const DateObjectSchema = valibot.object({
|
|
9
49
|
start: valibot.string(),
|
|
10
|
-
end: valibot.string()
|
|
11
|
-
|
|
50
|
+
end: valibot.nullable(valibot.string()),
|
|
51
|
+
time_zone: valibot.nullable(valibot.string())
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
161
|
+
const DateRangeSchema = valibot.pipe(valibot.object({ date: DateObjectSchema }), valibot.transform((v) => ({
|
|
12
162
|
start: new Date(v.date.start),
|
|
13
|
-
end: new Date(v.date.end)
|
|
163
|
+
end: v.date.end ? new Date(v.date.end) : null,
|
|
164
|
+
time_zone: v.date.time_zone
|
|
14
165
|
})));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
*/
|
|
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
|
-
end: v.date.end ? new Date(v.date.end) : null
|
|
208
|
+
end: v.date.end ? new Date(v.date.end) : null,
|
|
209
|
+
time_zone: v.date.time_zone
|
|
21
210
|
} : null));
|
|
22
211
|
|
|
23
212
|
//#endregion
|
|
213
|
+
exports.DateObjectSchema = DateObjectSchema;
|
|
214
|
+
exports.DateRangeSchema = DateRangeSchema;
|
|
24
215
|
exports.DateSchema = DateSchema;
|
|
25
|
-
exports.
|
|
216
|
+
exports.NullableDateRangeSchema = NullableDateRangeSchema;
|
|
26
217
|
exports.NullableDateSchema = NullableDateSchema;
|
|
27
|
-
exports.NullableFullDateSchema = NullableFullDateSchema;
|
|
28
218
|
//# sourceMappingURL=date.cjs.map
|
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\
|
|
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,52 +1,260 @@
|
|
|
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
|
+
*/
|
|
47
|
+
declare const DateObjectSchema: v.ObjectSchema<{
|
|
48
|
+
readonly start: v.StringSchema<undefined>;
|
|
49
|
+
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
50
|
+
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
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
|
+
*/
|
|
4
85
|
declare const DateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
86
|
readonly date: v.ObjectSchema<{
|
|
6
87
|
readonly start: v.StringSchema<undefined>;
|
|
88
|
+
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
89
|
+
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
90
|
}, undefined>;
|
|
8
91
|
}, undefined>, v.TransformAction<{
|
|
9
92
|
date: {
|
|
10
93
|
start: string;
|
|
94
|
+
end: string | null;
|
|
95
|
+
time_zone: string | null;
|
|
11
96
|
};
|
|
12
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
|
+
*/
|
|
13
131
|
declare const NullableDateSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
14
132
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
15
133
|
readonly start: v.StringSchema<undefined>;
|
|
134
|
+
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
135
|
+
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
16
136
|
}, undefined>, undefined>;
|
|
17
137
|
}, undefined>, v.TransformAction<{
|
|
18
138
|
date: {
|
|
19
139
|
start: string;
|
|
140
|
+
end: string | null;
|
|
141
|
+
time_zone: string | null;
|
|
20
142
|
} | null;
|
|
21
143
|
}, Date | null>]>;
|
|
22
|
-
|
|
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
|
+
*/
|
|
184
|
+
declare const DateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
23
185
|
readonly date: v.ObjectSchema<{
|
|
24
186
|
readonly start: v.StringSchema<undefined>;
|
|
25
|
-
readonly end: v.StringSchema<undefined>;
|
|
187
|
+
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
188
|
+
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
26
189
|
}, undefined>;
|
|
27
190
|
}, undefined>, v.TransformAction<{
|
|
28
191
|
date: {
|
|
29
192
|
start: string;
|
|
30
|
-
end: string;
|
|
193
|
+
end: string | null;
|
|
194
|
+
time_zone: string | null;
|
|
31
195
|
};
|
|
32
196
|
}, {
|
|
33
197
|
start: Date;
|
|
34
|
-
end: Date;
|
|
198
|
+
end: Date | null;
|
|
199
|
+
time_zone: string | null;
|
|
35
200
|
}>]>;
|
|
36
|
-
|
|
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
|
+
*/
|
|
241
|
+
declare const NullableDateRangeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
37
242
|
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
38
243
|
readonly start: v.StringSchema<undefined>;
|
|
39
244
|
readonly end: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
245
|
+
readonly time_zone: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
40
246
|
}, undefined>, undefined>;
|
|
41
247
|
}, undefined>, v.TransformAction<{
|
|
42
248
|
date: {
|
|
43
249
|
start: string;
|
|
44
250
|
end: string | null;
|
|
251
|
+
time_zone: string | null;
|
|
45
252
|
} | null;
|
|
46
253
|
}, {
|
|
47
254
|
start: Date;
|
|
48
255
|
end: Date | null;
|
|
256
|
+
time_zone: string | null;
|
|
49
257
|
} | null>]>;
|
|
50
258
|
//#endregion
|
|
51
|
-
export { DateSchema,
|
|
259
|
+
export { DateObjectSchema, DateRangeSchema, DateSchema, NullableDateRangeSchema, NullableDateSchema };
|
|
52
260
|
//# sourceMappingURL=date.d.cts.map
|