@nakanoaas/notion-valibot-schema 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -176,7 +176,7 @@ const tasks = v.parse(TaskListSchema, results);
176
176
  | **Created/Edited By** (convenience) | `CreatedByIdSchema` / `NullableCreatedByNameSchema` / `LastEditedByIdSchema` / `NullableLastEditedByNameSchema` | `string` / `string \| null` |
177
177
  | **Created/Edited Time**| `CreatedTimeSchema` / `LastEditedTimeSchema` | `Date` |
178
178
  | **Place** | `PlaceSchema` / `NullablePlaceSchema` | `{ lat: number; lon: number; name?: string \| null; address?: string \| null }` / `{ lat: number; lon: number; name?: string \| null; address?: string \| null } \| null` |
179
- | **Unique ID** | `UniqueIdNumberSchema` / `NullableUniqueIdSchema` | `number` / `{ prefix: string \| null; number: number \| null }` |
179
+ | **Unique ID** | `UniqueIdNumberSchema` / `PrefixedUniqueIdStringSchema` / `NullableUniqueIdSchema` | `number` / `string` (e.g. `"PREFIX-123"`) / `{ prefix: string \| null; number: number \| null }` |
180
180
  | **Verification** | `VerificationSchema` / `NullableVerificationSchema` | `{ state: "unverified" \| "verified" \| "expired"; date: DateObject \| null; verified_by: { id: string; object: "user"; name: string \| null; avatar_url: string \| null } \| null }` / same \| `null` |
181
181
 
182
182
  ### Advanced Schemas
package/dist/index.cjs CHANGED
@@ -65,6 +65,7 @@ exports.PeopleSchema = require_people.PeopleSchema;
65
65
  exports.PersonSchema = require_people.PersonSchema;
66
66
  exports.PhoneNumberSchema = require_phone_number.PhoneNumberSchema;
67
67
  exports.PlaceSchema = require_place.PlaceSchema;
68
+ exports.PrefixedUniqueIdStringSchema = require_unique_id.PrefixedUniqueIdStringSchema;
68
69
  exports.RangeDateSchema = require_date.RangeDateSchema;
69
70
  exports.RelationSchema = require_relation.RelationSchema;
70
71
  exports.RichTextSchema = require_text.RichTextSchema;
