open-index/open-npm huggingface dataset:
npm package: @larsbaalmans/cast-util-from-slate
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [Slate](https://docs.slatejs.org/) editor document to a [CAST]() abstract syntax tree.
Latest version: 1.2.1

# cast-util-from-slate

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a utility to convert a [Slate](https://docs.slatejs.org/) editor document to a [CAST]() abstract syntax tree.

## Usage

Using the utility `cast` from `slate` looks as follows:
```ts
import {fromSlate} from 'cast-util-from-slate'

const slate = [
    {
        type: 'paragraph',
        children: [
            { text: 'Hello, world!' }
        ]
    }
]

console.info(fromSlate(slate))
```

yields:
```json
{
    "type": "root",
    "children": [
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text",
                    "value": "Hello, world!"
                }
            ]
        }
    ]
}
```

## Building

Run `nx build cast-util-from-slate` to build the library.

## Running unit tests

Run `nx test cast-util-from-slate` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/cast-util-to-hast
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree to a [Hast]() abstract syntax tree.
Latest version: 1.2.0

# cast-util-to-hast

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a utility to convert a [CAST]() abstract syntax tree to a [Hast]() abstract syntax tree.

## Usage

Using the utility `cast` to `hast` looks as follows:
```ts
/**
 * @import {Root} from 'cast'
 */

import {toHast} from 'cast-util-to-hast'

/** @type {Root} */
const tree = {
    type: 'root',
    children: [
        {
            type: 'paragraph',
            children: [
                { type: 'text', value: 'Hello, world!' }
            ]
        }
    ]
}

console.info(toHast(tree))
```

yields:
```json
{
    "type": "root",
        "children": [
        {
            "type": "element",
            "tagName": "p",
            "properties": {},
            "children": [
                { 
                  "type": "text", 
                  "value": "Hello, world!"
                }
            ]
        }
    ]
}
```

## Building

Run `nx build cast-util-to-hast` to build the library.

## Running unit tests

Run `nx test cast-util-to-hast` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/cast-util-to-html
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree directly to html.
Latest version: 1.2.0

# cast-util-to-html

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a utility to convert a [CAST]() abstract syntax tree directly to html.

The converter uses cast to hast and hast to html to convert the tree.
It also sanitizes the html using [rehype-sanitize]() on the Hast syntax tree.


## Usage

Using the utility `cast` to html looks as follows:
```ts
/**
 * @import {Root} from 'cast'
 */

import {toHtml} from 'cast-util-to-html'

/** @type {Root} */
const tree = [
    {
        type: 'paragraph',
        children: [
            { text: 'Hello, world!' }
        ]
    },
    {
        type: 'heading',
        level: 1,
        children: [
            {
                type: 'bold',
                children: [
                    { 
                        type: 'text', 
                        text: 'Hello, world!' 
                    }
                ]
            }
        ]
    }
]

console.info(toHtml(tree))
```

yields:
```ts
const result = {
    type: 'root',
    children: [
        {
            type: 'element',
            tagName: 'p',
            properties: {},
            children: [
                { type: 'text', value: 'Hello, world!' }
            ]
        },
        {
            type: 'element',
            tagName: 'h1',
            properties: {},
            children: [
                {
                    type: 'element',
                    tagName: 'strong',
                    properties: {},
                    children: [
                        { type: 'text', value: 'Hello, world!' }
                    ]
                }
            ]
        }
    ]
}
```

## Building

Run `nx build cast-util-to-html` to build the library.

## Running unit tests

Run `nx test cast-util-to-html` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/cast-util-to-plaintext
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree directly to plaintext.
Latest version: 1.2.6

# cast-util-to-plaintext

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a utility to convert a [CAST]() abstract syntax tree directly to plaintext.

## Usage

Using the utility `cast` to plaintext looks as follows:
```ts
/**
 * @import {Root} from 'cast'
 */

import {toPlaintext} from 'cast-util-to-plaintext'

/** @type {Root} */
const tree = [
    {
        type: 'paragraph',
        children: [
            { text: 'Hello' }
        ]
    },
    {
        type: 'heading',
        level: 1,
        children: [
            {
                type: 'bold',
                children: [
                    { 
                        type: 'text', 
                        text: 'world' 
                    }
                ]
            }
        ]
    }
]

console.info(toPlaintext(tree))
```

yields:
```
'Hello world'
```

## Building

Run `nx build cast-util-to-plaintext` to build the library.

## Running unit tests

Run `nx test cast-util-to-plaintext` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/cast-util-to-slate
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree to a [Slate](https://docs.slatejs.org/) editor document
Latest version: 1.2.0

# cast-util-to-slate

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a utility to convert a [CAST]() abstract syntax tree to a [Slate](https://docs.slatejs.org/) editor document

## Usage

Using the utility `slate` to `cast` looks as follows:
```ts
import {toSlate} from 'cast-util-to-slate'

const tree ={
    type: 'root',
    children: [
        {
            type: 'paragraph',
            children: [
                { type: 'text', value: 'Hello, world!' }
            ]
        }
    ]
}

console.info(toSlate(tree))
```

yields:
```ts
[
    {
        "type": "paragraph",
        "children": [
            { "text": "Hello, world!" }
        ]
    }
]
```

## Building

Run `nx build cast-util-to-slate` to build the library.

## Running unit tests

Run `nx test cast-util-to-slate` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/castscript
Description: This library is part of the [CAST]() abstract syntax tree utilities. It provides a scriptable interface to help with creating cast trees.
Latest version: 1.2.4

# castscript

This library is part of the [CAST]() abstract syntax tree utilities.
It provides a scriptable interface to help with creating cast trees.

## Usage

Castscript provides an easy way to create cast trees using a scriptable interface.
Using the utility `script` to `cast` looks as follows:
```ts
import {c} from 'castscript'

const tree = c('root', [
    // only using the type argument
    c('paragraph', [
        // using the type and text arguments
        c('text', 'Hello, world!')
    ]),
    // using the type, properties and children arguments
    c('heading', { level: 1 }, [
        c('bold', [
            c('text', 'Hello, world!')
        ])
    ]),
    //using the type, text, properties and children arguments
    c('paragraph', 'Hello,', { class: 'text' }, [
        c('text', 'world!')
    ])
])
```

yields:
```json
{
  "type": "root",
  "children": [
    {
      "type": "paragraph",
      "children": [
        { "type": "text", "value": "Hello, world!" }
      ]
    },
    {
      "type": "heading",
      "level": 1,
      "children": [
        {
          "type": "bold",
          "children": [
            { "type": "text", "value": "Hello, world!" }
          ]
        }
      ]
    },
    {
      "type": "paragraph",
      "properties": { "class": "text" },
      "children": [
        { "type": "text", "value": "Hello," },
        { "type": "text", "value": "world!" }
      ]
    }
  ]
}
```

You can use the following arguments to create complex cast trees:

Required arguments
- `type`: The type of the node

Optional arguments, these can be used in different combinations
- `text`: The text value of the node.
- `properties`: The properties of the node.
- `children`: The children of the node.

Signature and overloads:
```ts
import {Root, Content} from 'cast'

function c(type: string): Root | Content {
    // function body
}

function c(type: string, text: string): Root | Content {
    // function body
}

function c(type: string, properties: Record<string, any>): Root | Content {
    // function body
}

function c(type: string, children: Node[]): Root | Content {
    // function body
}

function c(type: string, text: string, properties: Record<string, any>): Root | Content {
    // function body
}

function c(type: string, text: string, children: Node[]): Root | Content {
    // function body
}

function c(type: string, properties: Record<string, any>, children: Node[]): Root | Content {
    // function body
}

function c(type: string, text: string, properties: Record<string, any>, children: Node[]): Root | Content {
    // function body
}
```

## Building

Run `nx build castscript` to build the library.

## Running unit tests

Run `nx test castscript` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/delta-client-schema
Description: This library is part of the [Delta Client]() utility packages. It provides a utility to convert abstract building blocks and their values to usable data structures.
Latest version: 1.2.7

# delta-client-schema

This library is part of the [Delta Client]() utility packages.
It provides a utility to convert abstract building blocks and their values to usable data structures.

## Usage

Defining a schema looks as follows consists of a root object and nested fields.
For example for a building block that has a welcome message, the schema would look like this:

```ts
import { s } from "@larsbaalmans/delta-client-schema";

const heroBuildingBlock = s.object({
    title: s.primitive(c('root', 'title')),
    description: s.cast(c('root', 'description')),
    images: s.array(s.asset())
})

```

The schema can then be used to convert the abstract building block to a usable data structure:

```ts
import { p as parser } from "@larsbaalmans/delta-client-schema";

const heroBuildingBlock = parser.parse(schema, buildingBlockFieldFulfillments);
```

Yields:

```ts
const heroBuildingBlock = {
    title: "Hero Title",
    description: {
        type: 'root',
        children: [
            {
                type: 'text',
                value: 'Welcome to our website'
            }
        ]
    },
    images: [
        {
            fileName: "first image",
            url: 'https://example.com/image.jpg',
        }
    ]
}
```

## API

### Object

```ts
s.object({
    // shape of the object
})
```

### Array

Default array with one placeholder

```ts
s.array(
    s.primitive('value')
)
```

Array with a limit of the maximum number of items to display

```ts
s.array(
    s.primitive('value'), 5 // limit to 5 items
)
```

Array with an array of placeholders, also uses this a minimum number of items to display

```ts
s.array(
    [
        s.primitive('value'),
        s.primitive('value'),
        // other fields
    ]
)
```

### Primitive

#### string
```ts
s.primitive('value')
```

#### number
```ts
s.primitive(23)
```

### Asset
   
Accepts a partial Asset object as a placeholder 
```ts
s.asset({
    fileName: 'first',
    url: 'https://example.com/image.jpg'
})
```

### PathPart

Accepts a partial PathPart object as a placeholder
```ts
s.pathPart({
    path: '/blogs',
})
```

### GridPlacement

Accepts a partial GridPlacement object as a placeholder
```ts
s.gridPlacement({
    prn: 'prn:grid:123',
    row: 1
})
```

### Cast

Accepts a correct root object to cast the schema to a usable data structure 
```ts
s.cast({
    type: 'root',
    children: []
})
```
npm package: @larsbaalmans/delta-client-types
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 1.3.1

# delta-client-types

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build delta-client-types` to build the library.

## Running unit tests

Run `nx test delta-client-types` to execute the unit tests via [Vitest](https://vitest.dev/).
npm package: @larsbaalmans/delta-client-utils
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 1.2.3

# delta-client-utils

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build delta-client-utils` to build the library.

## Running unit tests

Run `nx test delta-client-utils` to execute the unit tests via [Jest](https://jestjs.io).