jsonapi-fractal
- AttributesObject
- Context
- DocumentObject
- ExistingDocumentObject
- ExistingResourceObject
- LinkObject
- MetaObject
- NewDocumentObject
- NewResourceObject
- Options
- RelationshipObject
- RelationshipTransformerInfo
- RelationshipTransformerInfoFunction
- ResourceIdentifierObject
- ResourceObject
- SerializeOptions
- TransformerRelationships
Ƭ JsonObject: { [Key in string]: JsonValue } & { [Key in string]?: JsonValue }
Matches a JSON object.
This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: jsonObject as unknown as CustomResponse
. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: interface CustomResponse extends JsonObject { … }
.
node_modules/type-fest/source/basic.d.ts:22
Ƭ AttributesObject: JsonObject
Ƭ Context<TEntity
, TExtraProperties
>: Object
Name | Type |
---|---|
TEntity |
TEntity |
TExtraProperties |
unknown |
Name | Type |
---|---|
included |
boolean |
input |
TEntity | undefined |
options |
Options <TExtraProperties > |
transformer |
Transformer <TEntity , TExtraProperties > |
Ƭ DocumentObject: ExistingDocumentObject
| NewDocumentObject
Ƭ ExistingDocumentObject: BaseDocumentObject
<ExistingResourceObject
>
Ƭ ExistingResourceObject: ResourceIdentifierObject
& { attributes
: AttributesObject
; id
: string
; links?
: LinkObject
; relationships?
: Record
<string
, RelationshipObject
> }
Ƭ LinkObject: JsonObject
Ƭ MetaObject: JsonObject
Ƭ NewDocumentObject: BaseDocumentObject
<NewResourceObject
>
Ƭ NewResourceObject: Omit
<ExistingResourceObject
, "id"
>
Ƭ Options<TExtraOptions
>: Object
Name | Type |
---|---|
TExtraOptions |
void |
Name | Type | Description |
---|---|---|
changeCase? |
CaseType |
change case of the attribute keys |
changeCaseDeep? |
boolean |
if true, also apply the change for sub objects |
extra? |
TExtraOptions |
custom properties, that are available in the transformer |
fields? |
Record <string , string []> |
map of EntityType => Fields Array, e.g. {"users": ["name", "age"], "images": ["width"]} |
idKey? |
string |
key that should be used as the id |
Ƭ RelationshipObject: Object
Name | Type |
---|---|
data |
ResourceIdentifierObject | ResourceIdentifierObject [] |
links? |
LinkObject |
Ƭ RelationshipTransformerInfo<TExtraOptions
, T
>: Object
Name | Type |
---|---|
TExtraOptions |
TExtraOptions |
T |
unknown |
Name | Type |
---|---|
included |
boolean |
input |
T |
transformer |
Transformer <T , TExtraOptions > |
Ƭ RelationshipTransformerInfoFunction<TEntity
, TExtraOptions
>: (entity
: TEntity
, options
: Options
<TExtraOptions
>) => RelationshipTransformerInfo
<TExtraOptions
>
Name |
---|
TEntity |
TExtraOptions |
▸ (entity
, options
): RelationshipTransformerInfo
<TExtraOptions
>
Name | Type |
---|---|
entity |
TEntity |
options |
Options <TExtraOptions > |
RelationshipTransformerInfo
<TExtraOptions
>
Ƭ ResourceIdentifierObject: Object
Name | Type |
---|---|
id |
string |
type |
string |
Ƭ ResourceObject: ExistingResourceObject
| NewResourceObject
Ƭ SerializeOptions<TExtraOptions
>: Options
<TExtraOptions
> & { included?
: boolean
; relationships?
: string
[] | Record
<string
, string
> }
Name | Type |
---|---|
TExtraOptions |
void |
Ƭ TransformerRelationships<TEntity
, TExtraOptions
>: Record
<string
, RelationshipTransformerInfoFunction
<TEntity
, TExtraOptions
>>
Name |
---|
TEntity |
TExtraOptions |
▸ deserialize<TEntity
, TExtraOptions
>(response
, options?
): TEntity
| TEntity
[] | undefined
Deserialize a JSON:API response
Name | Type |
---|---|
TEntity |
TEntity |
TExtraOptions |
unknown |
Name | Type |
---|---|
response |
DocumentObject |
options |
Options <TExtraOptions > |
TEntity
| TEntity
[] | undefined
▸ serialize<TEntity
, TExtraOptions
>(data
, type
, options?
): DocumentObject
Serialize the entity
Name | Type |
---|---|
TEntity |
TEntity |
TExtraOptions |
unknown |
Name | Type | Description |
---|---|---|
data |
TEntity |
entity to be serialized |
type |
string |
type of the entity |
options? |
SerializeOptions <TExtraOptions > |
options used in the serialization |
▸ transform<TEntity
, TExtraOptions
>(): ContextBuilder
<TEntity
, TExtraOptions
>
Create a ContextBuilder, used to configure the transformation
Name | Type |
---|---|
TEntity |
TEntity |
TExtraOptions |
unknown |
ContextBuilder
<TEntity
, TExtraOptions
>
▸ whitelist(object
, list
): AttributesObject
Keep only a set of fields on a given object
Name | Type |
---|---|
object |
unknown |
list |
string [] |