Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crowdin/crowdin-api-client

Package Overview
Dependencies
Maintainers
5
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crowdin/crowdin-api-client - npm Package Compare versions

Comparing version 1.5.7 to 1.6.0

out/core/internal/retry/index.d.ts

6

CHANGELOG.md

@@ -8,2 +8,8 @@ # Change Log

## [1.6.0]
### Added
- Added retry mechanism
## [1.5.0]

@@ -10,0 +16,0 @@

3

out/core/index.d.ts

@@ -0,1 +1,2 @@

import { RetryConfig, RetryService } from './internal/retry';
export interface RequestConfig {

@@ -26,2 +27,3 @@ headers?: any;

integrationUserAgent?: string;
retryConfig?: RetryConfig;
}

@@ -97,2 +99,3 @@ export interface ResponseList<T> {

readonly config: ClientConfig | undefined;
readonly retryService: RetryService;
/**

@@ -99,0 +102,0 @@ * @param credentials credentials

25

out/core/index.js

@@ -5,2 +5,3 @@ "use strict";

const fetchClient_1 = require("./internal/fetch/fetchClient");
const retry_1 = require("./internal/retry");
var HttpClientType;

@@ -39,2 +40,14 @@ (function (HttpClientType) {

}
let retryConfig;
if (!!config && !!config.retryConfig) {
retryConfig = config.retryConfig;
}
else {
retryConfig = {
waitInterval: 0,
retries: 0,
conditions: [],
};
}
this.retryService = new retry_1.RetryService(retryConfig);
this.config = config;

@@ -85,18 +98,18 @@ }

get(url, config) {
return this.httpClient.get(url, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.get(url, config));
}
delete(url, config) {
return this.httpClient.delete(url, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.delete(url, config));
}
head(url, config) {
return this.httpClient.head(url, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.head(url, config));
}
post(url, data, config) {
return this.httpClient.post(url, data, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.post(url, data, config));
}
put(url, data, config) {
return this.httpClient.put(url, data, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.put(url, data, config));
}
patch(url, data, config) {
return this.httpClient.patch(url, data, config);
return this.retryService.executeAsyncFunc(() => this.httpClient.patch(url, data, config));
}

@@ -103,0 +116,0 @@ }

{
"name": "@crowdin/crowdin-api-client",
"version": "1.5.7",
"version": "1.6.0",
"description": "JavaScript library for Crowdin API v2.",

@@ -5,0 +5,0 @@ "main": "out/index.js",

@@ -163,2 +163,24 @@ [<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)

### Retry configuration
There is a possibility to configure client invoke http calls with retry mechanism.
```typescript
import { ProjectsGroups, HttpClientType } from '@crowdin/crowdin-api-client';
const projectsGroupsApi = new ProjectsGroups(credentials, {
retryConfig: {
retries: 2, // amount of retries (gte 1)
waitInterval: 100, // wait interval in ms between retries
conditions: [ // array of conditions which will check if retry should not be applied
{
test(error) {
return error.code === 40
}
}
]
}
});
```
## Contribution

@@ -165,0 +187,0 @@ We are happy to accept contributions to the Crowdin JavaScript client. To contribute please do the following:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc