Releases: VKCOM/api-schema-typescript
Releases · VKCOM/api-schema-typescript
v1.5131.0
Breaking Changes
The library no longer contains TypeScript enums in favor of union types.
Before:
export enum UsersUserRelation {
NOT_SPECIFIED = 0,
SINGLE = 1,
IN_A_RELATIONSHIP = 2,
ENGAGED = 3,
MARRIED = 4,
COMPLICATED = 5,
ACTIVELY_SEARCHING = 6,
IN_LOVE = 7,
IN_A_CIVIL_UNION = 8,
}After:
export const UsersUserRelationEnumNames = {
NOT_SPECIFIED: 0,
SINGLE: 1,
IN_A_RELATIONSHIP: 2,
ENGAGED: 3,
MARRIED: 4,
COMPLICATED: 5,
ACTIVELY_SEARCHING: 6,
IN_LOVE: 7,
IN_A_CIVIL_UNION: 8,
} as const;
/**
* @note This enum have auto-generated constant with keys and values
* @see UsersUserRelationEnumNames
*
* `0` — not specified
* `1` — single
* `2` — in a relationship
* `3` — engaged
* `4` — married
* `5` — complicated
* `6` — actively searching
* `7` — in love
* `8` — in a civil union
*/
export type UsersUserRelation = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;All numeric JSON Schema enums have auto-generated constants with keys and values. This constants allows to use not magic numbers in code, but some understandable values.
/* What `5` means? */
if (relation === 5) {}
/* Looks better */
if (relation === UsersUserRelation.COMPLICATED) {}v0.5131.1
Scheme update for 5.131 API version.
v0.5130.0
Features
- Export
API_VERSIONconstant.
Breaking changes
Before now the generator created TypeScript enum types for properties with inline-descriptive enum values. Now it will be generated as union type with the constant, which can be imported to project.
Before:
// users_online_info status enum
export enum UsersOnlineInfoStatusEnum {
RECENTLY = 'recently',
LAST_WEEK = 'last_week',
LAST_MONTH = 'last_month',
LONG_AGO = 'long_ago',
NOT_SHOW = 'not_show',
}
// users_online_info
export interface UsersOnlineInfo {
/**
* In case user online is not visible, it indicates approximate timeframe of user online
*/
status?: UsersOnlineInfoStatusEnum;
}After:
// users_online_info status enumNames
export const UsersOnlineInfoStatusEnumNames = {
RECENTLY: 'recently',
LAST_WEEK: 'last_week',
LAST_MONTH: 'last_month',
LONG_AGO: 'long_ago',
NOT_SHOW: 'not_show',
} as const;
// users_online_info
export interface UsersOnlineInfo {
/**
* In case user online is not visible, it indicates approximate timeframe of user online
*/
status?: 'recently' | 'last_week' | 'last_month' | 'long_ago' | 'not_show';
}v0.5126.0
Now methods parameters with array type have string type. The reason is, VK API accepts only a comma-separated string for array parameters. This may change in the future when VK API starts accepting a json body.
Before:
interface SomeMethodParams {
user_ids: number[];
filters: string[];
fields: UsersFields[];
}After:
interface SomeMethodParams {
user_ids: string;
filters: string;
fields: string;
}