@nakanoaas/notion-valibot-schema 0.9.0 → 1.0.0-rc.2
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 +154 -72
- package/dist/checkbox.cjs +3 -1
- package/dist/checkbox.cjs.map +1 -1
- package/dist/checkbox.d.cts +3 -1
- package/dist/checkbox.d.mts +3 -1
- package/dist/checkbox.mjs +3 -1
- package/dist/checkbox.mjs.map +1 -1
- package/dist/created-by.cjs +8 -0
- package/dist/created-by.cjs.map +1 -1
- package/dist/created-by.d.cts +8 -0
- package/dist/created-by.d.mts +8 -0
- package/dist/created-by.mjs +8 -0
- package/dist/created-by.mjs.map +1 -1
- package/dist/created-time.cjs +3 -1
- package/dist/created-time.cjs.map +1 -1
- package/dist/created-time.d.cts +3 -1
- package/dist/created-time.d.mts +3 -1
- package/dist/created-time.mjs +3 -1
- package/dist/created-time.mjs.map +1 -1
- package/dist/date.cjs +31 -19
- package/dist/date.cjs.map +1 -1
- package/dist/date.d.cts +28 -16
- package/dist/date.d.mts +28 -16
- package/dist/date.mjs +28 -16
- package/dist/date.mjs.map +1 -1
- package/dist/email.cjs +6 -2
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +6 -2
- package/dist/email.d.mts +6 -2
- package/dist/email.mjs +6 -2
- package/dist/email.mjs.map +1 -1
- package/dist/files.cjs +15 -6
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.cts +15 -6
- package/dist/files.d.mts +15 -6
- package/dist/files.mjs +15 -6
- package/dist/files.mjs.map +1 -1
- package/dist/formula.cjs +13 -2
- package/dist/formula.cjs.map +1 -1
- package/dist/formula.d.cts +13 -2
- package/dist/formula.d.mts +13 -2
- package/dist/formula.mjs +13 -2
- package/dist/formula.mjs.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +5 -5
- package/dist/last-edited-by.cjs +8 -0
- package/dist/last-edited-by.cjs.map +1 -1
- package/dist/last-edited-by.d.cts +8 -0
- package/dist/last-edited-by.d.mts +8 -0
- package/dist/last-edited-by.mjs +8 -0
- package/dist/last-edited-by.mjs.map +1 -1
- package/dist/last-edited-time.cjs +3 -1
- package/dist/last-edited-time.cjs.map +1 -1
- package/dist/last-edited-time.d.cts +3 -1
- package/dist/last-edited-time.d.mts +3 -1
- package/dist/last-edited-time.mjs +3 -1
- package/dist/last-edited-time.mjs.map +1 -1
- package/dist/multi-select.cjs +4 -2
- package/dist/multi-select.cjs.map +1 -1
- package/dist/multi-select.d.cts +4 -2
- package/dist/multi-select.d.mts +4 -2
- package/dist/multi-select.mjs +4 -2
- package/dist/multi-select.mjs.map +1 -1
- package/dist/number.cjs +6 -2
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.cts +6 -2
- package/dist/number.d.mts +6 -2
- package/dist/number.mjs +6 -2
- package/dist/number.mjs.map +1 -1
- package/dist/people.cjs +33 -0
- package/dist/people.cjs.map +1 -1
- package/dist/people.d.cts +33 -0
- package/dist/people.d.mts +33 -0
- package/dist/people.mjs +33 -0
- package/dist/people.mjs.map +1 -1
- package/dist/phone-number.cjs +6 -2
- package/dist/phone-number.cjs.map +1 -1
- package/dist/phone-number.d.cts +6 -2
- package/dist/phone-number.d.mts +6 -2
- package/dist/phone-number.mjs +6 -2
- package/dist/phone-number.mjs.map +1 -1
- package/dist/place.cjs +7 -3
- package/dist/place.cjs.map +1 -1
- package/dist/place.d.cts +6 -2
- package/dist/place.d.mts +6 -2
- package/dist/place.mjs +7 -3
- package/dist/place.mjs.map +1 -1
- package/dist/relation.cjs +13 -4
- package/dist/relation.cjs.map +1 -1
- package/dist/relation.d.cts +12 -3
- package/dist/relation.d.mts +12 -3
- package/dist/relation.mjs +13 -4
- package/dist/relation.mjs.map +1 -1
- package/dist/rollup.cjs +39 -27
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +36 -24
- package/dist/rollup.d.mts +36 -24
- package/dist/rollup.mjs +36 -24
- package/dist/rollup.mjs.map +1 -1
- package/dist/select.cjs +8 -4
- package/dist/select.cjs.map +1 -1
- package/dist/select.d.cts +8 -4
- package/dist/select.d.mts +8 -4
- package/dist/select.mjs +8 -4
- package/dist/select.mjs.map +1 -1
- package/dist/status.cjs +8 -4
- package/dist/status.cjs.map +1 -1
- package/dist/status.d.cts +8 -4
- package/dist/status.d.mts +8 -4
- package/dist/status.mjs +8 -4
- package/dist/status.mjs.map +1 -1
- package/dist/text.cjs +17 -5
- package/dist/text.cjs.map +1 -1
- package/dist/text.d.cts +16 -4
- package/dist/text.d.mts +16 -4
- package/dist/text.mjs +17 -5
- package/dist/text.mjs.map +1 -1
- package/dist/unique-id.cjs +18 -12
- package/dist/unique-id.cjs.map +1 -1
- package/dist/unique-id.d.cts +16 -10
- package/dist/unique-id.d.mts +16 -10
- package/dist/unique-id.mjs +16 -10
- package/dist/unique-id.mjs.map +1 -1
- package/dist/url.cjs +6 -2
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.cts +6 -2
- package/dist/url.d.mts +6 -2
- package/dist/url.mjs +6 -2
- package/dist/url.mjs.map +1 -1
- package/dist/verification.cjs +4 -0
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.d.cts +4 -0
- package/dist/verification.d.mts +4 -0
- package/dist/verification.mjs +4 -0
- package/dist/verification.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ No more checking for `property.type === 'date'`, handling `null`, or digging thr
|
|
|
54
54
|
- 🔒 **Type-Safe**: Full TypeScript support with inferred types.
|
|
55
55
|
- ✅ **Well Tested**: Backed by a comprehensive test suite covering edge cases.
|
|
56
56
|
- 🛠 **Comprehensive**: Supports complex properties like Rollups, Formulas, and Relations.
|
|
57
|
+
- 📋 **Partial-aware**: Each schema documents whether it accepts partial `pages.retrieve` / `databases.query` responses via `@notionPartial` JSDoc tags.
|
|
57
58
|
|
|
58
59
|
## Installation
|
|
59
60
|
|
|
@@ -86,7 +87,7 @@ import {
|
|
|
86
87
|
RichTextSchema,
|
|
87
88
|
StatusSchema,
|
|
88
89
|
MultiSelectSchema,
|
|
89
|
-
|
|
90
|
+
NullableDateSchema,
|
|
90
91
|
CheckboxSchema,
|
|
91
92
|
PeopleIdSchema,
|
|
92
93
|
} from "@nakanoaas/notion-valibot-schema";
|
|
@@ -108,7 +109,7 @@ const TaskPageSchema = v.object({
|
|
|
108
109
|
Tags: MultiSelectSchema(v.string()),
|
|
109
110
|
|
|
110
111
|
// Map "Due Date" -> Date | null
|
|
111
|
-
DueDate:
|
|
112
|
+
DueDate: NullableDateSchema,
|
|
112
113
|
|
|
113
114
|
// Map "IsUrgent" -> boolean
|
|
114
115
|
IsUrgent: CheckboxSchema,
|
|
@@ -142,46 +143,131 @@ const { results } = await notion.dataSources.query({ data_source_id: "..." });
|
|
|
142
143
|
const tasks = v.parse(TaskListSchema, results);
|
|
143
144
|
```
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
### Partial API Responses
|
|
147
|
+
|
|
148
|
+
When you fetch pages with [`pages.retrieve`](https://developers.notion.com/reference/retrieve-a-page) or list them with [`databases.query`](https://developers.notion.com/reference/query-a-data-source), Notion may return **partial** property values. This happens when a property has many references (relations, people, rollups, inline mentions, and so on). The API returns at most **25** page/person references per property; beyond that, lists can be truncated (`relation.has_more: true`) or entries may be incomplete.
|
|
149
|
+
|
|
150
|
+
Each exported schema includes JSDoc tags so you can tell at a glance whether it works with these partial shapes:
|
|
151
|
+
|
|
152
|
+
| Tag | Meaning |
|
|
153
|
+
| :--- | :--- |
|
|
154
|
+
| `@notionPartial supported` | Typical partial responses from `pages.retrieve` / `databases.query` parse successfully |
|
|
155
|
+
| `@notionPartial not-supported` | Partial responses are missing required fields and `v.parse` will fail |
|
|
156
|
+
| `@notionPartialNote` | Optional caveat (truncated lists, required inner schema, recommended alternative) |
|
|
157
|
+
|
|
158
|
+
**Examples of `supported` schemas** (scalar properties, ID extraction, and schemas that only read fields present in partial responses):
|
|
159
|
+
|
|
160
|
+
- `CheckboxSchema`, `NumberSchema`, `TitleSchema`, `SelectSchema`, `RelationSchema`, `PeopleIdSchema`, `RollupScalarSchema`, …
|
|
161
|
+
|
|
162
|
+
**`supported`, but data may still be incomplete** — parsing succeeds, but you may not get every referenced item. Use [`pages.properties.retrieve`](https://developers.notion.com/reference/retrieve-a-page-property) when you need the full list or accurate rollup:
|
|
146
163
|
|
|
147
|
-
|
|
164
|
+
- `RelationSchema`, `PeopleIdSchema`, `FilesSchema`, `RollupSchema`, `TitleSchema` / `RichTextSchema` (inline mentions)
|
|
148
165
|
|
|
149
|
-
|
|
166
|
+
**`not-supported` — choose a different schema for partial responses:**
|
|
167
|
+
|
|
168
|
+
| Schema | Why | Use instead |
|
|
150
169
|
| :--- | :--- | :--- |
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
170
|
+
| `PersonSchema`, `BotSchema` | Require full user objects (`type: "person"`, `person`, …) | `UserOrGroupSchema`, `UserSchema`, or `PeopleIdSchema` |
|
|
171
|
+
| `PeopleSchema(PersonSchema)` / `CreatedBySchema(PersonSchema)` | Inner schema requires full person | `PeopleSchema(UserOrGroupSchema)`, `CreatedByIdSchema`, … |
|
|
172
|
+
| Rollup schemas + `type: "incomplete"` / `"unsupported"` | Calculation not finished or unsupported | Wait and retry, or use `pages.properties.retrieve` |
|
|
173
|
+
|
|
174
|
+
Factory schemas (`PeopleSchema`, `RollupSchema`, `CreatedBySchema`, …) document partial support on the factory itself and on `@param schema` — passing `PersonSchema` or `BotSchema` as the inner schema is **not supported** for partial responses.
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import * as v from "valibot";
|
|
178
|
+
import {
|
|
179
|
+
PeopleIdSchema,
|
|
180
|
+
PeopleSchema,
|
|
181
|
+
PersonSchema,
|
|
182
|
+
RelationSchema,
|
|
183
|
+
UserOrGroupSchema,
|
|
184
|
+
} from "@nakanoaas/notion-valibot-schema";
|
|
185
|
+
|
|
186
|
+
const PageSchema = v.object({
|
|
187
|
+
id: v.string(),
|
|
188
|
+
properties: v.object({
|
|
189
|
+
// ✅ IDs only — works with partial people responses
|
|
190
|
+
AssigneeIds: PeopleIdSchema,
|
|
191
|
+
|
|
192
|
+
// ✅ Minimal user objects ({ id, object }) — works with partial responses
|
|
193
|
+
Assignees: PeopleSchema(UserOrGroupSchema),
|
|
194
|
+
|
|
195
|
+
// ❌ Full person details — fails when API returns partial user objects
|
|
196
|
+
// Owners: PeopleSchema(PersonSchema),
|
|
197
|
+
|
|
198
|
+
// ✅ Relation IDs — works; list may be truncated when has_more is true
|
|
199
|
+
RelatedTasks: RelationSchema,
|
|
200
|
+
}),
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const page = await notion.pages.retrieve({ page_id: "..." });
|
|
204
|
+
const parsed = v.parse(PageSchema, page);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
See each schema's JSDoc on [JSR](https://jsr.io/@nakanoaas/notion-valibot-schema/doc) for its `@notionPartial` status and notes.
|
|
208
|
+
|
|
209
|
+
## Schema Reference
|
|
210
|
+
|
|
211
|
+
> 📚 **For complete API documentation, including all available schemas, `@notionPartial` tags, and types, please visit the [JSR Documentation](https://jsr.io/@nakanoaas/notion-valibot-schema/doc).**
|
|
212
|
+
|
|
213
|
+
| Notion Property | Schema | Output Type | Partial |
|
|
214
|
+
| :--- | :--- | :--- | :--- |
|
|
215
|
+
| **Text** / Title | `TitleSchema` / `NullableTitleSchema` | `string` / `string \| null` | supported¹ |
|
|
216
|
+
| **Rich Text** | `RichTextSchema` / `NullableRichTextSchema` | `string` / `string \| null` | supported¹ |
|
|
217
|
+
| **Number** | `NumberSchema` / `NullableNumberSchema` | `number` / `number \| null` | supported |
|
|
218
|
+
| **Checkbox** | `CheckboxSchema` | `boolean` | supported |
|
|
219
|
+
| **Select** | `SelectSchema(schema)` / `NullableSelectSchema(schema)` | `Inferred<schema>` / `Inferred<schema> \| null` | supported |
|
|
220
|
+
| **Multi-Select** | `MultiSelectSchema(schema)` | `Inferred<schema>[]` | supported |
|
|
221
|
+
| **Status** | `StatusSchema(schema)` / `NullableStatusSchema(schema)` | `Inferred<schema>` / `Inferred<schema> \| null` | supported |
|
|
222
|
+
| **Date** | `DateSchema` / `NullableDateSchema` | `Date` / `Date \| null` | supported |
|
|
223
|
+
| **Date** (full object) | `FullDateSchema` / `NullableFullDateSchema` | `{ start: Date; end: Date \| null; time_zone: string \| null }` / same `\| null` | supported |
|
|
224
|
+
| **Date** (range, end required) | `DateRangeSchema` / `NullableDateRangeSchema` | `{ start: Date; end: Date; time_zone: string \| null }` / same `\| null` | supported |
|
|
225
|
+
| **Relation** | `RelationSchema` / `SingleRelationSchema` / `NullableSingleRelationSchema` | `string[]` / `string` / `string \| null` | supported¹ |
|
|
226
|
+
| **Rollup** (array) | `RollupSchema(schema)` | `Inferred<schema>[]` | supported¹² |
|
|
227
|
+
| **Rollup** (array, single) | `SingleRollupSchema(schema)` / `NullableSingleRollupSchema(schema)` | `Inferred<schema>` / `Inferred<schema> \| null` | supported¹² |
|
|
228
|
+
| **Rollup** (scalar) | `RollupScalarSchema(schema)` | `Inferred<schema>` | supported² |
|
|
229
|
+
| **Formula** | `FormulaSchema(schema)` | `Inferred<schema>` | supported¹ |
|
|
230
|
+
| **URL** | `UrlSchema` / `NullableUrlSchema` | `string` / `string \| null` | supported |
|
|
231
|
+
| **Email** | `EmailSchema` / `NullableEmailSchema` | `string` / `string \| null` | supported |
|
|
232
|
+
| **Phone** | `PhoneNumberSchema` / `NullablePhoneNumberSchema` | `string` / `string \| null` | supported |
|
|
233
|
+
| **Files** | `FilesSchema` / `SingleFileSchema` / `NullableSingleFileSchema` | `string[]` / `string` / `string \| null` | supported¹ |
|
|
234
|
+
| **People** (building blocks) | `UserOrGroupIdSchema` / `UserOrGroupSchema` / `UserSchema` / `PersonSchema` / `BotSchema` | Building-block object types | supported / supported / supported / **not-supported** / **not-supported** |
|
|
235
|
+
| **People** (generic) | `PeopleSchema(schema)` / `SinglePeopleSchema(schema)` / `NullableSinglePeopleSchema(schema)` | `Inferred<schema>[]` / `Inferred<schema>` / `Inferred<schema> \| null` | depends on inner schema³ |
|
|
236
|
+
| **People** (IDs only) | `PeopleIdSchema` / `SinglePeopleIdSchema` / `NullableSinglePeopleIdSchema` | `string[]` / `string` / `string \| null` | supported¹ |
|
|
237
|
+
| **Created By** | `CreatedBySchema(schema)` / `CreatedByIdSchema` / `NullableCreatedByNameSchema` | `Inferred<schema>` / `string` / `string \| null` | depends on inner schema³ / supported / supported |
|
|
238
|
+
| **Last Edited By** | `LastEditedBySchema(schema)` / `LastEditedByIdSchema` / `NullableLastEditedByNameSchema` | `Inferred<schema>` / `string` / `string \| null` | depends on inner schema³ / supported / supported |
|
|
239
|
+
| **Created / Edited Time** | `CreatedTimeSchema` / `LastEditedTimeSchema` | `Date` | supported |
|
|
240
|
+
| **Place** | `PlaceSchema` / `NullablePlaceSchema` | `{ lat: number; lon: number; name?: string \| null; address?: string \| null }` / same `\| null` | supported |
|
|
241
|
+
| **Unique ID** | `UniqueIdSchema` / `PrefixedUniqueIdSchema` / `FullUniqueIdSchema` | `number` / `string` (e.g. `"PREFIX-123"`) / `{ prefix: string \| null; number: number \| null }` | supported |
|
|
242
|
+
| **Verification** | `VerificationSchema` / `NullableVerificationSchema` | `{ state: "unverified" \| "verified" \| "expired"; date: DateObject \| null; verified_by: UserObject \| null }` / same `\| null` | supported |
|
|
243
|
+
|
|
244
|
+
¹ Parsing succeeds, but lists or inline mentions may be **truncated** beyond 25 references. Use `pages.properties.retrieve` for complete data.
|
|
245
|
+
|
|
246
|
+
² Does not accept rollup `type: "incomplete"` or `type: "unsupported"`.
|
|
247
|
+
|
|
248
|
+
³ Use `UserOrGroupSchema` or `UserSchema` for partial responses. `PersonSchema` / `BotSchema` inner schemas are **not supported**.
|
|
181
249
|
|
|
182
250
|
### Advanced Schemas
|
|
183
251
|
|
|
252
|
+
#### Date variants
|
|
253
|
+
|
|
254
|
+
The Date property has three levels of detail depending on how much you need:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import {
|
|
258
|
+
DateSchema, // start only → Date
|
|
259
|
+
NullableDateSchema, // start only → Date | null
|
|
260
|
+
|
|
261
|
+
FullDateSchema, // start + optional end → { start: Date; end: Date | null; time_zone }
|
|
262
|
+
NullableFullDateSchema, // → same | null
|
|
263
|
+
|
|
264
|
+
DateRangeSchema, // start + required end → { start: Date; end: Date; time_zone }
|
|
265
|
+
NullableDateRangeSchema, // → same | null
|
|
266
|
+
} from "@nakanoaas/notion-valibot-schema";
|
|
267
|
+
```
|
|
268
|
+
|
|
184
269
|
#### Formulas
|
|
270
|
+
|
|
185
271
|
Formulas in Notion can return different types (string, number, boolean, date). Use `FormulaSchema` with the matching inner schema for each formula property.
|
|
186
272
|
|
|
187
273
|
```ts
|
|
@@ -190,56 +276,55 @@ import {
|
|
|
190
276
|
BooleanFormulaSchema,
|
|
191
277
|
FormulaSchema,
|
|
192
278
|
NumberSchema,
|
|
193
|
-
|
|
279
|
+
DateSchema,
|
|
194
280
|
StringFormulaSchema,
|
|
195
281
|
} from "@nakanoaas/notion-valibot-schema";
|
|
196
282
|
|
|
197
283
|
const PageSchema = v.object({
|
|
198
284
|
id: v.string(),
|
|
199
285
|
properties: v.object({
|
|
200
|
-
FormulaText:
|
|
201
|
-
FormulaNumber:
|
|
286
|
+
FormulaText: FormulaSchema(StringFormulaSchema),
|
|
287
|
+
FormulaNumber: FormulaSchema(NumberSchema),
|
|
202
288
|
FormulaBoolean: FormulaSchema(BooleanFormulaSchema),
|
|
203
|
-
FormulaDate:
|
|
289
|
+
FormulaDate: FormulaSchema(DateSchema),
|
|
204
290
|
}),
|
|
205
291
|
});
|
|
206
292
|
|
|
207
293
|
const page = await notion.pages.retrieve({ page_id: "..." });
|
|
208
294
|
const parsed = v.parse(PageSchema, page);
|
|
209
|
-
// parsed.properties.FormulaText:
|
|
210
|
-
// parsed.properties.FormulaNumber:
|
|
295
|
+
// parsed.properties.FormulaText: string
|
|
296
|
+
// parsed.properties.FormulaNumber: number
|
|
211
297
|
// parsed.properties.FormulaBoolean: boolean
|
|
212
|
-
// parsed.properties.FormulaDate:
|
|
298
|
+
// parsed.properties.FormulaDate: Date
|
|
213
299
|
```
|
|
214
300
|
|
|
215
301
|
#### Rollups
|
|
216
|
-
Rollups are powerful but complex. We provide helpers for common rollup types.
|
|
217
302
|
|
|
218
303
|
```ts
|
|
219
|
-
import {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
304
|
+
import {
|
|
305
|
+
RollupSchema, // array rollup → Inferred<schema>[]
|
|
306
|
+
SingleRollupSchema, // array rollup, first item → Inferred<schema>
|
|
307
|
+
NullableSingleRollupSchema, // array rollup, first item or null → Inferred<schema> | null
|
|
308
|
+
RollupScalarSchema, // scalar rollup (number / date) → Inferred<schema>
|
|
224
309
|
NumberSchema,
|
|
225
|
-
|
|
310
|
+
DateSchema,
|
|
226
311
|
} from "@nakanoaas/notion-valibot-schema";
|
|
227
312
|
|
|
228
313
|
const MySchema = v.object({
|
|
229
314
|
// Sum/Average rollup (returns number)
|
|
230
|
-
TotalCost:
|
|
231
|
-
|
|
315
|
+
TotalCost: RollupScalarSchema(NumberSchema),
|
|
316
|
+
|
|
232
317
|
// Date rollup (returns Date)
|
|
233
|
-
LatestMeeting:
|
|
234
|
-
|
|
318
|
+
LatestMeeting: RollupScalarSchema(DateSchema),
|
|
319
|
+
|
|
235
320
|
// Array rollup (e.g., pulling tags from related items)
|
|
236
|
-
AllTags:
|
|
237
|
-
|
|
321
|
+
AllTags: RollupSchema(v.string()),
|
|
322
|
+
|
|
238
323
|
// Single-element array rollup (returns the one item, not an array)
|
|
239
|
-
PrimaryTag:
|
|
240
|
-
|
|
324
|
+
PrimaryTag: SingleRollupSchema(v.string()),
|
|
325
|
+
|
|
241
326
|
// Single-element or empty array rollup (returns item or null)
|
|
242
|
-
OptionalPrimaryTag:
|
|
327
|
+
OptionalPrimaryTag: NullableSingleRollupSchema(v.string()),
|
|
243
328
|
});
|
|
244
329
|
```
|
|
245
330
|
|
|
@@ -259,7 +344,6 @@ import {
|
|
|
259
344
|
PeopleIdSchema,
|
|
260
345
|
PeopleSchema,
|
|
261
346
|
PersonSchema,
|
|
262
|
-
UserOrGroupSchema,
|
|
263
347
|
UserSchema,
|
|
264
348
|
} from "@nakanoaas/notion-valibot-schema";
|
|
265
349
|
|
|
@@ -269,29 +353,27 @@ const PageSchema = v.object({
|
|
|
269
353
|
// Full person details
|
|
270
354
|
People: PeopleSchema(PersonSchema),
|
|
271
355
|
|
|
272
|
-
// IDs only
|
|
356
|
+
// IDs only
|
|
273
357
|
AssigneeIds: PeopleIdSchema,
|
|
274
358
|
|
|
275
|
-
// created_by ID
|
|
359
|
+
// created_by ID
|
|
276
360
|
CreatedById: CreatedByIdSchema,
|
|
277
361
|
|
|
278
|
-
//
|
|
362
|
+
// created_by full user object
|
|
279
363
|
CreatedBy: CreatedBySchema(UserSchema),
|
|
280
364
|
}),
|
|
281
365
|
});
|
|
282
366
|
```
|
|
283
367
|
|
|
284
|
-
|
|
368
|
+
#### Unique ID
|
|
285
369
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
For ID-only extraction, use the convenience schemas instead: `PeopleIdSchema`, `CreatedByIdSchema`, `LastEditedByIdSchema`.
|
|
370
|
+
```ts
|
|
371
|
+
import {
|
|
372
|
+
UniqueIdSchema, // → number (e.g. 123)
|
|
373
|
+
PrefixedUniqueIdSchema, // → string (e.g. "TASK-123"; requires prefix to be non-null)
|
|
374
|
+
FullUniqueIdSchema, // → { prefix: string | null; number: number | null }
|
|
375
|
+
} from "@nakanoaas/notion-valibot-schema";
|
|
376
|
+
```
|
|
295
377
|
|
|
296
378
|
## License
|
|
297
379
|
|
package/dist/checkbox.cjs
CHANGED
|
@@ -14,10 +14,12 @@ valibot = require_runtime.__toESM(valibot, 1);
|
|
|
14
14
|
*
|
|
15
15
|
* **Output:** `boolean`
|
|
16
16
|
*
|
|
17
|
+
* @notionPartial supported
|
|
18
|
+
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
19
21
|
* import * as v from "valibot";
|
|
20
|
-
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-
|
|
22
|
+
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-schema";
|
|
21
23
|
*
|
|
22
24
|
* const PageSchema = v.object({
|
|
23
25
|
* id: v.string(),
|
package/dist/checkbox.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.cjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-
|
|
1
|
+
{"version":3,"file":"checkbox.cjs","names":["v"],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Checkbox: CheckboxSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Checkbox: boolean\n * ```\n */\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,iBAAiBA,QAAE,KAC/BA,QAAE,OAAO,EACR,UAAUA,QAAE,QAAQ,EACrB,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,QAAQ,CAC9B"}
|
package/dist/checkbox.d.cts
CHANGED
|
@@ -13,10 +13,12 @@ import * as v from "valibot";
|
|
|
13
13
|
*
|
|
14
14
|
* **Output:** `boolean`
|
|
15
15
|
*
|
|
16
|
+
* @notionPartial supported
|
|
17
|
+
*
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import * as v from "valibot";
|
|
19
|
-
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-
|
|
21
|
+
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-schema";
|
|
20
22
|
*
|
|
21
23
|
* const PageSchema = v.object({
|
|
22
24
|
* id: v.string(),
|
package/dist/checkbox.d.mts
CHANGED
|
@@ -13,10 +13,12 @@ import * as v from "valibot";
|
|
|
13
13
|
*
|
|
14
14
|
* **Output:** `boolean`
|
|
15
15
|
*
|
|
16
|
+
* @notionPartial supported
|
|
17
|
+
*
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import * as v from "valibot";
|
|
19
|
-
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-
|
|
21
|
+
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-schema";
|
|
20
22
|
*
|
|
21
23
|
* const PageSchema = v.object({
|
|
22
24
|
* id: v.string(),
|
package/dist/checkbox.mjs
CHANGED
|
@@ -12,10 +12,12 @@ import * as v from "valibot";
|
|
|
12
12
|
*
|
|
13
13
|
* **Output:** `boolean`
|
|
14
14
|
*
|
|
15
|
+
* @notionPartial supported
|
|
16
|
+
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```ts
|
|
17
19
|
* import * as v from "valibot";
|
|
18
|
-
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-
|
|
20
|
+
* import { CheckboxSchema } from "@nakanoaas/notion-valibot-schema";
|
|
19
21
|
*
|
|
20
22
|
* const PageSchema = v.object({
|
|
21
23
|
* id: v.string(),
|
package/dist/checkbox.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.mjs","names":[],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-
|
|
1
|
+
{"version":3,"file":"checkbox.mjs","names":[],"sources":["../src/checkbox.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `checkbox` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * checkbox: boolean;\n * }\n * ```\n *\n * **Output:** `boolean`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CheckboxSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * Checkbox: CheckboxSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.Checkbox: boolean\n * ```\n */\nexport const CheckboxSchema = v.pipe(\n\tv.object({\n\t\tcheckbox: v.boolean(),\n\t}),\n\tv.transform((v) => v.checkbox),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,iBAAiB,EAAE,KAC/B,EAAE,OAAO,EACR,UAAU,EAAE,QAAQ,EACrB,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,QAAQ,CAC9B"}
|
package/dist/created-by.cjs
CHANGED
|
@@ -20,6 +20,8 @@ valibot = require_runtime.__toESM(valibot, 1);
|
|
|
20
20
|
*
|
|
21
21
|
* **Output:** `string`
|
|
22
22
|
*
|
|
23
|
+
* @notionPartial supported
|
|
24
|
+
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
|
25
27
|
* import * as v from "valibot";
|
|
@@ -55,6 +57,8 @@ const CreatedByIdSchema = valibot.pipe(valibot.object({ created_by: require_peop
|
|
|
55
57
|
*
|
|
56
58
|
* **Output:** `string | null`
|
|
57
59
|
*
|
|
60
|
+
* @notionPartial supported
|
|
61
|
+
*
|
|
58
62
|
* @example
|
|
59
63
|
* ```ts
|
|
60
64
|
* import * as v from "valibot";
|
|
@@ -94,7 +98,11 @@ const NullableCreatedByNameSchema = valibot.pipe(valibot.object({ created_by: re
|
|
|
94
98
|
*
|
|
95
99
|
* **Output:** The output type depends on the schema passed as a parameter.
|
|
96
100
|
*
|
|
101
|
+
* @notionPartial supported
|
|
102
|
+
* @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).
|
|
103
|
+
*
|
|
97
104
|
* @param schema - A schema that validates the `created_by` user or group object.
|
|
105
|
+
* Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.
|
|
98
106
|
*
|
|
99
107
|
* @example
|
|
100
108
|
* ```ts
|
package/dist/created-by.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created-by.cjs","names":["v","UserOrGroupIdSchema","UserOrGroupSchema"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n\n/**\n * Schema to extract the `created_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableCreatedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": NullableCreatedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string | null\n * ```\n */\nexport const NullableCreatedByNameSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.created_by.name),\n);\n\n/**\n * Schema factory to extract the `created_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @param schema - A schema that validates the `created_by` user or group object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * CreatedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function CreatedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tcreated_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.created_by),\n\t) as v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"created-by.cjs","names":["v","UserOrGroupIdSchema","UserOrGroupSchema"],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n\n/**\n * Schema to extract the `created_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableCreatedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": NullableCreatedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string | null\n * ```\n */\nexport const NullableCreatedByNameSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.created_by.name),\n);\n\n/**\n * Schema factory to extract the `created_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @notionPartial supported\n * @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).\n *\n * @param schema - A schema that validates the `created_by` user or group object.\n * Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * CreatedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function CreatedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tcreated_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.created_by),\n\t) as v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,YAAYC,eAAAA,oBACb,CAAC,GACDD,QAAE,WAAW,MAAM,EAAE,WAAW,EAAE,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,8BAA8BA,QAAE,KAC5CA,QAAE,OAAO,EACR,YAAYE,eAAAA,kBACb,CAAC,GACDF,QAAE,WAAW,MAAM,EAAE,WAAW,IAAI,CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,gBAGf,QACqE;CACrE,OAAOA,QAAE,KACRA,QAAE,OAAO,EACR,YAAY,OACb,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,UAAU,CAChC;AACD"}
|
package/dist/created-by.d.cts
CHANGED
|
@@ -18,6 +18,8 @@ import * as v from "valibot";
|
|
|
18
18
|
*
|
|
19
19
|
* **Output:** `string`
|
|
20
20
|
*
|
|
21
|
+
* @notionPartial supported
|
|
22
|
+
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```ts
|
|
23
25
|
* import * as v from "valibot";
|
|
@@ -61,6 +63,8 @@ declare const CreatedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
61
63
|
*
|
|
62
64
|
* **Output:** `string | null`
|
|
63
65
|
*
|
|
66
|
+
* @notionPartial supported
|
|
67
|
+
*
|
|
64
68
|
* @example
|
|
65
69
|
* ```ts
|
|
66
70
|
* import * as v from "valibot";
|
|
@@ -112,7 +116,11 @@ declare const NullableCreatedByNameSchema: v.SchemaWithPipe<readonly [v.ObjectSc
|
|
|
112
116
|
*
|
|
113
117
|
* **Output:** The output type depends on the schema passed as a parameter.
|
|
114
118
|
*
|
|
119
|
+
* @notionPartial supported
|
|
120
|
+
* @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).
|
|
121
|
+
*
|
|
115
122
|
* @param schema - A schema that validates the `created_by` user or group object.
|
|
123
|
+
* Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.
|
|
116
124
|
*
|
|
117
125
|
* @example
|
|
118
126
|
* ```ts
|
package/dist/created-by.d.mts
CHANGED
|
@@ -18,6 +18,8 @@ import * as v from "valibot";
|
|
|
18
18
|
*
|
|
19
19
|
* **Output:** `string`
|
|
20
20
|
*
|
|
21
|
+
* @notionPartial supported
|
|
22
|
+
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```ts
|
|
23
25
|
* import * as v from "valibot";
|
|
@@ -61,6 +63,8 @@ declare const CreatedByIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
61
63
|
*
|
|
62
64
|
* **Output:** `string | null`
|
|
63
65
|
*
|
|
66
|
+
* @notionPartial supported
|
|
67
|
+
*
|
|
64
68
|
* @example
|
|
65
69
|
* ```ts
|
|
66
70
|
* import * as v from "valibot";
|
|
@@ -112,7 +116,11 @@ declare const NullableCreatedByNameSchema: v.SchemaWithPipe<readonly [v.ObjectSc
|
|
|
112
116
|
*
|
|
113
117
|
* **Output:** The output type depends on the schema passed as a parameter.
|
|
114
118
|
*
|
|
119
|
+
* @notionPartial supported
|
|
120
|
+
* @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).
|
|
121
|
+
*
|
|
115
122
|
* @param schema - A schema that validates the `created_by` user or group object.
|
|
123
|
+
* Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.
|
|
116
124
|
*
|
|
117
125
|
* @example
|
|
118
126
|
* ```ts
|
package/dist/created-by.mjs
CHANGED
|
@@ -18,6 +18,8 @@ import * as v from "valibot";
|
|
|
18
18
|
*
|
|
19
19
|
* **Output:** `string`
|
|
20
20
|
*
|
|
21
|
+
* @notionPartial supported
|
|
22
|
+
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```ts
|
|
23
25
|
* import * as v from "valibot";
|
|
@@ -53,6 +55,8 @@ const CreatedByIdSchema = v.pipe(v.object({ created_by: UserOrGroupIdSchema }),
|
|
|
53
55
|
*
|
|
54
56
|
* **Output:** `string | null`
|
|
55
57
|
*
|
|
58
|
+
* @notionPartial supported
|
|
59
|
+
*
|
|
56
60
|
* @example
|
|
57
61
|
* ```ts
|
|
58
62
|
* import * as v from "valibot";
|
|
@@ -92,7 +96,11 @@ const NullableCreatedByNameSchema = v.pipe(v.object({ created_by: UserOrGroupSch
|
|
|
92
96
|
*
|
|
93
97
|
* **Output:** The output type depends on the schema passed as a parameter.
|
|
94
98
|
*
|
|
99
|
+
* @notionPartial supported
|
|
100
|
+
* @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).
|
|
101
|
+
*
|
|
95
102
|
* @param schema - A schema that validates the `created_by` user or group object.
|
|
103
|
+
* Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.
|
|
96
104
|
*
|
|
97
105
|
* @example
|
|
98
106
|
* ```ts
|
package/dist/created-by.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created-by.mjs","names":[],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n\n/**\n * Schema to extract the `created_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableCreatedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": NullableCreatedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string | null\n * ```\n */\nexport const NullableCreatedByNameSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.created_by.name),\n);\n\n/**\n * Schema factory to extract the `created_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @param schema - A schema that validates the `created_by` user or group object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * CreatedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function CreatedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tcreated_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.created_by),\n\t) as v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"created-by.mjs","names":[],"sources":["../src/created-by.ts"],"sourcesContent":["import * as v from \"valibot\";\n\nimport { UserOrGroupIdSchema, UserOrGroupSchema } from \"./people\";\n\n/**\n * Schema to extract the `created_by` person ID from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedByIdSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedByIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string\n * ```\n */\nexport const CreatedByIdSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupIdSchema,\n\t}),\n\tv.transform((v) => v.created_by.id),\n);\n\n/**\n * Schema to extract the `created_by` person name from a Notion page.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** `string | null`\n *\n * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableCreatedByNameSchema } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": NullableCreatedByNameSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: string | null\n * ```\n */\nexport const NullableCreatedByNameSchema = v.pipe(\n\tv.object({\n\t\tcreated_by: UserOrGroupSchema,\n\t}),\n\tv.transform((v) => v.created_by.name),\n);\n\n/**\n * Schema factory to extract the `created_by` person object from a Notion page.\n *\n * This is a generic schema factory that accepts another schema as a parameter,\n * allowing you to combine it with building-block schemas such as\n * `UserOrGroupSchema`, `UserSchema`, or `PersonSchema`.\n *\n * **Input:**\n * ```\n * {\n * created_by: {\n * id: string;\n * object: \"user\" | \"group\";\n * name?: string | null;\n * ...\n * }\n * }\n * ```\n *\n * **Output:** The output type depends on the schema passed as a parameter.\n *\n * @notionPartial supported\n * @notionPartialNote Supported with `UserOrGroupSchema` or `UserSchema`. Not supported with `PersonSchema` (requires full person object).\n *\n * @param schema - A schema that validates the `created_by` user or group object.\n * Use `UserOrGroupSchema` or `UserSchema` for partial responses; `PersonSchema` requires a full person object.\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import {\n * CreatedBySchema,\n * UserOrGroupSchema,\n * } from \"@nakanoaas/notion-valibot-schema\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * \"Created By\": CreatedBySchema(UserOrGroupSchema),\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties[\"Created By\"]: { id: string; object: \"user\" | \"group\"; name: string | null }\n * ```\n */\nexport function CreatedBySchema<\n\tS extends v.GenericSchema<{ id: string; object: \"user\" | \"group\" }, unknown>,\n>(\n\tschema: S,\n): v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>> {\n\treturn v.pipe(\n\t\tv.object({\n\t\t\tcreated_by: schema,\n\t\t}),\n\t\tv.transform((v) => v.created_by),\n\t) as v.GenericSchema<{ created_by: v.InferInput<S> }, v.InferOutput<S>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,oBAAoB,EAAE,KAClC,EAAE,OAAO,EACR,YAAY,oBACb,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,WAAW,EAAE,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,8BAA8B,EAAE,KAC5C,EAAE,OAAO,EACR,YAAY,kBACb,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,WAAW,IAAI,CACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,gBAGf,QACqE;CACrE,OAAO,EAAE,KACR,EAAE,OAAO,EACR,YAAY,OACb,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,UAAU,CAChC;AACD"}
|
package/dist/created-time.cjs
CHANGED
|
@@ -14,10 +14,12 @@ valibot = require_runtime.__toESM(valibot, 1);
|
|
|
14
14
|
*
|
|
15
15
|
* **Output:** `Date`
|
|
16
16
|
*
|
|
17
|
+
* @notionPartial supported
|
|
18
|
+
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
19
21
|
* import * as v from "valibot";
|
|
20
|
-
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-
|
|
22
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-schema";
|
|
21
23
|
*
|
|
22
24
|
* const PageSchema = v.object({
|
|
23
25
|
* id: v.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created-time.cjs","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-
|
|
1
|
+
{"version":3,"file":"created-time.cjs","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 * @notionPartial supported\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { CreatedTimeSchema } from \"@nakanoaas/notion-valibot-schema\";\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,oBAAoBA,QAAE,KAClCA,QAAE,OAAO,EACR,cAAcA,QAAE,OAAO,EACxB,CAAC,GACDA,QAAE,WAAW,MAAM,IAAI,KAAK,EAAE,YAAY,CAAC,CAC5C"}
|
package/dist/created-time.d.cts
CHANGED
|
@@ -13,10 +13,12 @@ import * as v from "valibot";
|
|
|
13
13
|
*
|
|
14
14
|
* **Output:** `Date`
|
|
15
15
|
*
|
|
16
|
+
* @notionPartial supported
|
|
17
|
+
*
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import * as v from "valibot";
|
|
19
|
-
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-
|
|
21
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-schema";
|
|
20
22
|
*
|
|
21
23
|
* const PageSchema = v.object({
|
|
22
24
|
* id: v.string(),
|
package/dist/created-time.d.mts
CHANGED
|
@@ -13,10 +13,12 @@ import * as v from "valibot";
|
|
|
13
13
|
*
|
|
14
14
|
* **Output:** `Date`
|
|
15
15
|
*
|
|
16
|
+
* @notionPartial supported
|
|
17
|
+
*
|
|
16
18
|
* @example
|
|
17
19
|
* ```ts
|
|
18
20
|
* import * as v from "valibot";
|
|
19
|
-
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-
|
|
21
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-schema";
|
|
20
22
|
*
|
|
21
23
|
* const PageSchema = v.object({
|
|
22
24
|
* id: v.string(),
|
package/dist/created-time.mjs
CHANGED
|
@@ -12,10 +12,12 @@ import * as v from "valibot";
|
|
|
12
12
|
*
|
|
13
13
|
* **Output:** `Date`
|
|
14
14
|
*
|
|
15
|
+
* @notionPartial supported
|
|
16
|
+
*
|
|
15
17
|
* @example
|
|
16
18
|
* ```ts
|
|
17
19
|
* import * as v from "valibot";
|
|
18
|
-
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-
|
|
20
|
+
* import { CreatedTimeSchema } from "@nakanoaas/notion-valibot-schema";
|
|
19
21
|
*
|
|
20
22
|
* const PageSchema = v.object({
|
|
21
23
|
* id: v.string(),
|