@@ -15,6 +15,8 @@ This document provides a comprehensive reference for all functions and classes a
15
15
- [ createWhiteLabelGDriveConnector] ( #createwhitelabelgdriveconnector )
16
16
- [ createVectorizeDropboxConnector] ( #createvectorizedropboxconnector )
17
17
- [ createWhiteLabelDropboxConnector] ( #createwhitelabeldropboxconnector )
18
+ - [ createVectorizeNotionConnector] ( #createvectorizenotionconnector )
19
+ - [ createWhiteLabelNotionConnector] ( #createwhitelabelnotionconnector )
18
20
- [ Base API Functions] ( #base-api-functions )
19
21
- [ createSourceConnector] ( #createsourceconnector )
20
22
- [ manageUser] ( #manageuser )
@@ -24,6 +26,9 @@ This document provides a comprehensive reference for all functions and classes a
24
26
- [ refreshGDriveToken] ( #refreshgdrivetoken )
25
27
- [ exchangeDropboxCodeForTokens] ( #exchangedropboxcodefortokens )
26
28
- [ refreshDropboxToken] ( #refreshdropboxtoken )
29
+ - [ exchangeNotionCodeForTokens] ( #exchangenotioncodefortokens )
30
+ - [ refreshNotionToken] ( #refreshnotiontoken )
31
+ - [ manageNotionUser] ( #managenotionuser )
27
32
28
33
## OAuth Classes
29
34
@@ -351,8 +356,8 @@ async function createVectorizeGDriveConnector(
351
356
** Parameters :**
352
357
353
358
- ` config ` : A ` VectorizeAPIConfig ` object containing :
354
- - ` authorization ` : Bearer token for authentication (use VECTORIZE_TOKEN env var )
355
- - ` organizationId ` : Your Vectorize organization ID (use VECTORIZE_ORG env var )
359
+ - ` authorization ` : Bearer token for authentication (use VECTORIZE_API_KEY env var )
360
+ - ` organizationId ` : Your Vectorize organization ID (use VECTORIZE_ORGANIZATION_ID env var )
356
361
- ` connectorName ` : Name for the connector
357
362
- ` platformUrl ` (optional ): URL of the Vectorize API (defaults to " https://api.vectorize.io/v1" )
358
363
@@ -364,8 +369,8 @@ async function createVectorizeGDriveConnector(
364
369
365
370
` ` ` typescript
366
371
const config = {
367
- authorization: process.env.VECTORIZE_TOKEN !,
368
- organizationId: process.env.VECTORIZE_ORG !,
372
+ authorization: process.env.VECTORIZE_API_KEY !,
373
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID !,
369
374
};
370
375
371
376
const connectorId = await createVectorizeGDriveConnector(
@@ -404,8 +409,8 @@ async function createWhiteLabelGDriveConnector(
404
409
405
410
` ` ` typescript
406
411
const config = {
407
- authorization: process.env.VECTORIZE_TOKEN !,
408
- organizationId: process.env.VECTORIZE_ORG !,
412
+ authorization: process.env.VECTORIZE_API_KEY !,
413
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID !,
409
414
};
410
415
411
416
const connectorId = await createWhiteLabelGDriveConnector(
@@ -442,8 +447,8 @@ async function createVectorizeDropboxConnector(
442
447
443
448
` ` ` typescript
444
449
const config = {
445
- authorization: process.env.VECTORIZE_TOKEN !,
446
- organizationId: process.env.VECTORIZE_ORG !,
450
+ authorization: process.env.VECTORIZE_API_KEY !,
451
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID !,
447
452
};
448
453
449
454
const connectorId = await createVectorizeDropboxConnector(
@@ -482,8 +487,8 @@ async function createWhiteLabelDropboxConnector(
482
487
483
488
` ` ` typescript
484
489
const config = {
485
- authorization: process.env.VECTORIZE_TOKEN !,
486
- organizationId: process.env.VECTORIZE_ORG !,
490
+ authorization: process.env.VECTORIZE_API_KEY !,
491
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID !,
487
492
};
488
493
489
494
const connectorId = await createWhiteLabelDropboxConnector(
@@ -494,6 +499,140 @@ const connectorId = await createWhiteLabelDropboxConnector(
494
499
);
495
500
` ` `
496
501
502
+ ### createVectorizeNotionConnector
503
+
504
+ Creates a Notion connector using Vectorize ' s managed OAuth credentials.
505
+
506
+ ` ` ` typescript
507
+ async function createVectorizeNotionConnector(
508
+ config: VectorizeAPIConfig,
509
+ connectorName: string,
510
+ platformUrl?: string
511
+ ): Promise<string>
512
+ ` ` `
513
+
514
+ ** Parameters :**
515
+
516
+ - ` config ` : A ` VectorizeAPIConfig ` object
517
+ - ` connectorName ` : Name for the connector
518
+ - ` platformUrl ` (optional ): URL of the Vectorize API (defaults to " https://api.vectorize.io/v1" )
519
+
520
+ ** Returns :**
521
+
522
+ - ` Promise<string> ` : The ID of the created connector
523
+
524
+ ** Example :**
525
+
526
+ ` ` ` typescript
527
+ const config = {
528
+ authorization: process.env.VECTORIZE_API_KEY!,
529
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
530
+ };
531
+
532
+ const connectorId = await createVectorizeNotionConnector(
533
+ config,
534
+ "My Notion Connector"
535
+ );
536
+ ` ` `
537
+
538
+ ### createWhiteLabelNotionConnector
539
+
540
+ Creates a Notion connector using your own OAuth credentials .
541
+
542
+ ` ` ` typescript
543
+ async function createWhiteLabelNotionConnector(
544
+ config: VectorizeAPIConfig,
545
+ connectorName: string,
546
+ clientId: string,
547
+ clientSecret: string,
548
+ platformUrl?: string
549
+ ): Promise<string>
550
+ ` ` `
551
+
552
+ ** Parameters :**
553
+
554
+ - ` config ` : A ` VectorizeAPIConfig ` object
555
+ - ` connectorName ` : Name for the connector
556
+ - ` clientId ` : Your Notion OAuth client ID
557
+ - ` clientSecret ` : Your Notion OAuth client secret
558
+ - ` platformUrl ` (optional ): URL of the Vectorize API (defaults to " https://api.vectorize.io/v1" )
559
+
560
+ ** Returns :**
561
+
562
+ - ` Promise<string> ` : The ID of the created connector
563
+
564
+ ** Example :**
565
+
566
+ ` ` ` typescript
567
+ const config = {
568
+ authorization: process.env.VECTORIZE_API_KEY!,
569
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
570
+ };
571
+
572
+ const connectorId = await createWhiteLabelNotionConnector(
573
+ config,
574
+ "My Custom Notion Connector",
575
+ process.env.NOTION_CLIENT_ID!,
576
+ process.env.NOTION_CLIENT_SECRET!
577
+ );
578
+ ` ` `
579
+
580
+ ### manageNotionUser
581
+
582
+ Manages a Notion user for a connector , allowing you to add , edit , or remove users .
583
+
584
+ ` ` ` typescript
585
+ async function manageNotionUser(
586
+ config: VectorizeAPIConfig,
587
+ connectorId: string,
588
+ selectedPages: Record<string, { title: string; pageId: string; parentType?: string }> | null,
589
+ accessToken: string,
590
+ userId: string,
591
+ action: UserAction,
592
+ platformUrl?: string
593
+ ): Promise<Response>
594
+ ` ` `
595
+
596
+ ** Parameters :**
597
+
598
+ - ` config ` : A ` VectorizeAPIConfig ` object
599
+ - ` connectorId ` : ID of the connector
600
+ - ` selectedPages ` : Record of selected pages with their metadata (required for add / edit actions )
601
+ - ` accessToken ` : Notion OAuth access token (required for add / edit actions )
602
+ - ` userId ` : User ID to manage
603
+ - ` action ` : Action to perform (" add" , " edit" , or " remove" )
604
+ - ` platformUrl ` (optional ): URL of the Vectorize API (defaults to " https://api.vectorize.io/v1" )
605
+
606
+ ** Returns :**
607
+
608
+ - ` Promise<Response> ` : The API response
609
+
610
+ ** Example :**
611
+
612
+ ` ` ` typescript
613
+ const config = {
614
+ authorization: process.env.VECTORIZE_API_KEY!,
615
+ organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
616
+ };
617
+
618
+ const selectedPages = {
619
+ "page1": {
620
+ title: "My Page",
621
+ pageId: "page1",
622
+ parentType: "workspace"
623
+ }
624
+ };
625
+
626
+ const response = await manageNotionUser(
627
+ config,
628
+ "connector123",
629
+ selectedPages,
630
+ "notion_access_token",
631
+ "user123",
632
+ "add"
633
+ );
634
+ ` ` `
635
+
497
636
## Base API Functions
498
637
499
638
### createSourceConnector
@@ -653,6 +792,67 @@ console.log('New access token:', tokens.access_token);
653
792
console.log('Expires in:', tokens.expires_in, 'seconds');
654
793
` ` `
655
794
795
+ ### exchangeNotionCodeForTokens
796
+
797
+ Exchanges an authorization code for Notion OAuth tokens .
798
+
799
+ ` ` ` typescript
800
+ async function exchangeNotionCodeForTokens(
801
+ code: string,
802
+ clientId: string,
803
+ clientSecret: string,
804
+ redirectUri: string
805
+ ): Promise<any>
806
+ ` ` `
807
+
808
+ ** Parameters :**
809
+
810
+ - ` code ` : Authorization code from Notion OAuth flow
811
+ - ` clientId ` : Notion OAuth client ID
812
+ - ` clientSecret ` : Notion OAuth client secret
813
+ - ` redirectUri ` : Redirect URI used in the OAuth flow
814
+
815
+ ** Returns :**
816
+
817
+ - ` Promise<any> ` : Notion OAuth tokens
818
+
819
+ ** Example :**
820
+
821
+ ` ` ` typescript
822
+ import { exchangeNotionCodeForTokens } from '@vectorize-io/vectorize-connect';
823
+
824
+ const tokens = await exchangeNotionCodeForTokens(
825
+ authCode,
826
+ process.env.NOTION_CLIENT_ID!,
827
+ process.env.NOTION_CLIENT_SECRET!,
828
+ "https://yourapp.com/callback"
829
+ );
830
+ ` ` `
831
+
832
+ ### refreshNotionToken
833
+
834
+ Validates an existing Notion access token by making an API request to Notion .
835
+
836
+ ` ` ` typescript
837
+ async function refreshNotionToken(accessToken: string): Promise<any>
838
+ ` ` `
839
+
840
+ ** Parameters :**
841
+
842
+ - ` accessToken ` : Notion access token to validate
843
+
844
+ ** Returns :**
845
+
846
+ - ` Promise<any> ` : Validated token information
847
+
848
+ ** Example :**
849
+
850
+ ` ` ` typescript
851
+ import { refreshNotionToken } from '@vectorize-io/vectorize-connect';
852
+
853
+ const validatedToken = await refreshNotionToken("notion_access_token");
854
+ ` ` `
855
+
656
856
### exchangeDropboxCodeForTokens
657
857
658
858
Exchanges an authorization code for access and refresh tokens .
0 commit comments