package/dist/index.d.cts CHANGED
@@ -17,7 +17,7 @@ import { NullableSingleRollupArraySchema, RollupArraySchema, RollupSimpleSchema,
17
17
  import { NullableSelectSchema, SelectSchema } from "./select.cjs";
18
18
  import { NullableStatusSchema, StatusSchema } from "./status.cjs";
19
19
  import { NullableRichTextSchema, NullableTitleSchema, RichTextSchema, TitleSchema } from "./text.cjs";
20
- import { NullableUniqueIdSchema, UniqueIdNumberSchema } from "./unique-id.cjs";
20
+ import { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema } from "./unique-id.cjs";
21
21
  import { NullableUrlSchema, UrlSchema } from "./url.cjs";
22
22
  import { NullableVerificationSchema, VerificationSchema } from "./verification.cjs";
23
- export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
23
+ export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, PrefixedUniqueIdStringSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
package/dist/index.d.mts CHANGED
@@ -17,7 +17,7 @@ import { NullableSingleRollupArraySchema, RollupArraySchema, RollupSimpleSchema,
17
17
  import { NullableSelectSchema, SelectSchema } from "./select.mjs";
18
18
  import { NullableStatusSchema, StatusSchema } from "./status.mjs";
19
19
  import { NullableRichTextSchema, NullableTitleSchema, RichTextSchema, TitleSchema } from "./text.mjs";
20
- import { NullableUniqueIdSchema, UniqueIdNumberSchema } from "./unique-id.mjs";
20
+ import { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema } from "./unique-id.mjs";
21
21
  import { NullableUrlSchema, UrlSchema } from "./url.mjs";
22
22
  import { NullableVerificationSchema, VerificationSchema } from "./verification.mjs";
23
- export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
23
+ export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, PrefixedUniqueIdStringSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import { NullableSingleRollupArraySchema, RollupArraySchema, RollupSimpleSchema,
17
17
  import { NullableSelectSchema, SelectSchema } from "./select.mjs";
18
18
  import { NullableStatusSchema, StatusSchema } from "./status.mjs";
19
19
  import { NullableRichTextSchema, NullableTitleSchema, RichTextSchema, TitleSchema } from "./text.mjs";
20
- import { NullableUniqueIdSchema, UniqueIdNumberSchema } from "./unique-id.mjs";
20
+ import { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema } from "./unique-id.mjs";
21
21
  import { NullableUrlSchema, UrlSchema } from "./url.mjs";
22
22
  import { NullableVerificationSchema, VerificationSchema } from "./verification.mjs";
23
- export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
23
+ export { BooleanFormulaSchema, BotSchema, CheckboxSchema, CreatedByIdSchema, CreatedBySchema, CreatedTimeSchema, DateObjectSchema, EmailSchema, FileSchema, FormulaSchema, FullDateSchema, LastEditedByIdSchema, LastEditedBySchema, LastEditedTimeSchema, MultiSelectSchema, NullableBooleanFormulaSchema, NullableCreatedByNameSchema, NullableEmailSchema, NullableFullDateSchema, NullableLastEditedByNameSchema, NullableNumberSchema, NullablePhoneNumberSchema, NullablePlaceSchema, NullableRangeDateSchema, NullableRichTextSchema, NullableSelectSchema, NullableSingleDateSchema, NullableSingleFileSchema, NullableSinglePeopleIdSchema, NullableSinglePeopleSchema, NullableSingleRelationSchema, NullableSingleRollupArraySchema, NullableStatusSchema, NullableStringFormulaSchema, NullableTitleSchema, NullableUniqueIdSchema, NullableUrlSchema, NullableVerificationSchema, NumberSchema, PeopleIdSchema, PeopleSchema, PersonSchema, PhoneNumberSchema, PlaceSchema, PrefixedUniqueIdStringSchema, RangeDateSchema, RelationSchema, RichTextSchema, RollupArraySchema, RollupSimpleSchema, SelectSchema, SingleDateSchema, SingleFileSchema, SinglePeopleIdSchema, SinglePeopleSchema, SingleRelationSchema, SingleRollupArraySchema, StatusSchema, StringFormulaSchema, TitleSchema, UniqueIdNumberSchema, UrlSchema, UserOrGroupIdSchema, UserOrGroupSchema, UserSchema, VerificationSchema };
@@ -35,6 +35,42 @@ valibot = require_runtime.__toESM(valibot, 1);
35
35
  */
36
36
  const UniqueIdNumberSchema = valibot.pipe(valibot.object({ unique_id: valibot.object({ number: valibot.number() }) }), valibot.transform((v) => v.unique_id.number));
37
37
  /**
38
+ * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.
39
+ *
40
+ * **Input:**
41
+ * ```
42
+ * {
43
+ * unique_id: {
44
+ * prefix: string;
45
+ * number: number;
46
+ * };
47
+ * }
48
+ * ```
49
+ *
50
+ * **Output:** `string` (e.g. `"PREFIX-123"`)
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import * as v from "valibot";
55
+ * import { PrefixedUniqueIdStringSchema } from "@nakanoaas/notion-valibot-utils";
56
+ *
57
+ * const PageSchema = v.object({
58
+ * id: v.string(),
59
+ * properties: v.object({
60
+ * ID: PrefixedUniqueIdStringSchema,
61
+ * }),
62
+ * });
63
+ *
64
+ * const page = await notion.pages.retrieve({ page_id: "..." });
65
+ * const parsed = v.parse(PageSchema, page);
66
+ * // parsed.properties.ID: string (e.g. "PREFIX-123")
67
+ * ```
68
+ */
69
+ const PrefixedUniqueIdStringSchema = valibot.pipe(valibot.object({ unique_id: valibot.object({
70
+ prefix: valibot.string(),
71
+ number: valibot.number()
72
+ }) }), valibot.transform((v) => `${v.unique_id.prefix}-${v.unique_id.number}`));
73
+ /**
38
74
  * Schema to extract the `unique_id` property from a Notion page property.
39
75
  *
40
76
  * **Input:**
@@ -78,6 +114,7 @@ const NullableUniqueIdSchema = valibot.pipe(valibot.object({ unique_id: valibot.
78
114
  }) }), valibot.transform((v) => v.unique_id));
79
115
  //#endregion
80
116
  exports.NullableUniqueIdSchema = NullableUniqueIdSchema;
117
+ exports.PrefixedUniqueIdStringSchema = PrefixedUniqueIdStringSchema;
81
118
  exports.UniqueIdNumberSchema = UniqueIdNumberSchema;
82
119
 
83
120
  //# sourceMappingURL=unique-id.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"unique-id.cjs","names":["v"],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `unique_id` property number from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { UniqueIdNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: UniqueIdNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: number\n * ```\n */\nexport const UniqueIdNumberSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id.number),\n);\n\n/**\n * Schema to extract the `unique_id` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string | null;\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * prefix: string | null;\n * number: number | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableUniqueIdSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: NullableUniqueIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: { prefix: string | null; number: number | null }\n * ```\n */\nexport const NullableUniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO,EACnB,QAAQA,QAAE,OAAO,EAClB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,UAAU,MAAM,CACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,yBAAyBA,QAAE,KACvCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO;CACnB,QAAQA,QAAE,SAASA,QAAE,OAAO,CAAC;CAC7B,QAAQA,QAAE,SAASA,QAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,SAAS,CAC/B"}
1
+ {"version":3,"file":"unique-id.cjs","names":["v"],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `unique_id` property number from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { UniqueIdNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: UniqueIdNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: number\n * ```\n */\nexport const UniqueIdNumberSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id.number),\n);\n\n/**\n * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string;\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `string` (e.g. `\"PREFIX-123\"`)\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PrefixedUniqueIdStringSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: PrefixedUniqueIdStringSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: string (e.g. \"PREFIX-123\")\n * ```\n */\nexport const PrefixedUniqueIdStringSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.string(),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => `${v.unique_id.prefix}-${v.unique_id.number}`),\n);\n\n/**\n * Schema to extract the `unique_id` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string | null;\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * prefix: string | null;\n * number: number | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableUniqueIdSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: NullableUniqueIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: { prefix: string | null; number: number | null }\n * ```\n */\nexport const NullableUniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuBA,QAAE,KACrCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO,EACnB,QAAQA,QAAE,OAAO,EAClB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,UAAU,MAAM,CACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,+BAA+BA,QAAE,KAC7CA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO;CACnB,QAAQA,QAAE,OAAO;CACjB,QAAQA,QAAE,OAAO;AAClB,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,GAAG,EAAE,UAAU,OAAO,GAAG,EAAE,UAAU,QAAQ,CACjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,yBAAyBA,QAAE,KACvCA,QAAE,OAAO,EACR,WAAWA,QAAE,OAAO;CACnB,QAAQA,QAAE,SAASA,QAAE,OAAO,CAAC;CAC7B,QAAQA,QAAE,SAASA,QAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACDA,QAAE,WAAW,MAAM,EAAE,SAAS,CAC/B"}
@@ -41,6 +41,49 @@ declare const UniqueIdNumberSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
41
41
  number: number;
42
42
  };
43
43
  }, number>]>;
