UNPKG

@crowdin/crowdin-api-client

Version:
327 lines (326 loc) 14.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SourceFilesModel = exports.SourceFiles = void 0; const core_1 = require("../core"); /** * Source files are resources for translation. You can keep files structure using folders or manage different versions of the content via branches. * * Use API to keep the source files up to date, check on file revisions, and manage project branches. * Before adding source files to the project, upload each file to the Storage first. */ class SourceFiles extends core_1.CrowdinApi { /** * @param projectId project identifier * @param branchId branch identifier * @param cloneId clone branch identifier * @see https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.branch.get */ getClonedBranch(projectId, branchId, cloneId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/clones/${cloneId}/branch`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param request request body * @see https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.post */ clonedBranch(projectId, branchId, request) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/clones`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param cloneId clone branch identifier * @see https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.get */ checkBranchClonedStatus(projectId, branchId, cloneId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/clones/${cloneId}`; return this.get(url, this.defaultConfig()); } listProjectBranches(projectId, options, deprecatedLimit, deprecatedOffset) { if ((0, core_1.isOptionalString)(options, '1' in arguments)) { options = { name: options, limit: deprecatedLimit, offset: deprecatedOffset }; } let url = `${this.url}/projects/${projectId}/branches`; url = this.addQueryParam(url, 'name', options.name); url = this.addQueryParam(url, 'orderBy', options.orderBy); 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.branches.post */ createBranch(projectId, request) { const url = `${this.url}/projects/${projectId}/branches`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.branches.get */ getBranch(projectId, branchId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.branches.delete */ deleteBranch(projectId, branchId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.branches.patch */ editBranch(projectId, branchId, request) { const url = `${this.url}/projects/${projectId}/branches/${branchId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param request request body * @see https://support.crowdin.com/developer/api/v2/string-based/#tag/Branches/operation/api.projects.branches.merges.post */ mergeBranch(projectId, branchId, request) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/merges`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param mergeId merge branch identifier * @see https://support.crowdin.com/developer/api/v2/string-based/#tag/Branches/operation/api.projects.branches.merges.get */ checkBranchMergeStatus(projectId, branchId, mergeId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/merges/${mergeId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param branchId branch identifier * @param mergeId merge branch identifier * @see https://support.crowdin.com/developer/api/v2/string-based/#tag/Branches/operation/api.projects.branches.merges.summary.get */ getBranchMergeSummary(projectId, branchId, mergeId) { const url = `${this.url}/projects/${projectId}/branches/${branchId}/merges/${mergeId}/summary`; return this.get(url, this.defaultConfig()); } listProjectDirectories(projectId, options, deprecatedDirectoryId, deprecatedLimit, deprecatedOffset, deprecatedFilter, deprecatedRecursion) { let url = `${this.url}/projects/${projectId}/directories`; if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) { options = { branchId: options, directoryId: deprecatedDirectoryId, limit: deprecatedLimit, offset: deprecatedOffset, recursion: deprecatedRecursion, filter: deprecatedFilter, }; } url = this.addQueryParam(url, 'branchId', options.branchId); url = this.addQueryParam(url, 'directoryId', options.directoryId); url = this.addQueryParam(url, 'filter', options.filter); url = this.addQueryParam(url, 'recursion', options.recursion); url = this.addQueryParam(url, 'orderBy', options.orderBy); 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.directories.post */ createDirectory(projectId, request) { const url = `${this.url}/projects/${projectId}/directories`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param directoryId directory identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.directories.get */ getDirectory(projectId, directoryId) { const url = `${this.url}/projects/${projectId}/directories/${directoryId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param directoryId directory identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.directories.delete */ deleteDirectory(projectId, directoryId) { const url = `${this.url}/projects/${projectId}/directories/${directoryId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param directoryId directory identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.directories.patch */ editDirectory(projectId, directoryId, request) { const url = `${this.url}/projects/${projectId}/directories/${directoryId}`; return this.patch(url, request, this.defaultConfig()); } listProjectFiles(projectId, options, deprecatedDirectoryId, deprecatedLimit, deprecatedOffset, deprecatedRecursion, deprecatedFilter) { let url = `${this.url}/projects/${projectId}/files`; if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) { options = { branchId: options, directoryId: deprecatedDirectoryId, limit: deprecatedLimit, offset: deprecatedOffset, recursion: deprecatedRecursion, filter: deprecatedFilter, }; } url = this.addQueryParam(url, 'branchId', options.branchId); url = this.addQueryParam(url, 'directoryId', options.directoryId); url = this.addQueryParam(url, 'recursion', options.recursion); url = this.addQueryParam(url, 'filter', options.filter); url = this.addQueryParam(url, 'orderBy', options.orderBy); 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.files.post */ createFile(projectId, request) { const url = `${this.url}/projects/${projectId}/files`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.get */ getFile(projectId, fileId) { const url = `${this.url}/projects/${projectId}/files/${fileId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.put */ updateOrRestoreFile(projectId, fileId, request) { const url = `${this.url}/projects/${projectId}/files/${fileId}`; return this.put(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.delete */ deleteFile(projectId, fileId) { const url = `${this.url}/projects/${projectId}/files/${fileId}`; return this.delete(url, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.patch */ editFile(projectId, fileId, request) { const url = `${this.url}/projects/${projectId}/files/${fileId}`; return this.patch(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.preview.get */ downloadFilePreview(projectId, fileId) { const url = `${this.url}/projects/${projectId}/files/${fileId}/preview`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param fileId file identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.download.get */ downloadFile(projectId, fileId) { const url = `${this.url}/projects/${projectId}/files/${fileId}/download`; return this.get(url, this.defaultConfig()); } listFileRevisions(projectId, fileId, options, deprecatedOffset) { if ((0, core_1.isOptionalNumber)(options, '2' in arguments)) { options = { limit: options, offset: deprecatedOffset }; } const url = `${this.url}/projects/${projectId}/files/${fileId}/revisions`; return this.getList(url, options.limit, options.offset); } /** * @param projectId project identifier * @param fileId file identifier * @param revisionId revision identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.get */ getFileRevision(projectId, fileId, revisionId) { const url = `${this.url}/projects/${projectId}/files/${fileId}/revisions/${revisionId}`; return this.get(url, this.defaultConfig()); } listReviewedSourceFilesBuild(projectId, options, deprecatedLimit, deprecatedOffset) { if ((0, core_1.isOptionalNumber)(options, '1' in arguments)) { options = { branchId: options, limit: deprecatedLimit, offset: deprecatedOffset }; } let url = `${this.url}/projects/${projectId}/strings/reviewed-builds`; url = this.addQueryParam(url, 'branchId', options.branchId); return this.getList(url, options.limit, options.offset); } /** * @param projectId project identifier * @param request request body * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.strings.reviewed-builds.post */ buildReviewedSourceFiles(projectId, request = {}) { const url = `${this.url}/projects/${projectId}/strings/reviewed-builds`; return this.post(url, request, this.defaultConfig()); } /** * @param projectId project identifier * @param buildId build identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.strings.reviewed-builds.get */ checkReviewedSourceFilesBuildStatus(projectId, buildId) { const url = `${this.url}/projects/${projectId}/strings/reviewed-builds/${buildId}`; return this.get(url, this.defaultConfig()); } /** * @param projectId project identifier * @param buildId build identifier * @see https://support.crowdin.com/enterprise/api/#operation/api.projects.strings.reviewed-builds.download.download */ downloadReviewedSourceFiles(projectId, buildId) { const url = `${this.url}/projects/${projectId}/strings/reviewed-builds/${buildId}/download`; return this.get(url, this.defaultConfig()); } } exports.SourceFiles = SourceFiles; var SourceFilesModel; (function (SourceFilesModel) { let EscapeQuotes; (function (EscapeQuotes) { EscapeQuotes[EscapeQuotes["ZERO"] = 0] = "ZERO"; EscapeQuotes[EscapeQuotes["ONE"] = 1] = "ONE"; EscapeQuotes[EscapeQuotes["TWO"] = 2] = "TWO"; EscapeQuotes[EscapeQuotes["THREE"] = 3] = "THREE"; })(EscapeQuotes = SourceFilesModel.EscapeQuotes || (SourceFilesModel.EscapeQuotes = {})); let ExportQuotes; (function (ExportQuotes) { ExportQuotes["SINGLE"] = "single"; ExportQuotes["DOUBLE"] = "double"; })(ExportQuotes = SourceFilesModel.ExportQuotes || (SourceFilesModel.ExportQuotes = {})); })(SourceFilesModel = exports.SourceFilesModel || (exports.SourceFilesModel = {}));