Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: SQL DDL plugin guide #969

Merged
merged 6 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 90 additions & 9 deletions plugins/schemas/convert-sql-ddl.mdx
Original file line number Diff line number Diff line change
@@ -1,23 +1,104 @@
---
title: "@flatfile/plugin-sql-ddl"
title: "@flatfile/plugin-convert-sql-ddl"
description: "A plugin for converting SQL DDL to Flatfile Blueprint."
icon: "clock"
icon: "download"
---

<Warning>
When embedding Flatfile, this plugin should be deployed in a server-side
listener. [Learn more](/orchestration/listeners#listener-types)
</Warning>

<CardGroup cols={1}>
<Card title="@flatfile/plugin-convert-sql-ddl" href="https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/sql-ddl" icon="github" >
*currently in development*<br/>
<br/>
check back soon for updates
</Card>
<Card title="@flatfile/plugin-convert-sql-ddl" icon="download">
The @flatfile/plugin-convert-sql-ddl plugin will automatically convert SQL
DDL to the Flatfile Blueprint, a powerful DDL (Data Definition Language)
created by Flatfile with a focus on validation and data preparation.
<br />
<br />
**Event Type:**
<br />
`listener.on('space:configure')`
</Card>
</CardGroup>


### Overview

This plugin will automatically convert SQL DDL to the Flatfile Blueprint, a powerful DDL (Data Definition Language) created by Flatfile with a focus on validation and data preparation.

## Parameters

<ParamField path="setupFactory" type="SqlSetupFactory" required>
The `setupFactory` parameter holds the Workbook and Sheet configuration
options and SQL DDL source.
</ParamField>

<ParamField path="callback" type="function">
The `callback` parameter receives three arguments: `event`, `workbookIds`, and
a `tick` function. The `tick` function can be used to update the Job's
progress. The `callback` function is invoked once the Space and Workbooks are
fully configured.
</ParamField>

## API Calls

- `api.spaces.update`
- `api.workbooks.create`

## Imported NPM Packages

- [`@flatfile/[email protected]+`](https://npmjs.com/package/@flatfile/api)
- [`@flatfile/[email protected]+`](https://npmjs.com/package/@flatfile/plugin-convert-json-schema)
- [`@flatfile/[email protected]+`](https://npmjs.com/package/@flatfile/plugin-space-configure)
- [`[email protected]+`](https://npmjs.com/package/axios)
- [`[email protected]+`](https://npmjs.com/package/sql-ddl-to-json-schema)

## Usage

---
The @flatfile/plugin-convert-sql-ddl plugin simplifies the setup of new Flatfile Spaces by configuring the Space from a provided SQL DDL.
Designed for server-side listeners, it auto-configures the Space using the supplied settings.

```bash install
npm i @flatfile/plugin-convert-sql-ddl
```

```js import
import { configureSpaceWithSqlDDL } from "@flatfile/plugin-convert-sql-ddl";
```

```js listener.js
listener.use(
configureSpaceWithSqlDDL({
workbooks: [
{
name: "SQL DDL Generated Workbook",
source: "src/data/example.sql",
sheets: [
{
name: "Users",
slug: "user",
},
{
name: "Products",
slug: "products",
},
{
name: "Locations",
slug: "locations",
},
],
},
],
})
);
```

## See the code

<CardGroup cols={2}>
<Card
title="@flatfile/plugin-convert-sql-ddl"
href="https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/sql-ddl-converter"
icon="github"
></Card>
</CardGroup>
Loading