44
+ /**
45
+ * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.
46
+ *
47
+ * **Input:**
48
+ * ```
49
+ * {
50
+ * unique_id: {
51
+ * prefix: string;
52
+ * number: number;
53
+ * };
54
+ * }
55
+ * ```
56
+ *
57
+ * **Output:** `string` (e.g. `"PREFIX-123"`)
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { PrefixedUniqueIdStringSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * ID: PrefixedUniqueIdStringSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.ID: string (e.g. "PREFIX-123")
74
+ * ```
75
+ */
76
+ declare const PrefixedUniqueIdStringSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
77
+ readonly unique_id: v.ObjectSchema<{
78
+ readonly prefix: v.StringSchema<undefined>;
79
+ readonly number: v.NumberSchema<undefined>;
80
+ }, undefined>;
81
+ }, undefined>, v.TransformAction<{
82
+ unique_id: {
83
+ prefix: string;
84
+ number: number;
85
+ };
86
+ }, string>]>;
44
87
  /**
45
88
  * Schema to extract the `unique_id` property from a Notion page property.
46
89
  *
@@ -94,5 +137,5 @@ declare const NullableUniqueIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
94
137
  number: number | null;
95
138
  }>]>;
96
139
  //#endregion
97
- export { NullableUniqueIdSchema, UniqueIdNumberSchema };
140
+ export { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema };
98
141
  //# sourceMappingURL=unique-id.d.cts.map
@@ -41,6 +41,49 @@ declare const UniqueIdNumberSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
41
41
  number: number;
42
42
  };
43
43
  }, number>]>;
44
+ /**
45
+ * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.
46
+ *
47
+ * **Input:**
48
+ * ```
49
+ * {
50
+ * unique_id: {
51
+ * prefix: string;
52
+ * number: number;
53
+ * };
54
+ * }
55
+ * ```
56
+ *
57
+ * **Output:** `string` (e.g. `"PREFIX-123"`)
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import * as v from "valibot";
62
+ * import { PrefixedUniqueIdStringSchema } from "@nakanoaas/notion-valibot-utils";
63
+ *
64
+ * const PageSchema = v.object({
65
+ * id: v.string(),
66
+ * properties: v.object({
67
+ * ID: PrefixedUniqueIdStringSchema,
68
+ * }),
69
+ * });
70
+ *
71
+ * const page = await notion.pages.retrieve({ page_id: "..." });
72
+ * const parsed = v.parse(PageSchema, page);
73
+ * // parsed.properties.ID: string (e.g. "PREFIX-123")
74
+ * ```
75
+ */
76
+ declare const PrefixedUniqueIdStringSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
77
+ readonly unique_id: v.ObjectSchema<{
78
+ readonly prefix: v.StringSchema<undefined>;
79
+ readonly number: v.NumberSchema<undefined>;
80
+ }, undefined>;
81
+ }, undefined>, v.TransformAction<{
82
+ unique_id: {
83
+ prefix: string;
84
+ number: number;
85
+ };
86
+ }, string>]>;
44
87
  /**
45
88
  * Schema to extract the `unique_id` property from a Notion page property.
46
89
  *
@@ -94,5 +137,5 @@ declare const NullableUniqueIdSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
94
137
  number: number | null;
95
138
  }>]>;
96
139
  //#endregion
97
- export { NullableUniqueIdSchema, UniqueIdNumberSchema };
140
+ export { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema };
98
141
  //# sourceMappingURL=unique-id.d.mts.map
@@ -33,6 +33,42 @@ import * as v from "valibot";
33
33
  */
