@visus-io/notion-sdk-ts 3.1.0 → 3.1.1
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 +17 -85
- package/dist/api/asyncTasks.api.d.ts +5 -3
- package/dist/api/asyncTasks.api.js +5 -3
- package/dist/api/base.api.d.ts +15 -4
- package/dist/api/base.api.js +19 -8
- package/dist/api/blocks.api.d.ts +2 -0
- package/dist/api/blocks.api.js +5 -2
- package/dist/api/comments.api.d.ts +2 -0
- package/dist/api/comments.api.js +2 -0
- package/dist/api/customEmojis.api.d.ts +2 -0
- package/dist/api/customEmojis.api.js +2 -0
- package/dist/api/dataSources.api.d.ts +5 -3
- package/dist/api/dataSources.api.js +4 -1
- package/dist/api/databases.api.d.ts +7 -5
- package/dist/api/databases.api.js +4 -1
- package/dist/api/fileUploads.api.d.ts +7 -4
- package/dist/api/fileUploads.api.js +11 -7
- package/dist/api/pages.api.d.ts +5 -3
- package/dist/api/pages.api.js +5 -3
- package/dist/api/search.api.d.ts +4 -2
- package/dist/api/search.api.js +5 -2
- package/dist/api/users.api.d.ts +2 -0
- package/dist/api/users.api.js +2 -0
- package/dist/api/views.api.d.ts +15 -13
- package/dist/api/views.api.js +10 -7
- package/dist/client.d.ts +17 -17
- package/dist/client.js +22 -27
- package/dist/errors.d.ts +14 -4
- package/dist/errors.js +10 -4
- package/dist/helpers/block.helpers.d.ts +22 -15
- package/dist/helpers/block.helpers.js +14 -12
- package/dist/helpers/file.helpers.d.ts +12 -6
- package/dist/helpers/file.helpers.js +12 -6
- package/dist/helpers/filter.helpers.d.ts +2 -0
- package/dist/helpers/filter.helpers.js +2 -0
- package/dist/helpers/pagination.helpers.d.ts +52 -36
- package/dist/helpers/pagination.helpers.js +49 -29
- package/dist/helpers/parent.helpers.d.ts +5 -3
- package/dist/helpers/parent.helpers.js +5 -3
- package/dist/helpers/property.helpers.d.ts +2 -0
- package/dist/helpers/property.helpers.js +3 -1
- package/dist/helpers/richText.helpers.d.ts +10 -5
- package/dist/helpers/richText.helpers.js +11 -6
- package/dist/helpers/sort.helpers.d.ts +2 -0
- package/dist/helpers/sort.helpers.js +2 -0
- package/dist/helpers/webhook.helpers.d.ts +14 -12
- package/dist/helpers/webhook.helpers.js +17 -15
- package/dist/models/asyncTask.model.d.ts +8 -6
- package/dist/models/asyncTask.model.js +8 -6
- package/dist/models/base.model.d.ts +16 -4
- package/dist/models/base.model.js +17 -5
- package/dist/models/block.model.d.ts +6 -2
- package/dist/models/block.model.js +48 -36
- package/dist/models/comment.model.d.ts +4 -2
- package/dist/models/comment.model.js +4 -2
- package/dist/models/customEmoji.model.d.ts +7 -5
- package/dist/models/customEmoji.model.js +7 -5
- package/dist/models/dataSource.model.d.ts +4 -2
- package/dist/models/dataSource.model.js +4 -2
- package/dist/models/database.model.d.ts +6 -2
- package/dist/models/database.model.js +8 -4
- package/dist/models/fileUpload.model.d.ts +6 -4
- package/dist/models/fileUpload.model.js +6 -4
- package/dist/models/page.model.d.ts +6 -2
- package/dist/models/page.model.js +8 -4
- package/dist/models/richText.model.d.ts +3 -1
- package/dist/models/richText.model.js +3 -1
- package/dist/models/user.model.d.ts +4 -2
- package/dist/models/user.model.js +4 -2
- package/dist/models/view.model.d.ts +9 -7
- package/dist/models/view.model.js +9 -7
- package/dist/notion.d.ts +6 -1
- package/dist/notion.js +6 -1
- package/dist/schemas/asyncTask.schema.d.ts +11 -0
- package/dist/schemas/asyncTask.schema.js +5 -0
- package/dist/schemas/block.schema.d.ts +12 -1
- package/dist/schemas/block.schema.js +6 -1
- package/dist/schemas/codeLanguages.d.ts +7 -1
- package/dist/schemas/codeLanguages.js +4 -1
- package/dist/schemas/colors.d.ts +7 -1
- package/dist/schemas/colors.js +4 -1
- package/dist/schemas/comment.schema.d.ts +20 -2
- package/dist/schemas/comment.schema.js +11 -2
- package/dist/schemas/customEmoji.schema.d.ts +5 -0
- package/dist/schemas/customEmoji.schema.js +2 -0
- package/dist/schemas/dataSource.schema.d.ts +19 -3
- package/dist/schemas/dataSource.schema.js +12 -5
- package/dist/schemas/database.schema.d.ts +13 -1
- package/dist/schemas/database.schema.js +7 -1
- package/dist/schemas/emoji.schema.d.ts +7 -2
- package/dist/schemas/emoji.schema.js +4 -2
- package/dist/schemas/file.schema.d.ts +18 -2
- package/dist/schemas/file.schema.js +6 -2
- package/dist/schemas/fileUpload.schema.d.ts +8 -2
- package/dist/schemas/fileUpload.schema.js +5 -2
- package/dist/schemas/icon.schema.d.ts +28 -4
- package/dist/schemas/icon.schema.js +16 -4
- package/dist/schemas/meetingNotesQuery.schema.d.ts +13 -2
- package/dist/schemas/meetingNotesQuery.schema.js +7 -2
- package/dist/schemas/page.schema.d.ts +5 -0
- package/dist/schemas/page.schema.js +2 -0
- package/dist/schemas/pageMarkdown.schema.d.ts +15 -4
- package/dist/schemas/pageMarkdown.schema.js +9 -4
- package/dist/schemas/pageProperties.schema.d.ts +75 -3
- package/dist/schemas/pageProperties.schema.js +6 -3
- package/dist/schemas/pagination.schema.d.ts +33 -10
- package/dist/schemas/pagination.schema.js +12 -5
- package/dist/schemas/parent.schema.d.ts +29 -2
- package/dist/schemas/parent.schema.js +8 -2
- package/dist/schemas/propertyObjects.schema.d.ts +81 -3
- package/dist/schemas/propertyObjects.schema.js +11 -5
- package/dist/schemas/richText.schema.d.ts +15 -0
- package/dist/schemas/richText.schema.js +6 -3
- package/dist/schemas/shared.schema.d.ts +6 -3
- package/dist/schemas/shared.schema.js +6 -3
- package/dist/schemas/user.schema.d.ts +15 -0
- package/dist/schemas/user.schema.js +5 -2
- package/dist/schemas/view.schema.d.ts +43 -9
- package/dist/schemas/view.schema.js +28 -9
- package/dist/validation.d.ts +11 -4
- package/dist/validation.js +11 -4
- package/package.json +5 -2
|
@@ -2,13 +2,16 @@ import * as z from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Notion parent object schemas.
|
|
4
4
|
*
|
|
5
|
-
* Parent objects
|
|
5
|
+
* Parent objects identify the container of a page or block within Notion.
|
|
6
6
|
* A parent can be a database, data source, page, workspace, or block.
|
|
7
7
|
*
|
|
8
8
|
* Notion API reference:
|
|
9
9
|
* https://developers.notion.com/reference/parent-object
|
|
10
10
|
*/
|
|
11
|
-
/** Database parent.
|
|
11
|
+
/** Database parent.
|
|
12
|
+
*
|
|
13
|
+
* @category Shared Types
|
|
14
|
+
*/
|
|
12
15
|
export declare const databaseParentSchema: z.ZodObject<{
|
|
13
16
|
type: z.ZodLiteral<"database_id">;
|
|
14
17
|
database_id: z.ZodUUID;
|
|
@@ -39,6 +42,9 @@ declare const agentParentSchema: z.ZodObject<{
|
|
|
39
42
|
type: z.ZodLiteral<"agent_id">;
|
|
40
43
|
agent_id: z.ZodUUID;
|
|
41
44
|
}, z.core.$strip>;
|
|
45
|
+
/**
|
|
46
|
+
* @category Shared Types
|
|
47
|
+
*/
|
|
42
48
|
export declare const parentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
43
49
|
type: z.ZodLiteral<"database_id">;
|
|
44
50
|
database_id: z.ZodUUID;
|
|
@@ -59,11 +65,32 @@ export declare const parentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
59
65
|
type: z.ZodLiteral<"agent_id">;
|
|
60
66
|
agent_id: z.ZodUUID;
|
|
61
67
|
}, z.core.$strip>], "type">;
|
|
68
|
+
/**
|
|
69
|
+
* @category Shared Types
|
|
70
|
+
*/
|
|
62
71
|
export type NotionParent = z.infer<typeof parentSchema>;
|
|
72
|
+
/**
|
|
73
|
+
* @category Shared Types
|
|
74
|
+
*/
|
|
63
75
|
export type DatabaseParent = z.infer<typeof databaseParentSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* @category Shared Types
|
|
78
|
+
*/
|
|
64
79
|
export type DataSourceParent = z.infer<typeof dataSourceParentSchema>;
|
|
80
|
+
/**
|
|
81
|
+
* @category Shared Types
|
|
82
|
+
*/
|
|
65
83
|
export type PageParent = z.infer<typeof pageParentSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* @category Shared Types
|
|
86
|
+
*/
|
|
66
87
|
export type WorkspaceParent = z.infer<typeof workspaceParentSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* @category Shared Types
|
|
90
|
+
*/
|
|
67
91
|
export type BlockParent = z.infer<typeof blockParentSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* @category Shared Types
|
|
94
|
+
*/
|
|
68
95
|
export type AgentParent = z.infer<typeof agentParentSchema>;
|
|
69
96
|
export {};
|
|
@@ -38,13 +38,16 @@ const z = __importStar(require("zod"));
|
|
|
38
38
|
/**
|
|
39
39
|
* Notion parent object schemas.
|
|
40
40
|
*
|
|
41
|
-
* Parent objects
|
|
41
|
+
* Parent objects identify the container of a page or block within Notion.
|
|
42
42
|
* A parent can be a database, data source, page, workspace, or block.
|
|
43
43
|
*
|
|
44
44
|
* Notion API reference:
|
|
45
45
|
* https://developers.notion.com/reference/parent-object
|
|
46
46
|
*/
|
|
47
|
-
/** Database parent.
|
|
47
|
+
/** Database parent.
|
|
48
|
+
*
|
|
49
|
+
* @category Shared Types
|
|
50
|
+
*/
|
|
48
51
|
exports.databaseParentSchema = z.object({
|
|
49
52
|
type: z.literal('database_id'),
|
|
50
53
|
database_id: z.uuid(),
|
|
@@ -75,6 +78,9 @@ const agentParentSchema = z.object({
|
|
|
75
78
|
type: z.literal('agent_id'),
|
|
76
79
|
agent_id: z.uuid(),
|
|
77
80
|
});
|
|
81
|
+
/**
|
|
82
|
+
* @category Shared Types
|
|
83
|
+
*/
|
|
78
84
|
exports.parentSchema = z.discriminatedUnion('type', [
|
|
79
85
|
exports.databaseParentSchema,
|
|
80
86
|
dataSourceParentSchema,
|
|
@@ -300,7 +300,7 @@ declare const statusPropertySchema: z.ZodObject<{
|
|
|
300
300
|
}, z.core.$strip>>;
|
|
301
301
|
}, z.core.$strip>;
|
|
302
302
|
}, z.core.$strip>;
|
|
303
|
-
/** Title property configuration (empty object)
|
|
303
|
+
/** Title property configuration (empty object). Every data source requires exactly one. */
|
|
304
304
|
declare const titlePropertySchema: z.ZodObject<{
|
|
305
305
|
type: z.ZodLiteral<"title">;
|
|
306
306
|
id: z.ZodString;
|
|
@@ -328,7 +328,9 @@ declare const uniqueIdPropertySchema: z.ZodObject<{
|
|
|
328
328
|
}, z.core.$strip>;
|
|
329
329
|
/**
|
|
330
330
|
* Discriminated union of all data source property object types.
|
|
331
|
-
*
|
|
331
|
+
* Together they define the configuration for a data source, not the values.
|
|
332
|
+
*
|
|
333
|
+
* @category Page Properties
|
|
332
334
|
*/
|
|
333
335
|
export declare const propertyObjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
334
336
|
type: z.ZodLiteral<"checkbox">;
|
|
@@ -614,7 +616,11 @@ export declare const propertyObjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
614
616
|
prefix: z.ZodOptional<z.ZodString>;
|
|
615
617
|
}, z.core.$strip>;
|
|
616
618
|
}, z.core.$strip>], "type">;
|
|
617
|
-
/**
|
|
619
|
+
/**
|
|
620
|
+
* Record of property objects keyed by property name.
|
|
621
|
+
*
|
|
622
|
+
* @category Page Properties
|
|
623
|
+
*/
|
|
618
624
|
export declare const propertiesObjectSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
619
625
|
type: z.ZodLiteral<"checkbox">;
|
|
620
626
|
id: z.ZodString;
|
|
@@ -899,28 +905,100 @@ export declare const propertiesObjectSchema: z.ZodRecord<z.ZodString, z.ZodDiscr
|
|
|
899
905
|
prefix: z.ZodOptional<z.ZodString>;
|
|
900
906
|
}, z.core.$strip>;
|
|
901
907
|
}, z.core.$strip>], "type">>;
|
|
908
|
+
/**
|
|
909
|
+
* @category Page Properties
|
|
910
|
+
*/
|
|
902
911
|
export type NotionPropertyObject = z.infer<typeof propertyObjectSchema>;
|
|
912
|
+
/**
|
|
913
|
+
* @category Page Properties
|
|
914
|
+
*/
|
|
903
915
|
export type NotionPropertiesObject = z.infer<typeof propertiesObjectSchema>;
|
|
916
|
+
/**
|
|
917
|
+
* @category Page Properties
|
|
918
|
+
*/
|
|
904
919
|
export type CheckboxPropertyObject = z.infer<typeof checkboxPropertySchema>;
|
|
920
|
+
/**
|
|
921
|
+
* @category Page Properties
|
|
922
|
+
*/
|
|
905
923
|
export type CreatedByPropertyObject = z.infer<typeof createdByPropertySchema>;
|
|
924
|
+
/**
|
|
925
|
+
* @category Page Properties
|
|
926
|
+
*/
|
|
906
927
|
export type CreatedTimePropertyObject = z.infer<typeof createdTimePropertySchema>;
|
|
928
|
+
/**
|
|
929
|
+
* @category Page Properties
|
|
930
|
+
*/
|
|
907
931
|
export type DatePropertyObject = z.infer<typeof datePropertySchema>;
|
|
932
|
+
/**
|
|
933
|
+
* @category Page Properties
|
|
934
|
+
*/
|
|
908
935
|
export type EmailPropertyObject = z.infer<typeof emailPropertySchema>;
|
|
936
|
+
/**
|
|
937
|
+
* @category Page Properties
|
|
938
|
+
*/
|
|
909
939
|
export type FilesPropertyObject = z.infer<typeof filesPropertySchema>;
|
|
940
|
+
/**
|
|
941
|
+
* @category Page Properties
|
|
942
|
+
*/
|
|
910
943
|
export type FormulaPropertyObject = z.infer<typeof formulaPropertySchema>;
|
|
944
|
+
/**
|
|
945
|
+
* @category Page Properties
|
|
946
|
+
*/
|
|
911
947
|
export type LastEditedByPropertyObject = z.infer<typeof lastEditedByPropertySchema>;
|
|
948
|
+
/**
|
|
949
|
+
* @category Page Properties
|
|
950
|
+
*/
|
|
912
951
|
export type LastEditedTimePropertyObject = z.infer<typeof lastEditedTimePropertySchema>;
|
|
952
|
+
/**
|
|
953
|
+
* @category Page Properties
|
|
954
|
+
*/
|
|
913
955
|
export type MultiSelectPropertyObject = z.infer<typeof multiSelectPropertySchema>;
|
|
956
|
+
/**
|
|
957
|
+
* @category Page Properties
|
|
958
|
+
*/
|
|
914
959
|
export type NumberPropertyObject = z.infer<typeof numberPropertySchema>;
|
|
960
|
+
/**
|
|
961
|
+
* @category Page Properties
|
|
962
|
+
*/
|
|
915
963
|
export type PeoplePropertyObject = z.infer<typeof peoplePropertySchema>;
|
|
964
|
+
/**
|
|
965
|
+
* @category Page Properties
|
|
966
|
+
*/
|
|
916
967
|
export type PhoneNumberPropertyObject = z.infer<typeof phoneNumberPropertySchema>;
|
|
968
|
+
/**
|
|
969
|
+
* @category Page Properties
|
|
970
|
+
*/
|
|
917
971
|
export type PlacePropertyObject = z.infer<typeof placePropertySchema>;
|
|
972
|
+
/**
|
|
973
|
+
* @category Page Properties
|
|
974
|
+
*/
|
|
918
975
|
export type RelationPropertyObject = z.infer<typeof relationPropertySchema>;
|
|
976
|
+
/**
|
|
977
|
+
* @category Page Properties
|
|
978
|
+
*/
|
|
919
979
|
export type RichTextPropertyObject = z.infer<typeof richTextPropertySchema>;
|
|
980
|
+
/**
|
|
981
|
+
* @category Page Properties
|
|
982
|
+
*/
|
|
920
983
|
export type RollupPropertyObject = z.infer<typeof rollupPropertySchema>;
|
|
984
|
+
/**
|
|
985
|
+
* @category Page Properties
|
|
986
|
+
*/
|
|
921
987
|
export type SelectPropertyObject = z.infer<typeof selectPropertySchema>;
|
|
988
|
+
/**
|
|
989
|
+
* @category Page Properties
|
|
990
|
+
*/
|
|
922
991
|
export type StatusPropertyObject = z.infer<typeof statusPropertySchema>;
|
|
992
|
+
/**
|
|
993
|
+
* @category Page Properties
|
|
994
|
+
*/
|
|
923
995
|
export type TitlePropertyObject = z.infer<typeof titlePropertySchema>;
|
|
996
|
+
/**
|
|
997
|
+
* @category Page Properties
|
|
998
|
+
*/
|
|
924
999
|
export type UrlPropertyObject = z.infer<typeof urlPropertySchema>;
|
|
1000
|
+
/**
|
|
1001
|
+
* @category Page Properties
|
|
1002
|
+
*/
|
|
925
1003
|
export type UniqueIdPropertyObject = z.infer<typeof uniqueIdPropertySchema>;
|
|
926
1004
|
export {};
|
|
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.propertiesObjectSchema = exports.propertyObjectSchema = void 0;
|
|
37
37
|
const z = __importStar(require("zod"));
|
|
38
38
|
/**
|
|
39
|
-
* Data source property objects define the schema
|
|
40
|
-
*
|
|
39
|
+
* Data source property objects define the schema and configuration for a data source.
|
|
40
|
+
* Page property values contain the actual data instead.
|
|
41
41
|
*
|
|
42
42
|
* Notion API reference:
|
|
43
43
|
* https://developers.notion.com/reference/property-object
|
|
@@ -318,7 +318,7 @@ const statusPropertySchema = z.object({
|
|
|
318
318
|
groups: z.array(statusGroupSchema),
|
|
319
319
|
}),
|
|
320
320
|
});
|
|
321
|
-
/** Title property configuration (empty object)
|
|
321
|
+
/** Title property configuration (empty object). Every data source requires exactly one. */
|
|
322
322
|
const titlePropertySchema = z.object({
|
|
323
323
|
type: z.literal('title'),
|
|
324
324
|
id: z.string().trim(),
|
|
@@ -346,7 +346,9 @@ const uniqueIdPropertySchema = z.object({
|
|
|
346
346
|
});
|
|
347
347
|
/**
|
|
348
348
|
* Discriminated union of all data source property object types.
|
|
349
|
-
*
|
|
349
|
+
* Together they define the configuration for a data source, not the values.
|
|
350
|
+
*
|
|
351
|
+
* @category Page Properties
|
|
350
352
|
*/
|
|
351
353
|
exports.propertyObjectSchema = z.discriminatedUnion('type', [
|
|
352
354
|
checkboxPropertySchema,
|
|
@@ -372,5 +374,9 @@ exports.propertyObjectSchema = z.discriminatedUnion('type', [
|
|
|
372
374
|
urlPropertySchema,
|
|
373
375
|
uniqueIdPropertySchema,
|
|
374
376
|
]);
|
|
375
|
-
/**
|
|
377
|
+
/**
|
|
378
|
+
* Record of property objects keyed by property name.
|
|
379
|
+
*
|
|
380
|
+
* @category Page Properties
|
|
381
|
+
*/
|
|
376
382
|
exports.propertiesObjectSchema = z.record(z.string().trim(), exports.propertyObjectSchema);
|
|
@@ -180,6 +180,9 @@ declare const equationRichTextSchema: z.ZodObject<{
|
|
|
180
180
|
plain_text: z.ZodString;
|
|
181
181
|
href: z.ZodNullable<z.ZodURL>;
|
|
182
182
|
}, z.core.$strip>;
|
|
183
|
+
/**
|
|
184
|
+
* @category Rich Text
|
|
185
|
+
*/
|
|
183
186
|
export declare const richTextSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
184
187
|
type: z.ZodLiteral<"text">;
|
|
185
188
|
text: z.ZodObject<{
|
|
@@ -356,8 +359,20 @@ export declare const richTextSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
356
359
|
plain_text: z.ZodString;
|
|
357
360
|
href: z.ZodNullable<z.ZodURL>;
|
|
358
361
|
}, z.core.$strip>], "type">>;
|
|
362
|
+
/**
|
|
363
|
+
* @category Rich Text
|
|
364
|
+
*/
|
|
359
365
|
export type NotionRichText = z.infer<typeof richTextSchema>;
|
|
366
|
+
/**
|
|
367
|
+
* @category Rich Text
|
|
368
|
+
*/
|
|
360
369
|
export type TextRichText = z.infer<typeof textRichTextSchema>;
|
|
370
|
+
/**
|
|
371
|
+
* @category Rich Text
|
|
372
|
+
*/
|
|
361
373
|
export type MentionRichText = z.infer<typeof mentionRichTextSchema>;
|
|
374
|
+
/**
|
|
375
|
+
* @category Rich Text
|
|
376
|
+
*/
|
|
362
377
|
export type EquationRichText = z.infer<typeof equationRichTextSchema>;
|
|
363
378
|
export {};
|
|
@@ -41,9 +41,9 @@ const user_schema_1 = require("./user.schema");
|
|
|
41
41
|
/**
|
|
42
42
|
* Notion rich text object schema.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
* three types: text
|
|
46
|
-
* and equations
|
|
44
|
+
* Notion uses rich text throughout the API for formatted text content. It supports
|
|
45
|
+
* three types: text with optional links, mentions of users, pages, dates, and other
|
|
46
|
+
* objects, and equations in LaTeX. You can style all types with annotations.
|
|
47
47
|
*
|
|
48
48
|
* Notion API reference:
|
|
49
49
|
* https://developers.notion.com/reference/rich-text
|
|
@@ -147,4 +147,7 @@ const equationRichTextSchema = z.object({
|
|
|
147
147
|
plain_text: z.string(),
|
|
148
148
|
href: z.url().nullable(),
|
|
149
149
|
});
|
|
150
|
+
/**
|
|
151
|
+
* @category Rich Text
|
|
152
|
+
*/
|
|
150
153
|
exports.richTextSchema = z.array(z.discriminatedUnion('type', [textRichTextSchema, mentionRichTextSchema, equationRichTextSchema]));
|
|
@@ -7,9 +7,12 @@ import * as z from 'zod';
|
|
|
7
7
|
/**
|
|
8
8
|
* Notion date string schema.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* This schema validates ISO 8601 date strings from the Notion API.
|
|
11
|
+
* It accepts a date-only format ("2023-02-23") and a full date-time format
|
|
12
|
+
* ("2023-02-23T00:00:00.000Z").
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
+
* The Notion API docs describe date fields as "A date, with an optional time".
|
|
15
|
+
*
|
|
16
|
+
* @category Shared Types
|
|
14
17
|
*/
|
|
15
18
|
export declare const notionDateStringSchema: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>;
|
|
@@ -43,10 +43,13 @@ const z = __importStar(require("zod"));
|
|
|
43
43
|
/**
|
|
44
44
|
* Notion date string schema.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* This schema validates ISO 8601 date strings from the Notion API.
|
|
47
|
+
* It accepts a date-only format ("2023-02-23") and a full date-time format
|
|
48
|
+
* ("2023-02-23T00:00:00.000Z").
|
|
48
49
|
*
|
|
49
|
-
*
|
|
50
|
+
* The Notion API docs describe date fields as "A date, with an optional time".
|
|
51
|
+
*
|
|
52
|
+
* @category Shared Types
|
|
50
53
|
*/
|
|
51
54
|
exports.notionDateStringSchema = z.union([
|
|
52
55
|
z.iso.datetime(), // Full ISO 8601 datetime: "2023-02-23T00:00:00.000Z"
|
|
@@ -37,6 +37,9 @@ declare const partialUserSchema: z.ZodObject<{
|
|
|
37
37
|
object: z.ZodLiteral<"user">;
|
|
38
38
|
id: z.ZodUUID;
|
|
39
39
|
}, z.core.$strip>;
|
|
40
|
+
/**
|
|
41
|
+
* @category Users
|
|
42
|
+
*/
|
|
40
43
|
export declare const userSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
41
44
|
object: z.ZodLiteral<"user">;
|
|
42
45
|
id: z.ZodUUID;
|
|
@@ -70,8 +73,20 @@ export declare const userSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
70
73
|
object: z.ZodLiteral<"user">;
|
|
71
74
|
id: z.ZodUUID;
|
|
72
75
|
}, z.core.$strip>]>;
|
|
76
|
+
/**
|
|
77
|
+
* @category Users
|
|
78
|
+
*/
|
|
73
79
|
export type NotionUser = z.infer<typeof userSchema>;
|
|
80
|
+
/**
|
|
81
|
+
* @category Users
|
|
82
|
+
*/
|
|
74
83
|
export type PersonUser = z.infer<typeof personUserSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* @category Users
|
|
86
|
+
*/
|
|
75
87
|
export type BotUser = z.infer<typeof botUserSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* @category Users
|
|
90
|
+
*/
|
|
76
91
|
export type PartialUser = z.infer<typeof partialUserSchema>;
|
|
77
92
|
export {};
|
|
@@ -38,8 +38,8 @@ const z = __importStar(require("zod"));
|
|
|
38
38
|
/**
|
|
39
39
|
* Notion user object schemas.
|
|
40
40
|
*
|
|
41
|
-
* Users can be people, bots, or partial user objects (
|
|
42
|
-
*
|
|
41
|
+
* Users can be people, bots, or partial user objects (only id and object type).
|
|
42
|
+
* The created_by and last_edited_by fields use this schema throughout the API.
|
|
43
43
|
*
|
|
44
44
|
* Notion API reference:
|
|
45
45
|
* https://developers.notion.com/reference/user
|
|
@@ -89,4 +89,7 @@ const partialUserSchema = z.object({
|
|
|
89
89
|
object: z.literal('user'),
|
|
90
90
|
id: z.uuid(),
|
|
91
91
|
});
|
|
92
|
+
/**
|
|
93
|
+
* @category Users
|
|
94
|
+
*/
|
|
92
95
|
exports.userSchema = z.union([personUserSchema, botUserSchema, partialUserSchema]);
|
|
@@ -2,19 +2,30 @@ import * as z from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* View object schema.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* A view controls how a database or data source displays its rows, for example as a
|
|
6
|
+
* table, board, or calendar. As of API version 2025-09-03, views have their own
|
|
7
|
+
* endpoints.
|
|
7
8
|
*
|
|
8
9
|
* Notion API reference:
|
|
9
10
|
* https://developers.notion.com/guides/data-apis/working-with-views
|
|
11
|
+
*
|
|
12
|
+
* @category Views
|
|
10
13
|
*/
|
|
11
14
|
export declare const VIEW_TYPES: readonly ["table", "board", "list", "calendar", "timeline", "gallery", "form", "chart", "map", "dashboard"];
|
|
15
|
+
/**
|
|
16
|
+
* @category Views
|
|
17
|
+
*/
|
|
12
18
|
export type ViewType = (typeof VIEW_TYPES)[number];
|
|
13
19
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* Configuration for a single view layout.
|
|
21
|
+
*
|
|
22
|
+
* Notion has not confirmed the exact fields for each view type against a live
|
|
23
|
+
* response. Examples include the table column order and the board group-by
|
|
24
|
+
* property. This schema stays permissive. It tags the object by its `type`
|
|
25
|
+
* field and passes all other fields through without validation. As a result,
|
|
26
|
+
* unknown fields round-trip unchanged instead of the schema rejecting them.
|
|
27
|
+
*
|
|
28
|
+
* @category Views
|
|
18
29
|
*/
|
|
19
30
|
export declare const viewConfigurationSchema: z.ZodObject<{
|
|
20
31
|
type: z.ZodEnum<{
|
|
@@ -30,7 +41,13 @@ export declare const viewConfigurationSchema: z.ZodObject<{
|
|
|
30
41
|
dashboard: "dashboard";
|
|
31
42
|
}>;
|
|
32
43
|
}, z.core.$catchall<z.ZodUnknown>>;
|
|
44
|
+
/**
|
|
45
|
+
* @category Views
|
|
46
|
+
*/
|
|
33
47
|
export type ViewConfiguration = z.infer<typeof viewConfigurationSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* @category Views
|
|
50
|
+
*/
|
|
34
51
|
export declare const viewSchema: z.ZodObject<{
|
|
35
52
|
object: z.ZodLiteral<"view">;
|
|
36
53
|
id: z.ZodUUID;
|
|
@@ -140,8 +157,16 @@ export declare const viewSchema: z.ZodObject<{
|
|
|
140
157
|
url: z.ZodURL;
|
|
141
158
|
dashboard_view_id: z.ZodOptional<z.ZodUUID>;
|
|
142
159
|
}, z.core.$strip>;
|
|
160
|
+
/**
|
|
161
|
+
* @category Views
|
|
162
|
+
*/
|
|
143
163
|
export type NotionView = z.infer<typeof viewSchema>;
|
|
144
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Notion's delete-view response includes only `object`, `id`, `parent`, and `type`.
|
|
166
|
+
* It omits the rest of the view shape.
|
|
167
|
+
*
|
|
168
|
+
* @category Views
|
|
169
|
+
*/
|
|
145
170
|
export declare const viewDeleteResponseSchema: z.ZodObject<{
|
|
146
171
|
object: z.ZodLiteral<"view">;
|
|
147
172
|
id: z.ZodUUID;
|
|
@@ -162,10 +187,16 @@ export declare const viewDeleteResponseSchema: z.ZodObject<{
|
|
|
162
187
|
dashboard: "dashboard";
|
|
163
188
|
}>;
|
|
164
189
|
}, z.core.$strip>;
|
|
190
|
+
/**
|
|
191
|
+
* @category Views
|
|
192
|
+
*/
|
|
165
193
|
export type ViewDeleteResult = z.infer<typeof viewDeleteResponseSchema>;
|
|
166
194
|
/**
|
|
167
|
-
* View query response schema.
|
|
168
|
-
* plus `expires_at
|
|
195
|
+
* View query response schema. This response has a non-standard pagination shape:
|
|
196
|
+
* `object: "view_query"`, plus `expires_at` and `total_count`. Queries expire
|
|
197
|
+
* about 15 minutes after creation.
|
|
198
|
+
*
|
|
199
|
+
* @category Views
|
|
169
200
|
*/
|
|
170
201
|
export declare const viewQueryResponseSchema: z.ZodObject<{
|
|
171
202
|
object: z.ZodLiteral<"view_query">;
|
|
@@ -1074,4 +1105,7 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
|
|
|
1074
1105
|
}>;
|
|
1075
1106
|
}, z.core.$strip>>;
|
|
1076
1107
|
}, z.core.$strip>;
|
|
1108
|
+
/**
|
|
1109
|
+
* @category Views
|
|
1110
|
+
*/
|
|
1077
1111
|
export type ViewQueryResponse = z.infer<typeof viewQueryResponseSchema>;
|
|
@@ -43,11 +43,14 @@ const user_schema_1 = require("./user.schema");
|
|
|
43
43
|
/**
|
|
44
44
|
* View object schema.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* A view controls how a database or data source displays its rows, for example as a
|
|
47
|
+
* table, board, or calendar. As of API version 2025-09-03, views have their own
|
|
48
|
+
* endpoints.
|
|
48
49
|
*
|
|
49
50
|
* Notion API reference:
|
|
50
51
|
* https://developers.notion.com/guides/data-apis/working-with-views
|
|
52
|
+
*
|
|
53
|
+
* @category Views
|
|
51
54
|
*/
|
|
52
55
|
exports.VIEW_TYPES = [
|
|
53
56
|
'table',
|
|
@@ -62,16 +65,24 @@ exports.VIEW_TYPES = [
|
|
|
62
65
|
'dashboard',
|
|
63
66
|
];
|
|
64
67
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
68
|
+
* Configuration for a single view layout.
|
|
69
|
+
*
|
|
70
|
+
* Notion has not confirmed the exact fields for each view type against a live
|
|
71
|
+
* response. Examples include the table column order and the board group-by
|
|
72
|
+
* property. This schema stays permissive. It tags the object by its `type`
|
|
73
|
+
* field and passes all other fields through without validation. As a result,
|
|
74
|
+
* unknown fields round-trip unchanged instead of the schema rejecting them.
|
|
75
|
+
*
|
|
76
|
+
* @category Views
|
|
69
77
|
*/
|
|
70
78
|
exports.viewConfigurationSchema = z
|
|
71
79
|
.object({
|
|
72
80
|
type: z.enum(exports.VIEW_TYPES),
|
|
73
81
|
})
|
|
74
82
|
.catchall(z.unknown());
|
|
83
|
+
/**
|
|
84
|
+
* @category Views
|
|
85
|
+
*/
|
|
75
86
|
exports.viewSchema = z.object({
|
|
76
87
|
object: z.literal('view'),
|
|
77
88
|
id: z.uuid(),
|
|
@@ -91,7 +102,12 @@ exports.viewSchema = z.object({
|
|
|
91
102
|
// Widget/dashboard views only.
|
|
92
103
|
dashboard_view_id: z.uuid().optional(),
|
|
93
104
|
});
|
|
94
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Notion's delete-view response includes only `object`, `id`, `parent`, and `type`.
|
|
107
|
+
* It omits the rest of the view shape.
|
|
108
|
+
*
|
|
109
|
+
* @category Views
|
|
110
|
+
*/
|
|
95
111
|
exports.viewDeleteResponseSchema = z.object({
|
|
96
112
|
object: z.literal('view'),
|
|
97
113
|
id: z.uuid(),
|
|
@@ -99,8 +115,11 @@ exports.viewDeleteResponseSchema = z.object({
|
|
|
99
115
|
type: z.enum(exports.VIEW_TYPES),
|
|
100
116
|
});
|
|
101
117
|
/**
|
|
102
|
-
* View query response schema.
|
|
103
|
-
* plus `expires_at
|
|
118
|
+
* View query response schema. This response has a non-standard pagination shape:
|
|
119
|
+
* `object: "view_query"`, plus `expires_at` and `total_count`. Queries expire
|
|
120
|
+
* about 15 minutes after creation.
|
|
121
|
+
*
|
|
122
|
+
* @category Views
|
|
104
123
|
*/
|
|
105
124
|
exports.viewQueryResponseSchema = z.object({
|
|
106
125
|
object: z.literal('view_query'),
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Notion API
|
|
2
|
+
* Maximum sizes the Notion API allows in a request.
|
|
3
3
|
*
|
|
4
4
|
* @see https://developers.notion.com/reference/request-limits#size-limits
|
|
5
|
+
*
|
|
6
|
+
* @category Client & Core
|
|
5
7
|
*/
|
|
6
8
|
export declare const LIMITS: {
|
|
7
9
|
/** Maximum characters in a single rich text `text.content` field. */
|
|
@@ -34,9 +36,10 @@ export declare const LIMITS: {
|
|
|
34
36
|
/**
|
|
35
37
|
* Thrown when a value exceeds a Notion API size limit.
|
|
36
38
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* The SDK throws this error before it sends the request. This gives you an
|
|
40
|
+
* early, actionable message instead of a generic 400 response from the API.
|
|
41
|
+
*
|
|
42
|
+
* @category Errors
|
|
40
43
|
*/
|
|
41
44
|
export declare class NotionValidationError extends Error {
|
|
42
45
|
constructor(message: string);
|
|
@@ -45,11 +48,15 @@ export declare class NotionValidationError extends Error {
|
|
|
45
48
|
* Assert that a string does not exceed `maxLength` characters.
|
|
46
49
|
*
|
|
47
50
|
* @throws {NotionValidationError}
|
|
51
|
+
*
|
|
52
|
+
* @category Client & Core
|
|
48
53
|
*/
|
|
49
54
|
export declare function validateStringLength(value: string, maxLength: number, label: string): void;
|
|
50
55
|
/**
|
|
51
56
|
* Assert that an array does not exceed `maxLength` elements.
|
|
52
57
|
*
|
|
53
58
|
* @throws {NotionValidationError}
|
|
59
|
+
*
|
|
60
|
+
* @category Client & Core
|
|
54
61
|
*/
|
|
55
62
|
export declare function validateArrayLength(array: unknown[], maxLength: number, label: string): void;
|
package/dist/validation.js
CHANGED
|
@@ -4,9 +4,11 @@ exports.NotionValidationError = exports.LIMITS = void 0;
|
|
|
4
4
|
exports.validateStringLength = validateStringLength;
|
|
5
5
|
exports.validateArrayLength = validateArrayLength;
|
|
6
6
|
/**
|
|
7
|
-
* Notion API
|
|
7
|
+
* Maximum sizes the Notion API allows in a request.
|
|
8
8
|
*
|
|
9
9
|
* @see https://developers.notion.com/reference/request-limits#size-limits
|
|
10
|
+
*
|
|
11
|
+
* @category Client & Core
|
|
10
12
|
*/
|
|
11
13
|
exports.LIMITS = {
|
|
12
14
|
/** Maximum characters in a single rich text `text.content` field. */
|
|
@@ -39,9 +41,10 @@ exports.LIMITS = {
|
|
|
39
41
|
/**
|
|
40
42
|
* Thrown when a value exceeds a Notion API size limit.
|
|
41
43
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
44
|
+
* The SDK throws this error before it sends the request. This gives you an
|
|
45
|
+
* early, actionable message instead of a generic 400 response from the API.
|
|
46
|
+
*
|
|
47
|
+
* @category Errors
|
|
45
48
|
*/
|
|
46
49
|
class NotionValidationError extends Error {
|
|
47
50
|
constructor(message) {
|
|
@@ -60,6 +63,8 @@ exports.NotionValidationError = NotionValidationError;
|
|
|
60
63
|
* Assert that a string does not exceed `maxLength` characters.
|
|
61
64
|
*
|
|
62
65
|
* @throws {NotionValidationError}
|
|
66
|
+
*
|
|
67
|
+
* @category Client & Core
|
|
63
68
|
*/
|
|
64
69
|
function validateStringLength(value, maxLength, label) {
|
|
65
70
|
if (value.length > maxLength) {
|
|
@@ -73,6 +78,8 @@ function validateStringLength(value, maxLength, label) {
|
|
|
73
78
|
* Assert that an array does not exceed `maxLength` elements.
|
|
74
79
|
*
|
|
75
80
|
* @throws {NotionValidationError}
|
|
81
|
+
*
|
|
82
|
+
* @category Client & Core
|
|
76
83
|
*/
|
|
77
84
|
function validateArrayLength(array, maxLength, label) {
|
|
78
85
|
if (array.length > maxLength) {
|