Open apsavin opened 7 years ago
Hi @apsavin,
I am using flow in my projects as well, and I considered to add it here. I am a bit busy nowadays, so this might be shipped in a month from now or so. PRs are welcome of course :)
Made a simple definition. Does not cover the actual transformations, that could probably be covered with generics.
declare module "json-api-normalizer" {
export interface IJsonApiResponse {
data: IJsonApiObject[]
included?: IJsonApiObject[]
links?: { [key: string]: string }
meta?: { [key: string]: any }
}
export interface IJsonApiObject {
attributes: { [key: string]: any }
id: string
links?: { [key: string]: string }
meta?: {}
relationships: {
[key: string]: {
data: IJsonApiReference | IJsonApiReference[]
links?: { [key: string]: string }
meta?: {}
}
}
type: string
}
interface IJsonApiReference {
id: string
type: string
}
interface IOpts {
camelizeKeys?: boolean
camelizeTypeValues?: boolean
endpoint?: boolean
filterEndpoint?: boolean
}
function normalize(json: IJsonApiResponse, opts?: IOpts): {}
export default normalize
}
@emp823 looks great! Would be more than happy to accept a good PR, once ready
Hi, Yury!
Thanks for the useful lib!
A lot of programmers in JS community use
flow
andTypescript
. My company usesflow
, so I'm interested inflow
mostly. Do you want to add annotations so the users of typed languges would benefit from it?Here's the docs for flow and typescript for reference.