@visus-io/notion-sdk-ts 2.0.1 → 3.0.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 +66 -23
- package/dist/api/base.api.d.ts +1 -1
- package/dist/api/blocks.api.d.ts +266 -87
- package/dist/api/comments.api.d.ts +7 -7
- package/dist/api/dataSources.api.d.ts +28 -31
- package/dist/api/dataSources.api.js +18 -19
- package/dist/api/databases.api.d.ts +27 -22
- package/dist/api/databases.api.js +18 -8
- package/dist/api/fileUploads.api.d.ts +2 -2
- package/dist/api/pages.api.d.ts +43 -38
- package/dist/api/pages.api.js +18 -8
- package/dist/api/users.api.d.ts +1 -1
- package/dist/client.d.ts +5 -3
- package/dist/client.js +7 -3
- package/dist/helpers/block.helpers.d.ts +4 -0
- package/dist/helpers/block.helpers.js +11 -0
- package/dist/helpers/parent.helpers.d.ts +2 -2
- package/dist/helpers/parent.helpers.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/models/base.model.d.ts +2 -2
- package/dist/models/block.model.d.ts +0 -1
- package/dist/models/block.model.js +0 -3
- package/dist/models/dataSource.model.d.ts +0 -4
- package/dist/models/dataSource.model.js +0 -6
- package/dist/models/database.model.d.ts +0 -4
- package/dist/models/database.model.js +0 -6
- package/dist/models/page.model.d.ts +0 -1
- package/dist/models/page.model.js +0 -3
- package/dist/schemas/block.schema.d.ts +275 -82
- package/dist/schemas/block.schema.js +165 -82
- package/dist/schemas/comment.schema.d.ts +9 -9
- package/dist/schemas/comment.schema.js +54 -20
- package/dist/schemas/dataSource.schema.d.ts +13 -14
- package/dist/schemas/dataSource.schema.js +46 -14
- package/dist/schemas/database.schema.d.ts +13 -14
- package/dist/schemas/database.schema.js +50 -17
- package/dist/schemas/emoji.schema.d.ts +1 -1
- package/dist/schemas/emoji.schema.js +37 -4
- package/dist/schemas/file.schema.d.ts +3 -3
- package/dist/schemas/file.schema.js +49 -15
- package/dist/schemas/fileUpload.schema.d.ts +3 -3
- package/dist/schemas/fileUpload.schema.js +47 -13
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/page.schema.d.ts +30 -31
- package/dist/schemas/page.schema.js +46 -13
- package/dist/schemas/pageProperties.schema.d.ts +47 -47
- package/dist/schemas/pageProperties.schema.js +162 -128
- package/dist/schemas/pagination.schema.d.ts +1 -1
- package/dist/schemas/pagination.schema.js +40 -7
- package/dist/schemas/parent.schema.d.ts +1 -1
- package/dist/schemas/parent.schema.js +51 -18
- package/dist/schemas/propertyObjects.schema.d.ts +1 -1
- package/dist/schemas/propertyObjects.schema.js +194 -161
- package/dist/schemas/richText.schema.d.ts +7 -7
- package/dist/schemas/richText.schema.js +95 -56
- package/dist/schemas/shared.schema.d.ts +15 -0
- package/dist/schemas/shared.schema.js +54 -0
- package/dist/schemas/user.schema.d.ts +3 -3
- package/dist/schemas/user.schema.js +63 -30
- package/package.json +7 -5
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.pagePropertiesSchema = void 0;
|
|
4
|
-
const
|
|
37
|
+
const z = __importStar(require("zod"));
|
|
5
38
|
const colors_1 = require("./colors");
|
|
6
39
|
const richText_schema_1 = require("./richText.schema");
|
|
40
|
+
const shared_schema_1 = require("./shared.schema");
|
|
7
41
|
const user_schema_1 = require("./user.schema");
|
|
8
42
|
/**
|
|
9
43
|
* Page property value schemas.
|
|
@@ -16,131 +50,131 @@ const user_schema_1 = require("./user.schema");
|
|
|
16
50
|
* https://developers.notion.com/reference/page-property-values
|
|
17
51
|
*/
|
|
18
52
|
/** Checkbox property. */
|
|
19
|
-
const checkboxPropertySchema =
|
|
20
|
-
id:
|
|
21
|
-
type:
|
|
22
|
-
checkbox:
|
|
53
|
+
const checkboxPropertySchema = z.object({
|
|
54
|
+
id: z.string().trim(),
|
|
55
|
+
type: z.literal('checkbox'),
|
|
56
|
+
checkbox: z.boolean(),
|
|
23
57
|
});
|
|
24
58
|
/** Created by property. */
|
|
25
|
-
const createdByPropertySchema =
|
|
26
|
-
id:
|
|
27
|
-
type:
|
|
59
|
+
const createdByPropertySchema = z.object({
|
|
60
|
+
id: z.string().trim(),
|
|
61
|
+
type: z.literal('created_by'),
|
|
28
62
|
created_by: user_schema_1.userSchema,
|
|
29
63
|
});
|
|
30
64
|
/** Created time property. */
|
|
31
|
-
const createdTimePropertySchema =
|
|
32
|
-
id:
|
|
33
|
-
type:
|
|
34
|
-
created_time:
|
|
65
|
+
const createdTimePropertySchema = z.object({
|
|
66
|
+
id: z.string().trim(),
|
|
67
|
+
type: z.literal('created_time'),
|
|
68
|
+
created_time: shared_schema_1.notionDateStringSchema,
|
|
35
69
|
});
|
|
36
70
|
/** Date property. */
|
|
37
|
-
const datePropertySchema =
|
|
38
|
-
id:
|
|
39
|
-
type:
|
|
40
|
-
date:
|
|
71
|
+
const datePropertySchema = z.object({
|
|
72
|
+
id: z.string().trim(),
|
|
73
|
+
type: z.literal('date'),
|
|
74
|
+
date: z
|
|
41
75
|
.object({
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
44
|
-
time_zone:
|
|
76
|
+
start: shared_schema_1.notionDateStringSchema,
|
|
77
|
+
end: shared_schema_1.notionDateStringSchema.nullable(),
|
|
78
|
+
time_zone: z.string().trim().nullable(),
|
|
45
79
|
})
|
|
46
80
|
.nullable(),
|
|
47
81
|
});
|
|
48
82
|
/** Email property. */
|
|
49
|
-
const emailPropertySchema =
|
|
50
|
-
id:
|
|
51
|
-
type:
|
|
52
|
-
email:
|
|
83
|
+
const emailPropertySchema = z.object({
|
|
84
|
+
id: z.string().trim(),
|
|
85
|
+
type: z.literal('email'),
|
|
86
|
+
email: z.string().trim().nullable(),
|
|
53
87
|
});
|
|
54
88
|
/** Files property. */
|
|
55
|
-
const filesPropertySchema =
|
|
56
|
-
id:
|
|
57
|
-
type:
|
|
58
|
-
files:
|
|
59
|
-
name:
|
|
60
|
-
type:
|
|
61
|
-
external:
|
|
62
|
-
file:
|
|
63
|
-
file_upload:
|
|
89
|
+
const filesPropertySchema = z.object({
|
|
90
|
+
id: z.string().trim(),
|
|
91
|
+
type: z.literal('files'),
|
|
92
|
+
files: z.array(z.object({
|
|
93
|
+
name: z.string().trim(),
|
|
94
|
+
type: z.enum(['external', 'file', 'file_upload']),
|
|
95
|
+
external: z.object({ url: z.url() }).optional(),
|
|
96
|
+
file: z.object({ url: z.url(), expiry_time: shared_schema_1.notionDateStringSchema }).optional(),
|
|
97
|
+
file_upload: z.object({ id: z.uuid() }).optional(),
|
|
64
98
|
})),
|
|
65
99
|
});
|
|
66
100
|
/** Formula property. */
|
|
67
|
-
const formulaPropertySchema =
|
|
68
|
-
id:
|
|
69
|
-
type:
|
|
70
|
-
formula:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
type:
|
|
74
|
-
date:
|
|
75
|
-
start:
|
|
76
|
-
end:
|
|
77
|
-
time_zone:
|
|
101
|
+
const formulaPropertySchema = z.object({
|
|
102
|
+
id: z.string().trim(),
|
|
103
|
+
type: z.literal('formula'),
|
|
104
|
+
formula: z.discriminatedUnion('type', [
|
|
105
|
+
z.object({ type: z.literal('boolean'), boolean: z.boolean() }),
|
|
106
|
+
z.object({
|
|
107
|
+
type: z.literal('date'),
|
|
108
|
+
date: z.object({
|
|
109
|
+
start: shared_schema_1.notionDateStringSchema,
|
|
110
|
+
end: shared_schema_1.notionDateStringSchema.nullable(),
|
|
111
|
+
time_zone: z.string().trim().nullable(),
|
|
78
112
|
}),
|
|
79
113
|
}),
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
z.object({ type: z.literal('number'), number: z.number().nullable() }),
|
|
115
|
+
z.object({ type: z.literal('string'), string: z.string().trim().nullable() }),
|
|
82
116
|
]),
|
|
83
117
|
});
|
|
84
118
|
/** Last edited by property. */
|
|
85
|
-
const lastEditedByPropertySchema =
|
|
86
|
-
id:
|
|
87
|
-
type:
|
|
119
|
+
const lastEditedByPropertySchema = z.object({
|
|
120
|
+
id: z.string().trim(),
|
|
121
|
+
type: z.literal('last_edited_by'),
|
|
88
122
|
last_edited_by: user_schema_1.userSchema,
|
|
89
123
|
});
|
|
90
124
|
/** Last edited time property. */
|
|
91
|
-
const lastEditedTimePropertySchema =
|
|
92
|
-
id:
|
|
93
|
-
type:
|
|
94
|
-
last_edited_time:
|
|
125
|
+
const lastEditedTimePropertySchema = z.object({
|
|
126
|
+
id: z.string().trim(),
|
|
127
|
+
type: z.literal('last_edited_time'),
|
|
128
|
+
last_edited_time: shared_schema_1.notionDateStringSchema,
|
|
95
129
|
});
|
|
96
130
|
/** Multi-select property. */
|
|
97
|
-
const multiSelectPropertySchema =
|
|
98
|
-
id:
|
|
99
|
-
type:
|
|
100
|
-
multi_select:
|
|
101
|
-
id:
|
|
102
|
-
name:
|
|
103
|
-
color:
|
|
131
|
+
const multiSelectPropertySchema = z.object({
|
|
132
|
+
id: z.string().trim(),
|
|
133
|
+
type: z.literal('multi_select'),
|
|
134
|
+
multi_select: z.array(z.object({
|
|
135
|
+
id: z.string().trim(),
|
|
136
|
+
name: z.string().trim(),
|
|
137
|
+
color: z.enum(colors_1.NOTION_COLORS),
|
|
104
138
|
})),
|
|
105
139
|
});
|
|
106
140
|
/** Number property. */
|
|
107
|
-
const numberPropertySchema =
|
|
108
|
-
id:
|
|
109
|
-
type:
|
|
110
|
-
number:
|
|
141
|
+
const numberPropertySchema = z.object({
|
|
142
|
+
id: z.string().trim(),
|
|
143
|
+
type: z.literal('number'),
|
|
144
|
+
number: z.number().nullable(),
|
|
111
145
|
});
|
|
112
146
|
/** People property. */
|
|
113
|
-
const peoplePropertySchema =
|
|
114
|
-
id:
|
|
115
|
-
type:
|
|
116
|
-
people:
|
|
147
|
+
const peoplePropertySchema = z.object({
|
|
148
|
+
id: z.string().trim(),
|
|
149
|
+
type: z.literal('people'),
|
|
150
|
+
people: z.array(user_schema_1.userSchema),
|
|
117
151
|
});
|
|
118
152
|
/** Phone number property. */
|
|
119
|
-
const phoneNumberPropertySchema =
|
|
120
|
-
id:
|
|
121
|
-
type:
|
|
122
|
-
phone_number:
|
|
153
|
+
const phoneNumberPropertySchema = z.object({
|
|
154
|
+
id: z.string().trim(),
|
|
155
|
+
type: z.literal('phone_number'),
|
|
156
|
+
phone_number: z.string().trim().nullable(),
|
|
123
157
|
});
|
|
124
158
|
/** Relation property. */
|
|
125
|
-
const relationPropertySchema =
|
|
126
|
-
id:
|
|
127
|
-
type:
|
|
128
|
-
relation:
|
|
129
|
-
has_more:
|
|
159
|
+
const relationPropertySchema = z.object({
|
|
160
|
+
id: z.string().trim(),
|
|
161
|
+
type: z.literal('relation'),
|
|
162
|
+
relation: z.array(z.object({ id: z.uuid() })),
|
|
163
|
+
has_more: z.boolean(),
|
|
130
164
|
});
|
|
131
165
|
/** Rich text property. */
|
|
132
|
-
const richTextPropertySchema =
|
|
133
|
-
id:
|
|
134
|
-
type:
|
|
166
|
+
const richTextPropertySchema = z.object({
|
|
167
|
+
id: z.string().trim(),
|
|
168
|
+
type: z.literal('rich_text'),
|
|
135
169
|
rich_text: richText_schema_1.richTextSchema,
|
|
136
170
|
});
|
|
137
171
|
/** Rollup property. */
|
|
138
|
-
const rollupPropertySchema =
|
|
139
|
-
id:
|
|
140
|
-
type:
|
|
141
|
-
rollup:
|
|
142
|
-
type:
|
|
143
|
-
function:
|
|
172
|
+
const rollupPropertySchema = z.object({
|
|
173
|
+
id: z.string().trim(),
|
|
174
|
+
type: z.literal('rollup'),
|
|
175
|
+
rollup: z.object({
|
|
176
|
+
type: z.enum(['number', 'date', 'array', 'incomplete', 'unsupported']),
|
|
177
|
+
function: z.enum([
|
|
144
178
|
'average',
|
|
145
179
|
'checked',
|
|
146
180
|
'count',
|
|
@@ -166,82 +200,82 @@ const rollupPropertySchema = zod_1.z.object({
|
|
|
166
200
|
'unchecked',
|
|
167
201
|
'unique',
|
|
168
202
|
]),
|
|
169
|
-
number:
|
|
170
|
-
date:
|
|
203
|
+
number: z.number().nullable().optional(),
|
|
204
|
+
date: z
|
|
171
205
|
.object({
|
|
172
|
-
start:
|
|
173
|
-
end:
|
|
174
|
-
time_zone:
|
|
206
|
+
start: shared_schema_1.notionDateStringSchema,
|
|
207
|
+
end: shared_schema_1.notionDateStringSchema.nullable(),
|
|
208
|
+
time_zone: z.string().trim().nullable(),
|
|
175
209
|
})
|
|
176
210
|
.nullable()
|
|
177
211
|
.optional(),
|
|
178
|
-
array:
|
|
212
|
+
array: z.array(z.unknown()).optional(),
|
|
179
213
|
}),
|
|
180
214
|
});
|
|
181
215
|
/** Select property. */
|
|
182
|
-
const selectPropertySchema =
|
|
183
|
-
id:
|
|
184
|
-
type:
|
|
185
|
-
select:
|
|
216
|
+
const selectPropertySchema = z.object({
|
|
217
|
+
id: z.string().trim(),
|
|
218
|
+
type: z.literal('select'),
|
|
219
|
+
select: z
|
|
186
220
|
.object({
|
|
187
|
-
id:
|
|
188
|
-
name:
|
|
189
|
-
color:
|
|
221
|
+
id: z.string().trim(),
|
|
222
|
+
name: z.string().trim(),
|
|
223
|
+
color: z.enum(colors_1.NOTION_COLORS),
|
|
190
224
|
})
|
|
191
225
|
.nullable(),
|
|
192
226
|
});
|
|
193
227
|
/** Status property. */
|
|
194
|
-
const statusPropertySchema =
|
|
195
|
-
id:
|
|
196
|
-
type:
|
|
197
|
-
status:
|
|
228
|
+
const statusPropertySchema = z.object({
|
|
229
|
+
id: z.string().trim(),
|
|
230
|
+
type: z.literal('status'),
|
|
231
|
+
status: z
|
|
198
232
|
.object({
|
|
199
|
-
id:
|
|
200
|
-
name:
|
|
201
|
-
color:
|
|
233
|
+
id: z.string().trim(),
|
|
234
|
+
name: z.string().trim(),
|
|
235
|
+
color: z.enum(colors_1.NOTION_COLORS),
|
|
202
236
|
})
|
|
203
237
|
.nullable(),
|
|
204
238
|
});
|
|
205
239
|
/** Title property. */
|
|
206
|
-
const titlePropertySchema =
|
|
207
|
-
id:
|
|
208
|
-
type:
|
|
240
|
+
const titlePropertySchema = z.object({
|
|
241
|
+
id: z.string().trim(),
|
|
242
|
+
type: z.literal('title'),
|
|
209
243
|
title: richText_schema_1.richTextSchema,
|
|
210
244
|
});
|
|
211
245
|
/** URL property. */
|
|
212
|
-
const urlPropertySchema =
|
|
213
|
-
id:
|
|
214
|
-
type:
|
|
215
|
-
url:
|
|
246
|
+
const urlPropertySchema = z.object({
|
|
247
|
+
id: z.string().trim(),
|
|
248
|
+
type: z.literal('url'),
|
|
249
|
+
url: z.url().nullable(),
|
|
216
250
|
});
|
|
217
251
|
/** Unique ID property. */
|
|
218
|
-
const uniqueIdPropertySchema =
|
|
219
|
-
id:
|
|
220
|
-
type:
|
|
221
|
-
unique_id:
|
|
222
|
-
number:
|
|
223
|
-
prefix:
|
|
252
|
+
const uniqueIdPropertySchema = z.object({
|
|
253
|
+
id: z.string().trim(),
|
|
254
|
+
type: z.literal('unique_id'),
|
|
255
|
+
unique_id: z.object({
|
|
256
|
+
number: z.int(),
|
|
257
|
+
prefix: z.string().trim().nullable(),
|
|
224
258
|
}),
|
|
225
259
|
});
|
|
226
260
|
/** Verification property. */
|
|
227
|
-
const verificationPropertySchema =
|
|
228
|
-
id:
|
|
229
|
-
type:
|
|
230
|
-
verification:
|
|
261
|
+
const verificationPropertySchema = z.object({
|
|
262
|
+
id: z.string().trim(),
|
|
263
|
+
type: z.literal('verification'),
|
|
264
|
+
verification: z
|
|
231
265
|
.object({
|
|
232
|
-
state:
|
|
266
|
+
state: z.enum(['verified', 'unverified']),
|
|
233
267
|
verified_by: user_schema_1.userSchema.nullable(),
|
|
234
|
-
date:
|
|
268
|
+
date: z
|
|
235
269
|
.object({
|
|
236
|
-
start:
|
|
237
|
-
end:
|
|
238
|
-
time_zone:
|
|
270
|
+
start: shared_schema_1.notionDateStringSchema,
|
|
271
|
+
end: shared_schema_1.notionDateStringSchema.nullable(),
|
|
272
|
+
time_zone: z.string().trim().nullable(),
|
|
239
273
|
})
|
|
240
274
|
.nullable(),
|
|
241
275
|
})
|
|
242
276
|
.nullable(),
|
|
243
277
|
});
|
|
244
|
-
exports.pagePropertiesSchema =
|
|
278
|
+
exports.pagePropertiesSchema = z.discriminatedUnion('type', [
|
|
245
279
|
checkboxPropertySchema,
|
|
246
280
|
createdByPropertySchema,
|
|
247
281
|
createdTimePropertySchema,
|
|
@@ -1,18 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.paginatedListSchema = void 0;
|
|
4
|
-
const
|
|
37
|
+
const z = __importStar(require("zod"));
|
|
5
38
|
/**
|
|
6
39
|
* Base paginated list response schema.
|
|
7
40
|
*/
|
|
8
41
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
9
42
|
const paginatedListSchema = (resultSchema) => {
|
|
10
|
-
return
|
|
11
|
-
object:
|
|
12
|
-
results:
|
|
13
|
-
next_cursor:
|
|
14
|
-
has_more:
|
|
15
|
-
type:
|
|
43
|
+
return z.object({
|
|
44
|
+
object: z.literal('list'),
|
|
45
|
+
results: z.array(resultSchema),
|
|
46
|
+
next_cursor: z.string().trim().nullable(),
|
|
47
|
+
has_more: z.boolean(),
|
|
48
|
+
type: z.enum([
|
|
16
49
|
'block',
|
|
17
50
|
'comment',
|
|
18
51
|
'database',
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.parentSchema = void 0;
|
|
4
|
-
const
|
|
37
|
+
const z = __importStar(require("zod"));
|
|
5
38
|
/**
|
|
6
39
|
* Notion parent object schemas.
|
|
7
40
|
*
|
|
@@ -12,32 +45,32 @@ const zod_1 = require("zod");
|
|
|
12
45
|
* https://developers.notion.com/reference/parent-object
|
|
13
46
|
*/
|
|
14
47
|
/** Database parent. */
|
|
15
|
-
const databaseParentSchema =
|
|
16
|
-
type:
|
|
17
|
-
database_id:
|
|
48
|
+
const databaseParentSchema = z.object({
|
|
49
|
+
type: z.literal('database_id'),
|
|
50
|
+
database_id: z.uuid(),
|
|
18
51
|
});
|
|
19
52
|
/** Data source parent. */
|
|
20
|
-
const dataSourceParentSchema =
|
|
21
|
-
type:
|
|
22
|
-
data_source_id:
|
|
23
|
-
database_id:
|
|
53
|
+
const dataSourceParentSchema = z.object({
|
|
54
|
+
type: z.literal('data_source_id'),
|
|
55
|
+
data_source_id: z.uuid(),
|
|
56
|
+
database_id: z.uuid(),
|
|
24
57
|
});
|
|
25
58
|
/** Page parent. */
|
|
26
|
-
const pageParentSchema =
|
|
27
|
-
type:
|
|
28
|
-
page_id:
|
|
59
|
+
const pageParentSchema = z.object({
|
|
60
|
+
type: z.literal('page_id'),
|
|
61
|
+
page_id: z.uuid(),
|
|
29
62
|
});
|
|
30
63
|
/** Workspace parent. */
|
|
31
|
-
const workspaceParentSchema =
|
|
32
|
-
type:
|
|
33
|
-
workspace:
|
|
64
|
+
const workspaceParentSchema = z.object({
|
|
65
|
+
type: z.literal('workspace'),
|
|
66
|
+
workspace: z.literal(true),
|
|
34
67
|
});
|
|
35
68
|
/** Block parent. */
|
|
36
|
-
const blockParentSchema =
|
|
37
|
-
type:
|
|
38
|
-
block_id:
|
|
69
|
+
const blockParentSchema = z.object({
|
|
70
|
+
type: z.literal('block_id'),
|
|
71
|
+
block_id: z.uuid(),
|
|
39
72
|
});
|
|
40
|
-
exports.parentSchema =
|
|
73
|
+
exports.parentSchema = z.discriminatedUnion('type', [
|
|
41
74
|
databaseParentSchema,
|
|
42
75
|
dataSourceParentSchema,
|
|
43
76
|
pageParentSchema,
|