|
| 1 | +interface AnyDict { |
| 2 | + [key: string]: any; |
| 3 | +} |
1 | 4 |
|
| 5 | +interface StringDict { |
| 6 | + [key: string]: string; |
| 7 | +} |
2 | 8 |
|
3 | 9 | declare class JsonApiResource { |
| 10 | + constructor({ |
| 11 | + id: string, |
| 12 | + attributes: AnyDict, |
| 13 | + relationships: AnyDict, |
| 14 | + links: StringDict, |
| 15 | + }); |
| 16 | + get(key: string): any; |
| 17 | + set(key: string, value: any): void; |
| 18 | + async reload(include: string[]): null; |
| 19 | + static async get(arg:string | AnyDict): JsonApiResource; |
| 20 | + async fetch(relationshipName: string, force: boolean): JsonApiResource | Collection; |
| 21 | + async save(arg: AnyDict | string[]): null; |
| 22 | + static async create({ |
| 23 | + id: string, |
| 24 | + attributes: AnyDict, |
| 25 | + relationships: AnyDict, |
| 26 | + links: StringDict, |
| 27 | + }): JsonApiResource; |
| 28 | + async delete(): void; |
| 29 | + async change(field: string, value:JsonApiResource | null): void; |
| 30 | + async add(field: string, values: JsonApiResource[]): null; |
| 31 | + async reset(field: string, values: JsonApiResource[]): null; |
| 32 | + async remove(field: string, values: JsonApiResource[]): null; |
| 33 | + static list(): Collection; |
| 34 | + static extra(AnyDict): Collection; |
| 35 | + static filter(filters: AnyDict): Collection; |
| 36 | + static page(arg: AnyDict | string): Collection; |
| 37 | + static include(...args: string[]): Collection; |
| 38 | + static sort(...args: string[]): Collection; |
| 39 | + static fields(...args: string[]): Collection; |
| 40 | + static all(): Iterable<JsonApiResource>; |
| 41 | + static allPages(): Iterable<Collection>; |
| 42 | +} |
| 43 | + |
| 44 | +declare class Collection { |
| 45 | + async fetch(): void; |
| 46 | + async getNext(): Collection |
| 47 | + async getPrevious(): Collection |
| 48 | + extra(AnyDict): Collection; |
| 49 | + filter(filters: AnyDict): Collection; |
| 50 | + page(arg: AnyDict | string): Collection; |
| 51 | + include(...args: string[]): Collection; |
| 52 | + sort(...args: string[]): Collection; |
| 53 | + fields(...args: string[]): Collection; |
| 54 | + all(): Iterable<JsonApiResource>; |
| 55 | + allPages(): Iterable<Collection>; |
4 | 56 | } |
5 | 57 |
|
| 58 | +type AuthFunction = () => string; |
| 59 | +type AuthArgument = string | AuthFunction; |
| 60 | + |
6 | 61 | declare export class TransifexApi { |
| 62 | + constructor({ host: string, auth: AuthArgument }); |
| 63 | + setup({ host: string, auth: AuthArgument }): void; |
| 64 | + |
7 | 65 | Organization: typeof JsonApiResource; |
8 | 66 | User: typeof JsonApiResource; |
9 | 67 | Language: typeof JsonApiResource; |
|
0 commit comments