# @cradlejs/core

Latest version **0.3.1** (published 2019-12-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install @cradlejs/core
pnpm add @cradlejs/core
yarn add @cradlejs/core
bun add @cradlejs/core
```

Provides the command `cradle`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2019-12-17 |
| First published | 2019-07-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 145.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | danielgary, johnmurphy01, justinneff |

## Links

- npm: https://www.npmjs.com/package/@cradlejs/core
- Repository: https://github.com/cradlejs/cradle
- Homepage: https://cradlejs.dev
- Issues: https://github.com/cradlejs/cradle/issues
- npm.io page: https://npm.io/package/@cradlejs/core

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^12.0.2
- [colors](https://npm.io/package/colors.md) ^1.3.2
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.12.0
- [chevrotain](https://npm.io/package/chevrotain.md) ^3.7.4

## Recent versions

- 0.3.1 (latest) — 2019-12-17
- 0.3.0 — 2019-12-06
- 0.2.5 — 2019-09-25
- 0.2.4 — 2019-09-18
- 0.2.3 — 2019-09-18
- 0.2.2 — 2019-09-18
- 0.2.0 — 2019-09-18
- 0.1.0 — 2019-07-02

## README

# Cradle - A Schema Pipeline [![Build Status](https://dev.azure.com/gatewayapps/cradlejs/_apis/build/status/cradlejs.cradle?branchName=master)](https://dev.azure.com/gatewayapps/cradlejs/_build/latest?definitionId=46&branchName=master)

## What is Cradle?

Cradle is a tool for loading data models from one place and emitting it to another. This can be leveraged to eliminate the manual creation of redundant and tedious code within your project/application. We provide the ability to create specs that can, in turn, be executed against emitters with the output resulting in the code you wish to use.

[Getting Started](#getting-started)  
[The Cradle CLI](#the-cradle-cli)  
[Loaders](#cradle-loader-api)  
[Emitters](#cradle-emitter-api)

## Getting Started

To get started, first install Cradle in your local project folder:
`npm i --save-dev @cradlejs/core`

## The Cradle Flow

Cradle was built to load a schema from any source via CradleLoaders and emit to any destination via CradleEmitters.

When you execute `npx cradle emit`, it will load your schema, then send it to each of your configured emitters. We have developed a few emitters for you to use (@cradlejs/template-emitter and @cradlejs/react-emitter), but the API is simple to understand and implement.

## Cradle Loader API

If you want to develop a custom Cradle Loader, (for instance, loading from Postgres or Mongo), all you have to do is implement ICradleLoader in a npm module.

```
    prepareLoader: (options: {[key: string]: any}, console: IConsole) => Promise < void >
    readModelNames: () => Promise < string[] >
    readModelPropertyNames: (modelName: string) => Promise < string[] >
    readModelPropertyType: (modelName: string, propertyName: string) => Promise < PropertyType >
    readModelReferenceNames: (modelName: string) => Promise < string[] >
    readModelReferenceType: (modelName: string, referenceName: string) => Promise < ModelReference >
    readModelMetadata: (modelName: string) => Promise < object >
    finalizeSchema: (schema: CradleSchema) => Promise < CradleSchema >
    loadSchema: () => Promise<CradleSchema>
```

You can reference @cradlejs/spec-loader for a functioning loader

## Cradle Emitter API

You can also write a custom emitter. Suppose you wanted to write your schema to a database, you could implement a sql-emitter by implementing the ICradleEmitter interface.

```
  prepareEmitter(options: IEmitterOptions, console: IConsole)
  emitSchema(schema: CradleSchema)
```

You can reference @cradlejs/file-emitter for an example.

---
_Source: https://npm.io/package/@cradlejs/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
