1.0.0-rc.38 • Published 5 months ago

@suada/core v1.0.0-rc.38

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@suada/core

Core functionality for Suada's integration management components. This package provides the foundation for all Suada front-end SDKs.

Installation

npm install @suada/core

Usage

import { SuadaClient } from '@suada/core';

const client = new SuadaClient({
  apiKey: 'your-api-key',
  externalUserIdentifier: 'user-123',
  gridColumns: 3, // Optional: Set number of columns in the grid (default: 3)
});

// Initialize the client
await client.initialize();

// Use the client to manage integrations
const integrations = await client.getIntegrations();

Features

Core Client

The SuadaClient class provides the main interface for interacting with Suada's API:

  • Authentication Management: Handles API authentication and token management
  • Integration Management: Methods for managing third-party integrations
  • Organization Context: Support for multi-organization environments
  • Type-safe API: Full TypeScript support with comprehensive type definitions
  • Customizable Grid Layout: Configure the number of columns in the integration grid

Integration Types

Built-in support for various integration types:

  • Notion
  • Slack
  • Google Analytics
  • Linear
  • Jira
  • HubSpot
  • Zoho
  • More integrations coming soon...

OAuth Flow Support

Simplified OAuth flow management:

// Initialize OAuth flow
const authUrl = await client.initializeOAuth('notion', {
  redirectUri: 'https://your-app.com/callback'
});

// Handle OAuth callback
const result = await client.handleOAuthCallback('notion', {
  code: 'auth-code',
  state: 'state-token'
});

Error Handling

Comprehensive error handling with detailed error types:

try {
  await client.someOperation();
} catch (error) {
  if (error instanceof SuadaAuthError) {
    // Handle authentication errors
  } else if (error instanceof SuadaApiError) {
    // Handle API errors
  }
}

Configuration Options

OptionTypeRequiredDefaultDescription
apiKeystringYes-Your Suada API key
externalUserIdentifierstringYes-Identifier for the user
baseUrlstringNoSuada API URLCustom API URL if needed
themeobjectNoDefault themeCustom theme options
size'small' \| 'medium' \| 'large'No'medium'Size of the component
gridColumnsnumberNo3Number of columns in the integration grid
enabledIntegrationsstring[]NoAll integrationsList of integration types to enable
onIntegrationConnectedfunctionNo-Callback when integration is connected
onIntegrationDisconnectedfunctionNo-Callback when integration is disconnected
onErrorfunctionNo-Callback when an error occurs

Development

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

# Run linting
npm run lint

# Run type checking
npm run typecheck

API Reference

SuadaClient

The main client class for interacting with Suada's API.

Constructor Options

interface SuadaClientOptions {
  apiKey: string;
  externalUserIdentifier: string;
  gridColumns?: number;
  baseUrl?: string;
}

Methods

  • initialize(): Initialize the client
  • getIntegrations(): Get all available integrations
  • createIntegration(type: string, config: IntegrationConfig): Create a new integration
  • deleteIntegration(id: string): Delete an integration
  • initializeOAuth(provider: string, options: OAuthOptions): Initialize OAuth flow
  • handleOAuthCallback(provider: string, params: OAuthCallbackParams): Handle OAuth callback

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT

1.0.0-rc.29

5 months ago

1.0.0-rc.31

5 months ago

1.0.0-rc.30

5 months ago

1.0.0-rc.35

5 months ago

1.0.0-rc.34

5 months ago

1.0.0-rc.33

5 months ago

1.0.0-rc.32

5 months ago

1.0.0-rc.38

5 months ago

1.0.0-rc.37

5 months ago

1.0.0-rc.36

5 months ago

1.0.0-rc.20

6 months ago

1.0.0-rc.24

6 months ago

1.0.0-rc.23

6 months ago

1.0.0-rc.22

6 months ago

1.0.0-rc.21

6 months ago

1.0.0-rc.28

6 months ago

1.0.0-rc.27

6 months ago

1.0.0-rc.26

6 months ago

1.0.0-rc.25

6 months ago

1.0.0-rc.13

6 months ago

1.0.0-rc.12

6 months ago

1.0.0-rc.17

6 months ago

1.0.0-rc.16

6 months ago

1.0.0-rc.15

6 months ago

1.0.0-rc.14

6 months ago

1.0.0-rc.19

6 months ago

1.0.0-rc.18

6 months ago

1.0.0-rc.11

6 months ago

1.0.0-rc.10

6 months ago

1.0.0-rc.9

6 months ago

1.0.0-rc.7

6 months ago

1.0.0-rc.6

6 months ago

1.0.0-rc.5

6 months ago

1.0.0-rc.4

6 months ago

1.0.0-rc.3

6 months ago

1.0.0-rc.2

6 months ago

1.0.0-rc.1

6 months ago

1.0.0

6 months ago

0.1.0

6 months ago