This page contains a detailed list of breaking changes and the steps required to upgrade from ts-api@1.x.x
to api-client@2.0.0
.
LocalazyApi
function was removed, use ApiClient
class instead.
// ts-api
import LocalazyApi from 'ts-api';
const api = LocalazyApi({ projectToken: 'your-project-token' });
// api-client
import { ApiClient } from 'api-client';
const api: ApiClient = new ApiClient({ authToken: 'your-project-token' });
listProjects
function was removed, use api.projects.list
function instead.
// ts-api
const options: ListProjects = {
organization: true,
languages: true
};
const projects: Project[] = await api.listProjects(options, config);
// api-client
const options: ProjectsListRequest = {
organization: true,
languages: true
};
const webhooks: Project[] = await api.projects.list(options, config);
import
function was removed, use api.import.json
function instead.
// ts-api
const options: Import = {
projectId: 'project-id',
importAsNew: true,
files: [
{
name: 'en.json',
content: {
type: 'json',
en: { headers: { name: 'Name' } }
}
}
]
};
const result: ImportResult = await api.import(options, config);
const id: string = result.result;
// api-client
const options: ImportJsonRequest = {
project: 'project-id',
json: { en: { headers: { name: 'Name' } } },
i18nOptions: {
importAsNew: true
},
fileOptions: {
name: 'en.json'
}
};
const file: File = await api.import.json(options, config);
const id: string = file.importBatch;
listFormats
function was removed, use api.formats.list
function instead.
// ts-api
const formats: Format[] = await api.listFormats(config);
// api-client
const formats: Format[] = await api.formats.list(config);
listFiles
function was removed, use api.files.list
function instead.
// ts-api
const options: ListFiles = {
projectId: 'project-id'
};
const files: FileResult[] = await api.listFiles(options, config);
// api-client
const options: FilesListRequest = {
project: 'project-id'
};
const files: File[] = await api.files.list(options, config);
getFileContents
function was removed,
use api.files.getContents
function instead.
// ts-api
const options: GetFileContents = {
projectId: 'project-id',
fileId: 'file-id',
lang: 'en'
};
const blob: Blob = await api.getFileContents(options, config);
// api-client
const options: FileGetContentsRequest = {
project: 'project-id',
file: 'file-id',
lang: 'en'
};
const blob: Blob = await api.files.getContents(options, config);
listKeysInFileForLanguage
function was removed,
use api.files.listKeys
function instead. New function no
longer returns paginated result, it returns all keys and pagination is done automatically.
updateKey
function was removed, use api.keys.update
function instead.
// ts-api
const options: UpdateKey = {
projectId: 'project-id',
keyId: 'key-id',
comment: 'comment'
};
await api.updateKey(options, config);
// api-client
const options: KeyUpdateRequest = {
project: 'project-id',
key: 'key-id',
comment: 'comment'
};
await api.keys.update(options, config);
deleteKey
function was removed, use api.keys.delete
function instead.
// ts-api
const options: DeleteKey = {
projectId: 'project-id',
keyId: 'key-id'
};
await api.deleteKey(options, config);
// api-client
const options: KeyDeleteRequest = {
project: 'project-id',
key: 'key-id'
};
await api.keys.delete(options, config);
listScreenshots
function was removed,
use api.screenshots.list
function instead.
// ts-api
const options: ListScreenshots = {
projectId: 'project-id'
};
const screenshots: Screenshot[] = await api.listScreenshots(options, config);
// api-client
const options: ScreenshotsListRequest = {
project: 'project-id'
};
const screenshots: Screenshot[] = await api.screenshots.list(options, config);
listScreenshotsTags
function was removed,
use api.screenshots.listTags
function instead.
// ts-api
const options: ListScreenshotsTags = {
projectId: 'project-id'
};
const tags: Tag[] = await api.listScreenshotsTags(options, config);
// api-client
const options: ScreenshotsListTagsRequest = {
project: 'project-id'
};
const tags: ScreenshotTag[] = await api.screenshots.listTags(options, config);
postScreenshots
function was removed,
use api.screenshots.create
function instead.
// ts-api
const options: PostScreenshot = {
projectId: 'project-id',
rawScreenshot: 'data:image/png;base64...'
};
const result: PostScreenhotsResult = await api.postScreenshots(options, config);
const id: string = result.id;
// api-client
const options: ScreenshotCreateRequest = {
project: 'project-id',
encodedData: 'data:image/png;base64...'
};
const id: string = await api.screenshots.create(options, config);
postScreenshot
function was removed,
use api.screenshots.updateImageData
function
instead.
// ts-api
const options: PostScreenshot = {
projectId: 'project-id',
screenshotId: 'screenshot-id',
rawScreenshot: 'data:image/png;base64...'
};
await api.postScreenshot(options, config);
// api-client
const options: ScreenshotUpdateImageDataRequest = {
project: 'project-id',
screenshot: 'screenshot-id',
encodedData: 'data:image/png;base64...'
};
await api.screenshots.updateImageData(options, config);
putScreenshot
function was removed,
use api.screenshots.update
function instead.
// ts-api
const options: PutScreenshot = {
projectId: 'project-id',
screenshotId: 'screenshot-id',
screenshot: {
comment: 'comment'
}
};
await api.putScreenshot(options, config);
// api-client
const options: ScreenshotUpdateRequest = {
project: 'project-id',
screenshot: 'screenshot-id',
comment: 'comment'
};
await api.screenshots.update(options, config);
deleteScreenshot
function was removed,
use api.screenshots.delete
function instead.
// ts-api
const options: DeleteScreenshot = {
projectId: 'project-id',
screenshotId: 'screenshot-id'
};
await api.deleteScreenshot(options, config);
// api-client
const options: ScreenshotDeleteRequest = {
project: 'project-id',
screenshot: 'screenshot-id'
};
await api.screenshots.delete(options, config);
listWebhooks
function was removed, use api.webhooks.list
function instead.
// ts-api
const options: ListWebhooks = {
projectId: 'project-id'
};
const result: ListWebhooksResult = await api.listWebhooks(options, config);
const webhooks: Webhook[] = result.items;
// api-client
const options: WebhooksListRequest = {
project: 'project-id'
};
const webhooks: Webhook[] = await api.webhooks.list(options, config);
postWebhooks
function was removed,
use api.webhooks.update
function instead.
// ts-api
const options: PostWebhooks = {
projectId: 'project-id',
webhooks: {
items: []
}
};
await api.postWebhooks(options, config);
// api-client
const options: WebhooksUpdateRequest = {
project: 'project-id',
items: []
};
await api.webhooks.update(options, config);
getWebhooksSecret
function was removed,
use api.webhooks.getSecret
function instead.
// ts-api
const options: GetWebhooksSecret = {
projectId: 'project-id'
};
const result: GetWebhooksSecretResult = await api.getWebhooksSecret(options, config);
const secret: string = result.secret;
// api-client
const options: WebhooksGetSecretRequest = {
project: 'project-id'
};
const secret: string = await api.webhooks.getSecret(options, config);