@crowdin/crowdin-api-client
Version:
JavaScript library for Crowdin API
114 lines (113 loc) • 5.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourceStringsModel = exports.SourceStrings = void 0;
const core_1 = require("../core");
/**
* Source strings are the text units for translation. Instead of modifying source files, you can manage source strings one by one.
*
* Use API to add, edit, or delete some specific strings in the source-based and files-based projects.
*/
class SourceStrings extends core_1.CrowdinApi {
/**
* @param projectId project identifier
* @param uploadId export identifier
*/
uploadStringsStatus(projectId, uploadId) {
const url = `${this.url}/projects/${projectId}/strings/uploads/${uploadId}`;
return this.get(url, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param request request payload
*/
uploadStrings(projectId, request) {
const url = `${this.url}/projects/${projectId}/strings/uploads`;
return this.post(url, request, this.defaultConfig());
}
listProjectStrings(projectId, options, deprecatedLimit, deprecatedOffset, deprecatedFilter, deprecatedDenormalizePlaceholders, deprecatedLabelIds, deprecatedScope, deprecatedCroql, deprecatedBranchId, deprecatedDirectoryId) {
let url = `${this.url}/projects/${projectId}/strings`;
if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) {
options = {
fileId: options,
limit: deprecatedLimit,
offset: deprecatedOffset,
filter: deprecatedFilter,
denormalizePlaceholders: deprecatedDenormalizePlaceholders,
labelIds: deprecatedLabelIds,
scope: deprecatedScope,
croql: deprecatedCroql,
branchId: deprecatedBranchId,
directoryId: deprecatedDirectoryId,
};
}
url = this.addQueryParam(url, 'fileId', options.fileId);
url = this.addQueryParam(url, 'filter', options.filter);
url = this.addQueryParam(url, 'denormalizePlaceholders', options.denormalizePlaceholders);
url = this.addQueryParam(url, 'labelIds', options.labelIds);
url = this.addQueryParam(url, 'scope', options.scope);
url = this.addQueryParam(url, 'croql', options.croql);
url = this.addQueryParam(url, 'branchId', options.branchId);
url = this.addQueryParam(url, 'directoryId', options.directoryId);
url = this.addQueryParam(url, 'orderBy', options.orderBy);
url = this.addQueryParam(url, 'taskId', options.taskId);
return this.getList(url, options.limit, options.offset);
}
/**
* @param projectId project identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.strings.post
*/
addString(projectId, request) {
const url = `${this.url}/projects/${projectId}/strings`;
return this.post(url, request, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.strings.batchPatch
*/
stringBatchOperations(projectId, request) {
const url = `${this.url}/projects/${projectId}/strings`;
return this.patch(url, request, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param stringId string identifier
* @param query query params
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.strings.get
*/
getString(projectId, stringId, query) {
let url = `${this.url}/projects/${projectId}/strings/${stringId}`;
url = this.addQueryParam(url, 'denormalizePlaceholders', query === null || query === void 0 ? void 0 : query.denormalizePlaceholders);
return this.get(url, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param stringId string identifier
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.strings.delete
*/
deleteString(projectId, stringId) {
const url = `${this.url}/projects/${projectId}/strings/${stringId}`;
return this.delete(url, this.defaultConfig());
}
/**
* @param projectId project identifier
* @param stringId string identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.strings.patch
*/
editString(projectId, stringId, request) {
const url = `${this.url}/projects/${projectId}/strings/${stringId}`;
return this.patch(url, request, this.defaultConfig());
}
}
exports.SourceStrings = SourceStrings;
var SourceStringsModel;
(function (SourceStringsModel) {
let Type;
(function (Type) {
Type[Type["TEXT"] = 0] = "TEXT";
Type[Type["ASSET"] = 1] = "ASSET";
Type[Type["ICU"] = 2] = "ICU";
})(Type = SourceStringsModel.Type || (SourceStringsModel.Type = {}));
})(SourceStringsModel = exports.SourceStringsModel || (exports.SourceStringsModel = {}));