@localazy/ts-api
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,61 +0,7 @@ | ||
declare type Constructor = { | ||
projectToken: string; | ||
baseUrl?: string; | ||
}; | ||
declare type NonStaticOptions = { | ||
/** Optionally override initially set project token */ | ||
projectToken?: string; | ||
baseUrl?: string; | ||
}; | ||
declare type ListProjects = { | ||
/** Add information about the owning organization. */ | ||
organization?: boolean; | ||
/** Add information about languages. */ | ||
languages?: boolean; | ||
}; | ||
declare type LocFileContentLanguage = { | ||
[k: string]: string | string[] | LocFileContentLanguage; | ||
}; | ||
declare type LocFileContent = { | ||
/** The file type to be used for backing the strings. @see https://localazy.com/docs/api/import#response-1 */ | ||
type?: string; | ||
plural?: string; | ||
array?: string; | ||
keyTransformer?: string; | ||
params?: Record<string, any>; | ||
features?: string[]; | ||
} & LocFileContentLanguage; | ||
declare type LocFile = { | ||
/** The file name */ | ||
name: string; | ||
/** The path to the file without the file name. */ | ||
path?: string; | ||
/** Optional module specification. */ | ||
module?: any; | ||
/** Optional build type. */ | ||
buildType?: any; | ||
library?: string; | ||
/** Optional product flavors. */ | ||
productFlavors?: any; | ||
content: LocFileContent; | ||
}; | ||
declare type Import = { | ||
projectId: string; | ||
importAsNew?: boolean; | ||
forceCurrent?: boolean; | ||
filterSource?: boolean; | ||
files: LocFile[]; | ||
}; | ||
declare type ListFiles = { | ||
projectId: string; | ||
}; | ||
declare type ListKeysInFile = { | ||
projectId: string; | ||
fileId: string; | ||
/** Locale code {lang} must be in the format: ll-Scrp-RR */ | ||
lang: string; | ||
deprecated?: boolean; | ||
limit?: number; | ||
next?: string; | ||
}; | ||
import Constructor from './models/constructor'; | ||
import CommonConfig from './models/common-config'; | ||
import ListProjects from './models/list-projects'; | ||
import Import from './models/import'; | ||
import ListFiles from './models/list-files'; | ||
import ListKeysInFile from './models/list-keys-in-file'; | ||
declare class LocalazyService { | ||
@@ -66,23 +12,28 @@ private projectToken; | ||
/** | ||
* @see https://localazy.com/docs/api/list-projects | ||
*/ | ||
listProjects(options?: ListProjects, config?: NonStaticOptions): Promise<any>; | ||
* List projects related to the project token. | ||
* @see https://localazy.com/docs/api/list-projects | ||
*/ | ||
listProjects(options?: ListProjects, config?: CommonConfig): Promise<any>; | ||
/** | ||
* @see https://localazy.com/docs/api/import | ||
*/ | ||
import(options: Import, config?: NonStaticOptions): Promise<any>; | ||
* Import content into Localazy. | ||
* @see https://localazy.com/docs/api/import | ||
*/ | ||
import(options: Import, config?: CommonConfig): Promise<any>; | ||
/** | ||
* @see https://localazy.com/docs/api/import#retrieve-a-list-of-available-file-types | ||
*/ | ||
listFormats(config?: NonStaticOptions): Promise<any>; | ||
* Retrieve list of available file formats and related options. | ||
* @see https://localazy.com/docs/api/import#retrieve-a-list-of-available-file-types | ||
*/ | ||
listFormats(config?: CommonConfig): Promise<any>; | ||
/** | ||
* @see https://localazy.com/docs/api/files | ||
*/ | ||
listFiles(options: ListFiles, config?: NonStaticOptions): Promise<any>; | ||
* List Localazy files. | ||
* @see https://localazy.com/docs/api/files | ||
*/ | ||
listFiles(options: ListFiles, config?: CommonConfig): Promise<any>; | ||
/** | ||
* @see https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file | ||
*/ | ||
listKeysInFileForLanguage(options: ListKeysInFile, config?: NonStaticOptions): Promise<any>; | ||
* Retrieve list of keys for language from file. | ||
* @see https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file | ||
*/ | ||
listKeysInFileForLanguage(options: ListKeysInFile, config?: CommonConfig): Promise<any>; | ||
} | ||
export default function LocalazyServiceFactory(options: Constructor): LocalazyService; | ||
export {}; |
@@ -72,4 +72,5 @@ "use strict"; | ||
/** | ||
* @see https://localazy.com/docs/api/list-projects | ||
*/ | ||
* List projects related to the project token. | ||
* @see https://localazy.com/docs/api/list-projects | ||
*/ | ||
Object.defineProperty(LocalazyService.prototype, "listProjects", { | ||
@@ -94,4 +95,5 @@ enumerable: false, | ||
/** | ||
* @see https://localazy.com/docs/api/import | ||
*/ | ||
* Import content into Localazy. | ||
* @see https://localazy.com/docs/api/import | ||
*/ | ||
Object.defineProperty(LocalazyService.prototype, "import", { | ||
@@ -117,4 +119,5 @@ enumerable: false, | ||
/** | ||
* @see https://localazy.com/docs/api/import#retrieve-a-list-of-available-file-types | ||
*/ | ||
* Retrieve list of available file formats and related options. | ||
* @see https://localazy.com/docs/api/import#retrieve-a-list-of-available-file-types | ||
*/ | ||
Object.defineProperty(LocalazyService.prototype, "listFormats", { | ||
@@ -137,4 +140,5 @@ enumerable: false, | ||
/** | ||
* @see https://localazy.com/docs/api/files | ||
*/ | ||
* List Localazy files. | ||
* @see https://localazy.com/docs/api/files | ||
*/ | ||
Object.defineProperty(LocalazyService.prototype, "listFiles", { | ||
@@ -159,4 +163,5 @@ enumerable: false, | ||
/** | ||
* @see https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file | ||
*/ | ||
* Retrieve list of keys for language from file. | ||
* @see https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file | ||
*/ | ||
Object.defineProperty(LocalazyService.prototype, "listKeysInFileForLanguage", { | ||
@@ -163,0 +168,0 @@ enumerable: false, |
{ | ||
"name": "@localazy/ts-api", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "This is a Typescript library facilitating usage of Localazy's API.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# @localazy/ts-api | ||
This is a Typescript library facilitating usage of Localazy's API. | ||
This is a Typescript library facilitating usage of Localazy's API. To better understand this library, it is recommended to study the [API documentation](https://localazy.com/docs/api/introduction) first. | ||
## Installation and usage | ||
To install this library, run the following command | ||
``` | ||
npm i @localazy/ts-api | ||
``` | ||
Afterwards, import the library and initialize it. | ||
``` | ||
import LocalazyApi from '@localazy/ts-api'; | ||
const api = LocalazyApi({ | ||
projectToken: "your-project-token" | ||
// ...additional options | ||
}) | ||
``` | ||
### Project token | ||
In order to access anything from Localazy, you need to [sign up](https://localazy.com/register) and create a project. | ||
Then, you'll be able to generate a project token [here](https://localazy.com/developer/tokens). | ||
See [documentation](https://localazy.com/docs/api/authentication) for more information. | ||
## Methods overview | ||
### listProjects | ||
List projects related to the project token. | ||
```ts | ||
async listProjects(options: ListProjects = {}, config: CommonConfig = {}); | ||
``` | ||
Documentation: https://localazy.com/docs/api/list-projects | ||
### import | ||
Import content into Localazy. | ||
```ts | ||
async import(options: Import, config: CommonConfig = {}) | ||
``` | ||
Documentation: https://localazy.com/docs/api/import | ||
### listFormats | ||
Retrieve list of available file formats and related options. | ||
```ts | ||
async listFormats(config: CommonConfig = {}) | ||
``` | ||
Documentation: https://localazy.com/docs/api/import#retrieve-a-list-of-available-file-types | ||
### listFiles | ||
List Localazy files. | ||
```ts | ||
async listFiles(options: ListFiles, config: CommonConfig = {}) | ||
``` | ||
Documentation: https://localazy.com/docs/api/files | ||
### listKeysInFileForLanguage | ||
This is the main method for retrieving translated content from given project and localazy file for given language. | ||
```ts | ||
async listKeysInFileForLanguage(options: ListKeysInFile, config: CommonConfig = {}) | ||
``` | ||
Documentation: https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file |
Sorry, the diff of this file is not supported yet
29470
32
479
65