> ## Documentation Index
> Fetch the complete documentation index at: https://flatfileinc-feat-updatereactquickstart.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# @flatfile/plugin-convert-yaml-schema

> A plugin for converting YAML Schema to Flatfile Blueprint.

<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-yaml-schema" href="https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/yaml-schema" icon="github">
    The @flatfile/plugin-convert-yaml-schema plugin converts YAML schema to
    Flatfile Blueprint.

    <br />

    <br />

    **Event Type:**

    <br />

    `listener.on('space:configure')`
  </Card>
</CardGroup>

### Overview

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

## Parameters

<ParamField path="models" type="ModelToSheetConfig[]" required>
  The `models` parameter holds the YAML Schema `sourceUrl` and take other Sheet
  configuration options.
</ParamField>

<ParamField path="options.workbookConfig" type="PartialWorkbookConfig">
  The `options.workbookConfig` parameter takes other optional Workbook
  configurations.
</ParamField>

<ParamField path="options.debug" type="boolean">
  The `options.debug` parameter lets you toggle on/off helpful debugging
  messages for development purposes.
</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>

## Imported NPM Packages

* [`@flatfile/api@1.5.37+`](https://npmjs.com/package/@flatfile/api)
* [`@flatfile/plugin-space-configure@0.1.6+`](https://npmjs.com/package/@flatfile/plugin-space-configure)
* [`@flatfile/plugin-json-schema@0.0.2+`](https://npmjs.com/package/@flatfile/plugin-json-schema)
* [`@hyperjump/json-schema@1.6.4+`](https://npmjs.com/package/@hyperjump/json-schema)
* [`axios@1.5.1+`](https://npmjs.com/package/axios)
* [`js-yaml@4.1.0+`](https://npmjs.com/package/js-yaml)

### Basic Example

```js listener.js
listener.use(
  configureSpaceWithYamlSchema([{ sourceUrl: "http://localhost:3000/yaml" }])
);
```

### Advanced Example

```js listener.js
import api, { Flatfile } from "@flatfile/api";
import type { FlatfileEvent, FlatfileListener } from "@flatfile/listener";
import {
  ModelToSheetConfig,
  PartialWorkbookConfig,
  configureSpaceWithYamlSchema,
} from "@flatfile/plugin-convert-yaml-schema";

export default function (listener: FlatfileListener) {
  const workbookActions: Flatfile.Action[] = [
    {
      operation: "submitActionFg",
      mode: "foreground",
      label: "Submit data",
      type: "string",
      description: "Submit this data to a webhook.",
      primary: true,
    },
  ];

  const sheetActions: Flatfile.Action[] = [
    {
      operation: "duplicateSheet",
      mode: "foreground",
      label: "Duplicate",
      description: "Duplicate this sheet.",
      primary: true,
    },
  ];

  const callback = async (
    event: FlatfileEvent,
    workbookIds: string[],
    tick: (progress?: number, message?: string) => Promise<Flatfile.JobResponse>
  ) => {
    const { spaceId } = event.context;
    await api.documents.create(spaceId, {
      title: "Welcome",
      body: `<div>
        <h1>Welcome!</h1>
        <h2>To get started, follow these steps:</h2>
        <h2>1. Step One</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
        <h3>Remember, if you need any assistance, you can always refer back to this page by clicking "Welcome" in the left-hand sidebar!</h3>
        </div>`,
    });
    await tick(80, "Document created");
  };

  listener.use(
    configureSpaceWithYamlSchema(
      [
        {
          sourceUrl:
            "https://raw.githubusercontent.com/FlatFilers/flatfile-docs-kitchen-sink/main/typescript/fetch-schemas/example-schemas/yaml/person.yml",
          name: "Custom Person Sheet Name",
          actions: sheetActions,
        },
        {
          sourceUrl:
            "https://raw.githubusercontent.com/FlatFilers/flatfile-docs-kitchen-sink/main/typescript/fetch-schemas/example-schemas/yaml/product.yml",
        },
      ] as ModelToSheetConfig[],
      {
        workbookConfig: {
          name: "Custom YAML Schema Workbook Name",
          actions: workbookActions,
        } as PartialWorkbookConfig,
        debug: true,
      },
      callback
    )
  );
}

```