34
34
  const UniqueIdNumberSchema = v.pipe(v.object({ unique_id: v.object({ number: v.number() }) }), v.transform((v) => v.unique_id.number));
35
35
  /**
36
+ * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.
37
+ *
38
+ * **Input:**
39
+ * ```
40
+ * {
41
+ * unique_id: {
42
+ * prefix: string;
43
+ * number: number;
44
+ * };
45
+ * }
46
+ * ```
47
+ *
48
+ * **Output:** `string` (e.g. `"PREFIX-123"`)
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import * as v from "valibot";
53
+ * import { PrefixedUniqueIdStringSchema } from "@nakanoaas/notion-valibot-utils";
54
+ *
55
+ * const PageSchema = v.object({
56
+ * id: v.string(),
57
+ * properties: v.object({
58
+ * ID: PrefixedUniqueIdStringSchema,
59
+ * }),
60
+ * });
61
+ *
62
+ * const page = await notion.pages.retrieve({ page_id: "..." });
63
+ * const parsed = v.parse(PageSchema, page);
64
+ * // parsed.properties.ID: string (e.g. "PREFIX-123")
65
+ * ```
66
+ */
67
+ const PrefixedUniqueIdStringSchema = v.pipe(v.object({ unique_id: v.object({
68
+ prefix: v.string(),
69
+ number: v.number()
70
+ }) }), v.transform((v) => `${v.unique_id.prefix}-${v.unique_id.number}`));
71
+ /**
36
72
  * Schema to extract the `unique_id` property from a Notion page property.
37
73
  *
38
74
  * **Input:**
@@ -75,6 +111,6 @@ const NullableUniqueIdSchema = v.pipe(v.object({ unique_id: v.object({
75
111
  number: v.nullable(v.number())
76
112
  }) }), v.transform((v) => v.unique_id));
77
113
  //#endregion
78
- export { NullableUniqueIdSchema, UniqueIdNumberSchema };
114
+ export { NullableUniqueIdSchema, PrefixedUniqueIdStringSchema, UniqueIdNumberSchema };
79
115
 
80
116
  //# sourceMappingURL=unique-id.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"unique-id.mjs","names":[],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `unique_id` property number from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { UniqueIdNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: UniqueIdNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: number\n * ```\n */\nexport const UniqueIdNumberSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id.number),\n);\n\n/**\n * Schema to extract the `unique_id` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string | null;\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * prefix: string | null;\n * number: number | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableUniqueIdSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: NullableUniqueIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: { prefix: string | null; number: number | null }\n * ```\n */\nexport const NullableUniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,WAAW,EAAE,OAAO,EACnB,QAAQ,EAAE,OAAO,EAClB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,UAAU,MAAM,CACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,yBAAyB,EAAE,KACvC,EAAE,OAAO,EACR,WAAW,EAAE,OAAO;CACnB,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;CAC7B,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,SAAS,CAC/B"}
