@crowdin/crowdin-apps-functions
Advanced tools
Comparing version 0.2.1 to 0.3.0
import Crowdin, { SourceFilesModel, TranslationsModel } from '@crowdin/crowdin-api-client'; | ||
/** | ||
* | ||
* @param client crowdin client instance | ||
* @param projectId crowdin project id | ||
* @param name file name | ||
* @param title file title | ||
* @param type file type | ||
* @param directoryId directory id | ||
* @param data file data | ||
* @param file file object | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId crowdin project id | ||
* @param arguments.name file name | ||
* @param arguments.title file title | ||
* @param arguments.type file type | ||
* @param arguments.directoryId directory id | ||
* @param arguments.data file data | ||
* @param arguments.file file object | ||
* @returns id of newly created or existing file id | ||
*/ | ||
export declare function updateOrCreateFile(client: Crowdin, projectId: number, name: string, title: string, type: SourceFilesModel.FileType, directoryId: number, data: any, file?: SourceFilesModel.File): Promise<number>; | ||
export declare function updateOrCreateFile({ client, projectId, name, title, type, directoryId, data, file, }: { | ||
client: Crowdin; | ||
projectId: number; | ||
name: string; | ||
title?: string; | ||
type?: SourceFilesModel.FileType; | ||
directoryId?: number; | ||
data: any; | ||
file?: SourceFilesModel.File; | ||
}): Promise<number>; | ||
/** | ||
* | ||
* @param directories all directories | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directoryName directory name to find | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.directories all directories | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directoryName directory name to find | ||
* @param arguments.parentDirectory parent directory | ||
* @returns found folder (or undefined in case if directory for given name does not exists) and files under it | ||
*/ | ||
export declare function getFolder(directories: SourceFilesModel.Directory[], crowdinClient: Crowdin, projectId: number, directoryName: string, parentDirectory?: SourceFilesModel.Directory): Promise<{ | ||
export declare function getFolder({ directories, client, projectId, directoryName, parentDirectory, }: { | ||
directories: SourceFilesModel.Directory[]; | ||
client: Crowdin; | ||
projectId: number; | ||
directoryName: string; | ||
parentDirectory?: SourceFilesModel.Directory; | ||
}): Promise<{ | ||
folder?: SourceFilesModel.Directory; | ||
@@ -30,10 +47,17 @@ files: SourceFilesModel.File[]; | ||
* | ||
* @param directories all directories | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directoryName directory name to find | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.directories all directories | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directoryName directory name to find | ||
* @param arguments.parentDirectory parent directory | ||
* @returns found or created folder and files under it | ||
*/ | ||
export declare function getOrCreateFolder(directories: SourceFilesModel.Directory[], crowdinClient: Crowdin, projectId: number, directoryName: string, parentDirectory?: SourceFilesModel.Directory): Promise<{ | ||
export declare function getOrCreateFolder({ directories, client, projectId, directoryName, parentDirectory, }: { | ||
directories: SourceFilesModel.Directory[]; | ||
client: Crowdin; | ||
projectId: number; | ||
directoryName: string; | ||
parentDirectory?: SourceFilesModel.Directory; | ||
}): Promise<{ | ||
folder: SourceFilesModel.Directory; | ||
@@ -45,31 +69,55 @@ files: SourceFilesModel.File[]; | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param fileId file id | ||
* @param language language id | ||
* @param fileName file name for upload storage request | ||
* @param fileContent file content | ||
* @param request extra request fields for upload translation request | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.fileId file id | ||
* @param arguments.language language id | ||
* @param arguments.fileName file name for upload storage request | ||
* @param arguments.fileContent file content | ||
* @param arguments.request extra request fields for upload translation request | ||
* @returns upload translation response | ||
*/ | ||
export declare function uploadTranslations(crowdinClient: Crowdin, projectId: number, fileId: number, language: string, fileName: string, fileContent: any, request?: Omit<TranslationsModel.UploadTranslationRequest, 'fileId' | 'storageId'>): Promise<TranslationsModel.UploadTranslationResponse>; | ||
export declare function uploadTranslations({ client, projectId, fileId, language, fileName, fileContent, request, }: { | ||
client: Crowdin; | ||
projectId: number; | ||
fileId: number; | ||
language: string; | ||
fileName: string; | ||
fileContent: any; | ||
request: Omit<TranslationsModel.UploadTranslationRequest, 'fileId' | 'storageId'>; | ||
}): Promise<TranslationsModel.UploadTranslationResponse>; | ||
/** | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directory directory name where files are located | ||
* @param fileEntities files information | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directory directory name where files are located | ||
* @param arguments.fileEntities files information | ||
* @param arguments.parentDirectory parent directory | ||
*/ | ||
export declare function updateSourceFiles(crowdinClient: Crowdin, projectId: number, directory: string, fileEntities: FileEntity[], parentDirectory?: SourceFilesModel.Directory): Promise<void>; | ||
export declare function updateSourceFiles({ client, projectId, directory, fileEntities, parentDirectory, }: { | ||
client: Crowdin; | ||
projectId: number; | ||
directory: string; | ||
fileEntities: FileEntity[]; | ||
parentDirectory?: SourceFilesModel.Directory; | ||
}): Promise<void>; | ||
/** | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId projecy id | ||
* @param directory directory name where source files are located | ||
* @param request request if file files and languages info | ||
* @param handleFn function that will be invoked for each translation file | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId projecy id | ||
* @param arguments.directory directory name where source files are located | ||
* @param arguments.request request if file files and languages info | ||
* @param arguments.handleFn function that will be invoked for each translation file | ||
* @param arguments.parentDirectory parent directory | ||
*/ | ||
export declare function handleTranslations(crowdinClient: Crowdin, projectId: number, directory: string, request: TranslationsRequest, handleFn: (translations: any, language: string, file: SourceFilesModel.File) => Promise<void>, parentDirectory?: SourceFilesModel.Directory): Promise<void>; | ||
export declare function handleTranslations({ client, projectId, directory, request, parentDirectory, handleFn, }: { | ||
client: Crowdin; | ||
projectId: number; | ||
directory: string; | ||
request: TranslationsRequest; | ||
parentDirectory?: SourceFilesModel.Directory; | ||
handleFn: (translations: any, language: string, file: SourceFilesModel.File) => Promise<void>; | ||
}): Promise<void>; | ||
export declare class PaymentRequiredError extends Error { | ||
@@ -76,0 +124,0 @@ subscribeLink: string; |
@@ -16,13 +16,14 @@ "use strict"; | ||
* | ||
* @param client crowdin client instance | ||
* @param projectId crowdin project id | ||
* @param name file name | ||
* @param title file title | ||
* @param type file type | ||
* @param directoryId directory id | ||
* @param data file data | ||
* @param file file object | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId crowdin project id | ||
* @param arguments.name file name | ||
* @param arguments.title file title | ||
* @param arguments.type file type | ||
* @param arguments.directoryId directory id | ||
* @param arguments.data file data | ||
* @param arguments.file file object | ||
* @returns id of newly created or existing file id | ||
*/ | ||
function updateOrCreateFile(client, projectId, name, title, type, directoryId, data, file) { | ||
function updateOrCreateFile({ client, projectId, name, title, type, directoryId, data, file, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -49,10 +50,11 @@ const storageFile = yield client.uploadStorageApi.addStorage(name, data); | ||
* | ||
* @param directories all directories | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directoryName directory name to find | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.directories all directories | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directoryName directory name to find | ||
* @param arguments.parentDirectory parent directory | ||
* @returns found folder (or undefined in case if directory for given name does not exists) and files under it | ||
*/ | ||
function getFolder(directories, crowdinClient, projectId, directoryName, parentDirectory) { | ||
function getFolder({ directories, client, projectId, directoryName, parentDirectory, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -62,3 +64,3 @@ const folder = directories.find(d => d.name === directoryName && ((!parentDirectory && !d.directoryId) || d.directoryId === (parentDirectory === null || parentDirectory === void 0 ? void 0 : parentDirectory.id))); | ||
if (folder) { | ||
files = (yield crowdinClient.sourceFilesApi.withFetchAll().listProjectFiles(projectId, { directoryId: folder.id })).data.map(e => e.data); | ||
files = (yield client.sourceFilesApi.withFetchAll().listProjectFiles(projectId, { directoryId: folder.id })).data.map(e => e.data); | ||
} | ||
@@ -71,20 +73,21 @@ return { folder, files }; | ||
* | ||
* @param directories all directories | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directoryName directory name to find | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.directories all directories | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directoryName directory name to find | ||
* @param arguments.parentDirectory parent directory | ||
* @returns found or created folder and files under it | ||
*/ | ||
function getOrCreateFolder(directories, crowdinClient, projectId, directoryName, parentDirectory) { | ||
function getOrCreateFolder({ directories, client, projectId, directoryName, parentDirectory, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let { folder, files } = yield getFolder(directories, crowdinClient, projectId, directoryName, parentDirectory); | ||
let { folder, files } = yield getFolder({ directories, client, projectId, directoryName, parentDirectory }); | ||
let created = false; | ||
if (!folder) { | ||
created = true; | ||
folder = (yield crowdinClient.sourceFilesApi.createDirectory(projectId, { | ||
folder = (yield client.sourceFilesApi.createDirectory(projectId, { | ||
name: directoryName, | ||
directoryId: parentDirectory ? parentDirectory.id : undefined, | ||
})).data; | ||
files = (yield crowdinClient.sourceFilesApi.withFetchAll().listProjectFiles(projectId, { directoryId: folder.id })).data.map(e => e.data); | ||
files = (yield client.sourceFilesApi.withFetchAll().listProjectFiles(projectId, { directoryId: folder.id })).data.map(e => e.data); | ||
} | ||
@@ -97,15 +100,16 @@ return { folder, files, created }; | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param fileId file id | ||
* @param language language id | ||
* @param fileName file name for upload storage request | ||
* @param fileContent file content | ||
* @param request extra request fields for upload translation request | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.fileId file id | ||
* @param arguments.language language id | ||
* @param arguments.fileName file name for upload storage request | ||
* @param arguments.fileContent file content | ||
* @param arguments.request extra request fields for upload translation request | ||
* @returns upload translation response | ||
*/ | ||
function uploadTranslations(crowdinClient, projectId, fileId, language, fileName, fileContent, request = {}) { | ||
function uploadTranslations({ client, projectId, fileId, language, fileName, fileContent, request = {}, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const storage = yield crowdinClient.uploadStorageApi.addStorage(fileName, fileContent); | ||
return (yield crowdinClient.translationsApi.uploadTranslation(projectId, language, Object.assign({ fileId, storageId: storage.data.id }, request))).data; | ||
const storage = yield client.uploadStorageApi.addStorage(fileName, fileContent); | ||
return (yield client.translationsApi.uploadTranslation(projectId, language, Object.assign({ fileId, storageId: storage.data.id }, request))).data; | ||
}); | ||
@@ -116,14 +120,30 @@ } | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId project id | ||
* @param directory directory name where files are located | ||
* @param fileEntities files information | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId project id | ||
* @param arguments.directory directory name where files are located | ||
* @param arguments.fileEntities files information | ||
* @param arguments.parentDirectory parent directory | ||
*/ | ||
function updateSourceFiles(crowdinClient, projectId, directory, fileEntities, parentDirectory) { | ||
function updateSourceFiles({ client, projectId, directory, fileEntities, parentDirectory, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const directories = yield crowdinClient.sourceFilesApi.withFetchAll().listProjectDirectories(projectId); | ||
const { folder, files } = yield getOrCreateFolder(directories.data.map(d => d.data), crowdinClient, projectId, directory, parentDirectory); | ||
const directories = yield client.sourceFilesApi.withFetchAll().listProjectDirectories(projectId); | ||
const { folder, files } = yield getOrCreateFolder({ | ||
directories: directories.data.map(d => d.data), | ||
client, | ||
projectId, | ||
directoryName: directory, | ||
parentDirectory, | ||
}); | ||
yield Promise.all(fileEntities.map((fileEntity) => __awaiter(this, void 0, void 0, function* () { | ||
return yield updateOrCreateFile(crowdinClient, projectId, fileEntity.name, fileEntity.title, fileEntity.type, folder.id, fileEntity.data, files.find(f => f.name === fileEntity.name)); | ||
return yield updateOrCreateFile({ | ||
client, | ||
projectId, | ||
name: fileEntity.name, | ||
title: fileEntity.title, | ||
type: fileEntity.type, | ||
directoryId: folder.id, | ||
data: fileEntity.data, | ||
file: files.find(f => f.name === fileEntity.name), | ||
}); | ||
}))); | ||
@@ -135,13 +155,20 @@ }); | ||
* | ||
* @param crowdinClient crowdin client instance | ||
* @param projectId projecy id | ||
* @param directory directory name where source files are located | ||
* @param request request if file files and languages info | ||
* @param handleFn function that will be invoked for each translation file | ||
* @param parentDirectory parent directory | ||
* @param arguments arguments | ||
* @param arguments.client crowdin client instance | ||
* @param arguments.projectId projecy id | ||
* @param arguments.directory directory name where source files are located | ||
* @param arguments.request request if file files and languages info | ||
* @param arguments.handleFn function that will be invoked for each translation file | ||
* @param arguments.parentDirectory parent directory | ||
*/ | ||
function handleTranslations(crowdinClient, projectId, directory, request, handleFn, parentDirectory) { | ||
function handleTranslations({ client, projectId, directory, request, parentDirectory, handleFn, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const directories = yield crowdinClient.sourceFilesApi.withFetchAll().listProjectDirectories(projectId); | ||
const { files } = yield getFolder(directories.data.map(d => d.data), crowdinClient, projectId, directory, parentDirectory); | ||
const directories = yield client.sourceFilesApi.withFetchAll().listProjectDirectories(projectId); | ||
const { files } = yield getFolder({ | ||
directories: directories.data.map(d => d.data), | ||
client, | ||
projectId, | ||
directoryName: directory, | ||
parentDirectory, | ||
}); | ||
for (const [fileId, targetLanguages] of Object.entries(request)) { | ||
@@ -153,3 +180,5 @@ const file = files.find(f => f.id === parseInt(fileId)); | ||
yield Promise.all(targetLanguages.map((languageCode) => __awaiter(this, void 0, void 0, function* () { | ||
const translationsLink = yield crowdinClient.translationsApi.buildProjectFileTranslation(projectId, file.id, { targetLanguageId: languageCode }); | ||
const translationsLink = yield client.translationsApi.buildProjectFileTranslation(projectId, file.id, { | ||
targetLanguageId: languageCode, | ||
}); | ||
if (!translationsLink) { | ||
@@ -170,2 +199,4 @@ return; | ||
this.initializedAt = initializedAt; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
this.code = 402; | ||
@@ -203,7 +234,17 @@ } | ||
catch (e) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
if (e.response) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
if (e.response.status === 402) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
throw new PaymentRequiredError((_a = e.response.data) === null || _a === void 0 ? void 0 : _a.subscribeLink, (_b = e.response.data) === null || _b === void 0 ? void 0 : _b.initializedAt); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
} | ||
else if ((_d = (_c = e.response.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.message) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
//@ts-ignore | ||
throw new Error(e.response.data.error.message); | ||
@@ -210,0 +251,0 @@ } |
import { AppToken, JwtPayload, Token } from './models'; | ||
/** | ||
* | ||
* @param appId Crowdin app identifier | ||
* @param appSecret Crowdin app secret received from install event | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param domain Crowdin organization domain | ||
* @param userId The user who installed the application | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.appId Crowdin app identifier | ||
* @param arguments.appSecret Crowdin app secret received from install event | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.domain Crowdin organization domain | ||
* @param arguments.userId The user who installed the application | ||
* @param arguments.url Custom url for token exchange | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
export declare function fetchAppToken(appId: string, appSecret: string, clientId: string, clientSecret: string, domain: string, userId: number, url?: string): Promise<AppToken>; | ||
export declare function fetchAppToken({ appId, appSecret, clientId, clientSecret, domain, userId, url, }: { | ||
appId: string; | ||
appSecret: string; | ||
clientId: string; | ||
clientSecret: string; | ||
domain: string; | ||
userId: number; | ||
url?: string; | ||
}): Promise<AppToken>; | ||
/** | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param code code used for authorization of your Crowdin app (returned in install event payload) | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.code code used for authorization of your Crowdin app (returned in install event payload) | ||
* @param arguments.url Custom url for token exchange | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
export declare function generateOAuthToken(clientId: string, clientSecret: string, code: string, url?: string): Promise<Token>; | ||
export declare function generateOAuthToken({ clientId, clientSecret, code, url, }: { | ||
clientId: string; | ||
clientSecret: string; | ||
code: string; | ||
url?: string; | ||
}): Promise<Token>; | ||
/** | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param refreshToken {@link Token#refreshToken} | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.refreshToken {@link Token#refreshToken} | ||
* @param arguments.url Custom url for token exchange | ||
* @returns updated token object | ||
*/ | ||
export declare function refreshOAuthToken(clientId: string, clientSecret: string, refreshToken: string, url?: string): Promise<Token>; | ||
export declare function refreshOAuthToken({ clientId, clientSecret, refreshToken, url, }: { | ||
clientId: string; | ||
clientSecret: string; | ||
refreshToken: string; | ||
url?: string; | ||
}): Promise<Token>; | ||
/** | ||
@@ -33,0 +54,0 @@ * |
@@ -18,12 +18,13 @@ "use strict"; | ||
* | ||
* @param appId Crowdin app identifier | ||
* @param appSecret Crowdin app secret received from install event | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param domain Crowdin organization domain | ||
* @param userId The user who installed the application | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.appId Crowdin app identifier | ||
* @param arguments.appSecret Crowdin app secret received from install event | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.domain Crowdin organization domain | ||
* @param arguments.userId The user who installed the application | ||
* @param arguments.url Custom url for token exchange | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
function fetchAppToken(appId, appSecret, clientId, clientSecret, domain, userId, url) { | ||
function fetchAppToken({ appId, appSecret, clientId, clientSecret, domain, userId, url, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -48,9 +49,10 @@ const token = yield axios_1.default.post(url || crowdinAuthUrl, { | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param code code used for authorization of your Crowdin app (returned in install event payload) | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.code code used for authorization of your Crowdin app (returned in install event payload) | ||
* @param arguments.url Custom url for token exchange | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
function generateOAuthToken(clientId, clientSecret, code, url) { | ||
function generateOAuthToken({ clientId, clientSecret, code, url, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -73,9 +75,10 @@ const token = yield axios_1.default.post(url || crowdinAuthUrl, { | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param refreshToken {@link Token#refreshToken} | ||
* @param url Custom url for token exchange | ||
* @param arguments arguments | ||
* @param arguments.clientId OAuth client id of the app | ||
* @param arguments.clientSecret OAuth client secret of the app | ||
* @param arguments.refreshToken {@link Token#refreshToken} | ||
* @param arguments.url Custom url for token exchange | ||
* @returns updated token object | ||
*/ | ||
function refreshOAuthToken(clientId, clientSecret, refreshToken, url) { | ||
function refreshOAuthToken({ clientId, clientSecret, refreshToken, url, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -82,0 +85,0 @@ const token = yield axios_1.default.post(url || crowdinAuthUrl, { |
{ | ||
"name": "@crowdin/crowdin-apps-functions", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Utility library to easily and quickly develop Crowdin App", | ||
@@ -49,4 +49,4 @@ "main": "out/index.js", | ||
"dependencies": { | ||
"@crowdin/crowdin-api-client": "1.19.2", | ||
"jsonwebtoken": "^8.5.1" | ||
"@crowdin/crowdin-api-client": "1.21.1", | ||
"jsonwebtoken": "^9.0.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "bugs": { |
@@ -44,3 +44,3 @@ [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='200' height='200' align='center'/></p>](https://crowdin.com) | ||
generateOAuthToken('app_client_id', 'app_client_secret', 'code_from_install_event'); | ||
generateOAuthToken({ clientId: 'app_client_id', clientSecret: 'app_client_secret', code: 'code_from_install_event'}); | ||
``` | ||
@@ -56,3 +56,3 @@ | ||
generateOAuthToken('app_client_id', 'app_client_secret', 'code_from_install_event'); | ||
generateOAuthToken({ clientId: 'app_client_id', clientSecret: 'app_client_secret', code: 'code_from_install_event'}); | ||
``` | ||
@@ -68,3 +68,3 @@ | ||
crowdinFunctions.generateOAuthToken('app_client_id', 'app_client_secret', 'code_from_install_event'); | ||
crowdinFunctions.generateOAuthToken({ clientId: 'app_client_id', clientSecret: 'app_client_secret', code: 'code_from_install_event'}); | ||
``` | ||
@@ -71,0 +71,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47483
671
+ Added@crowdin/crowdin-api-client@1.21.1(transitive)
+ Addedjsonwebtoken@9.0.2(transitive)
+ Addedsemver@7.6.3(transitive)
- Removed@crowdin/crowdin-api-client@1.19.2(transitive)
- Removedjsonwebtoken@8.5.1(transitive)
- Removedsemver@5.7.2(transitive)
Updatedjsonwebtoken@^9.0.0