# @shingo/describe2ts

> Converts salesforce DescribeSObject results to typescript interfaces

Latest version **0.1.1** (published 2019-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @shingo/describe2ts
pnpm add @shingo/describe2ts
yarn add @shingo/describe2ts
bun add @shingo/describe2ts
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-03-13 |
| First published | 2019-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Abraham White |
| Maintainers | whiteabelincoln |
| Keywords | Salesforce, Typescript, DescribeSObject |

## Links

- npm: https://www.npmjs.com/package/@shingo/describe2ts
- Repository: https://github.com/shingoinstitute/describe2ts
- Homepage: https://github.com/shingoinstitute/describe2ts#readme
- Issues: https://github.com/shingoinstitute/describe2ts/issues
- npm.io page: https://npm.io/package/@shingo/describe2ts

## Dependencies (5)

- [fp-ts](https://npm.io/package/fp-ts.md) ^1.13.0
- [isemail](https://npm.io/package/isemail.md) ^3.2.0
- [valid-url](https://npm.io/package/valid-url.md) ^1.0.9
- [newtype-ts](https://npm.io/package/newtype-ts.md) ^0.2.4
- [@types/jsforce](https://npm.io/package/@types/jsforce.md) ^1.9.4

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2019-03-13
- 0.1.0 — 2019-03-13

## README

# describe2ts

Converts a salesforce DescribeSObjectResult object (typically produced by jsforce)
to a salesforce interface

## Usage Example

```ts
import describe2ts from 'describe2ts'
import { writeFileSync } from 'fs'

// describe files retrieved from somewhere
const describes: DescribeSObjectResult[] = getDescribes()

const nameMatch = ['Contact', 'Account']

// only create interfaces for the objects in the nameMatch array
const resolver = (name: string) =>
  nameMatch.includes(name) ? `import("./${name}").default` : null

// used for determining nillability of child relationships
// this is optional
const sobjectResolver = (name: string) => describes.find(d => d.name === name)

for (const desc of describes) {
  const iface = describe2ts(desc, resolver, sobjectResolver)
  writeFileSync(`${desc.name}.ts`, iface, 'utf8')
}
```

## API

### describe2ts

| Parameter       | Type                                                                                                   | Description                                                                                     | Required |
| --------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | -------- |
| desc            | `DescribeSObjectResult`                                                                                | a DescribeSObjectResult object                                                                  | ✓        |
| resolver        | `string => Option<string> \| string \| null \| undefined`                                              | a function that resolves the name of a Salesforce Object to a typescript type string            | ✓        |
| sobjectResolver | `undefined \| (string => Option<DescribeSObjectResult> \| DescribeSObjectResult \| null \| undefined)` | an optional function that resolves the name of a Salesforce Object to its DescribeSObjectResult | ✗        |
| newtype         | `undefined \| boolean`                                                                                 | use newtypes instead of typescript primitives                                                   | ✗        |
| sfTypeResolver  | `undefined \| { readonly [k in FieldType]: (f: Field, newtype?: boolean) => string }`                  | a map of functions from salesforce types to typescript types                                    | ✗        |
| defaultExport   | `undefined \| boolean`                                                                                 | add a default export line to the output text                                                    | ✗        |

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