### Install OneSchema Angular SDK
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-angular/projects/oneschema/README.md
Install the necessary OneSchema packages for Angular using npm. This includes the core SDK and the importer module.
```bash
npm i --save @oneschema/angular @oneschema/importer
```
--------------------------------
### Install OneSchema Vue SDK
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-vue/README.md
Install the required package using npm to enable OneSchema functionality in your Vue project.
```bash
npm i --save @oneschema/vue
```
--------------------------------
### Install OneSchema FileFeeds SDK
Source: https://github.com/oneschema/sdk/blob/main/packages/filefeeds/README.md
Methods for adding the OneSchema FileFeeds library to your project via npm or a direct script tag inclusion.
```bash
npm i --save @oneschema/filefeeds
```
```html
```
--------------------------------
### Install OneSchema Importer SDK
Source: https://github.com/oneschema/sdk/blob/main/packages/importer/README.md
Methods for adding the OneSchema Importer library to your project. You can use a package manager like npm or include it directly via a script tag in your HTML.
```bash
npm i --save @oneschema/importer
```
```html
```
--------------------------------
### Install OneSchema React Package
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-react/README.md
Installs the OneSchema React package using npm. This is the first step to integrating the OneSchema Importer into your React application.
```bash
npm i --save @oneschema/react
```
--------------------------------
### Install OneSchema FileFeeds React Package
Source: https://github.com/oneschema/sdk/blob/main/packages/filefeeds-react/README.md
Installs the @oneschema/filefeeds-react package using npm. This is the first step to integrate OneSchema FileFeeds into a React application.
```bash
npm i --save @oneschema/filefeeds-react
```
--------------------------------
### Apply CSS Styles to OneSchema Iframe
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-angular/projects/oneschema/README.md
Style the OneSchema iframe using CSS. Styles can be applied globally, to a specific component, or directly via the module configuration. This example shows global CSS for full viewport coverage.
```css
.oneschema-iframe {
position: fixed;
right: 0;
top: 0;
width: 100vw;
height: 100vh;
}
```
--------------------------------
### Initialize and Launch OneSchema FileFeeds
Source: https://github.com/oneschema/sdk/blob/main/packages/filefeeds/README.md
Demonstrates how to import the library, initialize the instance with a user JWT, and set up event listeners for lifecycle hooks like initialization and saving.
```javascript
import oneschemaFileFeeds from "@oneschema/filefeeds"
const fileFeeds = oneschemaFileFeeds({
userJwt: "YOUR_USER_JWT",
devMode: true,
className: "oneschema-filefeeds",
})
fileFeeds.launch()
fileFeeds.on("init-failed", (data) => {
// handle failures.
})
fileFeeds.on("init-succeeded", (data) => {
// handle embedding session updates.
})
fileFeeds.on("saved", (data) => {
// handle FileFeeds transforms being saved.
})
```
--------------------------------
### Initialize and Launch OneSchema Importer (JavaScript)
Source: https://context7.com/oneschema/sdk/llms.txt
Demonstrates how to initialize and launch the OneSchema Importer using the core JavaScript library. It covers configuration options for clientId, templateKey, userJwt, and customization overrides. It also shows how to handle import success, cancellation, errors, and launch status, along with methods to close the importer.
```javascript
import oneschemaImporter from "@oneschema/importer"
// Initialize the importer with configuration
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "contacts_template",
userJwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
devMode: true,
className: "oneschema-importer",
styles: {
position: "fixed",
top: "0",
left: "0",
width: "100vw",
height: "100vh",
zIndex: "10000"
},
importConfig: { type: "local" },
customizationOverrides: {
fileSizeLimit: 50000000,
skipHeaderRow: "detect",
mappingStrategy: ["fuzzy", "historical_user"],
autofixAfterMapping: true
}
})
// Launch the importer
const status = importer.launch()
console.log("Launch status:", status) // { success: true }
// Handle successful import - data contains all validated rows
importer.on("success", (data) => {
console.log("Imported rows:", data.rows)
console.log("Row count:", data.count)
// Process the cleaned data
data.rows.forEach(row => {
console.log(`Contact: ${row.first_name} ${row.last_name}, Email: ${row.email}`)
})
})
// Handle user cancellation
importer.on("cancel", () => {
console.log("User cancelled the import")
})
// Handle errors during import
importer.on("error", (error) => {
console.error("Import error:", error.message)
console.error("Severity:", error.severity) // "error" or "fatal"
})
// Handle launch status
importer.on("launched", (result) => {
if (result.success) {
console.log("Importer ready, session token:", result.sessionToken)
console.log("Embed ID:", result.embedId)
} else {
console.error("Launch failed:", result.error)
}
})
// Close the importer when done
importer.close()
// Clean up completely (removes iframe and listeners)
importer.close(true)
```
--------------------------------
### Initialize and Launch OneSchema Importer
Source: https://github.com/oneschema/sdk/blob/main/packages/importer/README.md
Configures the OneSchema importer instance with client credentials and template keys. It demonstrates how to launch the importer and attach event listeners for success, cancellation, and error states.
```javascript
import oneschemaImporter from "@oneschema/importer"
const importer = oneschemaImporter({
clientID: 'YOUR_CLIENT_ID',
templateKey: 'YOUR_TEMPLATE_KEY',
userJwt: 'YOUR_USER_JWT',
importConfig: { type: "local" },
devMode: true,
className: 'oneschema-importer',
})
importer.launch()
importer.on("success", (data) => {
// handle success
})
importer.on("cancel", () => {
// handle cancel
})
importer.on("error", (message) => {
// handle error
})
```
--------------------------------
### Initialize and Manage OneSchema FileFeeds
Source: https://context7.com/oneschema/sdk/llms.txt
This snippet demonstrates how to initialize the FileFeeds instance with configuration options, launch the interface, and attach event listeners for lifecycle and session management. It also covers methods for showing, hiding, and destroying the instance.
```javascript
import oneschemaFileFeeds from "@oneschema/filefeeds"
const fileFeeds = oneschemaFileFeeds({
userJwt: "YOUR_USER_JWT",
devMode: true,
className: "oneschema-filefeeds",
styles: {
position: "fixed",
top: "0",
left: "0",
width: "100vw",
height: "100vh",
zIndex: "10000"
},
saveSession: true,
customizationKey: "default",
customizationOverrides: {
primaryColor: "#6366F1",
fileSizeLimit: 50000000
}
})
fileFeeds.launch({ userJwt: "YOUR_USER_JWT" })
fileFeeds.on("init-started", () => console.log("FileFeeds initialization started"))
fileFeeds.on("init-succeeded", (data) => console.log("FileFeeds ready!", data))
fileFeeds.on("init-failed", (data) => console.error("Initialization failed:", data.error.message))
fileFeeds.on("saved", (data) => console.log("Transforms saved:", data))
fileFeeds.on("cancelled", () => console.log("Editing cancelled"))
fileFeeds.on("shown", () => console.log("Iframe shown"))
fileFeeds.on("hidden", () => console.log("Iframe hidden"))
fileFeeds.on("session-invalidated", (data) => console.warn("Session invalidated:", data.error.message))
fileFeeds.hide()
fileFeeds.launch()
fileFeeds.destroy()
```
--------------------------------
### Launch OneSchema Importer and Handle Events
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-angular/projects/oneschema/README.md
Implement a component to launch the OneSchema importer and subscribe to its events (success, error, cancel). This involves using the OneSchemaService to manage the importer's lifecycle and callbacks.
```javascript
import { Component, OnDestroy } from '@angular/core'
import { OneSchemaService } from './oneschema.service'
@Component({
selector: 'oneschema-button',
template: ``,
styles: [],
})
export class OneSchemaButton implements OnDestroy {
constructor(public oneschema: OneSchemaService) {
this.oneschema.on('success', this.onSuccess)
this.oneschema.on('error', this.onError)
this.oneschema.on('cancel', this.onCancel)
}
launch() {
this.oneschema.launch()
}
onSuccess(data: any) {
// handle success
}
onError(error: any) {
// handle error
}
onCancel() {
// handle cancel
}
ngOnDestroy() {
this.oneschema.off('success', this.onSuccess)
this.oneschema.off('error', this.onError)
this.oneschema.off('cancel', this.onCancel)
}
}
```
--------------------------------
### Manage OneSchema Importer Sessions
Source: https://context7.com/oneschema/sdk/llms.txt
Demonstrates how to enable session persistence in the OneSchema Importer to allow users to resume previous import sessions. It covers initializing the importer with session saving enabled, handling the 'launched' event to capture session tokens, and resuming sessions via the API.
```javascript
import oneschemaImporter from "@oneschema/importer"
// Enable session saving for automatic resume capability
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "orders_template",
userJwt: "YOUR_USER_JWT",
importConfig: { type: "local" },
saveSession: true // Saves session to localStorage
})
// Launch with a specific session token (for API-created sessions)
const status = importer.launch({
sessionToken: "existing_session_token_from_api"
})
// Handle launched event to get session information
importer.on("launched", (result) => {
if (result.success) {
// Store session token for later use
const sessionToken = result.sessionToken
const embedId = result.embedId
console.log("Session token:", sessionToken)
console.log("Embed ID:", embedId)
// You can save this to your backend to track import sessions
saveSessionToBackend(embedId, sessionToken)
}
})
// To resume a session later:
const resumeImporter = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
devMode: true
})
// Resume with the saved session token
resumeImporter.launch({
sessionToken: savedSessionToken
})
```
--------------------------------
### Implement OneSchema Importer with Composition API
Source: https://context7.com/oneschema/sdk/llms.txt
Shows how to use the useOneSchemaImporter hook to launch the importer, handle success/error/cancel events, and ensure proper cleanup when the component is unmounted.
```typescript
```
--------------------------------
### Customize Import Experience with OneSchema Importer
Source: https://context7.com/oneschema/sdk/llms.txt
Shows how to customize the look, feel, and behavior of the import experience using the OneSchema Importer SDK. This includes UI elements, validation behavior, branding, and text overrides. It requires the @oneschema/importer package and potentially a preset customization key.
```javascript
import oneschemaImporter from "@oneschema/importer"
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "employees_template",
userJwt: "YOUR_USER_JWT",
importConfig: { type: "local" },
customizationKey: "enterprise_theme", // Use a preset customization
customizationOverrides: {
// File size and upload settings
fileSizeLimit: 100000000, // 100MB
// Header row detection
skipHeaderRow: "detect", // "always" | "detect" | "never"
// Column mapping behavior
mappingStrategy: ["exact", "fuzzy", "historical_user"],
aiSuggestedMappings: ["column", "picklist"],
includeUnmappedColumns: true,
oneClickMode: false,
// Review and validation settings
autofixAfterMapping: true,
acceptCodeHookSuggestions: true,
importErrorUX: "promptIfErrors", // "blockIfErrors" | "promptIfErrors" | "ignoreErrors"
preventRowDeletion: ["selection"],
allowEmptyImports: false,
importMaxRowLimit: 50000,
// Sidebar configuration
uploaderShowSidebar: true,
uploaderSidebarDetails: "required",
mappingShowSidebar: true,
mappingSidebarDetails: "all",
// Branding colors
primaryColor: "#4F46E5",
backgroundPrimaryColor: "#FFFFFF",
headerColor: "#F9FAFB",
successColor: "#10B981",
errorColor: "#EF4444",
// Button styling
buttonBorderRadius: "8px",
buttonPrimaryFillColor: "#4F46E5",
buttonPrimaryTextColor: "#FFFFFF",
// Modal styling
modalFullscreen: false,
modalBorderRadius: "12px",
hideCloseButton: false,
// Font customization
fontFamily: "Inter, sans-serif",
fontColorPrimary: "#111827",
fontColorSecondary: "#6B7280",
// Text overrides
uploadPaneHeaderText: "Upload Your Data",
uploaderHeaderText: "Drag and drop your file",
uploaderSubheaderText: "Supports CSV and Excel files",
mappingPaneHeaderText: "Map Your Columns",
cleaningPaneHeaderText: "Review and Fix Issues",
cleaningConfirmButtonText: "Complete Import",
// Education widgets
showUploadEducationWidget: true,
uploadEducationWidgetMessage: "Upload CSV or Excel files up to 100MB",
uploadEducationWidgetAutoOpen: true
}
})
importer.launch()
```
--------------------------------
### Initialize and Use OneSchema Importer via Script Tag
Source: https://context7.com/oneschema/sdk/llms.txt
This snippet shows how to include the OneSchema Importer script and initialize it within an HTML page. It configures the importer with client ID, template key, user JWT, and development mode. It also sets up event listeners for import success, cancellation, and errors, and handles the UI updates for the import button and results display.
```html
Data Import
Customer Import
```
--------------------------------
### Override Template Configuration with OneSchema Importer
Source: https://context7.com/oneschema/sdk/llms.txt
Demonstrates how to override template configurations at runtime using the OneSchema Importer SDK. This includes adding, updating, and removing columns, as well as adding validation webhooks and mapping validations. It requires the @oneschema/importer package.
```javascript
import oneschemaImporter from "@oneschema/importer"
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "base_contacts_template",
userJwt: "YOUR_USER_JWT",
importConfig: { type: "local" },
templateOverrides: {
// Add new columns to the template
columns_to_add: [
{
key: "customer_segment",
label: "Customer Segment",
data_type: "PICKLIST",
is_required: true,
validation_options: {
picklist_options: [
{ value: "Enterprise", alternative_names: ["corp", "corporate"] },
{ value: "SMB", alternative_names: ["small business"] },
{ value: "Consumer", alternative_names: ["individual", "personal"] }
]
}
},
{
key: "annual_revenue",
label: "Annual Revenue",
data_type: "NUMBER",
validation_options: {
min_num: 0,
allow_thousand_separators: true,
format: "us"
}
}
],
// Update existing columns
columns_to_update: [
{
key: "email",
is_required: true,
is_unique: true
},
{
key: "phone",
data_type: "PHONE_NUMBER"
}
],
// Remove columns from the template
columns_to_remove: [
{ key: "legacy_id" }
],
// Add validation webhooks
validation_hooks_to_add: [
{
name: "Validate Email Domain",
url: "https://api.example.com/validate/email",
column_keys: ["email"],
hook_type: "column",
authorization_type: "bearer_user_jwt",
batch_size: 100
}
],
// Add mapping validations
mapping_validations_to_add: [
{
type: "required-column-group",
columns: ["phone", "email"] // At least one must be mapped
}
]
}
})
importer.launch()
```
--------------------------------
### Configure OneSchema Plugin
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-vue/README.md
Initialize the OneSchema plugin within your Vue application instance by providing your client ID and configuration parameters.
```javascript
import { createOneSchemaImporter } from '@oneschema/vue'
const app = createApp(App)
app.use(
createOneSchemaImporter({
clientId: '',
...initParams
})
)
app.mount('#app')
```
--------------------------------
### Launch OneSchema Importer
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-vue/README.md
Use the useOneSchemaImporter hook to launch the importer and handle success, cancel, and error events within a Vue component.
```vue
```
--------------------------------
### Configure OneSchema Importer Plugin in Vue 3
Source: https://context7.com/oneschema/sdk/llms.txt
Demonstrates how to register the OneSchema Importer plugin globally in a Vue 3 application using the createOneSchemaImporter function within the main entry file.
```typescript
import { createApp } from 'vue'
import App from './App.vue'
import { createOneSchemaImporter } from '@oneschema/vue'
const app = createApp(App)
app.use(
createOneSchemaImporter({
clientId: 'YOUR_CLIENT_ID',
templateKey: 'inventory_template',
userJwt: 'YOUR_USER_JWT',
devMode: import.meta.env.DEV,
importConfig: { type: 'local' },
customizationOverrides: {
primaryColor: '#8B5CF6'
}
})
)
app.mount('#app')
```
--------------------------------
### Configure OneSchema Importer for Webhook Import (JavaScript)
Source: https://context7.com/oneschema/sdk/llms.txt
Shows how to configure the OneSchema Importer to send validated data to a webhook endpoint. This is useful for server-side processing of large datasets. It includes setting up the import type, webhook key, and event listeners for import status.
```javascript
import oneschemaImporter from "@oneschema/importer"
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "orders_template",
userJwt: "YOUR_USER_JWT",
importConfig: {
type: "webhook",
key: "orders_webhook_key"
},
eventWebhookKeys: ["import_started", "import_completed"]
})
importer.launch()
// For webhook imports, success event contains webhook response info
importer.on("success", (data) => {
console.log("Event ID:", data.eventId)
console.log("Webhook responses:", data.responses)
})
```
--------------------------------
### Configure OneSchema Importer for File Upload (JavaScript)
Source: https://context7.com/oneschema/sdk/llms.txt
Illustrates how to configure the OneSchema Importer to upload cleaned data directly to a specified URL. Supports CSV and JSON formats, with options for custom headers and format-specific settings like header style.
```javascript
import oneschemaImporter from "@oneschema/importer"
const importer = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "products_template",
userJwt: "YOUR_USER_JWT",
importConfig: {
type: "file-upload",
url: "https://api.example.com/upload/products",
format: "csv",
headers: {
"Authorization": "Bearer your-api-token",
"X-Custom-Header": "custom-value"
},
formatOptions: {
headerStyle: "keys" // Use column keys instead of labels
}
}
})
importer.launch()
// For JSON format uploads
const jsonImporter = oneschemaImporter({
clientId: "YOUR_CLIENT_ID",
templateKey: "products_template",
userJwt: "YOUR_USER_JWT",
importConfig: {
type: "file-upload",
url: "https://api.example.com/upload/products",
format: "json",
headers: {
"Authorization": "Bearer your-api-token"
}
}
})
```
--------------------------------
### OneSchemaService API
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-angular/projects/oneschema/README.md
Interacting with the OneSchema service to launch the importer and handle lifecycle events.
```APIDOC
## OneSchemaService Methods
### Description
Provides methods to control the importer lifecycle and subscribe to events.
### Methods
- **launch()**: Opens the OneSchema importer interface.
- **on(event, callback)**: Subscribes to events such as 'success', 'error', or 'cancel'.
- **off(event, callback)**: Unsubscribes from specific events.
- **setIframe(element)**: Manually binds an iframe element for inline mode.
### Event Handling Example
this.oneschema.on('success', (data) => { console.log(data); });
this.oneschema.on('error', (err) => { console.error(err); });
```
--------------------------------
### React Component for OneSchema Importer
Source: https://github.com/oneschema/sdk/blob/main/packages/importer-react/README.md
Demonstrates the usage of the OneSchemaImporter React component. It shows how to manage the modal's open state, configure essential props like clientId, userJwt, and templateKey, and handle import results via onSuccess, onCancel, and onError callbacks.
```javascript
import React, { useState } from "react"
import OneSchemaImporter from "@oneschema/react"
function OneSchemaExample() {
const [isOpen, setIsOpen] = useState(false)
const handleData = (data) => {
console.log(data)
}
return (
)
}
export default FileFeedManager
```
--------------------------------
### React Component for OneSchema FileFeeds Integration
Source: https://github.com/oneschema/sdk/blob/main/packages/filefeeds-react/README.md
Demonstrates how to use the OneSchemaFileFeeds React component. It shows how to manage the component's visibility, pass required configuration like userJwt, and handle initialization and save events. The component allows embedding an iframe for creating and editing OneSchema FileFeeds.
```javascript
import React, { useState } from "react"
import OneSchemaFileFeeds from "@oneschema/filefeeds-react"
function OneSchemaFileFeedsExample() {
const [isOpen, setIsOpen] = useState(false)
const handleData = (data) => {
console.log(data)
}
return (