smartling-api-sdk-nodejs 2.19.1 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +2 -1
- package/.nvmrc +1 -0
- package/.scannerwork/report-task.txt +2 -2
- package/CLAUDE.md +67 -0
- package/api/auth/access-token-provider.ts +5 -0
- package/api/auth/index.ts +2 -1
- package/api/auth/static-access-token-provider.ts +27 -0
- package/api/base/index.ts +2 -2
- package/api/builder/index.ts +9 -6
- package/api/context/index.ts +2 -2
- package/api/file-translations/index.ts +2 -2
- package/api/files/index.ts +2 -2
- package/api/glossaries/dto/fallback-locale-dto.ts +4 -0
- package/api/glossaries/dto/glossary-dto.ts +17 -0
- package/api/glossaries/dto/pagination-dto.ts +4 -0
- package/api/glossaries/dto/sorting-dto.ts +4 -0
- package/api/glossaries/index.ts +32 -0
- package/api/glossaries/params/search-glossaries-parameters.ts +47 -0
- package/api/job-batches/index.ts +2 -2
- package/api/jobs/index.ts +2 -2
- package/api/locales/index.ts +2 -2
- package/api/mt/index.ts +2 -2
- package/api/projects/dto/project-dto.ts +3 -9
- package/api/projects/dto/project-without-target-locales-dto.ts +13 -0
- package/api/projects/index.ts +18 -2
- package/api/projects/params/list-projects-parameters.ts +37 -0
- package/api/published-files/index.ts +2 -2
- package/api/strings/index.ts +2 -2
- package/built/api/auth/access-token-provider.d.ts +5 -0
- package/built/api/auth/access-token-provider.js +3 -0
- package/built/api/auth/access-token-provider.js.map +1 -0
- package/built/api/auth/index.d.ts +2 -1
- package/built/api/auth/index.js.map +1 -1
- package/built/api/auth/static-access-token-provider.d.ts +9 -0
- package/built/api/auth/static-access-token-provider.js +34 -0
- package/built/api/auth/static-access-token-provider.js.map +1 -0
- package/built/api/base/index.d.ts +2 -2
- package/built/api/base/index.js.map +1 -1
- package/built/api/builder/index.d.ts +4 -4
- package/built/api/builder/index.js +5 -3
- package/built/api/builder/index.js.map +1 -1
- package/built/api/context/index.d.ts +2 -2
- package/built/api/context/index.js.map +1 -1
- package/built/api/file-translations/index.d.ts +2 -2
- package/built/api/file-translations/index.js.map +1 -1
- package/built/api/files/index.d.ts +2 -2
- package/built/api/files/index.js.map +1 -1
- package/built/api/glossaries/dto/fallback-locale-dto.d.ts +4 -0
- package/built/api/glossaries/dto/fallback-locale-dto.js +3 -0
- package/built/api/glossaries/dto/fallback-locale-dto.js.map +1 -0
- package/built/api/glossaries/dto/glossary-dto.d.ts +16 -0
- package/built/api/glossaries/dto/glossary-dto.js +3 -0
- package/built/api/glossaries/dto/glossary-dto.js.map +1 -0
- package/built/api/glossaries/dto/pagination-dto.d.ts +4 -0
- package/built/api/glossaries/dto/pagination-dto.js +3 -0
- package/built/api/glossaries/dto/pagination-dto.js.map +1 -0
- package/built/api/glossaries/dto/sorting-dto.d.ts +4 -0
- package/built/api/glossaries/dto/sorting-dto.js +3 -0
- package/built/api/glossaries/dto/sorting-dto.js.map +1 -0
- package/built/api/glossaries/index.d.ts +11 -0
- package/built/api/glossaries/index.js +32 -0
- package/built/api/glossaries/index.js.map +1 -0
- package/built/api/glossaries/params/search-glossaries-parameters.d.ts +12 -0
- package/built/api/glossaries/params/search-glossaries-parameters.js +36 -0
- package/built/api/glossaries/params/search-glossaries-parameters.js.map +1 -0
- package/built/api/job-batches/index.d.ts +2 -2
- package/built/api/job-batches/index.js.map +1 -1
- package/built/api/jobs/index.d.ts +2 -2
- package/built/api/jobs/index.js.map +1 -1
- package/built/api/locales/index.d.ts +2 -2
- package/built/api/locales/index.js.map +1 -1
- package/built/api/mt/index.d.ts +2 -2
- package/built/api/mt/index.js.map +1 -1
- package/built/api/projects/dto/project-dto.d.ts +2 -8
- package/built/api/projects/dto/project-without-target-locales-dto.d.ts +12 -0
- package/built/api/projects/dto/project-without-target-locales-dto.js +3 -0
- package/built/api/projects/dto/project-without-target-locales-dto.js.map +1 -0
- package/built/api/projects/index.d.ts +6 -2
- package/built/api/projects/index.js +6 -0
- package/built/api/projects/index.js.map +1 -1
- package/built/api/projects/params/list-projects-parameters.d.ts +9 -0
- package/built/api/projects/params/list-projects-parameters.js +36 -0
- package/built/api/projects/params/list-projects-parameters.js.map +1 -0
- package/built/api/published-files/index.d.ts +2 -2
- package/built/api/published-files/index.js.map +1 -1
- package/built/api/strings/index.d.ts +2 -2
- package/built/api/strings/index.js.map +1 -1
- package/built/index.d.ts +10 -0
- package/built/index.js +10 -0
- package/built/index.js.map +1 -1
- package/built/package.json +1 -1
- package/index.ts +10 -0
- package/package.json +1 -1
- package/test/access-token-provider.spec.ts +13 -0
- package/test/base.spec.ts +48 -0
- package/test/builder.spec.ts +12 -12
- package/test/glossaries.spec.ts +89 -0
- package/test/projects.spec.ts +45 -0
package/.eslintrc
CHANGED
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"react/jsx-indent-props": ["error", 4],
|
|
70
70
|
"react/no-unescaped-entities": "off",
|
|
71
71
|
"react/prefer-stateless-function": "off",
|
|
72
|
-
"react/require-default-props": "off"
|
|
72
|
+
"react/require-default-props": "off",
|
|
73
|
+
"flowtype/no-types-missing-file-annotation": "off"
|
|
73
74
|
},
|
|
74
75
|
env: {
|
|
75
76
|
browser: true,
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v18.20.8
|
|
@@ -2,5 +2,5 @@ projectKey=smartling-api-sdk-nodejs
|
|
|
2
2
|
serverUrl=https://sonar-next.connectors.stg.smartling.net
|
|
3
3
|
serverVersion=8.6.1.40680
|
|
4
4
|
dashboardUrl=https://sonar-next.connectors.stg.smartling.net/dashboard?id=smartling-api-sdk-nodejs
|
|
5
|
-
ceTaskId=
|
|
6
|
-
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=
|
|
5
|
+
ceTaskId=AZgehViuvqXrVO8s0Rrs
|
|
6
|
+
ceTaskUrl=https://sonar-next.connectors.stg.smartling.net/api/ce/task?id=AZgehViuvqXrVO8s0Rrs
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This is the Smartling Translation API SDK for Node.js, providing TypeScript interfaces for interacting with Smartling's translation services. The SDK covers all major API endpoints including files, jobs, locales, projects, and translation management.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
### Build Commands
|
|
12
|
+
- `npm run build` - Production build (TypeScript compilation to `built/` directory)
|
|
13
|
+
- `npm run build:dev` - Development build (includes test files)
|
|
14
|
+
|
|
15
|
+
### Testing
|
|
16
|
+
- `npm test` - Run full test suite with lint, build, and coverage
|
|
17
|
+
- `npm run test:dev` - Run tests without JUnit reporting (for development)
|
|
18
|
+
|
|
19
|
+
### Linting
|
|
20
|
+
- `npm run pretest` - Run ESLint on all TypeScript files
|
|
21
|
+
- ESLint configuration in `.eslintrc` with TypeScript, Airbnb, and custom rules
|
|
22
|
+
|
|
23
|
+
### Single Test Execution
|
|
24
|
+
Run individual test files using Mocha directly:
|
|
25
|
+
```bash
|
|
26
|
+
npm run build:dev && npx mocha built/test/[specific-test].spec.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
### Core Structure
|
|
32
|
+
- **API Layer**: Organized by feature domains (`/api/`)
|
|
33
|
+
- `auth/` - Authentication and token management
|
|
34
|
+
- `files/` - File upload/download operations
|
|
35
|
+
- `jobs/` - Translation job management
|
|
36
|
+
- `locales/` - Language and locale handling
|
|
37
|
+
- `projects/` - Project management
|
|
38
|
+
- `strings/` - String resource management
|
|
39
|
+
- `context/` - Context matching for translations
|
|
40
|
+
- `job-batches/` - Batch job processing
|
|
41
|
+
- `published-files/` - Published file management
|
|
42
|
+
- `file-translations/` - File translation services
|
|
43
|
+
- `mt/` - Machine translation services
|
|
44
|
+
|
|
45
|
+
### Pattern Structure
|
|
46
|
+
Each API domain follows a consistent pattern:
|
|
47
|
+
- `index.ts` - Main API client class
|
|
48
|
+
- `dto/` - Data transfer objects (response/request types)
|
|
49
|
+
- `params/` - Parameter classes for API calls
|
|
50
|
+
|
|
51
|
+
### Key Components
|
|
52
|
+
- **SmartlingApiClientBuilder**: Main entry point for creating API clients
|
|
53
|
+
- **AccessTokenProvider**: Interface for authentication (with StaticAccessTokenProvider implementation)
|
|
54
|
+
- **SmartlingListResponse**: Generic wrapper for paginated API responses
|
|
55
|
+
- **Logger**: Centralized logging utility
|
|
56
|
+
|
|
57
|
+
### TypeScript Configuration
|
|
58
|
+
- Uses `tsconfig.json` for production builds
|
|
59
|
+
- Uses `tsconfig.dev.json` for development (includes test files)
|
|
60
|
+
- Targets ES6 with CommonJS modules
|
|
61
|
+
- Generates declaration files and source maps
|
|
62
|
+
|
|
63
|
+
### Testing Framework
|
|
64
|
+
- Mocha test runner with TypeScript support
|
|
65
|
+
- Sinon for mocking and stubbing
|
|
66
|
+
- NYC for code coverage reporting
|
|
67
|
+
- Tests located in `/test/` directory matching API structure
|
package/api/auth/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
2
|
import { SmartlingException } from "../exception/index";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
|
+
import { AccessTokenProvider } from "./access-token-provider";
|
|
4
5
|
import { AccessTokenDto } from "./dto/access-token-dto";
|
|
5
6
|
|
|
6
|
-
export class SmartlingAuthApi extends SmartlingBaseApi {
|
|
7
|
+
export class SmartlingAuthApi extends SmartlingBaseApi implements AccessTokenProvider {
|
|
7
8
|
private ttlCorrectionSec: number;
|
|
8
9
|
private userIdentifier: string;
|
|
9
10
|
private tokenSecret: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AccessTokenProvider } from "./access-token-provider";
|
|
2
|
+
|
|
3
|
+
export class StaticAccessTokenProvider implements AccessTokenProvider {
|
|
4
|
+
private accessToken: string;
|
|
5
|
+
private tokenType: string;
|
|
6
|
+
|
|
7
|
+
constructor(
|
|
8
|
+
accessToken: string,
|
|
9
|
+
tokenType: string
|
|
10
|
+
) {
|
|
11
|
+
this.accessToken = accessToken;
|
|
12
|
+
this.tokenType = tokenType;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getAccessToken(): Promise<string> {
|
|
16
|
+
return this.accessToken;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getTokenType(): Promise<string> {
|
|
20
|
+
return this.tokenType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resetToken(): void {
|
|
24
|
+
this.accessToken = null;
|
|
25
|
+
this.tokenType = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/api/base/index.ts
CHANGED
|
@@ -5,14 +5,14 @@ import fetch from "cross-fetch";
|
|
|
5
5
|
import { ParsedUrlQueryInput, stringify } from "querystring";
|
|
6
6
|
import { Logger } from "../logger";
|
|
7
7
|
import { SmartlingException } from "../exception/index";
|
|
8
|
-
import {
|
|
8
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
9
9
|
import { ResponseBodyType } from "./enum/response-body-type";
|
|
10
10
|
|
|
11
11
|
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
12
12
|
const packageJson = require("../../package.json");
|
|
13
13
|
|
|
14
14
|
export class SmartlingBaseApi {
|
|
15
|
-
protected authApi:
|
|
15
|
+
protected authApi: AccessTokenProvider = undefined;
|
|
16
16
|
protected entrypoint: string;
|
|
17
17
|
protected defaultClientLibId: string;
|
|
18
18
|
protected defaultClientVersion: string;
|
package/api/builder/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
1
2
|
import { SmartlingAuthApi } from "../auth/index";
|
|
2
3
|
import { SmartlingBaseApi } from "../base/index";
|
|
3
4
|
import { Logger } from "../logger";
|
|
@@ -6,7 +7,7 @@ import { Logger } from "../logger";
|
|
|
6
7
|
const packageJson = require("../../package.json");
|
|
7
8
|
|
|
8
9
|
export class SmartlingApiClientBuilder {
|
|
9
|
-
protected authApiClient:
|
|
10
|
+
protected authApiClient: AccessTokenProvider = null;
|
|
10
11
|
protected userId: string = null;
|
|
11
12
|
protected userSecret: string = null;
|
|
12
13
|
protected baseSmartlingApiUrl: string;
|
|
@@ -60,14 +61,14 @@ export class SmartlingApiClientBuilder {
|
|
|
60
61
|
return this;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
public authWithAuthApiClient(authApiClient:
|
|
64
|
+
public authWithAuthApiClient(authApiClient: AccessTokenProvider): SmartlingApiClientBuilder {
|
|
64
65
|
this.authApiClient = authApiClient;
|
|
65
66
|
|
|
66
67
|
return this;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
public build<T extends SmartlingBaseApi>(
|
|
70
|
-
constructor: new (baseUrl: string, authApi:
|
|
71
|
+
constructor: new (baseUrl: string, authApi: AccessTokenProvider, logger) => T
|
|
71
72
|
): T {
|
|
72
73
|
if (this.authApiClient === null && this.userId !== null && this.userSecret !== null) {
|
|
73
74
|
this.authApiClient = new SmartlingAuthApi(
|
|
@@ -77,9 +78,11 @@ export class SmartlingApiClientBuilder {
|
|
|
77
78
|
this.logger
|
|
78
79
|
);
|
|
79
80
|
|
|
80
|
-
this.authApiClient
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
if (this.authApiClient instanceof SmartlingAuthApi) {
|
|
82
|
+
this.authApiClient.setClientLibVersion(this.clientLibVersion);
|
|
83
|
+
this.authApiClient.setClientLibId(this.clientLibId);
|
|
84
|
+
this.authApiClient.setOptions(this.httpClientOptions);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
const instance = new constructor(this.baseSmartlingApiUrl, this.authApiClient, this.logger);
|
package/api/context/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import string2fileStream from "string-to-file-stream";
|
|
2
2
|
import FormData from "form-data";
|
|
3
3
|
import { SmartlingBaseApi } from "../base/index";
|
|
4
|
-
import {
|
|
4
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
5
5
|
import { ContextUploadParameters } from "./params/context-upload-parameters";
|
|
6
6
|
import { ContextDto } from "./dto/context-dto";
|
|
7
7
|
import { ContextAutomaticMatchParameters } from "./params/context-automatic-match-parameters";
|
|
@@ -13,7 +13,7 @@ import { ListParameters } from "./params/list-parameters";
|
|
|
13
13
|
import { Logger } from "../logger";
|
|
14
14
|
|
|
15
15
|
export class SmartlingContextApi extends SmartlingBaseApi {
|
|
16
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
16
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
17
17
|
super(logger);
|
|
18
18
|
|
|
19
19
|
this.authApi = authApi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FormData from "form-data";
|
|
2
2
|
import { SmartlingBaseApi } from "../base";
|
|
3
|
-
import {
|
|
3
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
4
4
|
import { Logger } from "../logger";
|
|
5
5
|
import { FtsUploadedFileDto } from "./dto/fts-uploaded-file-dto";
|
|
6
6
|
import { FtsUploadFileParameters } from "./params/fts-upload-file-parameters";
|
|
@@ -14,7 +14,7 @@ import { ResponseBodyType } from "../base/enum/response-body-type";
|
|
|
14
14
|
import { LanguageDetectionParameters } from "./params/language-detection-parameters";
|
|
15
15
|
|
|
16
16
|
export class SmartlingFileTranslationsApi extends SmartlingBaseApi {
|
|
17
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
17
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
18
18
|
super(logger);
|
|
19
19
|
this.authApi = authApi;
|
|
20
20
|
this.entrypoint = `${smartlingApiBaseUrl}/file-translations-api/v2/accounts`;
|
package/api/files/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FormData from "form-data";
|
|
2
2
|
import { SmartlingBaseApi } from "../base/index";
|
|
3
|
-
import {
|
|
3
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
4
4
|
import { Logger } from "../logger";
|
|
5
5
|
import { DownloadFileParameters } from "./params/download-file-parameters";
|
|
6
6
|
import { UploadFileParameters } from "./params/upload-file-parameters";
|
|
@@ -14,7 +14,7 @@ import { RecentlyUploadedFilesParameters } from "./params/recently-uploaded-file
|
|
|
14
14
|
import { ResponseBodyType } from "../base/enum/response-body-type";
|
|
15
15
|
|
|
16
16
|
export class SmartlingFilesApi extends SmartlingBaseApi {
|
|
17
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
17
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
18
18
|
super(logger);
|
|
19
19
|
this.authApi = authApi;
|
|
20
20
|
this.entrypoint = `${smartlingApiBaseUrl}/files-api/v2/projects`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FallbackLocaleDto } from "./fallback-locale-dto";
|
|
2
|
+
|
|
3
|
+
export interface GlossaryDto {
|
|
4
|
+
glossaryUid: string;
|
|
5
|
+
accountUid: string;
|
|
6
|
+
glossaryName: string;
|
|
7
|
+
description: string;
|
|
8
|
+
verificationMode: boolean;
|
|
9
|
+
archived: boolean;
|
|
10
|
+
createdByUserUid: string;
|
|
11
|
+
modifiedByUserUid: string;
|
|
12
|
+
createdDate: Date;
|
|
13
|
+
modifiedDate: Date;
|
|
14
|
+
localeIds: Array<string>;
|
|
15
|
+
fallbackLocales: Array<FallbackLocaleDto>;
|
|
16
|
+
entriesCount: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
|
+
import { Logger } from "../logger";
|
|
4
|
+
import { GlossaryDto } from "./dto/glossary-dto";
|
|
5
|
+
import { SearchGlossariesParameters } from "./params/search-glossaries-parameters";
|
|
6
|
+
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
7
|
+
|
|
8
|
+
export class SmartlingGlossariesApi extends SmartlingBaseApi {
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
10
|
+
super(logger);
|
|
11
|
+
this.authApi = authApi;
|
|
12
|
+
this.entrypoint = `${smartlingApiBaseUrl}/glossary-api/v3`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async searchGlossaries(
|
|
16
|
+
accountUid: string,
|
|
17
|
+
parameters: SearchGlossariesParameters
|
|
18
|
+
): Promise<SmartlingListResponse<GlossaryDto>> {
|
|
19
|
+
return await this.makeRequest(
|
|
20
|
+
"post",
|
|
21
|
+
`${this.entrypoint}/accounts/${accountUid}/glossaries/search`,
|
|
22
|
+
JSON.stringify(parameters.export())
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getGlossary(accountUid: string, glossaryUid: string): Promise<GlossaryDto> {
|
|
27
|
+
return await this.makeRequest(
|
|
28
|
+
"get",
|
|
29
|
+
`${this.entrypoint}/accounts/${accountUid}/glossaries/${glossaryUid}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
import { PaginationDto } from "../dto/pagination-dto";
|
|
3
|
+
import { SortingDto } from "../dto/sorting-dto";
|
|
4
|
+
|
|
5
|
+
export class SearchGlossariesParameters extends BaseParameters {
|
|
6
|
+
setQuery(query: string): SearchGlossariesParameters {
|
|
7
|
+
this.set("query", query);
|
|
8
|
+
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setGlossaryState(glossaryState: "ACTIVE" | "ARCHIVED" | "BOTH"): SearchGlossariesParameters {
|
|
13
|
+
this.set("glossaryState", glossaryState);
|
|
14
|
+
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setTargetLocaleId(targetLocaleId: string): SearchGlossariesParameters {
|
|
19
|
+
this.set("targetLocaleId", targetLocaleId);
|
|
20
|
+
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setGlossaryUids(glossaryUids: Array<string>): SearchGlossariesParameters {
|
|
25
|
+
this.set("glossaryUids", glossaryUids);
|
|
26
|
+
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setPaging(paging: PaginationDto): SearchGlossariesParameters {
|
|
31
|
+
this.set("paging", paging);
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setSorting(sorting: SortingDto): SearchGlossariesParameters {
|
|
37
|
+
this.set("sorting", sorting);
|
|
38
|
+
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setIncludeEntriesCount(includeEntriesCount: boolean): SearchGlossariesParameters {
|
|
43
|
+
this.set("includeEntriesCount", includeEntriesCount);
|
|
44
|
+
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/api/job-batches/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FormData from "form-data";
|
|
2
2
|
import { SmartlingBaseApi } from "../base";
|
|
3
|
-
import {
|
|
3
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
4
4
|
import { Logger } from "../logger";
|
|
5
5
|
import { CreateBatchParameters } from "./params/create-batch-parameters";
|
|
6
6
|
import { UploadBatchFileParameters } from "./params/upload-batch-file-parameters";
|
|
@@ -15,7 +15,7 @@ import { BaseJobDto } from "../jobs/dto/base-job-dto";
|
|
|
15
15
|
import { JobBatchesParameters } from "./params/job-batches-parameters";
|
|
16
16
|
|
|
17
17
|
export class SmartlingJobBatchesApi extends SmartlingBaseApi {
|
|
18
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
18
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
19
19
|
super(logger);
|
|
20
20
|
this.authApi = authApi;
|
|
21
21
|
this.entrypoint = `${smartlingApiBaseUrl}/job-batches-api/v2/projects`;
|
package/api/jobs/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
import { CreateJobParameters } from "./params/create-job-parameters";
|
|
5
5
|
import { ListJobFilesParameters } from "./params/list-job-files-parameters";
|
|
@@ -24,7 +24,7 @@ import { AuthorizeJobParameters } from "./params/authorize-job-parameters";
|
|
|
24
24
|
import { UpdateJobParameters } from "./params/update-job-parameters";
|
|
25
25
|
|
|
26
26
|
export class SmartlingJobsApi extends SmartlingBaseApi {
|
|
27
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
27
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
28
28
|
super(logger);
|
|
29
29
|
this.authApi = authApi;
|
|
30
30
|
this.entrypoint = `${smartlingApiBaseUrl}/jobs-api/v3/projects`;
|
package/api/locales/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
import { SmartlingLocaleDto } from "./dto/smartling-locale-dto";
|
|
5
5
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
6
6
|
import { GetLocalesParameters } from "./params/get-locales-parameters";
|
|
7
7
|
|
|
8
8
|
export class SmartlingLocalesApi extends SmartlingBaseApi {
|
|
9
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
10
10
|
super(logger);
|
|
11
11
|
this.authApi = authApi;
|
|
12
12
|
this.entrypoint = `${smartlingApiBaseUrl}/locales-api/v2/dictionary`;
|
package/api/mt/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
import { SmartlingMTParameters } from "./params/smartling-mt-parameters";
|
|
5
5
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
6
6
|
import { TranslationTextItemDto } from "./dto/translation-text-item-dto";
|
|
7
7
|
|
|
8
8
|
export class SmartlingMachineTranslationsApi extends SmartlingBaseApi {
|
|
9
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
10
10
|
super(logger);
|
|
11
11
|
this.authApi = authApi;
|
|
12
12
|
this.entrypoint = `${smartlingApiBaseUrl}/mt-router-api/v2/accounts`;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { LocaleDto } from "./locale-dto";
|
|
2
|
+
import { ProjectWithoutTargetLocalesDto } from "./project-without-target-locales-dto";
|
|
2
3
|
|
|
3
|
-
interface ProjectDto {
|
|
4
|
-
|
|
5
|
-
archived: boolean;
|
|
6
|
-
projectId: string;
|
|
7
|
-
projectName: string;
|
|
8
|
-
projectTypeCode: string;
|
|
9
|
-
sourceLocaleDescription: string;
|
|
10
|
-
sourceLocaleId: string;
|
|
11
|
-
targetLocales: Array<LocaleDto>
|
|
4
|
+
interface ProjectDto extends ProjectWithoutTargetLocalesDto {
|
|
5
|
+
targetLocales: Array<LocaleDto>;
|
|
12
6
|
}
|
|
13
7
|
|
|
14
8
|
export { ProjectDto };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ProjectWithoutTargetLocalesDto {
|
|
2
|
+
accountUid: string;
|
|
3
|
+
archived: boolean;
|
|
4
|
+
projectId: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
projectTypeCode: string;
|
|
7
|
+
sourceLocaleDescription: string;
|
|
8
|
+
sourceLocaleId: string;
|
|
9
|
+
projectTypeDisplayValue: string;
|
|
10
|
+
packageUid: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ProjectWithoutTargetLocalesDto };
|
package/api/projects/index.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
import { ProjectDto } from "./dto/project-dto";
|
|
5
|
+
import { ListProjectsParameters } from "./params/list-projects-parameters";
|
|
6
|
+
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
7
|
+
import { ProjectWithoutTargetLocalesDto } from "./dto/project-without-target-locales-dto";
|
|
5
8
|
|
|
6
9
|
export class SmartlingProjectsApi extends SmartlingBaseApi {
|
|
7
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
10
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
8
11
|
super(logger);
|
|
9
12
|
this.authApi = authApi;
|
|
10
13
|
this.entrypoint = `${smartlingApiBaseUrl}/projects-api/v2/projects`;
|
|
@@ -16,4 +19,17 @@ export class SmartlingProjectsApi extends SmartlingBaseApi {
|
|
|
16
19
|
`${this.entrypoint}/${projectId}`
|
|
17
20
|
);
|
|
18
21
|
}
|
|
22
|
+
|
|
23
|
+
async listProjects(
|
|
24
|
+
accountUid: string,
|
|
25
|
+
parameters?: ListProjectsParameters
|
|
26
|
+
): Promise<SmartlingListResponse<ProjectWithoutTargetLocalesDto>> {
|
|
27
|
+
const accountsEndpoint = this.entrypoint.replace("/projects-api/v2/projects", `/accounts-api/v2/accounts/${accountUid}/projects`);
|
|
28
|
+
|
|
29
|
+
return await this.makeRequest(
|
|
30
|
+
"get",
|
|
31
|
+
accountsEndpoint,
|
|
32
|
+
parameters ? parameters.export() : undefined
|
|
33
|
+
);
|
|
34
|
+
}
|
|
19
35
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseParameters } from "../../parameters/index";
|
|
2
|
+
|
|
3
|
+
export class ListProjectsParameters extends BaseParameters {
|
|
4
|
+
setProjectNameFilter(projectNameFilter: string): ListProjectsParameters {
|
|
5
|
+
this.set("projectNameFilter", projectNameFilter);
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setIncludeArchived(includeArchived: boolean): ListProjectsParameters {
|
|
10
|
+
this.set("includeArchived", includeArchived);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setOffset(offset: number): ListProjectsParameters {
|
|
15
|
+
if (offset >= 0) {
|
|
16
|
+
this.set("offset", offset);
|
|
17
|
+
}
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setLimit(limit: number): ListProjectsParameters {
|
|
22
|
+
if (limit > 0) {
|
|
23
|
+
this.set("limit", limit);
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setProjectTypeCode(projectTypeCode: string): ListProjectsParameters {
|
|
29
|
+
this.set("projectTypeCode", projectTypeCode);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setProjectTypeCodes(projectTypeCodes: Array<string>): ListProjectsParameters {
|
|
34
|
+
this.set("projectTypeCodes", projectTypeCodes);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { Logger } from "../logger";
|
|
4
4
|
import { RecentlyPublishedFilesParameters } from "./params/recently-published-files-parameters";
|
|
5
5
|
import { PublishedFileDto } from "./dto/published-file-dto";
|
|
6
6
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
7
7
|
|
|
8
8
|
export class SmartlingPublishedFilesApi extends SmartlingBaseApi {
|
|
9
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
10
10
|
super(logger);
|
|
11
11
|
|
|
12
12
|
this.authApi = authApi;
|
package/api/strings/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
|
-
import {
|
|
2
|
+
import { AccessTokenProvider } from "../auth/access-token-provider";
|
|
3
3
|
import { FetchSourceStringsParameters } from "./params/fetch-source-strings-parameters";
|
|
4
4
|
import { SmartlingListResponse } from "../http/smartling-list-response";
|
|
5
5
|
import { SourceStringDto } from "./dto/source-string-dto";
|
|
6
6
|
import { Logger } from "../logger";
|
|
7
7
|
|
|
8
8
|
export class SmartlingStringsApi extends SmartlingBaseApi {
|
|
9
|
-
constructor(smartlingApiBaseUrl: string, authApi:
|
|
9
|
+
constructor(smartlingApiBaseUrl: string, authApi: AccessTokenProvider, logger: Logger) {
|
|
10
10
|
super(logger);
|
|
11
11
|
this.authApi = authApi;
|
|
12
12
|
this.entrypoint = `${smartlingApiBaseUrl}/strings-api/v2/projects`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-token-provider.js","sourceRoot":"","sources":["../../../api/auth/access-token-provider.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SmartlingBaseApi } from "../base/index";
|
|
2
2
|
import { Logger } from "../logger";
|
|
3
|
+
import { AccessTokenProvider } from "./access-token-provider";
|
|
3
4
|
import { AccessTokenDto } from "./dto/access-token-dto";
|
|
4
|
-
export declare class SmartlingAuthApi extends SmartlingBaseApi {
|
|
5
|
+
export declare class SmartlingAuthApi extends SmartlingBaseApi implements AccessTokenProvider {
|
|
5
6
|
private ttlCorrectionSec;
|
|
6
7
|
private userIdentifier;
|
|
7
8
|
private tokenSecret;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;AACjD,8CAAwD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../api/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAiD;AACjD,8CAAwD;AAKxD,MAAa,gBAAiB,SAAQ,wBAAgB;IAOlD,YACI,mBAA2B,EAAE,cAAsB,EAAE,WAAmB,EAAE,MAAc;QAExF,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,GAAG,mBAAmB,cAAc,CAAC;QACvD,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAEK,YAAY;;YACd,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAE7B,OAAO,MAAM,IAAI,CAAC,WAAW,CACzB,MAAM,EACN,GAAG,IAAI,CAAC,UAAU,eAAe,EACjC,IAAI,CAAC,SAAS,CAAC;gBACX,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,UAAU,EAAE,IAAI,CAAC,WAAW;aAC/B,CAAC,CACL,CAAC;QACN,CAAC;KAAA;IAEK,YAAY;;YACd,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE;gBAChD,IAAI,CAAC,qBAAqB,EAAE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,EAAE,CAAC;iBAC7C;gBAED,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;aAClC;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBAEvD,MAAM,IAAI,0BAAkB,CAAC,0BAA0B,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;aAC1E;QACL,CAAC;KAAA;IAED,UAAU;QACN,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAGD,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;CACJ;AAxID,4CAwIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccessTokenProvider } from "./access-token-provider";
|
|
2
|
+
export declare class StaticAccessTokenProvider implements AccessTokenProvider {
|
|
3
|
+
private accessToken;
|
|
4
|
+
private tokenType;
|
|
5
|
+
constructor(accessToken: string, tokenType: string);
|
|
6
|
+
getAccessToken(): Promise<string>;
|
|
7
|
+
getTokenType(): Promise<string>;
|
|
8
|
+
resetToken(): void;
|
|
9
|
+
}
|