@marketing-sdk/notion 0.1.1-experimental.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/LICENSE +21 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +273 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.d.ts +8 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +39 -0
- package/dist/validators.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cody
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CreateResponse, BaseProvider } from '@marketing-sdk/core';
|
|
2
|
+
import { Notion } from './types';
|
|
3
|
+
export declare class NotionClient extends BaseProvider {
|
|
4
|
+
private integrationToken;
|
|
5
|
+
private notionVersion;
|
|
6
|
+
constructor(integrationToken: string);
|
|
7
|
+
protected getDefaultHeaders(): Record<string, string>;
|
|
8
|
+
protected getAuthHeaders(): Record<string, string>;
|
|
9
|
+
createPage(page: Notion.PagePayload): Promise<CreateResponse<Notion.PageResponse>>;
|
|
10
|
+
getPage(pageId: string): Promise<CreateResponse<Notion.PageResponse>>;
|
|
11
|
+
updatePage(pageId: string, properties: Record<string, any>, archived?: boolean): Promise<CreateResponse<Notion.PageResponse>>;
|
|
12
|
+
getDatabase(databaseId: string): Promise<CreateResponse<Notion.DatabaseResponse>>;
|
|
13
|
+
queryDatabase(databaseId: string, query?: Notion.DatabaseQueryPayload): Promise<CreateResponse<Notion.DatabaseQueryResponse>>;
|
|
14
|
+
createDatabaseEntry(databaseId: string, properties: Record<string, any>, children?: Notion.BlockPayload[]): Promise<CreateResponse<Notion.PageResponse>>;
|
|
15
|
+
getBlock(blockId: string): Promise<CreateResponse<Notion.BlockResponse>>;
|
|
16
|
+
getBlockChildren(blockId: string, params?: {
|
|
17
|
+
start_cursor?: string;
|
|
18
|
+
page_size?: number;
|
|
19
|
+
}): Promise<CreateResponse<Notion.BlocksResponse>>;
|
|
20
|
+
appendBlocks(blockId: string, children: Notion.BlockPayload[]): Promise<CreateResponse<Notion.BlocksResponse>>;
|
|
21
|
+
deleteBlock(blockId: string): Promise<CreateResponse<Notion.BlockResponse>>;
|
|
22
|
+
getUser(userId: string): Promise<CreateResponse<Notion.UserResponse>>;
|
|
23
|
+
listUsers(params?: {
|
|
24
|
+
start_cursor?: string;
|
|
25
|
+
page_size?: number;
|
|
26
|
+
}): Promise<CreateResponse<Notion.UsersResponse>>;
|
|
27
|
+
search(searchParams?: Notion.SearchPayload): Promise<CreateResponse<Notion.SearchResponse>>;
|
|
28
|
+
searchPages(query?: string, params?: {
|
|
29
|
+
start_cursor?: string;
|
|
30
|
+
page_size?: number;
|
|
31
|
+
sort?: {
|
|
32
|
+
direction: "ascending" | "descending";
|
|
33
|
+
timestamp: "last_edited_time";
|
|
34
|
+
};
|
|
35
|
+
}): Promise<CreateResponse<Notion.SearchResponse>>;
|
|
36
|
+
searchDatabases(query?: string, params?: {
|
|
37
|
+
start_cursor?: string;
|
|
38
|
+
page_size?: number;
|
|
39
|
+
sort?: {
|
|
40
|
+
direction: "ascending" | "descending";
|
|
41
|
+
timestamp: "last_edited_time";
|
|
42
|
+
};
|
|
43
|
+
}): Promise<CreateResponse<Notion.SearchResponse>>;
|
|
44
|
+
static createTextBlock(content: string, type?: "paragraph" | "heading_1" | "heading_2" | "heading_3"): Notion.BlockPayload;
|
|
45
|
+
static createTodoBlock(content: string, checked?: boolean): Notion.BlockPayload;
|
|
46
|
+
static createBulletedListItem(content: string): Notion.BlockPayload;
|
|
47
|
+
static createNumberedListItem(content: string): Notion.BlockPayload;
|
|
48
|
+
static createCodeBlock(code: string, language?: string): Notion.BlockPayload;
|
|
49
|
+
static createCalloutBlock(content: string, emoji?: string): Notion.BlockPayload;
|
|
50
|
+
static createDivider(): Notion.BlockPayload;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAc,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,C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AE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE;YACL,SAAS,EAAE,WAAW,GAAG,YAAY,CAAC;YACtC,SAAS,EAAE,kBAAkB,CAAC;SAC/B,CAAC;KACH,GACA,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;WAgBnC,eAAe,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAyB,GACxE,MAAM,CAAC,YAAY;WAYR,eAAe,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,OAAe,GACvB,MAAM,CAAC,YAAY;WAaR,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,YAAY;WAY5D,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,YAAY;WAY5D,eAAe,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAqB,GAC9B,MAAM,CAAC,YAAY;WAaR,kBAAkB,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,MAAoB,GAC1B,MAAM,CAAC,YAAY;WAgBR,aAAa,IAAI,MAAM,CAAC,YAAY;CAMnD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotionClient = void 0;
|
|
4
|
+
const core_1 = require("@marketing-sdk/core");
|
|
5
|
+
const validators_1 = require("./validators");
|
|
6
|
+
class NotionClient extends core_1.BaseProvider {
|
|
7
|
+
constructor(integrationToken) {
|
|
8
|
+
super({
|
|
9
|
+
baseURL: "https://api.notion.com",
|
|
10
|
+
timeout: 30000,
|
|
11
|
+
});
|
|
12
|
+
this.notionVersion = "2022-06-28";
|
|
13
|
+
this.integrationToken = integrationToken;
|
|
14
|
+
}
|
|
15
|
+
getDefaultHeaders() {
|
|
16
|
+
return {
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
"Notion-Version": this.notionVersion,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
getAuthHeaders() {
|
|
22
|
+
return {
|
|
23
|
+
Authorization: `Bearer ${this.integrationToken}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async createPage(page) {
|
|
27
|
+
validators_1.NotionValidators.validatePagePayload(page);
|
|
28
|
+
return this.makeRequest({
|
|
29
|
+
url: "/v1/pages",
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: page,
|
|
32
|
+
}, "Create Page");
|
|
33
|
+
}
|
|
34
|
+
async getPage(pageId) {
|
|
35
|
+
core_1.Validators.validateId(pageId, "pageId");
|
|
36
|
+
return this.makeRequest({
|
|
37
|
+
url: `/v1/pages/${pageId}`,
|
|
38
|
+
method: "GET",
|
|
39
|
+
}, "Get Page");
|
|
40
|
+
}
|
|
41
|
+
async updatePage(pageId, properties, archived) {
|
|
42
|
+
core_1.Validators.validateId(pageId, "pageId");
|
|
43
|
+
const body = { properties };
|
|
44
|
+
if (archived !== undefined) {
|
|
45
|
+
body.archived = archived;
|
|
46
|
+
}
|
|
47
|
+
return this.makeRequest({
|
|
48
|
+
url: `/v1/pages/${pageId}`,
|
|
49
|
+
method: "PATCH",
|
|
50
|
+
body,
|
|
51
|
+
}, "Update Page");
|
|
52
|
+
}
|
|
53
|
+
async getDatabase(databaseId) {
|
|
54
|
+
core_1.Validators.validateId(databaseId, "databaseId");
|
|
55
|
+
return this.makeRequest({
|
|
56
|
+
url: `/v1/databases/${databaseId}`,
|
|
57
|
+
method: "GET",
|
|
58
|
+
}, "Get Database");
|
|
59
|
+
}
|
|
60
|
+
async queryDatabase(databaseId, query) {
|
|
61
|
+
core_1.Validators.validateId(databaseId, "databaseId");
|
|
62
|
+
if (query) {
|
|
63
|
+
validators_1.NotionValidators.validateDatabaseQuery(query);
|
|
64
|
+
}
|
|
65
|
+
return this.makeRequest({
|
|
66
|
+
url: `/v1/databases/${databaseId}/query`,
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: query || {},
|
|
69
|
+
}, "Query Database");
|
|
70
|
+
}
|
|
71
|
+
async createDatabaseEntry(databaseId, properties, children) {
|
|
72
|
+
const page = {
|
|
73
|
+
parent: {
|
|
74
|
+
type: "database_id",
|
|
75
|
+
database_id: databaseId,
|
|
76
|
+
},
|
|
77
|
+
properties,
|
|
78
|
+
};
|
|
79
|
+
if (children) {
|
|
80
|
+
page.children = children;
|
|
81
|
+
}
|
|
82
|
+
return this.createPage(page);
|
|
83
|
+
}
|
|
84
|
+
async getBlock(blockId) {
|
|
85
|
+
core_1.Validators.validateId(blockId, "blockId");
|
|
86
|
+
return this.makeRequest({
|
|
87
|
+
url: `/v1/blocks/${blockId}`,
|
|
88
|
+
method: "GET",
|
|
89
|
+
}, "Get Block");
|
|
90
|
+
}
|
|
91
|
+
async getBlockChildren(blockId, params) {
|
|
92
|
+
core_1.Validators.validateId(blockId, "blockId");
|
|
93
|
+
if (params?.page_size) {
|
|
94
|
+
core_1.Validators.validatePaginationParams({ limit: params.page_size });
|
|
95
|
+
}
|
|
96
|
+
const queryParams = new URLSearchParams();
|
|
97
|
+
if (params?.start_cursor)
|
|
98
|
+
queryParams.append("start_cursor", params.start_cursor);
|
|
99
|
+
if (params?.page_size)
|
|
100
|
+
queryParams.append("page_size", params.page_size.toString());
|
|
101
|
+
const queryString = queryParams.toString();
|
|
102
|
+
const url = `/v1/blocks/${blockId}/children${queryString ? `?${queryString}` : ""}`;
|
|
103
|
+
return this.makeRequest({
|
|
104
|
+
url,
|
|
105
|
+
method: "GET",
|
|
106
|
+
}, "Get Block Children");
|
|
107
|
+
}
|
|
108
|
+
async appendBlocks(blockId, children) {
|
|
109
|
+
core_1.Validators.validateId(blockId, "blockId");
|
|
110
|
+
if (!children || children.length === 0) {
|
|
111
|
+
throw new Error("At least one block must be provided");
|
|
112
|
+
}
|
|
113
|
+
return this.makeRequest({
|
|
114
|
+
url: `/v1/blocks/${blockId}/children`,
|
|
115
|
+
method: "PATCH",
|
|
116
|
+
body: { children },
|
|
117
|
+
}, "Append Blocks");
|
|
118
|
+
}
|
|
119
|
+
async deleteBlock(blockId) {
|
|
120
|
+
core_1.Validators.validateId(blockId, "blockId");
|
|
121
|
+
return this.makeRequest({
|
|
122
|
+
url: `/v1/blocks/${blockId}`,
|
|
123
|
+
method: "DELETE",
|
|
124
|
+
}, "Delete Block");
|
|
125
|
+
}
|
|
126
|
+
async getUser(userId) {
|
|
127
|
+
core_1.Validators.validateId(userId, "userId");
|
|
128
|
+
return this.makeRequest({
|
|
129
|
+
url: `/v1/users/${userId}`,
|
|
130
|
+
method: "GET",
|
|
131
|
+
}, "Get User");
|
|
132
|
+
}
|
|
133
|
+
async listUsers(params) {
|
|
134
|
+
if (params?.page_size) {
|
|
135
|
+
core_1.Validators.validatePaginationParams({ limit: params.page_size });
|
|
136
|
+
}
|
|
137
|
+
const queryParams = new URLSearchParams();
|
|
138
|
+
if (params?.start_cursor)
|
|
139
|
+
queryParams.append("start_cursor", params.start_cursor);
|
|
140
|
+
if (params?.page_size)
|
|
141
|
+
queryParams.append("page_size", params.page_size.toString());
|
|
142
|
+
const queryString = queryParams.toString();
|
|
143
|
+
const url = `/v1/users${queryString ? `?${queryString}` : ""}`;
|
|
144
|
+
return this.makeRequest({
|
|
145
|
+
url,
|
|
146
|
+
method: "GET",
|
|
147
|
+
}, "List Users");
|
|
148
|
+
}
|
|
149
|
+
async search(searchParams) {
|
|
150
|
+
if (searchParams?.page_size) {
|
|
151
|
+
core_1.Validators.validatePaginationParams({ limit: searchParams.page_size });
|
|
152
|
+
}
|
|
153
|
+
return this.makeRequest({
|
|
154
|
+
url: "/v1/search",
|
|
155
|
+
method: "POST",
|
|
156
|
+
body: searchParams || {},
|
|
157
|
+
}, "Search");
|
|
158
|
+
}
|
|
159
|
+
async searchPages(query, params) {
|
|
160
|
+
const searchParams = {
|
|
161
|
+
filter: {
|
|
162
|
+
value: "page",
|
|
163
|
+
property: "object",
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
if (query)
|
|
167
|
+
searchParams.query = query;
|
|
168
|
+
if (params?.start_cursor)
|
|
169
|
+
searchParams.start_cursor = params.start_cursor;
|
|
170
|
+
if (params?.page_size)
|
|
171
|
+
searchParams.page_size = params.page_size;
|
|
172
|
+
if (params?.sort)
|
|
173
|
+
searchParams.sort = params.sort;
|
|
174
|
+
return this.search(searchParams);
|
|
175
|
+
}
|
|
176
|
+
async searchDatabases(query, params) {
|
|
177
|
+
const searchParams = {
|
|
178
|
+
filter: {
|
|
179
|
+
value: "database",
|
|
180
|
+
property: "object",
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
if (query)
|
|
184
|
+
searchParams.query = query;
|
|
185
|
+
if (params?.start_cursor)
|
|
186
|
+
searchParams.start_cursor = params.start_cursor;
|
|
187
|
+
if (params?.page_size)
|
|
188
|
+
searchParams.page_size = params.page_size;
|
|
189
|
+
if (params?.sort)
|
|
190
|
+
searchParams.sort = params.sort;
|
|
191
|
+
return this.search(searchParams);
|
|
192
|
+
}
|
|
193
|
+
static createTextBlock(content, type = "paragraph") {
|
|
194
|
+
return {
|
|
195
|
+
type,
|
|
196
|
+
[type]: {
|
|
197
|
+
rich_text: [{
|
|
198
|
+
type: "text",
|
|
199
|
+
text: { content },
|
|
200
|
+
}],
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
static createTodoBlock(content, checked = false) {
|
|
205
|
+
return {
|
|
206
|
+
type: "to_do",
|
|
207
|
+
to_do: {
|
|
208
|
+
rich_text: [{
|
|
209
|
+
type: "text",
|
|
210
|
+
text: { content },
|
|
211
|
+
}],
|
|
212
|
+
checked,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
static createBulletedListItem(content) {
|
|
217
|
+
return {
|
|
218
|
+
type: "bulleted_list_item",
|
|
219
|
+
bulleted_list_item: {
|
|
220
|
+
rich_text: [{
|
|
221
|
+
type: "text",
|
|
222
|
+
text: { content },
|
|
223
|
+
}],
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
static createNumberedListItem(content) {
|
|
228
|
+
return {
|
|
229
|
+
type: "numbered_list_item",
|
|
230
|
+
numbered_list_item: {
|
|
231
|
+
rich_text: [{
|
|
232
|
+
type: "text",
|
|
233
|
+
text: { content },
|
|
234
|
+
}],
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
static createCodeBlock(code, language = "plain text") {
|
|
239
|
+
return {
|
|
240
|
+
type: "code",
|
|
241
|
+
code: {
|
|
242
|
+
rich_text: [{
|
|
243
|
+
type: "text",
|
|
244
|
+
text: { content: code },
|
|
245
|
+
}],
|
|
246
|
+
language,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
static createCalloutBlock(content, emoji = "\u{1F4A1}") {
|
|
251
|
+
return {
|
|
252
|
+
type: "callout",
|
|
253
|
+
callout: {
|
|
254
|
+
rich_text: [{
|
|
255
|
+
type: "text",
|
|
256
|
+
text: { content },
|
|
257
|
+
}],
|
|
258
|
+
icon: {
|
|
259
|
+
type: "emoji",
|
|
260
|
+
emoji,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
static createDivider() {
|
|
266
|
+
return {
|
|
267
|
+
type: "divider",
|
|
268
|
+
divider: {},
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.NotionClient = NotionClient;
|
|
273
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,8CAA+E;AAE/E,6CAAgD;AAEhD,MAAa,YAAa,SAAQ,mBAAY;IAI5C,YAAY,gBAAwB;QAClC,KAAK,CAAC;YACJ,OAAO,EAAE,wBAAwB;YACjC,O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AE,MAAM;wBACZ,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;qBACxB,CAAC;gBACF,QAAQ;aACT;SACF,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,OAAe,EACf,QAAgB,WAAW;QAE3B,OAAO;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,SAAS,EAAE,CAAC;wBACV,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,EAAE,OAAO,EAAE;qBAClB,CAAC;gBACF,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK;iBACN;aACF;SACF,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,aAAa;QACzB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;CACF;AAtXD,oCAsXC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = exports.NotionValidators = exports.NotionClient = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "NotionClient", { enumerable: true, get: function () { return client_1.NotionClient; } });
|
|
6
|
+
var validators_1 = require("./validators");
|
|
7
|
+
Object.defineProperty(exports, "NotionValidators", { enumerable: true, get: function () { return validators_1.NotionValidators; } });
|
|
8
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validators_1.ValidationError; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,2CAAiE;AAAxD,8GAAA,gBAAgB,OAAA;AAAE,6GAAA,eAAe,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export declare namespace Notion {
|
|
2
|
+
type PagePayload = {
|
|
3
|
+
parent: {
|
|
4
|
+
type: "database_id" | "page_id" | "workspace";
|
|
5
|
+
database_id?: string;
|
|
6
|
+
page_id?: string;
|
|
7
|
+
};
|
|
8
|
+
properties: Record<string, any>;
|
|
9
|
+
children?: BlockPayload[];
|
|
10
|
+
icon?: {
|
|
11
|
+
type: "emoji" | "external";
|
|
12
|
+
emoji?: string;
|
|
13
|
+
external?: {
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
cover?: {
|
|
18
|
+
type: "external";
|
|
19
|
+
external: {
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type PageResponse = {
|
|
25
|
+
object: "page";
|
|
26
|
+
id: string;
|
|
27
|
+
created_time: string;
|
|
28
|
+
last_edited_time: string;
|
|
29
|
+
created_by: {
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
last_edited_by: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
parent: {
|
|
36
|
+
type: "database_id" | "page_id" | "workspace";
|
|
37
|
+
database_id?: string;
|
|
38
|
+
page_id?: string;
|
|
39
|
+
};
|
|
40
|
+
archived: boolean;
|
|
41
|
+
properties: Record<string, any>;
|
|
42
|
+
url: string;
|
|
43
|
+
};
|
|
44
|
+
type DatabaseQueryPayload = {
|
|
45
|
+
filter?: any;
|
|
46
|
+
sorts?: Array<{
|
|
47
|
+
property: string;
|
|
48
|
+
direction: "ascending" | "descending";
|
|
49
|
+
}>;
|
|
50
|
+
start_cursor?: string;
|
|
51
|
+
page_size?: number;
|
|
52
|
+
};
|
|
53
|
+
type DatabaseResponse = {
|
|
54
|
+
object: "database";
|
|
55
|
+
id: string;
|
|
56
|
+
created_time: string;
|
|
57
|
+
last_edited_time: string;
|
|
58
|
+
title: Array<{
|
|
59
|
+
type: "text";
|
|
60
|
+
text: {
|
|
61
|
+
content: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
properties: Record<string, any>;
|
|
65
|
+
parent: {
|
|
66
|
+
type: "page_id" | "workspace";
|
|
67
|
+
page_id?: string;
|
|
68
|
+
};
|
|
69
|
+
url: string;
|
|
70
|
+
};
|
|
71
|
+
type DatabaseQueryResponse = {
|
|
72
|
+
object: "list";
|
|
73
|
+
results: PageResponse[];
|
|
74
|
+
next_cursor: string | null;
|
|
75
|
+
has_more: boolean;
|
|
76
|
+
};
|
|
77
|
+
type BlockType = "paragraph" | "heading_1" | "heading_2" | "heading_3" | "bulleted_list_item" | "numbered_list_item" | "to_do" | "code" | "quote" | "callout" | "divider" | "table" | "table_row";
|
|
78
|
+
type BlockPayload = {
|
|
79
|
+
type: BlockType;
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
};
|
|
82
|
+
type BlockResponse = {
|
|
83
|
+
object: "block";
|
|
84
|
+
id: string;
|
|
85
|
+
created_time: string;
|
|
86
|
+
last_edited_time: string;
|
|
87
|
+
created_by: {
|
|
88
|
+
id: string;
|
|
89
|
+
};
|
|
90
|
+
last_edited_by: {
|
|
91
|
+
id: string;
|
|
92
|
+
};
|
|
93
|
+
has_children: boolean;
|
|
94
|
+
archived: boolean;
|
|
95
|
+
type: BlockType;
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
};
|
|
98
|
+
type BlocksResponse = {
|
|
99
|
+
object: "list";
|
|
100
|
+
results: BlockResponse[];
|
|
101
|
+
next_cursor: string | null;
|
|
102
|
+
has_more: boolean;
|
|
103
|
+
};
|
|
104
|
+
type UserResponse = {
|
|
105
|
+
object: "user";
|
|
106
|
+
id: string;
|
|
107
|
+
type: "person" | "bot";
|
|
108
|
+
name: string;
|
|
109
|
+
avatar_url: string | null;
|
|
110
|
+
};
|
|
111
|
+
type UsersResponse = {
|
|
112
|
+
object: "list";
|
|
113
|
+
results: UserResponse[];
|
|
114
|
+
next_cursor: string | null;
|
|
115
|
+
has_more: boolean;
|
|
116
|
+
};
|
|
117
|
+
type SearchPayload = {
|
|
118
|
+
query?: string;
|
|
119
|
+
filter?: {
|
|
120
|
+
value: "page" | "database";
|
|
121
|
+
property: "object";
|
|
122
|
+
};
|
|
123
|
+
sort?: {
|
|
124
|
+
direction: "ascending" | "descending";
|
|
125
|
+
timestamp: "last_edited_time";
|
|
126
|
+
};
|
|
127
|
+
start_cursor?: string;
|
|
128
|
+
page_size?: number;
|
|
129
|
+
};
|
|
130
|
+
type SearchResponse = {
|
|
131
|
+
object: "list";
|
|
132
|
+
results: Array<PageResponse | DatabaseResponse>;
|
|
133
|
+
next_cursor: string | null;
|
|
134
|
+
has_more: boolean;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,yBAAiB,MAAM,CAAC;IACtB,KAAY,WAAW,GAAG;QACxB,MAAM,EAAE;YACN,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;YAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;QAC1B,IAAI,CAAC,EAAE;YACL,IAAI,EAAE,OAAO,GAA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","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationError } from '@marketing-sdk/core';
|
|
2
|
+
import { Notion } from './types';
|
|
3
|
+
export { ValidationError };
|
|
4
|
+
export declare class NotionValidators {
|
|
5
|
+
static validatePagePayload(payload: Notion.PagePayload): void;
|
|
6
|
+
static validateDatabaseQuery(query: Notion.DatabaseQueryPayload): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,GAAG,IAAI;IAsB7D,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,oBAAoB,GAAG,IAAI;CAcvE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotionValidators = exports.ValidationError = void 0;
|
|
4
|
+
const core_1 = require("@marketing-sdk/core");
|
|
5
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return core_1.ValidationError; } });
|
|
6
|
+
class NotionValidators {
|
|
7
|
+
static validatePagePayload(payload) {
|
|
8
|
+
if (!payload.parent) {
|
|
9
|
+
throw new core_1.ValidationError('parent', 'Parent is required');
|
|
10
|
+
}
|
|
11
|
+
if (!payload.parent.type) {
|
|
12
|
+
throw new core_1.ValidationError('parent.type', 'Parent type is required');
|
|
13
|
+
}
|
|
14
|
+
if (payload.parent.type === 'database_id' && !payload.parent.database_id) {
|
|
15
|
+
throw new core_1.ValidationError('parent.database_id', 'Database ID is required when parent type is database_id');
|
|
16
|
+
}
|
|
17
|
+
if (payload.parent.type === 'page_id' && !payload.parent.page_id) {
|
|
18
|
+
throw new core_1.ValidationError('parent.page_id', 'Page ID is required when parent type is page_id');
|
|
19
|
+
}
|
|
20
|
+
if (!payload.properties || Object.keys(payload.properties).length === 0) {
|
|
21
|
+
throw new core_1.ValidationError('properties', 'Properties are required');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static validateDatabaseQuery(query) {
|
|
25
|
+
if (query.page_size !== undefined) {
|
|
26
|
+
if (!Number.isInteger(query.page_size) || query.page_size < 1) {
|
|
27
|
+
throw new core_1.ValidationError('page_size', 'Page size must be a positive integer');
|
|
28
|
+
}
|
|
29
|
+
if (query.page_size > 100) {
|
|
30
|
+
throw new core_1.ValidationError('page_size', 'Page size cannot exceed 100');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (query.sorts && !Array.isArray(query.sorts)) {
|
|
34
|
+
throw new core_1.ValidationError('sorts', 'Sorts must be an array');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.NotionValidators = NotionValidators;
|
|
39
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":";;;AAAA,8CAAsD;AAG7C,gGAHA,sBAAe,OAGA;AAExB,MAAa,gBAAgB;IAC3B,MAAM,CAAC,mBAAmB,CAAC,OAA2B;QACpD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,sBAAe,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QAC5D,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,sBAAe,CAAC,aAAa,EAAE,yBAAy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;AArCD,4CAqCC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@marketing-sdk/notion",
|
|
3
|
+
"version": "0.1.1-experimental.0",
|
|
4
|
+
"description": "Notion provider for marketing-sdk",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@marketing-sdk/core": "0.1.1-experimental.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@marketing-sdk/core": ">=0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.3.0",
|
|
28
|
+
"jest": "^29.7.0",
|
|
29
|
+
"ts-jest": "^29.1.0",
|
|
30
|
+
"@types/jest": "^29.5.0",
|
|
31
|
+
"@types/node": "^20.0.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"test": "jest",
|
|
36
|
+
"test:coverage": "jest --coverage",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
}
|
|
39
|
+
}
|