1
+ {"version":3,"file":"unique-id.mjs","names":[],"sources":["../src/unique-id.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Schema to extract the `unique_id` property number from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `number`\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { UniqueIdNumberSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: UniqueIdNumberSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: number\n * ```\n */\nexport const UniqueIdNumberSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id.number),\n);\n\n/**\n * Schema to extract the `unique_id` property as a prefixed string from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string;\n * number: number;\n * };\n * }\n * ```\n *\n * **Output:** `string` (e.g. `\"PREFIX-123\"`)\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { PrefixedUniqueIdStringSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: PrefixedUniqueIdStringSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: string (e.g. \"PREFIX-123\")\n * ```\n */\nexport const PrefixedUniqueIdStringSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.string(),\n\t\t\tnumber: v.number(),\n\t\t}),\n\t}),\n\tv.transform((v) => `${v.unique_id.prefix}-${v.unique_id.number}`),\n);\n\n/**\n * Schema to extract the `unique_id` property from a Notion page property.\n *\n * **Input:**\n * ```\n * {\n * unique_id: {\n * prefix: string | null;\n * number: number | null;\n * };\n * }\n * ```\n *\n * **Output:**\n * ```\n * {\n * prefix: string | null;\n * number: number | null;\n * }\n * ```\n *\n * @example\n * ```ts\n * import * as v from \"valibot\";\n * import { NullableUniqueIdSchema } from \"@nakanoaas/notion-valibot-utils\";\n *\n * const PageSchema = v.object({\n * id: v.string(),\n * properties: v.object({\n * ID: NullableUniqueIdSchema,\n * }),\n * });\n *\n * const page = await notion.pages.retrieve({ page_id: \"...\" });\n * const parsed = v.parse(PageSchema, page);\n * // parsed.properties.ID: { prefix: string | null; number: number | null }\n * ```\n */\nexport const NullableUniqueIdSchema = v.pipe(\n\tv.object({\n\t\tunique_id: v.object({\n\t\t\tprefix: v.nullable(v.string()),\n\t\t\tnumber: v.nullable(v.number()),\n\t\t}),\n\t}),\n\tv.transform((v) => v.unique_id),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBAAuB,EAAE,KACrC,EAAE,OAAO,EACR,WAAW,EAAE,OAAO,EACnB,QAAQ,EAAE,OAAO,EAClB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,UAAU,MAAM,CACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,+BAA+B,EAAE,KAC7C,EAAE,OAAO,EACR,WAAW,EAAE,OAAO;CACnB,QAAQ,EAAE,OAAO;CACjB,QAAQ,EAAE,OAAO;AAClB,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,GAAG,EAAE,UAAU,OAAO,GAAG,EAAE,UAAU,QAAQ,CACjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,yBAAyB,EAAE,KACvC,EAAE,OAAO,EACR,WAAW,EAAE,OAAO;CACnB,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;CAC7B,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;AAC9B,CAAC,EACF,CAAC,GACD,EAAE,WAAW,MAAM,EAAE,SAAS,CAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakanoaas/notion-valibot-schema",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Turn Notion's nested API responses into clean, typed JavaScript values.",
5
5
  "author": "Nakano as a Service",
6
6
  "license": "MIT",