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: add typeKey #147

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
225 changes: 113 additions & 112 deletions docs/README.md

Large diffs are not rendered by default.

82 changes: 39 additions & 43 deletions docs/classes/ContextBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

## Type parameters

| Name | Type |
| :------ | :------ |
| `TEntity` | `TEntity` |
| Name | Type |
| :----------------- | :-------- |
| `TEntity` | `TEntity` |
| `TExtraProperties` | `unknown` |

## Table of contents
Expand Down Expand Up @@ -40,20 +40,20 @@

#### Type parameters

| Name | Type |
| :------ | :------ |
| `TEntity` | `TEntity` |
| Name | Type |
| :----------------- | :-------- |
| `TEntity` | `TEntity` |
| `TExtraProperties` | `unknown` |

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :--------------- | :-------------------------------------------------------------------------------------------------------------------------- |
| `renderFunction` | (`c`: [`Context`](../README.md#context)<`TEntity`, `TExtraProperties`\>) => [`DocumentObject`](../README.md#documentobject) |

#### Defined in

[src/context.ts:18](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L18)
[src/context.ts:18](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L18)

## Properties

Expand All @@ -63,29 +63,29 @@

#### Defined in

[src/context.ts:15](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L15)
[src/context.ts:15](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L15)

___
---

### input

• `Optional` **input**: `TEntity`

#### Defined in

[src/context.ts:13](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L13)
[src/context.ts:13](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L13)

___
---

### options

• `Optional` **options**: [`Options`](../README.md#options)<`TExtraProperties`\>

#### Defined in

[src/context.ts:16](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L16)
[src/context.ts:16](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L16)

___
---

### renderFunction

Expand All @@ -97,27 +97,23 @@ ___

##### Parameters

| Name | Type |
| :------ | :------ |
| `c` | [`Context`](../README.md#context)<`TEntity`, `TExtraProperties`\> |
| Name | Type |
| :--- | :---------------------------------------------------------------- |
| `c` | [`Context`](../README.md#context)<`TEntity`, `TExtraProperties`\> |

##### Returns

[`DocumentObject`](../README.md#documentobject)

#### Defined in

[src/context.ts:18](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L18)

___
---

### transformer

• `Optional` **transformer**: [`Transformer`](Transformer.md)<`TEntity`, `TExtraProperties`\>

#### Defined in

[src/context.ts:14](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L14)
[src/context.ts:14](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L14)

## Methods

Expand All @@ -131,9 +127,9 @@ ___

#### Defined in

[src/context.ts:60](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L60)
[src/context.ts:60](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L60)

___
---

### toContext

Expand All @@ -145,18 +141,18 @@ ___

#### Defined in

[src/context.ts:43](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L43)
[src/context.ts:43](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L43)

___
---

### withIncluded

▸ **withIncluded**(`included`): [`ContextBuilder`](ContextBuilder.md)<`TEntity`, `TExtraProperties`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :--------- | :-------- |
| `included` | `boolean` |

#### Returns
Expand All @@ -165,18 +161,18 @@ ___

#### Defined in

[src/context.ts:31](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L31)
[src/context.ts:31](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L31)

___
---

### withInput

▸ **withInput**(`input`): [`ContextBuilder`](ContextBuilder.md)<`TEntity`, `TExtraProperties`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :------ | :-------- |
| `input` | `TEntity` |

#### Returns
Expand All @@ -185,18 +181,18 @@ ___

#### Defined in

[src/context.ts:20](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L20)
[src/context.ts:20](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L20)

___
---

### withOptions

▸ **withOptions**(`options`): [`ContextBuilder`](ContextBuilder.md)<`TEntity`, `TExtraProperties`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :-------- | :----------------------------------------------------- |
| `options` | [`Options`](../README.md#options)<`TExtraProperties`\> |

#### Returns
Expand All @@ -205,18 +201,18 @@ ___

#### Defined in

[src/context.ts:37](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L37)
[src/context.ts:37](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L37)

___
---

### withTransformer

▸ **withTransformer**(`transformer`): [`ContextBuilder`](ContextBuilder.md)<`TEntity`, `TExtraProperties`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :------------ | :-------------------------------------------------------------- |
| `transformer` | [`Transformer`](Transformer.md)<`TEntity`, `TExtraProperties`\> |

#### Returns
Expand All @@ -225,4 +221,4 @@ ___

#### Defined in

[src/context.ts:25](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/context.ts#L25)
[src/context.ts:25](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/context.ts#L25)
51 changes: 29 additions & 22 deletions docs/classes/DefaultTransformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

## Type parameters

| Name | Type |
| :------ | :------ |
| `TEntity` | `unknown` |
| `TExtraOptions` | `void` |
| Name | Type |
| :-------------- | :-------- |
| `TEntity` | `unknown` |
| `TExtraOptions` | `void` |

## Hierarchy

Expand All @@ -23,6 +23,7 @@

### Properties

- [options](DefaultTransformer.md#options)
- [relationships](DefaultTransformer.md#relationships)
- [type](DefaultTransformer.md#type)

Expand All @@ -38,28 +39,38 @@

#### Type parameters

| Name | Type |
| :------ | :------ |
| `TEntity` | `unknown` |
| `TExtraOptions` | `void` |
| Name | Type |
| :-------------- | :-------- |
| `TEntity` | `unknown` |
| `TExtraOptions` | `void` |

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `type` | `string` | `undefined` |
| `relationships` | `string`[] \| `Record`<`string`, `string`\> | `[]` |
| Name | Type | Default value |
| :-------------- | :------------------------------------------ | :------------ |
| `type` | `string` | `undefined` |
| `relationships` | `string`[] \| `Record`<`string`, `string`\> | `[]` |

#### Overrides

[Transformer](Transformer.md).[constructor](Transformer.md#constructor)

#### Defined in

[src/default-transformer.ts:8](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/default-transformer.ts#L8)
[src/default-transformer.ts:9](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/default-transformer.ts#L9)

## Properties

### options

• `Optional` `Readonly` **options**: [`Options`](../README.md#options)<`TExtraOptions`\>

#### Defined in

[src/default-transformer.ts:7](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/default-transformer.ts#L7)

---

### relationships

• `Readonly` **relationships**: `Record`<`string`, [`RelationshipTransformerInfoFunction`](../README.md#relationshiptransformerinfofunction)<`TEntity`, `TExtraOptions`\>\>
Expand All @@ -70,9 +81,9 @@

#### Defined in

[src/default-transformer.ts:6](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/default-transformer.ts#L6)
[src/default-transformer.ts:6](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/default-transformer.ts#L6)

___
---

### type

Expand All @@ -82,10 +93,6 @@ ___

[Transformer](Transformer.md).[type](Transformer.md#type)

#### Defined in

[src/default-transformer.ts:8](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/default-transformer.ts#L8)

## Methods

### transform
Expand All @@ -94,8 +101,8 @@ ___

#### Parameters

| Name | Type |
| :------ | :------ |
| Name | Type |
| :------- | :---- |
| `entity` | `any` |

#### Returns
Expand All @@ -108,4 +115,4 @@ ___

#### Defined in

[src/default-transformer.ts:28](https://github.com/andersondanilo/jsonapi-fractal/blob/9e4f6c2/src/default-transformer.ts#L28)
[src/default-transformer.ts:29](https://github.com/andersondanilo/jsonapi-fractal/blob/5f3ab68/src/default-transformer.ts#L29)
Loading