@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/date.d.mts
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.mts.map
|
package/dist/date.mjs
CHANGED
|
@@ -1,23 +1,212 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/date.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Schema for a Notion date object structure.
|
|
6
|
+
*
|
|
7
|
+
* **Input:**
|
|
8
|
+
* ```
|
|
9
|
+
* {
|
|
10
|
+
* start: string;
|
|
11
|
+
* end: string | null;
|
|
12
|
+
* time_zone: string | null;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* **Output:**
|
|
17
|
+
* ```
|
|
18
|
+
* {
|
|
19
|
+
* start: string;
|
|
20
|
+
* end: string | null;
|
|
21
|
+
* time_zone: string | null;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import * as v from "valibot";
|
|
28
|
+
* import { DateObjectSchema } from "@nakanoaas/notion-valibot-utils";
|
|
29
|
+
*
|
|
30
|
+
* const PageSchema = v.object({
|
|
31
|
+
* id: v.string(),
|
|
32
|
+
* properties: v.object({
|
|
33
|
+
* Date: v.object({
|
|
34
|
+
* date: DateObjectSchema,
|
|
35
|
+
* }),
|
|
36
|
+
* }),
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
40
|
+
* const parsed = v.parse(PageSchema, page);
|
|
41
|
+
* // parsed.properties.Date.date: { start: string; end: string | null; time_zone: string | null }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
const DateObjectSchema = v.object({
|
|
7
47
|
start: v.string(),
|
|
8
|
-
end: v.string()
|
|
9
|
-
|
|
48
|
+
end: v.nullable(v.string()),
|
|
49
|
+
time_zone: v.nullable(v.string())
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object.
|
|
53
|
+
*
|
|
54
|
+
* **Input:**
|
|
55
|
+
* ```
|
|
56
|
+
* {
|
|
57
|
+
* date: {
|
|
58
|
+
* start: string;
|
|
59
|
+
* end: string | null;
|
|
60
|
+
* time_zone: string | null;
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* **Output:** `Date`
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import * as v from "valibot";
|
|
70
|
+
* import { DateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
71
|
+
*
|
|
72
|
+
* const PageSchema = v.object({
|
|
73
|
+
* id: v.string(),
|
|
74
|
+
* properties: v.object({
|
|
75
|
+
* Date: DateSchema,
|
|
76
|
+
* }),
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
80
|
+
* const parsed = v.parse(PageSchema, page);
|
|
81
|
+
* // parsed.properties.Date: Date
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
const DateSchema = v.pipe(v.object({ date: DateObjectSchema }), v.transform((v$1) => new Date(v$1.date.start)));
|
|
85
|
+
/**
|
|
86
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a `Date` object or `null`.
|
|
87
|
+
*
|
|
88
|
+
* **Input:**
|
|
89
|
+
* ```
|
|
90
|
+
* {
|
|
91
|
+
* date: {
|
|
92
|
+
* start: string;
|
|
93
|
+
* end: string | null;
|
|
94
|
+
* time_zone: string | null;
|
|
95
|
+
* } | null
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* **Output:** `Date | null`
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* import * as v from "valibot";
|
|
104
|
+
* import { NullableDateSchema } from "@nakanoaas/notion-valibot-utils";
|
|
105
|
+
*
|
|
106
|
+
* const PageSchema = v.object({
|
|
107
|
+
* id: v.string(),
|
|
108
|
+
* properties: v.object({
|
|
109
|
+
* Date: NullableDateSchema,
|
|
110
|
+
* }),
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
114
|
+
* const parsed = v.parse(PageSchema, page);
|
|
115
|
+
* // parsed.properties.Date: Date | null
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
const NullableDateSchema = v.pipe(v.object({ date: v.nullable(DateObjectSchema) }), v.transform((v$1) => v$1.date?.start ? new Date(v$1.date.start) : null));
|
|
119
|
+
/**
|
|
120
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object.
|
|
121
|
+
*
|
|
122
|
+
* **Input:**
|
|
123
|
+
* ```
|
|
124
|
+
* {
|
|
125
|
+
* date: {
|
|
126
|
+
* start: string;
|
|
127
|
+
* end: string | null;
|
|
128
|
+
* time_zone: string | null;
|
|
129
|
+
* }
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* **Output:**
|
|
134
|
+
* ```
|
|
135
|
+
* {
|
|
136
|
+
* start: Date;
|
|
137
|
+
* end: Date | null;
|
|
138
|
+
* time_zone: string | null;
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import * as v from "valibot";
|
|
145
|
+
* import { DateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
146
|
+
*
|
|
147
|
+
* const PageSchema = v.object({
|
|
148
|
+
* id: v.string(),
|
|
149
|
+
* properties: v.object({
|
|
150
|
+
* DateRange: DateRangeSchema,
|
|
151
|
+
* }),
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
155
|
+
* const parsed = v.parse(PageSchema, page);
|
|
156
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
const DateRangeSchema = v.pipe(v.object({ date: DateObjectSchema }), v.transform((v$1) => ({
|
|
10
160
|
start: new Date(v$1.date.start),
|
|
11
|
-
end: new Date(v$1.date.end)
|
|
161
|
+
end: v$1.date.end ? new Date(v$1.date.end) : null,
|
|
162
|
+
time_zone: v$1.date.time_zone
|
|
12
163
|
})));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Schema to extract the `date` property from a Notion page property and transform it to a date range object or `null`.
|
|
166
|
+
*
|
|
167
|
+
* **Input:**
|
|
168
|
+
* ```
|
|
169
|
+
* {
|
|
170
|
+
* date: {
|
|
171
|
+
* start: string;
|
|
172
|
+
* end: string | null;
|
|
173
|
+
* time_zone: string | null;
|
|
174
|
+
* } | null
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* **Output:**
|
|
179
|
+
* ```
|
|
180
|
+
* {
|
|
181
|
+
* start: Date;
|
|
182
|
+
* end: Date | null;
|
|
183
|
+
* time_zone: string | null;
|
|
184
|
+
* } | null
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* import * as v from "valibot";
|
|
190
|
+
* import { NullableDateRangeSchema } from "@nakanoaas/notion-valibot-utils";
|
|
191
|
+
*
|
|
192
|
+
* const PageSchema = v.object({
|
|
193
|
+
* id: v.string(),
|
|
194
|
+
* properties: v.object({
|
|
195
|
+
* DateRange: NullableDateRangeSchema,
|
|
196
|
+
* }),
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
200
|
+
* const parsed = v.parse(PageSchema, page);
|
|
201
|
+
* // parsed.properties.DateRange: { start: Date; end: Date | null; time_zone: string | null } | null
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
const NullableDateRangeSchema = v.pipe(v.object({ date: v.nullable(DateObjectSchema) }), v.transform((v$1) => v$1.date ? {
|
|
17
205
|
start: new Date(v$1.date.start),
|
|
18
|
-
end: v$1.date.end ? new Date(v$1.date.end) : null
|
|
206
|
+
end: v$1.date.end ? new Date(v$1.date.end) : null,
|
|
207
|
+
time_zone: v$1.date.time_zone
|
|
19
208
|
} : null));
|
|
20
209
|
|
|
21
210
|
//#endregion
|
|
22
|
-
export { DateSchema,
|
|
211
|
+
export { DateObjectSchema, DateRangeSchema, DateSchema, NullableDateRangeSchema, NullableDateSchema };
|
|
23
212
|
//# sourceMappingURL=date.mjs.map
|
package/dist/date.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.mjs","names":["v"],"sources":["../src/date.ts"],"sourcesContent":["import * as v from \"valibot\";\n\
|
|
1
|
+
{"version":3,"file":"date.mjs","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,mBAAmB,EAAE,OAAO;CACxC,OAAO,EAAE,QAAQ;CACjB,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC3B,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CACjC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCF,MAAa,aAAa,EAAE,KAC3B,EAAE,OAAO,EACR,MAAM,kBACN,CAAC,EACF,EAAE,WAAW,QAAM,IAAI,KAAKA,IAAE,KAAK,MAAM,CAAC,CAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCD,MAAa,qBAAqB,EAAE,KACnC,EAAE,OAAO,EACR,MAAM,EAAE,SAAS,iBAAiB,EAClC,CAAC,EACF,EAAE,WAAW,QAAOA,IAAE,MAAM,QAAQ,IAAI,KAAKA,IAAE,KAAK,MAAM,GAAG,KAAM,CACnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CD,MAAa,kBAAkB,EAAE,KAChC,EAAE,OAAO,EACR,MAAM,kBACN,CAAC,EACF,EAAE,WAAW,SAAO;CACnB,OAAO,IAAI,KAAKA,IAAE,KAAK,MAAM;CAC7B,KAAKA,IAAE,KAAK,MAAM,IAAI,KAAKA,IAAE,KAAK,IAAI,GAAG;CACzC,WAAWA,IAAE,KAAK;CAClB,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CD,MAAa,0BAA0B,EAAE,KACxC,EAAE,OAAO,EACR,MAAM,EAAE,SAAS,iBAAiB,EAClC,CAAC,EACF,EAAE,WAAW,QACZA,IAAE,OACC;CACA,OAAO,IAAI,KAAKA,IAAE,KAAK,MAAM;CAC7B,KAAKA,IAAE,KAAK,MAAM,IAAI,KAAKA,IAAE,KAAK,IAAI,GAAG;CACzC,WAAWA,IAAE,KAAK;CAClB,GACA,KACH,CACD"}
|
package/dist/email.cjs
CHANGED
|
@@ -3,7 +3,65 @@ let valibot = require("valibot");
|
|
|
3
3
|
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
4
4
|
|
|
5
5
|
//#region src/email.ts
|
|
6
|
+
/**
|
|
7
|
+
* Schema to extract the `email` property from a Notion page property.
|
|
8
|
+
*
|
|
9
|
+
* **Input:**
|
|
10
|
+
* ```
|
|
11
|
+
* {
|
|
12
|
+
* email: string;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* **Output:** `string`
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import * as v from "valibot";
|
|
21
|
+
* import { EmailSchema } from "@nakanoaas/notion-valibot-utils";
|
|
22
|
+
*
|
|
23
|
+
* const PageSchema = v.object({
|
|
24
|
+
* id: v.string(),
|
|
25
|
+
* properties: v.object({
|
|
26
|
+
* Email: EmailSchema,
|
|
27
|
+
* }),
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
31
|
+
* const parsed = v.parse(PageSchema, page);
|
|
32
|
+
* // parsed.properties.Email: string
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
6
35
|
const EmailSchema = valibot.pipe(valibot.object({ email: valibot.string() }), valibot.transform((v) => v.email));
|
|
36
|
+
/**
|
|
37
|
+
* Schema to extract the `email` property from a Notion page property or `null`.
|
|
38
|
+
*
|
|
39
|
+
* **Input:**
|
|
40
|
+
* ```
|
|
41
|
+
* {
|
|
42
|
+
* email: string | null;
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* **Output:** `string | null`
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import * as v from "valibot";
|
|
51
|
+
* import { NullableEmailSchema } from "@nakanoaas/notion-valibot-utils";
|
|
52
|
+
*
|
|
53
|
+
* const PageSchema = v.object({
|
|
54
|
+
* id: v.string(),
|
|
55
|
+
* properties: v.object({
|
|
56
|
+
* Email: NullableEmailSchema,
|
|
57
|
+
* }),
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
61
|
+
* const parsed = v.parse(PageSchema, page);
|
|
62
|
+
* // parsed.properties.Email: string | null
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
7
65
|
const NullableEmailSchema = valibot.pipe(valibot.object({ email: valibot.nullable(valibot.string()) }), valibot.transform((v) => v.email));
|
|
8
66
|
|
|
9
67
|
//#endregion
|
package/dist/email.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.cjs","names":["v"],"sources":["../src/email.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nexport const EmailSchema = v.pipe(\n\tv.object({\n\t\temail: v.string(),\n\t}),\n\tv.transform((v) => v.email),\n);\n\nexport const NullableEmailSchema = v.pipe(\n\tv.object({\n\t\temail: v.nullable(v.string()),\n\t}),\n\tv.transform((v) => v.email),\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.cjs","names":["v"],"sources":["../src/email.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `email` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * email: string;\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { EmailSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Email: EmailSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Email: string\n * ```\n */\nexport const EmailSchema = v.pipe(\n\tv.object({\n\t\temail: v.string(),\n\t}),\n\tv.transform((v) => v.email),\n);\n\n/**\n * Schema to extract the `email` property from a Notion page property or `null`.\n *\n * **Input:**\n * ```\n * {\n * email: string | null;\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableEmailSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Email: NullableEmailSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Email: string | null\n * ```\n */\nexport const NullableEmailSchema = v.pipe(\n\tv.object({\n\t\temail: v.nullable(v.string()),\n\t}),\n\tv.transform((v) => v.email),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,cAAcA,QAAE,KAC5BA,QAAE,OAAO,EACR,OAAOA,QAAE,QAAQ,EACjB,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BD,MAAa,sBAAsBA,QAAE,KACpCA,QAAE,OAAO,EACR,OAAOA,QAAE,SAASA,QAAE,QAAQ,CAAC,EAC7B,CAAC,EACFA,QAAE,WAAW,MAAM,EAAE,MAAM,CAC3B"}
|
package/dist/email.d.cts
CHANGED
|
@@ -1,11 +1,70 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
|
|
3
3
|
//#region src/email.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema to extract the `email` property from a Notion page property.
|
|
7
|
+
*
|
|
8
|
+
* **Input:**
|
|
9
|
+
* ```
|
|
10
|
+
* {
|
|
11
|
+
* email: string;
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* **Output:** `string`
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import * as v from "valibot";
|
|
20
|
+
* import { EmailSchema } from "@nakanoaas/notion-valibot-utils";
|
|
21
|
+
*
|
|
22
|
+
* const PageSchema = v.object({
|
|
23
|
+
* id: v.string(),
|
|
24
|
+
* properties: v.object({
|
|
25
|
+
* Email: EmailSchema,
|
|
26
|
+
* }),
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
30
|
+
* const parsed = v.parse(PageSchema, page);
|
|
31
|
+
* // parsed.properties.Email: string
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
4
34
|
declare const EmailSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
35
|
readonly email: v.StringSchema<undefined>;
|
|
6
36
|
}, undefined>, v.TransformAction<{
|
|
7
37
|
email: string;
|
|
8
38
|
}, string>]>;
|
|
39
|
+
/**
|
|
40
|
+
* Schema to extract the `email` property from a Notion page property or `null`.
|
|
41
|
+
*
|
|
42
|
+
* **Input:**
|
|
43
|
+
* ```
|
|
44
|
+
* {
|
|
45
|
+
* email: string | null;
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **Output:** `string | null`
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import * as v from "valibot";
|
|
54
|
+
* import { NullableEmailSchema } from "@nakanoaas/notion-valibot-utils";
|
|
55
|
+
*
|
|
56
|
+
* const PageSchema = v.object({
|
|
57
|
+
* id: v.string(),
|
|
58
|
+
* properties: v.object({
|
|
59
|
+
* Email: NullableEmailSchema,
|
|
60
|
+
* }),
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* const page = await notion.pages.retrieve({ page_id: "..." });
|
|
64
|
+
* const parsed = v.parse(PageSchema, page);
|
|
65
|
+
* // parsed.properties.Email: string | null
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
9
68
|
declare const NullableEmailSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
10
69
|
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
11
70
|
}, undefined>, v.TransformAction<{
|