Skip to content

Commit 00a0141

Browse files
committed
feat: add notion integration
1 parent 7aa3bfb commit 00a0141

File tree

7 files changed

+620
-3
lines changed

7 files changed

+620
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import OAuth2Strategy from 'passport-oauth2'
2+
3+
class NotionPassportStrategy extends OAuth2Strategy {
4+
name = 'notion'
5+
6+
constructor(options: OAuth2Strategy.StrategyOptions, verify: OAuth2Strategy.VerifyFunction) {
7+
options.customHeaders = {
8+
Authorization: `Basic ${Buffer.from(`${options.clientID}:${options.clientSecret}`).toString('base64')}`,
9+
}
10+
super(options, verify)
11+
}
12+
}
13+
14+
export const Strategy = NotionPassportStrategy

libs/definitions/src/integration-definition.factory.ts

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { MongoDBDefinition } from './integration-definitions/mongodb.definition'
4545
import { MoonbeamMoonscanDefinition } from './integration-definitions/moonbeam-moonscan.definition'
4646
import { MoonriverMoonscanDefinition } from './integration-definitions/moonriver-moonscan.definition'
4747
import { MoralisDefinition } from './integration-definitions/moralis.definition'
48+
import { NotionDefinition } from './integration-definitions/notion/notion.definition'
4849
import { OptimisticEtherscanDefinition } from './integration-definitions/optimistic-etherscan.definition'
4950
import { PolygonscanDefinition } from './integration-definitions/polygonscan.definition'
5051
import { RedditDefinition } from './integration-definitions/reddit.definition'
@@ -118,6 +119,7 @@ export class IntegrationDefinitionFactory {
118119
'moonbeam-moonscan': MoonbeamMoonscanDefinition,
119120
'moonriver-moonscan': MoonriverMoonscanDefinition,
120121
moralis: MoralisDefinition,
122+
notion: NotionDefinition,
121123
'optimistic-etherscan': OptimisticEtherscanDefinition,
122124
// pagerduty: PagerdutyDefinition,
123125
// pancakeswap: PancakeSwapDefinition,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { PipedreamMixin } from '@app/definitions/mixins/pipedream.mixin'
2+
import { SingleIntegrationDefinition } from '@app/definitions/single-integration.definition'
3+
import { IntegrationAccount } from 'apps/api/src/integration-accounts/entities/integration-account'
4+
import { IntegrationAccountService } from 'apps/api/src/integration-accounts/services/integration-account.service'
5+
import { OpenAPIObject } from 'openapi3-ts'
6+
7+
export class NotionDefinition extends PipedreamMixin(SingleIntegrationDefinition) {
8+
integrationKey = 'notion'
9+
pipedreamKey = 'notion'
10+
integrationVersion = '1'
11+
schemaUrl = null
12+
13+
async createOrUpdateIntegrationAccount(schema: OpenAPIObject): Promise<IntegrationAccount | null> {
14+
const integrationAccount = await super.createOrUpdateIntegrationAccount(schema)
15+
if (!integrationAccount) {
16+
return null
17+
}
18+
return await IntegrationAccountService.instance.createOrUpdateOne({
19+
key: integrationAccount.key,
20+
authParams: {
21+
user: 'owner',
22+
},
23+
customStrategyKey: 'notion',
24+
})
25+
}
26+
27+
async getOperation(type: string, key: string) {
28+
const op = await import(`../../../../../dist/pipedream/components/notion/${type}/${key}/${key}.mjs`)
29+
return op.default
30+
}
31+
}

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@nestjs/passport": "^9.0.0",
4444
"@nestjs/platform-express": "^9.0.8",
4545
"@nestjs/schedule": "2.1.0",
46+
"@notionhq/client": "2.2.3",
4647
"@octokit/core": "^4.0.5",
4748
"@octokit/plugin-paginate-rest": "^4.1.0",
4849
"@openapi-contrib/openapi-schema-to-json-schema": "^3.0.4",
@@ -52,6 +53,7 @@
5253
"@pipedream/platform": "^1.1.0",
5354
"@ptc-org/nestjs-query-core": "1.1.2",
5455
"@ptc-org/nestjs-query-graphql": "1.1.2",
56+
"@tryfabric/martian": "1.2.4",
5557
"@typegoose/typegoose": "9.11.0",
5658
"@xmtp/xmtp-js": "7.7.2",
5759
"apollo-server-core": "3.10.0",

patches/pipedream+1.2.1.patch

+22
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,25 @@ index a8c4216..c6caf28 100644
1010
* @returns {object} the new object
1111
*/
1212
function omitEmptyKey({
13+
diff --git a/node_modules/pipedream/components/notion/actions/create-page-from-database/create-page-from-database.mjs b/node_modules/pipedream/components/notion/actions/create-page-from-database/create-page-from-database.mjs
14+
index 92a8956..8ab8f2c 100644
15+
--- a/node_modules/pipedream/components/notion/actions/create-page-from-database/create-page-from-database.mjs
16+
+++ b/node_modules/pipedream/components/notion/actions/create-page-from-database/create-page-from-database.mjs
17+
@@ -1,4 +1,4 @@
18+
-import { pick } from "lodash-es";
19+
+import { pick } from "lodash";
20+
import notion from "../../notion.app.mjs";
21+
import base from "../common/base-page-builder.mjs";
22+
23+
diff --git a/node_modules/pipedream/components/notion/actions/update-page/update-page.mjs b/node_modules/pipedream/components/notion/actions/update-page/update-page.mjs
24+
index 550f513..6cf71cb 100644
25+
--- a/node_modules/pipedream/components/notion/actions/update-page/update-page.mjs
26+
+++ b/node_modules/pipedream/components/notion/actions/update-page/update-page.mjs
27+
@@ -1,6 +1,6 @@
28+
import notion from "../../notion.app.mjs";
29+
import base from "../common/base-page-builder.mjs";
30+
-import { pick } from "lodash-es";
31+
+import { pick } from "lodash";
32+
33+
export default {
34+
...base,

schemas/openapi3/notion-1.json

+294
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Notion",
5+
"version": "1",
6+
"x-categories": ["popular", "blog", "document"],
7+
"x-logo": {
8+
"url": "https://github.com/chainjet/assets/blob/master/integrations/notion.png?raw=true"
9+
}
10+
},
11+
"paths": {
12+
"/notion-append-block": {
13+
"get": {
14+
"operationId": "notion-append-block",
15+
"x-actionOnly": true,
16+
"x-learnResponseWorkflow": true,
17+
"summary": "",
18+
"responses": {
19+
"200": {
20+
"description": "",
21+
"content": { "application/json": { "schema": {} } }
22+
}
23+
}
24+
}
25+
},
26+
"/notion-create-page": {
27+
"get": {
28+
"operationId": "notion-create-page",
29+
"x-actionOnly": true,
30+
"x-learnResponseWorkflow": true,
31+
"summary": "",
32+
"parameters": [
33+
{
34+
"name": "pageContent",
35+
"in": "query",
36+
"schema": { "x-ui:widget": "textarea" }
37+
}
38+
],
39+
"responses": {
40+
"200": {
41+
"description": "",
42+
"content": { "application/json": { "schema": {} } }
43+
}
44+
}
45+
}
46+
},
47+
"/notion-create-page-from-database": {
48+
"get": {
49+
"operationId": "notion-create-page-from-database",
50+
"x-actionOnly": true,
51+
"x-learnResponseWorkflow": true,
52+
"summary": "",
53+
"parameters": [
54+
{
55+
"name": "pageContent",
56+
"in": "query",
57+
"schema": { "x-ui:widget": "textarea" }
58+
}
59+
],
60+
"responses": {
61+
"200": {
62+
"description": "",
63+
"content": { "application/json": { "schema": {} } }
64+
}
65+
}
66+
}
67+
},
68+
"/notion-duplicate-page": {
69+
"get": {
70+
"operationId": "notion-duplicate-page",
71+
"x-actionOnly": true,
72+
"x-learnResponseWorkflow": true,
73+
"summary": "",
74+
"responses": {
75+
"200": {
76+
"description": "",
77+
"content": { "application/json": { "schema": {} } }
78+
}
79+
}
80+
}
81+
},
82+
"/notion-find-page": {
83+
"get": {
84+
"operationId": "notion-find-page",
85+
"x-actionOnly": true,
86+
"x-learnResponseWorkflow": true,
87+
"summary": "",
88+
"responses": {
89+
"200": {
90+
"description": "",
91+
"content": { "application/json": { "schema": {} } }
92+
}
93+
}
94+
}
95+
},
96+
"/notion-query-database": {
97+
"get": {
98+
"operationId": "notion-query-database",
99+
"x-actionOnly": true,
100+
"x-learnResponseWorkflow": true,
101+
"summary": "",
102+
"responses": {
103+
"200": {
104+
"description": "",
105+
"content": { "application/json": { "schema": {} } }
106+
}
107+
}
108+
}
109+
},
110+
"/notion-retrieve-block": {
111+
"get": {
112+
"operationId": "notion-retrieve-block",
113+
"x-actionOnly": true,
114+
"x-learnResponseWorkflow": true,
115+
"summary": "",
116+
"responses": {
117+
"200": {
118+
"description": "",
119+
"content": { "application/json": { "schema": {} } }
120+
}
121+
}
122+
}
123+
},
124+
"/notion-retrieve-database-content": {
125+
"get": {
126+
"operationId": "notion-retrieve-database-content",
127+
"x-actionOnly": true,
128+
"x-learnResponseWorkflow": true,
129+
"summary": "",
130+
"responses": {
131+
"200": {
132+
"description": "",
133+
"content": { "application/json": { "schema": {} } }
134+
}
135+
}
136+
}
137+
},
138+
"/notion-retrieve-database-schema": {
139+
"get": {
140+
"operationId": "notion-retrieve-database-schema",
141+
"x-actionOnly": true,
142+
"x-learnResponseWorkflow": true,
143+
"summary": "",
144+
"responses": {
145+
"200": {
146+
"description": "",
147+
"content": { "application/json": { "schema": {} } }
148+
}
149+
}
150+
}
151+
},
152+
"/notion-retrieve-page": {
153+
"get": {
154+
"operationId": "notion-retrieve-page",
155+
"x-actionOnly": true,
156+
"x-learnResponseWorkflow": true,
157+
"summary": "",
158+
"responses": {
159+
"200": {
160+
"description": "",
161+
"content": { "application/json": { "schema": {} } }
162+
}
163+
}
164+
}
165+
},
166+
"/notion-retrieve-page-property-item": {
167+
"get": {
168+
"operationId": "notion-retrieve-page-property-item",
169+
"x-actionOnly": true,
170+
"x-learnResponseWorkflow": true,
171+
"summary": "",
172+
"responses": {
173+
"200": {
174+
"description": "",
175+
"content": { "application/json": { "schema": {} } }
176+
}
177+
}
178+
}
179+
},
180+
"/notion-search": {
181+
"get": {
182+
"operationId": "notion-search",
183+
"x-actionOnly": true,
184+
"x-learnResponseWorkflow": true,
185+
"summary": "",
186+
"responses": {
187+
"200": {
188+
"description": "",
189+
"content": { "application/json": { "schema": {} } }
190+
}
191+
}
192+
}
193+
},
194+
"/notion-update-page": {
195+
"get": {
196+
"operationId": "notion-update-page",
197+
"x-actionOnly": true,
198+
"x-learnResponseWorkflow": true,
199+
"summary": "",
200+
"responses": {
201+
"200": {
202+
"description": "",
203+
"content": { "application/json": { "schema": {} } }
204+
}
205+
}
206+
}
207+
},
208+
"/notion-new-database": {
209+
"get": {
210+
"operationId": "notion-new-database",
211+
"x-triggerOnly": true,
212+
"x-learnResponseWorkflow": true,
213+
"summary": "",
214+
"responses": {
215+
"200": {
216+
"description": "",
217+
"content": { "application/json": { "schema": {} } }
218+
}
219+
}
220+
}
221+
},
222+
"/notion-new-page": {
223+
"get": {
224+
"operationId": "notion-new-page",
225+
"x-triggerOnly": true,
226+
"x-learnResponseWorkflow": true,
227+
"summary": "",
228+
"responses": {
229+
"200": {
230+
"description": "",
231+
"content": { "application/json": { "schema": {} } }
232+
}
233+
}
234+
}
235+
},
236+
"/notion-page-or-subpage-updated": {
237+
"get": {
238+
"operationId": "notion-page-or-subpage-updated",
239+
"x-triggerOnly": true,
240+
"x-learnResponseWorkflow": true,
241+
"summary": "",
242+
"responses": {
243+
"200": {
244+
"description": "",
245+
"content": { "application/json": { "schema": {} } }
246+
}
247+
}
248+
}
249+
},
250+
"/notion-updated-page": {
251+
"get": {
252+
"operationId": "notion-updated-page",
253+
"x-triggerOnly": true,
254+
"x-learnResponseWorkflow": true,
255+
"summary": "",
256+
"responses": {
257+
"200": {
258+
"description": "",
259+
"content": { "application/json": { "schema": {} } }
260+
}
261+
}
262+
}
263+
},
264+
"/notion-updated-page-id": {
265+
"get": {
266+
"operationId": "notion-updated-page-id",
267+
"x-triggerOnly": true,
268+
"x-learnResponseWorkflow": true,
269+
"summary": "",
270+
"responses": {
271+
"200": {
272+
"description": "",
273+
"content": { "application/json": { "schema": {} } }
274+
}
275+
}
276+
}
277+
}
278+
},
279+
"components": {
280+
"securitySchemes": {
281+
"oauth2": {
282+
"type": "oauth2",
283+
"flows": {
284+
"authorizationCode": {
285+
"authorizationUrl": "https://api.notion.com/v1/oauth/authorize",
286+
"tokenUrl": "https://api.notion.com/v1/oauth/token",
287+
"scopes": {}
288+
}
289+
}
290+
}
291+
}
292+
},
293+
"security": [{ "oauth2": [] }]
294+
}

0 commit comments

Comments
 (0)