From fde5f56f58f248ea8621208f5c54a3baf621fff2 Mon Sep 17 00:00:00 2001 From: bodrovis Date: Tue, 22 Aug 2023 21:01:31 +0300 Subject: [PATCH 1/6] ota endpoints, sdk tokens --- dist/collections/base_collection.d.ts | 3 + dist/collections/base_collection.js | 16 +++-- dist/collections/base_collection.js.map | 2 +- dist/http_client/base.d.ts | 3 +- dist/http_client/base.js | 10 ++- dist/http_client/base.js.map | 2 +- dist/http_client/ota_request.d.ts | 5 ++ dist/http_client/ota_request.js | 5 ++ dist/http_client/ota_request.js.map | 1 + dist/interfaces/index.d.ts | 1 + dist/interfaces/ota_api_error.d.ts | 5 ++ dist/interfaces/ota_api_error.js | 2 + dist/interfaces/ota_api_error.js.map | 1 + dist/interfaces/ota_team_project.d.ts | 4 ++ dist/interfaces/ota_team_project.js | 2 + dist/interfaces/ota_team_project.js.map | 1 + dist/interfaces/ota_token.d.ts | 7 ++ dist/interfaces/ota_token.js | 2 + dist/interfaces/ota_token.js.map | 1 + dist/interfaces/sdk_token.d.ts | 7 ++ dist/interfaces/sdk_token.js | 2 + dist/interfaces/sdk_token.js.map | 1 + dist/lokalise/lokalise_api_ota.d.ts | 7 ++ dist/lokalise/lokalise_api_ota.js | 13 ++++ dist/lokalise/lokalise_api_ota.js.map | 1 + dist/models/ota_api_error.d.ts | 7 ++ dist/models/ota_api_error.js | 4 ++ dist/models/ota_api_error.js.map | 1 + dist/models/ota_token.d.ts | 9 +++ dist/models/ota_token.js | 4 ++ dist/models/ota_token.js.map | 1 + dist/models/sdk_token.d.ts | 9 +++ dist/models/sdk_token.js | 4 ++ dist/models/sdk_token.js.map | 1 + dist/ota_collections/ota_collection.d.ts | 8 +++ dist/ota_collections/ota_collection.js | 17 +++++ dist/ota_collections/ota_collection.js.map | 1 + dist/ota_collections/ota_tokens.d.ts | 10 +++ dist/ota_collections/ota_tokens.js | 12 ++++ dist/ota_collections/ota_tokens.js.map | 1 + dist/ota_collections/sdk_tokens.d.ts | 17 +++++ dist/ota_collections/sdk_tokens.js | 18 +++++ dist/ota_collections/sdk_tokens.js.map | 1 + package-lock.json | 12 ++-- package.json | 4 +- src/collections/base_collection.ts | 37 +++++++--- src/http_client/base.ts | 13 +++- src/interfaces/index.ts | 1 + src/interfaces/ota_api_error.ts | 5 ++ src/interfaces/ota_team_project.ts | 4 ++ src/interfaces/sdk_token.ts | 7 ++ src/lokalise/lokalise_api_ota.ts | 15 ++++ src/models/ota_api_error.ts | 8 +++ src/models/sdk_token.ts | 10 +++ src/ota_collections/ota_collection.ts | 30 ++++++++ src/ota_collections/sdk_tokens.ts | 31 ++++++++ test/cassettes/SdkTokens create.cassette | 67 +++++++++++++++++ test/cassettes/SdkTokens delete.cassette | 64 +++++++++++++++++ test/cassettes/SdkTokens error.cassette | 63 ++++++++++++++++ test/cassettes/SdkTokens list.cassette | 83 ++++++++++++++++++++++ test/ota/ota_tokens.spec.ts | 68 ++++++++++++++++++ 61 files changed, 721 insertions(+), 30 deletions(-) create mode 100644 dist/http_client/ota_request.d.ts create mode 100644 dist/http_client/ota_request.js create mode 100644 dist/http_client/ota_request.js.map create mode 100644 dist/interfaces/ota_api_error.d.ts create mode 100644 dist/interfaces/ota_api_error.js create mode 100644 dist/interfaces/ota_api_error.js.map create mode 100644 dist/interfaces/ota_team_project.d.ts create mode 100644 dist/interfaces/ota_team_project.js create mode 100644 dist/interfaces/ota_team_project.js.map create mode 100644 dist/interfaces/ota_token.d.ts create mode 100644 dist/interfaces/ota_token.js create mode 100644 dist/interfaces/ota_token.js.map create mode 100644 dist/interfaces/sdk_token.d.ts create mode 100644 dist/interfaces/sdk_token.js create mode 100644 dist/interfaces/sdk_token.js.map create mode 100644 dist/lokalise/lokalise_api_ota.d.ts create mode 100644 dist/lokalise/lokalise_api_ota.js create mode 100644 dist/lokalise/lokalise_api_ota.js.map create mode 100644 dist/models/ota_api_error.d.ts create mode 100644 dist/models/ota_api_error.js create mode 100644 dist/models/ota_api_error.js.map create mode 100644 dist/models/ota_token.d.ts create mode 100644 dist/models/ota_token.js create mode 100644 dist/models/ota_token.js.map create mode 100644 dist/models/sdk_token.d.ts create mode 100644 dist/models/sdk_token.js create mode 100644 dist/models/sdk_token.js.map create mode 100644 dist/ota_collections/ota_collection.d.ts create mode 100644 dist/ota_collections/ota_collection.js create mode 100644 dist/ota_collections/ota_collection.js.map create mode 100644 dist/ota_collections/ota_tokens.d.ts create mode 100644 dist/ota_collections/ota_tokens.js create mode 100644 dist/ota_collections/ota_tokens.js.map create mode 100644 dist/ota_collections/sdk_tokens.d.ts create mode 100644 dist/ota_collections/sdk_tokens.js create mode 100644 dist/ota_collections/sdk_tokens.js.map create mode 100644 src/interfaces/ota_api_error.ts create mode 100644 src/interfaces/ota_team_project.ts create mode 100644 src/interfaces/sdk_token.ts create mode 100644 src/lokalise/lokalise_api_ota.ts create mode 100644 src/models/ota_api_error.ts create mode 100644 src/models/sdk_token.ts create mode 100644 src/ota_collections/ota_collection.ts create mode 100644 src/ota_collections/sdk_tokens.ts create mode 100644 test/cassettes/SdkTokens create.cassette create mode 100644 test/cassettes/SdkTokens delete.cassette create mode 100644 test/cassettes/SdkTokens error.cassette create mode 100644 test/cassettes/SdkTokens list.cassette create mode 100644 test/ota/ota_tokens.spec.ts diff --git a/dist/collections/base_collection.d.ts b/dist/collections/base_collection.d.ts index a54eaf65..92424a81 100644 --- a/dist/collections/base_collection.d.ts +++ b/dist/collections/base_collection.d.ts @@ -1,4 +1,5 @@ import { Options } from "got"; +import { ApiRequest } from "../http_client/base.js"; import { ApiError } from "../models/api_error.js"; import { PaginatedResult } from "../models/paginated_result.js"; import { Keyable } from "../interfaces/keyable.js"; @@ -30,6 +31,8 @@ export declare abstract class BaseCollection { protected returnBareJSON(json: Keyable | Array): Keyable | Array; protected handleReject(data: any): ApiError; protected createPromise(method: Options["method"], params: Keyable, resolveFn: ResolveHandler, rejectFn: RejectHandler, body: object | object[] | null, uri?: string | null): Promise; + protected prepareRequest(method: Options["method"], body: object | object[] | null, params: Keyable, uri?: string | null): ApiRequest; + protected getUri(uri: string | null): string; protected objToArray(raw_body: Keyable | Keyable[]): Array; } export {}; diff --git a/dist/collections/base_collection.js b/dist/collections/base_collection.js index 68c5fbda..f9703d2a 100644 --- a/dist/collections/base_collection.js +++ b/dist/collections/base_collection.js @@ -106,11 +106,7 @@ export class BaseCollection { return this.populateApiErrorFromJson(data); } async createPromise(method, params, resolveFn, rejectFn, body, uri = null) { - const childClass = this.constructor; - if (!uri) { - uri = childClass.prefixURI; - } - const request = new ApiRequest(uri, method, body, params, this.clientData); + const request = this.prepareRequest(method, body, params, uri); try { const data = await request.promise; return Promise.resolve(resolveFn.call(this, data["json"], data["headers"])); @@ -119,6 +115,16 @@ export class BaseCollection { return Promise.reject(rejectFn.call(this, err)); } } + prepareRequest(method, body, params, uri = null) { + return new ApiRequest(this.getUri(uri), method, body, params, this.clientData); + } + getUri(uri) { + const childClass = this.constructor; + if (!uri) { + uri = childClass.prefixURI; + } + return uri; + } objToArray(raw_body) { if (!Array.isArray(raw_body)) { return Array(raw_body); diff --git a/dist/collections/base_collection.js.map b/dist/collections/base_collection.js.map index e23bf777..fb45f605 100644 --- a/dist/collections/base_collection.js.map +++ b/dist/collections/base_collection.js.map @@ -1 +1 @@ -{"version":3,"file":"base_collection.js","sourceRoot":"","sources":["../../src/collections/base_collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAQhE,MAAM,OAAgB,cAAc;IACzB,UAAU,CAAa;IACtB,MAAM,CAAC,eAAe,CAAS;IAC/B,MAAM,CAAC,uBAAuB,CAAgB;IAC9C,MAAM,CAAC,QAAQ,CAAgB;IAC/B,MAAM,CAAC,SAAS,CAAgB;IAChC,MAAM,CAAC,YAAY,CAAM;IAEnC,+EAA+E;IAC/E,2DAA2D;IACjD,MAAM,CAAC,4BAA4B,CAAgB;IACnD,MAAM,CAAC,qBAAqB,CAA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AAM,EACN,IAAI,EACJ,MAAM,EACN,IAAI,CAAC,UAAU,CAChB,CAAC;QACF,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC;YACnC,OAAO,OAAO,CAAC,OAAO,CACpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CACpD,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;SACjD;IACH,CAAC;IAES,UAAU,CAAC,QAA6B;QAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;SACxB;aAAM;YACL,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"base_collection.js","sourceRoot":"","sources":["../../src/collections/base_collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAQhE,MAAM,OAAgB,cAAc;IACzB,UAAU,CAAa;IACtB,MAAM,CAAC,eAAe,CAAS;IAC/B,MAAM,CAAC,uBAAuB,CAAgB;IAC9C,MAAM,CAAC,QAAQ,CAAgB;IAC/B,MAAM,CAAC,SAAS,CAAgB;IAChC,MAAM,CAAC,YAAY,CAAM;IAEnC,+EAA+E;IAC/E,2DAA2D;IACjD,MAAM,CAAC,4BAA4B,CAAgB;IACnD,MAAM,CAAC,qBAAqB,CAAM;IAE5C,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAES,MAAM,CAAC,UAAmB;QAClC,MAAM,MAAM,GAAG;YACb,GAAG,UAAU;SACd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,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;SACjD;IACH,CAAC;IAES,cAAc,CACtB,MAAyB,EACzB,IAA8B,EAC9B,MAAe,EACf,MAAqB,IAAI;QAEzB,OAAO,IAAI,UAAU,CACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAChB,MAAM,EACN,IAAI,EACJ,MAAM,EACN,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;IAES,MAAM,CAAC,GAAkB;QACjC,MAAM,UAAU,GAA0B,IAAI,CAAC,WAAW,CAAC;QAC3D,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC;SAC5B;QAED,OAAe,GAAG,CAAC;IACrB,CAAC;IAES,UAAU,CAAC,QAA6B;QAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;SACxB;aAAM;YACL,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/dist/http_client/base.d.ts b/dist/http_client/base.d.ts index 474f8ff1..d4b0c2d6 100644 --- a/dist/http_client/base.d.ts +++ b/dist/http_client/base.d.ts @@ -4,9 +4,10 @@ import { ClientData } from "../interfaces/client_data.js"; export declare class ApiRequest { promise: Promise; params: WritableKeyable; - private readonly urlRoot; + protected readonly urlRoot: NonNullable; constructor(uri: string, method: Options["method"], body: object | object[] | null, params: Keyable, clientData: ClientData); protected createPromise(uri: string, method: Options["method"], body: object | object[] | null, clientData: ClientData): Promise; + protected getErrorFromResp(respJson: any): any; protected composeURI(rawUri: string): string; protected mapUriParams(): (_entity: any, isMandaratory: string, paramName: string) => string; } diff --git a/dist/http_client/base.js b/dist/http_client/base.js index 496c5875..1b8cf843 100644 --- a/dist/http_client/base.js +++ b/dist/http_client/base.js @@ -37,7 +37,7 @@ export class ApiRequest { const response = await got(undefined, undefined, options); const responseJSON = JSON.parse(response.body); if (response.statusCode > 399) { - return Promise.reject(responseJSON["error"] || responseJSON); + return Promise.reject(this.getErrorFromResp(responseJSON)); } return Promise.resolve({ json: responseJSON, headers: response.headers }); /* c8 ignore next 4 */ @@ -46,6 +46,14 @@ export class ApiRequest { return Promise.reject(err); } } + getErrorFromResp(respJson) { + if (typeof respJson["error"] === "object") { + return respJson["error"]; + } + else { + return respJson; + } + } composeURI(rawUri) { const regexp = /{(!{0,1}):(\w*)}/g; const uri = rawUri.replace(regexp, this.mapUriParams()); diff --git a/dist/http_client/base.js.map b/dist/http_client/base.js.map index c803f453..ef3a8876 100644 --- a/dist/http_client/base.js.map +++ b/dist/http_client/base.js.map @@ -1 +1 @@ -{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/http_client/base.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAiB,OAAO,EAAE,MAAM,KAAK,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,UAAU;IACd,OAAO,CAAe;IACtB,MAAM,GAAoB,EAAE,CAAC;IACnB,OAAO,GACtB,gCAAgC,CAAC;IAEnC,YACE,GAAW,EACX,MAAyB,EACzB,IAA8B,EAC9B,MAAe,EACf,UAAsB;QAEtB,uFAAuF;QACvF,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,aAAa,CAC3B,GAAW,EACX,MAAyB,EACzB,IAA8B,EAC9B,UAAsB;QAEtB,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEjC,MAAM,OA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AC1E,sBAAsB;SACvB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC5B;IACH,CAAC;IAES,UAAU,CAAC,MAAc;QACjC,MAAM,MAAM,GAAG,mBAAmB,CAAC;QACnC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACxD,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACpD,CAAC;IAES,YAAY;QACpB,OAAO,CAAC,OAAY,EAAE,aAAqB,EAAE,SAAiB,EAAU,EAAE;YACxE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE;gBAClC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBACvC,oEAAoE;gBACpE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9B,OAAO,OAAO,CAAC;aAChB;iBAAM;gBACL,IAAI,aAAa,KAAK,GAAG,EAAE;oBACzB,oBAAoB;oBACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;iBAChD;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;aACF;QACH,CAAC,CAAC;IACJ,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/http_client/base.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAiB,OAAO,EAAE,MAAM,KAAK,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,UAAU;IACd,OAAO,CAAe;IACtB,MAAM,GAAoB,EAAE,CAAC;IACjB,OAAO,GACx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BAClC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBACvC,oEAAoE;gBACpE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9B,OAAO,OAAO,CAAC;aAChB;iBAAM;gBACL,IAAI,aAAa,KAAK,GAAG,EAAE;oBACzB,oBAAoB;oBACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;iBAChD;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;aACF;QACH,CAAC,CAAC;IACJ,CAAC;CACF"} \ No newline at end of file diff --git a/dist/http_client/ota_request.d.ts b/dist/http_client/ota_request.d.ts new file mode 100644 index 00000000..37d31403 --- /dev/null +++ b/dist/http_client/ota_request.d.ts @@ -0,0 +1,5 @@ +import { Options } from "got"; +import { ApiRequest } from "./base.js"; +export declare class OtaRequest extends ApiRequest { + protected readonly urlRoot: NonNullable; +} diff --git a/dist/http_client/ota_request.js b/dist/http_client/ota_request.js new file mode 100644 index 00000000..f707c27f --- /dev/null +++ b/dist/http_client/ota_request.js @@ -0,0 +1,5 @@ +import { ApiRequest } from "./base.js"; +export class OtaRequest extends ApiRequest { + urlRoot = "https://ota.lokalise.com/v3"; +} +//# sourceMappingURL=ota_request.js.map \ No newline at end of file diff --git a/dist/http_client/ota_request.js.map b/dist/http_client/ota_request.js.map new file mode 100644 index 00000000..8de2af78 --- /dev/null +++ b/dist/http_client/ota_request.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_request.js","sourceRoot":"","sources":["../../src/http_client/ota_request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,UAAW,SAAQ,UAAU;IACrB,OAAO,GACxB,6BAA6B,CAAC;CACjC"} \ No newline at end of file diff --git a/dist/interfaces/index.d.ts b/dist/interfaces/index.d.ts index 575be79b..055fbb2c 100644 --- a/dist/interfaces/index.d.ts +++ b/dist/interfaces/index.d.ts @@ -24,6 +24,7 @@ export { ProjectSettings } from "./project_settings.js"; export { ProjectStatistics } from "./project_statistics.js"; export { ProjectWithPagination } from "./project_with_pagination.js"; export { Project } from "./project.js"; +export { SdkToken } from "./sdk_token.js"; export { QueuedProcess } from "./queued_process.js"; export { RefreshTokenResponse } from "./refresh_token_response.js"; export { RequestTokenResponse } from "./request_token_response.js"; diff --git a/dist/interfaces/ota_api_error.d.ts b/dist/interfaces/ota_api_error.d.ts new file mode 100644 index 00000000..593cecf9 --- /dev/null +++ b/dist/interfaces/ota_api_error.d.ts @@ -0,0 +1,5 @@ +export interface OtaApiError { + statusCode: string; + message: string; + error: string; +} diff --git a/dist/interfaces/ota_api_error.js b/dist/interfaces/ota_api_error.js new file mode 100644 index 00000000..98b4baea --- /dev/null +++ b/dist/interfaces/ota_api_error.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ota_api_error.js.map \ No newline at end of file diff --git a/dist/interfaces/ota_api_error.js.map b/dist/interfaces/ota_api_error.js.map new file mode 100644 index 00000000..567cf075 --- /dev/null +++ b/dist/interfaces/ota_api_error.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_api_error.js","sourceRoot":"","sources":["../../src/interfaces/ota_api_error.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/interfaces/ota_team_project.d.ts b/dist/interfaces/ota_team_project.d.ts new file mode 100644 index 00000000..e56aa22b --- /dev/null +++ b/dist/interfaces/ota_team_project.d.ts @@ -0,0 +1,4 @@ +export interface OtaTeamProject { + teamId: number | string; + lokaliseProjectId: string; +} diff --git a/dist/interfaces/ota_team_project.js b/dist/interfaces/ota_team_project.js new file mode 100644 index 00000000..de699962 --- /dev/null +++ b/dist/interfaces/ota_team_project.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ota_team_project.js.map \ No newline at end of file diff --git a/dist/interfaces/ota_team_project.js.map b/dist/interfaces/ota_team_project.js.map new file mode 100644 index 00000000..d510860b --- /dev/null +++ b/dist/interfaces/ota_team_project.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_team_project.js","sourceRoot":"","sources":["../../src/interfaces/ota_team_project.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/interfaces/ota_token.d.ts b/dist/interfaces/ota_token.d.ts new file mode 100644 index 00000000..46d257e9 --- /dev/null +++ b/dist/interfaces/ota_token.d.ts @@ -0,0 +1,7 @@ +export interface OtaToken { + id: number; + token: string; + projectId: string; + lokaliseId: number; + createdAt: string; +} diff --git a/dist/interfaces/ota_token.js b/dist/interfaces/ota_token.js new file mode 100644 index 00000000..830935ef --- /dev/null +++ b/dist/interfaces/ota_token.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ota_token.js.map \ No newline at end of file diff --git a/dist/interfaces/ota_token.js.map b/dist/interfaces/ota_token.js.map new file mode 100644 index 00000000..b346330f --- /dev/null +++ b/dist/interfaces/ota_token.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_token.js","sourceRoot":"","sources":["../../src/interfaces/ota_token.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/interfaces/sdk_token.d.ts b/dist/interfaces/sdk_token.d.ts new file mode 100644 index 00000000..132a8b2f --- /dev/null +++ b/dist/interfaces/sdk_token.d.ts @@ -0,0 +1,7 @@ +export interface SdkToken { + id: number; + token: string; + projectId: number; + lokaliseId: number; + createdAt: string; +} diff --git a/dist/interfaces/sdk_token.js b/dist/interfaces/sdk_token.js new file mode 100644 index 00000000..974f1284 --- /dev/null +++ b/dist/interfaces/sdk_token.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=sdk_token.js.map \ No newline at end of file diff --git a/dist/interfaces/sdk_token.js.map b/dist/interfaces/sdk_token.js.map new file mode 100644 index 00000000..2589e338 --- /dev/null +++ b/dist/interfaces/sdk_token.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sdk_token.js","sourceRoot":"","sources":["../../src/interfaces/sdk_token.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lokalise/lokalise_api_ota.d.ts b/dist/lokalise/lokalise_api_ota.d.ts new file mode 100644 index 00000000..8a64076a --- /dev/null +++ b/dist/lokalise/lokalise_api_ota.d.ts @@ -0,0 +1,7 @@ +import { ClientParams } from "./lokalise_api.js"; +import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { SdkTokens } from "../ota_collections/sdk_tokens.js"; +export declare class LokaliseApiOta extends LokaliseApiOAuth { + constructor(params: ClientParams); + sdkTokens(): SdkTokens; +} diff --git a/dist/lokalise/lokalise_api_ota.js b/dist/lokalise/lokalise_api_ota.js new file mode 100644 index 00000000..d70d52c9 --- /dev/null +++ b/dist/lokalise/lokalise_api_ota.js @@ -0,0 +1,13 @@ +import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { SdkTokens } from "../ota_collections/sdk_tokens.js"; +export class LokaliseApiOta extends LokaliseApiOAuth { + constructor(params) { + super(params); + this.clientData.host = + this.clientData.host ?? "https://ota.lokalise.com/v3"; + } + sdkTokens() { + return new SdkTokens(this.clientData); + } +} +//# sourceMappingURL=lokalise_api_ota.js.map \ No newline at end of file diff --git a/dist/lokalise/lokalise_api_ota.js.map b/dist/lokalise/lokalise_api_ota.js.map new file mode 100644 index 00000000..3baae795 --- /dev/null +++ b/dist/lokalise/lokalise_api_ota.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lokalise_api_ota.js","sourceRoot":"","sources":["../../src/lokalise/lokalise_api_ota.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAClD,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,UAAU,CAAC,IAAI;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,6BAA6B,CAAC;IAC1D,CAAC;IAED,SAAS;QACP,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"} \ No newline at end of file diff --git a/dist/models/ota_api_error.d.ts b/dist/models/ota_api_error.d.ts new file mode 100644 index 00000000..73a2a75a --- /dev/null +++ b/dist/models/ota_api_error.d.ts @@ -0,0 +1,7 @@ +import { OtaApiError as OtaApiErrorInterface } from "../interfaces/ota_api_error.js"; +import { BaseModel } from "./base_model.js"; +export declare class OtaApiError extends BaseModel implements OtaApiErrorInterface { + statusCode: string; + message: string; + error: string; +} diff --git a/dist/models/ota_api_error.js b/dist/models/ota_api_error.js new file mode 100644 index 00000000..7b46195e --- /dev/null +++ b/dist/models/ota_api_error.js @@ -0,0 +1,4 @@ +import { BaseModel } from "./base_model.js"; +export class OtaApiError extends BaseModel { +} +//# sourceMappingURL=ota_api_error.js.map \ No newline at end of file diff --git a/dist/models/ota_api_error.js.map b/dist/models/ota_api_error.js.map new file mode 100644 index 00000000..54a8b8f3 --- /dev/null +++ b/dist/models/ota_api_error.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_api_error.js","sourceRoot":"","sources":["../../src/models/ota_api_error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,WAAY,SAAQ,SAAS;CAIzC"} \ No newline at end of file diff --git a/dist/models/ota_token.d.ts b/dist/models/ota_token.d.ts new file mode 100644 index 00000000..0ed85497 --- /dev/null +++ b/dist/models/ota_token.d.ts @@ -0,0 +1,9 @@ +import { BaseModel } from "./base_model.js"; +import { OtaToken as OtaTokenInterface } from "../interfaces/ota_token.js"; +export declare class OtaToken extends BaseModel implements OtaTokenInterface { + id: number; + token: string; + projectId: string; + lokaliseId: number; + createdAt: string; +} diff --git a/dist/models/ota_token.js b/dist/models/ota_token.js new file mode 100644 index 00000000..13421a8a --- /dev/null +++ b/dist/models/ota_token.js @@ -0,0 +1,4 @@ +import { BaseModel } from "./base_model.js"; +export class OtaToken extends BaseModel { +} +//# sourceMappingURL=ota_token.js.map \ No newline at end of file diff --git a/dist/models/ota_token.js.map b/dist/models/ota_token.js.map new file mode 100644 index 00000000..aa38ef27 --- /dev/null +++ b/dist/models/ota_token.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_token.js","sourceRoot":"","sources":["../../src/models/ota_token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,QAAS,SAAQ,SAAS;CAMtC"} \ No newline at end of file diff --git a/dist/models/sdk_token.d.ts b/dist/models/sdk_token.d.ts new file mode 100644 index 00000000..2abd8a1c --- /dev/null +++ b/dist/models/sdk_token.d.ts @@ -0,0 +1,9 @@ +import { BaseModel } from "./base_model.js"; +import { SdkToken as SdkTokenInterface } from "../interfaces/sdk_token.js"; +export declare class SdkToken extends BaseModel implements SdkTokenInterface { + id: number; + token: string; + projectId: number; + lokaliseId: number; + createdAt: string; +} diff --git a/dist/models/sdk_token.js b/dist/models/sdk_token.js new file mode 100644 index 00000000..31192c2d --- /dev/null +++ b/dist/models/sdk_token.js @@ -0,0 +1,4 @@ +import { BaseModel } from "./base_model.js"; +export class SdkToken extends BaseModel { +} +//# sourceMappingURL=sdk_token.js.map \ No newline at end of file diff --git a/dist/models/sdk_token.js.map b/dist/models/sdk_token.js.map new file mode 100644 index 00000000..eebff966 --- /dev/null +++ b/dist/models/sdk_token.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sdk_token.js","sourceRoot":"","sources":["../../src/models/sdk_token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,QAAS,SAAQ,SAAS;CAMtC"} \ No newline at end of file diff --git a/dist/ota_collections/ota_collection.d.ts b/dist/ota_collections/ota_collection.d.ts new file mode 100644 index 00000000..8da5f014 --- /dev/null +++ b/dist/ota_collections/ota_collection.d.ts @@ -0,0 +1,8 @@ +import { BaseCollection } from "../collections/base_collection.js"; +import { ApiError } from "../models/api_error.js"; +import { Keyable } from "../interfaces/keyable.js"; +export declare abstract class OtaCollection extends BaseCollection { + protected populateApiErrorFromJson(json: any): ApiError; + protected doDelete(id: string | number, req_params?: Keyable): Promise; + protected returnJSONFromData(json: Keyable): Keyable | Array; +} diff --git a/dist/ota_collections/ota_collection.js b/dist/ota_collections/ota_collection.js new file mode 100644 index 00000000..da4fa31b --- /dev/null +++ b/dist/ota_collections/ota_collection.js @@ -0,0 +1,17 @@ +import { BaseCollection } from "../collections/base_collection.js"; +export class OtaCollection extends BaseCollection { + populateApiErrorFromJson(json) { + return json; + } + doDelete(id, req_params = {}) { + const params = { + ...req_params, + id, + }; + return this.createPromise("DELETE", params, this.returnJSONFromData, this.handleReject, null); + } + returnJSONFromData(json) { + return json["data"]; + } +} +//# sourceMappingURL=ota_collection.js.map \ No newline at end of file diff --git a/dist/ota_collections/ota_collection.js.map b/dist/ota_collections/ota_collection.js.map new file mode 100644 index 00000000..ee98a331 --- /dev/null +++ b/dist/ota_collections/ota_collection.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_collection.js","sourceRoot":"","sources":["../../src/ota_collections/ota_collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInE,MAAM,OAAgB,aAAc,SAAQ,cAAc;IAC9C,wBAAwB,CAAC,IAAS;QAC1C,OAAiB,IAAI,CAAC;IACxB,CAAC;IAES,QAAQ,CAChB,EAAmB,EACnB,aAAsB,EAAE;QAExB,MAAM,MAAM,GAAG;YACb,GAAG,UAAU;YACb,EAAE;SACH,CAAC;QACF,OAAO,IAAI,CAAC,aAAa,CACvB,QAAQ,EACR,MAAM,EACN,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,YAAY,EACjB,IAAI,CACL,CAAC;IACJ,CAAC;IAES,kBAAkB,CAAC,IAAa;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;CACF"} \ No newline at end of file diff --git a/dist/ota_collections/ota_tokens.d.ts b/dist/ota_collections/ota_tokens.d.ts new file mode 100644 index 00000000..a285acae --- /dev/null +++ b/dist/ota_collections/ota_tokens.d.ts @@ -0,0 +1,10 @@ +import { OtaCollection } from "./ota_collection.js"; +import { OtaToken } from "../models/ota_token.js"; +import { OtaTeamProject } from "../interfaces/ota_team_project.js"; +export declare class OtaTokens extends OtaCollection { + protected static rootElementName: string; + protected static rootElementNameSingular: string; + protected static prefixURI: string; + protected static elementClass: typeof OtaToken; + list(request_params: OtaTeamProject): Promise; +} diff --git a/dist/ota_collections/ota_tokens.js b/dist/ota_collections/ota_tokens.js new file mode 100644 index 00000000..7c8993b6 --- /dev/null +++ b/dist/ota_collections/ota_tokens.js @@ -0,0 +1,12 @@ +import { OtaCollection } from "./ota_collection.js"; +import { OtaToken } from "../models/ota_token.js"; +export class OtaTokens extends OtaCollection { + static rootElementName = "data"; + static rootElementNameSingular = "data"; + static prefixURI = "teams/{!:teamId}/projects/{!:lokaliseProjectId}/tokens"; + static elementClass = OtaToken; + list(request_params) { + return this.doList(request_params); + } +} +//# sourceMappingURL=ota_tokens.js.map \ No newline at end of file diff --git a/dist/ota_collections/ota_tokens.js.map b/dist/ota_collections/ota_tokens.js.map new file mode 100644 index 00000000..b0747b14 --- /dev/null +++ b/dist/ota_collections/ota_tokens.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_tokens.js","sourceRoot":"","sources":["../../src/ota_collections/ota_tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,MAAM,OAAO,SAAU,SAAQ,aAAa;IAChC,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,uBAAuB,GAAG,MAAM,CAAC;IACxC,MAAM,CAAC,SAAS,GACxB,wDAAwD,CAAC;IACjD,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAC;IAEzC,IAAI,CAAC,cAA8B;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACrC,CAAC"} \ No newline at end of file diff --git a/dist/ota_collections/sdk_tokens.d.ts b/dist/ota_collections/sdk_tokens.d.ts new file mode 100644 index 00000000..11e14917 --- /dev/null +++ b/dist/ota_collections/sdk_tokens.d.ts @@ -0,0 +1,17 @@ +import { OtaCollection } from "./ota_collection.js"; +import { SdkToken } from "../models/sdk_token.js"; +import { OtaTeamProject } from "../interfaces/ota_team_project.js"; +type SdkTokenDeleted = { + id: number; + deleted: boolean; +}; +export declare class SdkTokens extends OtaCollection { + protected static rootElementName: string; + protected static rootElementNameSingular: string; + protected static prefixURI: string; + protected static elementClass: typeof SdkToken; + list(request_params: OtaTeamProject): Promise; + create(request_params: OtaTeamProject): Promise; + delete(tokenId: string | number, request_params: OtaTeamProject): Promise; +} +export {}; diff --git a/dist/ota_collections/sdk_tokens.js b/dist/ota_collections/sdk_tokens.js new file mode 100644 index 00000000..e9b5faeb --- /dev/null +++ b/dist/ota_collections/sdk_tokens.js @@ -0,0 +1,18 @@ +import { OtaCollection } from "./ota_collection.js"; +import { SdkToken } from "../models/sdk_token.js"; +export class SdkTokens extends OtaCollection { + static rootElementName = "data"; + static rootElementNameSingular = "data"; + static prefixURI = "teams/{!:teamId}/projects/{!:lokaliseProjectId}/tokens/{:id}"; + static elementClass = SdkToken; + list(request_params) { + return this.doList(request_params); + } + create(request_params) { + return this.doCreate(null, request_params, this.populateObjectFromJsonRoot); + } + delete(tokenId, request_params) { + return this.doDelete(tokenId, request_params); + } +} +//# sourceMappingURL=sdk_tokens.js.map \ No newline at end of file diff --git a/dist/ota_collections/sdk_tokens.js.map b/dist/ota_collections/sdk_tokens.js.map new file mode 100644 index 00000000..980bdc9e --- /dev/null +++ b/dist/ota_collections/sdk_tokens.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sdk_tokens.js","sourceRoot":"","sources":["../../src/ota_collections/sdk_tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAQlD,MAAM,OAAO,SAAU,SAAQ,aAAa;IAChC,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,uBAAuB,GAAG,MAAM,CAAC;IACxC,MAAM,CAAC,SAAS,GACxB,8DAA8D,CAAC;IACvD,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAC;IAEzC,IAAI,CAAC,cAA8B;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,cAA8B;QACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,CACJ,OAAwB,EACxB,cAA8B;QAE9B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f306bec2..fef66453 100644 --- a/package-lock.json +++ b/package-lock.json @@ -84,9 +84,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", - "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.7.0.tgz", + "integrity": "sha512-+HencqxU7CFJnQb7IKtuNBqS6Yx3Tz4kOL8BJXo+JyeiBm5MEX6pO8onXDkjrkCRlfYXS1Axro15ZjVFe9YgsA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -372,9 +372,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.1.tgz", - "integrity": "sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==", + "version": "20.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.2.tgz", + "integrity": "sha512-5j/lXt7unfPOUlrKC34HIaedONleyLtwkKggiD/0uuMfT8gg2EOpg0dz4lCD15Ga7muC+1WzJZAjIB9simWd6Q==", "dev": true }, "node_modules/@types/semver": { diff --git a/package.json b/package.json index feabadf1..2d7f94b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lokalise/node-api", - "version": "10.0.0", + "version": "11.0.0", "description": "Official Lokalise API 2.0 Node.js client", "license": "BSD-3-Clause", "type": "module", @@ -18,7 +18,7 @@ ], "scripts": { "build": "tsc", - "test": "tsc && c8 --reporter=lcov ts-mocha -n loader=ts-node/esm -p tsconfig.json --type-check test/**/*.spec.ts --timeout 10000" + "test": "tsc && c8 --reporter=lcov ts-mocha -n loader=ts-node/esm -p tsconfig.json --type-check test/ota/ota_tokens.spec.ts --timeout 10000" }, "devDependencies": { "@types/chai": "^4.2.22", diff --git a/src/collections/base_collection.ts b/src/collections/base_collection.ts index fbb5ab0f..2bded538 100644 --- a/src/collections/base_collection.ts +++ b/src/collections/base_collection.ts @@ -195,17 +195,8 @@ export abstract class BaseCollection { body: object | object[] | null, uri: string | null = null, ): Promise { - const childClass = this.constructor; - if (!uri) { - uri = childClass.prefixURI; - } - const request: ApiRequest = new ApiRequest( - uri, - method, - body, - params, - this.clientData, - ); + const request = this.prepareRequest(method, body, params, uri); + try { const data = await request.promise; return Promise.resolve( @@ -216,6 +207,30 @@ export abstract class BaseCollection { } } + protected prepareRequest( + method: Options["method"], + body: object | object[] | null, + params: Keyable, + uri: string | null = null, + ): ApiRequest { + return new ApiRequest( + this.getUri(uri), + method, + body, + params, + this.clientData, + ); + } + + protected getUri(uri: string | null): string { + const childClass = this.constructor; + if (!uri) { + uri = childClass.prefixURI; + } + + return uri; + } + protected objToArray(raw_body: Keyable | Keyable[]): Array { if (!Array.isArray(raw_body)) { return Array(raw_body); diff --git a/src/http_client/base.ts b/src/http_client/base.ts index a4f17459..043dbf2d 100644 --- a/src/http_client/base.ts +++ b/src/http_client/base.ts @@ -6,7 +6,7 @@ import { LokalisePkg } from "../lokalise/pkg.js"; export class ApiRequest { public promise: Promise; public params: WritableKeyable = {}; - private readonly urlRoot: NonNullable = + protected readonly urlRoot: NonNullable = "https://api.lokalise.com/api2/"; constructor( @@ -60,8 +60,9 @@ export class ApiRequest { try { const response = await got(undefined, undefined, options); const responseJSON = JSON.parse(response.body); + if (response.statusCode > 399) { - return Promise.reject(responseJSON["error"] || responseJSON); + return Promise.reject(this.getErrorFromResp(responseJSON)); } return Promise.resolve({ json: responseJSON, headers: response.headers }); /* c8 ignore next 4 */ @@ -70,6 +71,14 @@ export class ApiRequest { } } + protected getErrorFromResp(respJson: any): any { + if (typeof respJson["error"] === "object") { + return respJson["error"]; + } else { + return respJson; + } + } + protected composeURI(rawUri: string): string { const regexp = /{(!{0,1}):(\w*)}/g; const uri = rawUri.replace(regexp, this.mapUriParams()); diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 575be79b..055fbb2c 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -24,6 +24,7 @@ export { ProjectSettings } from "./project_settings.js"; export { ProjectStatistics } from "./project_statistics.js"; export { ProjectWithPagination } from "./project_with_pagination.js"; export { Project } from "./project.js"; +export { SdkToken } from "./sdk_token.js"; export { QueuedProcess } from "./queued_process.js"; export { RefreshTokenResponse } from "./refresh_token_response.js"; export { RequestTokenResponse } from "./request_token_response.js"; diff --git a/src/interfaces/ota_api_error.ts b/src/interfaces/ota_api_error.ts new file mode 100644 index 00000000..ca99a3ba --- /dev/null +++ b/src/interfaces/ota_api_error.ts @@ -0,0 +1,5 @@ +export interface OtaApiError { + statusCode: string; + message: string; + error: string; +} diff --git a/src/interfaces/ota_team_project.ts b/src/interfaces/ota_team_project.ts new file mode 100644 index 00000000..2c31478c --- /dev/null +++ b/src/interfaces/ota_team_project.ts @@ -0,0 +1,4 @@ +export interface OtaTeamProject { + teamId: number | string; + lokaliseProjectId: string; +} diff --git a/src/interfaces/sdk_token.ts b/src/interfaces/sdk_token.ts new file mode 100644 index 00000000..25545c24 --- /dev/null +++ b/src/interfaces/sdk_token.ts @@ -0,0 +1,7 @@ +export interface SdkToken { + id: number; + token: string; + projectId: number; + lokaliseId: number; + createdAt: string; +} diff --git a/src/lokalise/lokalise_api_ota.ts b/src/lokalise/lokalise_api_ota.ts new file mode 100644 index 00000000..6600d600 --- /dev/null +++ b/src/lokalise/lokalise_api_ota.ts @@ -0,0 +1,15 @@ +import { ClientParams } from "./lokalise_api.js"; +import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { SdkTokens } from "../ota_collections/sdk_tokens.js"; + +export class LokaliseApiOta extends LokaliseApiOAuth { + constructor(params: ClientParams) { + super(params); + this.clientData.host = + this.clientData.host ?? "https://ota.lokalise.com/v3"; + } + + sdkTokens(): SdkTokens { + return new SdkTokens(this.clientData); + } +} diff --git a/src/models/ota_api_error.ts b/src/models/ota_api_error.ts new file mode 100644 index 00000000..0b73e79a --- /dev/null +++ b/src/models/ota_api_error.ts @@ -0,0 +1,8 @@ +import { OtaApiError as OtaApiErrorInterface } from "../interfaces/ota_api_error.js"; +import { BaseModel } from "./base_model.js"; + +export class OtaApiError extends BaseModel implements OtaApiErrorInterface { + declare statusCode: string; + declare message: string; + declare error: string; +} diff --git a/src/models/sdk_token.ts b/src/models/sdk_token.ts new file mode 100644 index 00000000..966140d1 --- /dev/null +++ b/src/models/sdk_token.ts @@ -0,0 +1,10 @@ +import { BaseModel } from "./base_model.js"; +import { SdkToken as SdkTokenInterface } from "../interfaces/sdk_token.js"; + +export class SdkToken extends BaseModel implements SdkTokenInterface { + declare id: number; + declare token: string; + declare projectId: number; + declare lokaliseId: number; + declare createdAt: string; +} diff --git a/src/ota_collections/ota_collection.ts b/src/ota_collections/ota_collection.ts new file mode 100644 index 00000000..996b659b --- /dev/null +++ b/src/ota_collections/ota_collection.ts @@ -0,0 +1,30 @@ +import { BaseCollection } from "../collections/base_collection.js"; +import { ApiError } from "../models/api_error.js"; +import { Keyable } from "../interfaces/keyable.js"; + +export abstract class OtaCollection extends BaseCollection { + protected populateApiErrorFromJson(json: any): ApiError { + return json; + } + + protected doDelete( + id: string | number, + req_params: Keyable = {}, + ): Promise { + const params = { + ...req_params, + id, + }; + return this.createPromise( + "DELETE", + params, + this.returnJSONFromData, + this.handleReject, + null, + ); + } + + protected returnJSONFromData(json: Keyable): Keyable | Array { + return json["data"]; + } +} diff --git a/src/ota_collections/sdk_tokens.ts b/src/ota_collections/sdk_tokens.ts new file mode 100644 index 00000000..ff07bc61 --- /dev/null +++ b/src/ota_collections/sdk_tokens.ts @@ -0,0 +1,31 @@ +import { OtaCollection } from "./ota_collection.js"; +import { SdkToken } from "../models/sdk_token.js"; +import { OtaTeamProject } from "../interfaces/ota_team_project.js"; + +type SdkTokenDeleted = { + id: number; + deleted: boolean; +}; + +export class SdkTokens extends OtaCollection { + protected static rootElementName = "data"; + protected static rootElementNameSingular = "data"; + protected static prefixURI = + "teams/{!:teamId}/projects/{!:lokaliseProjectId}/tokens/{:id}"; + protected static elementClass = SdkToken; + + list(request_params: OtaTeamProject): Promise { + return this.doList(request_params); + } + + create(request_params: OtaTeamProject): Promise { + return this.doCreate(null, request_params, this.populateObjectFromJsonRoot); + } + + delete( + tokenId: string | number, + request_params: OtaTeamProject, + ): Promise { + return this.doDelete(tokenId, request_params); + } +} diff --git a/test/cassettes/SdkTokens create.cassette b/test/cassettes/SdkTokens create.cassette new file mode 100644 index 00000000..a52c7722 --- /dev/null +++ b/test/cassettes/SdkTokens create.cassette @@ -0,0 +1,67 @@ +[ + { + "scope": "https://ota.lokalise.com:443", + "method": "POST", + "path": "/v3/teams/176692/projects/963054665b7c313dd9b323.35886655/tokens", + "body": "", + "status": 200, + "response": { + "data": { + "id": 9433, + "token": "c72f9bf9f88e0779275d4832ca0e56933a89", + "projectId": 20984, + "lokaliseId": null, + "createdAt": "2023-08-22T15:05:51.227Z" + } + }, + "rawHeaders": [ + "Date", + "Tue, 22 Aug 2023 15:05:51 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "142", + "Connection", + "close", + "Content-Security-Policy", + "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", + "Cross-Origin-Embedder-Policy", + "require-corp", + "Cross-Origin-Opener-Policy", + "same-origin", + "Cross-Origin-Resource-Policy", + "same-origin", + "X-DNS-Prefetch-Control", + "off", + "X-Frame-Options", + "SAMEORIGIN", + "Strict-Transport-Security", + "max-age=15552000; includeSubDomains", + "X-Download-Options", + "noopen", + "X-Content-Type-Options", + "nosniff", + "Origin-Agent-Cluster", + "?1", + "X-Permitted-Cross-Domain-Policies", + "none", + "Referrer-Policy", + "no-referrer", + "X-XSS-Protection", + "0", + "x-request-id", + "e08cd5502e3a6234267608c8d3db4d00", + "Access-Control-Allow-Origin", + "*", + "Access-Control-Allow-Credentials", + "true", + "Access-Control-Allow-Methods", + "GET, PUT, POST, DELETE, PATCH, OPTIONS", + "Access-Control-Allow-Headers", + "x-lokalise-api-key,x-lokalise-project-id,x-lokalise-device-language,x-lokalise-app-language,x-lokalise-sdk-build,x-lokalise-app-build,x-lokalise-uid,x-lokalise-prerelease,x-lokalise-current-bundle,x-ota-api-token,x-request-id,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization", + "Access-Control-Max-Age", + "1728000" + ], + "responseIsBinary": false + } +] \ No newline at end of file diff --git a/test/cassettes/SdkTokens delete.cassette b/test/cassettes/SdkTokens delete.cassette new file mode 100644 index 00000000..f55716f6 --- /dev/null +++ b/test/cassettes/SdkTokens delete.cassette @@ -0,0 +1,64 @@ +[ + { + "scope": "https://ota.lokalise.com:443", + "method": "DELETE", + "path": "/v3/teams/176692/projects/963054665b7c313dd9b323.35886655/tokens/9428", + "body": "", + "status": 200, + "response": { + "data": { + "id": 9428, + "deleted": true + } + }, + "rawHeaders": [ + "Date", + "Tue, 22 Aug 2023 17:56:01 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "35", + "Connection", + "close", + "Content-Security-Policy", + "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", + "Cross-Origin-Embedder-Policy", + "require-corp", + "Cross-Origin-Opener-Policy", + "same-origin", + "Cross-Origin-Resource-Policy", + "same-origin", + "X-DNS-Prefetch-Control", + "off", + "X-Frame-Options", + "SAMEORIGIN", + "Strict-Transport-Security", + "max-age=15552000; includeSubDomains", + "X-Download-Options", + "noopen", + "X-Content-Type-Options", + "nosniff", + "Origin-Agent-Cluster", + "?1", + "X-Permitted-Cross-Domain-Policies", + "none", + "Referrer-Policy", + "no-referrer", + "X-XSS-Protection", + "0", + "x-request-id", + "4013fa21b01681ac67ada1ca03333c88", + "Access-Control-Allow-Origin", + "*", + "Access-Control-Allow-Credentials", + "true", + "Access-Control-Allow-Methods", + "GET, PUT, POST, DELETE, PATCH, OPTIONS", + "Access-Control-Allow-Headers", + "x-lokalise-api-key,x-lokalise-project-id,x-lokalise-device-language,x-lokalise-app-language,x-lokalise-sdk-build,x-lokalise-app-build,x-lokalise-uid,x-lokalise-prerelease,x-lokalise-current-bundle,x-ota-api-token,x-request-id,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization", + "Access-Control-Max-Age", + "1728000" + ], + "responseIsBinary": false + } +] \ No newline at end of file diff --git a/test/cassettes/SdkTokens error.cassette b/test/cassettes/SdkTokens error.cassette new file mode 100644 index 00000000..4f6f0aac --- /dev/null +++ b/test/cassettes/SdkTokens error.cassette @@ -0,0 +1,63 @@ +[ + { + "scope": "https://ota.lokalise.com:443", + "method": "GET", + "path": "/v3/teams/176692/projects/fake/tokens", + "body": "", + "status": 404, + "response": { + "message": "Project not found", + "statusCode": 404, + "error": "ENTITY_NOT_FOUND" + }, + "rawHeaders": [ + "Date", + "Tue, 22 Aug 2023 14:48:54 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "75", + "Connection", + "close", + "Content-Security-Policy", + "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", + "Cross-Origin-Embedder-Policy", + "require-corp", + "Cross-Origin-Opener-Policy", + "same-origin", + "Cross-Origin-Resource-Policy", + "same-origin", + "X-DNS-Prefetch-Control", + "off", + "X-Frame-Options", + "SAMEORIGIN", + "Strict-Transport-Security", + "max-age=15552000; includeSubDomains", + "X-Download-Options", + "noopen", + "X-Content-Type-Options", + "nosniff", + "Origin-Agent-Cluster", + "?1", + "X-Permitted-Cross-Domain-Policies", + "none", + "Referrer-Policy", + "no-referrer", + "X-XSS-Protection", + "0", + "x-request-id", + "6280966225bf6b88554fd0fa0f40e515", + "Access-Control-Allow-Origin", + "*", + "Access-Control-Allow-Credentials", + "true", + "Access-Control-Allow-Methods", + "GET, PUT, POST, DELETE, PATCH, OPTIONS", + "Access-Control-Allow-Headers", + "x-lokalise-api-key,x-lokalise-project-id,x-lokalise-device-language,x-lokalise-app-language,x-lokalise-sdk-build,x-lokalise-app-build,x-lokalise-uid,x-lokalise-prerelease,x-lokalise-current-bundle,x-ota-api-token,x-request-id,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization", + "Access-Control-Max-Age", + "1728000" + ], + "responseIsBinary": false + } +] \ No newline at end of file diff --git a/test/cassettes/SdkTokens list.cassette b/test/cassettes/SdkTokens list.cassette new file mode 100644 index 00000000..052ea645 --- /dev/null +++ b/test/cassettes/SdkTokens list.cassette @@ -0,0 +1,83 @@ +[ + { + "scope": "https://ota.lokalise.com:443", + "method": "GET", + "path": "/v3/teams/176692/projects/963054665b7c313dd9b323.35886655/tokens", + "body": "", + "status": 200, + "response": { + "data": [ + { + "id": 9428, + "token": "a952aac5c1a5811618253acd7c935582596e", + "projectId": 20984, + "lokaliseId": null, + "createdAt": "2023-08-22T14:21:25.643Z" + }, + { + "id": 9429, + "token": "8531fd155d5ac3c76564f4a22dbada4f0a6f", + "projectId": 20984, + "lokaliseId": null, + "createdAt": "2023-08-22T14:21:26.883Z" + }, + { + "id": 9430, + "token": "f9de1558a5b41416e6f96b40dc1c2e348cd5", + "projectId": 20984, + "lokaliseId": null, + "createdAt": "2023-08-22T14:21:28.473Z" + } + ] + }, + "rawHeaders": [ + "Date", + "Tue, 22 Aug 2023 14:39:07 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "412", + "Connection", + "close", + "Content-Security-Policy", + "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", + "Cross-Origin-Embedder-Policy", + "require-corp", + "Cross-Origin-Opener-Policy", + "same-origin", + "Cross-Origin-Resource-Policy", + "same-origin", + "X-DNS-Prefetch-Control", + "off", + "X-Frame-Options", + "SAMEORIGIN", + "Strict-Transport-Security", + "max-age=15552000; includeSubDomains", + "X-Download-Options", + "noopen", + "X-Content-Type-Options", + "nosniff", + "Origin-Agent-Cluster", + "?1", + "X-Permitted-Cross-Domain-Policies", + "none", + "Referrer-Policy", + "no-referrer", + "X-XSS-Protection", + "0", + "x-request-id", + "4bbfefec7c0b88ca28b4f1c3d3d0ccd6", + "Access-Control-Allow-Origin", + "*", + "Access-Control-Allow-Credentials", + "true", + "Access-Control-Allow-Methods", + "GET, PUT, POST, DELETE, PATCH, OPTIONS", + "Access-Control-Allow-Headers", + "x-lokalise-api-key,x-lokalise-project-id,x-lokalise-device-language,x-lokalise-app-language,x-lokalise-sdk-build,x-lokalise-app-build,x-lokalise-uid,x-lokalise-prerelease,x-lokalise-current-bundle,x-ota-api-token,x-request-id,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization", + "Access-Control-Max-Age", + "1728000" + ], + "responseIsBinary": false + } +] \ No newline at end of file diff --git a/test/ota/ota_tokens.spec.ts b/test/ota/ota_tokens.spec.ts new file mode 100644 index 00000000..50db9126 --- /dev/null +++ b/test/ota/ota_tokens.spec.ts @@ -0,0 +1,68 @@ +import "../setup.js"; +import { expect } from "chai"; +import { Cassettes } from "mocha-cassettes"; +import { LokaliseApiOta } from "../../src/lokalise/lokalise_api_ota.js"; +import { OtaApiError } from "../../src/models/ota_api_error.js"; + +describe("SdkTokens", function () { + const cassette = new Cassettes("./test/cassettes"); + const lokaliseApiOta = new LokaliseApiOta({ apiKey: process.env.API_JWT }); + const teamId = 176692; + const projectId = "963054665b7c313dd9b323.35886655"; + const tokenId = 9428; + + cassette + .createTest("error", async () => { + await lokaliseApiOta + .sdkTokens() + .list({ + teamId: teamId, + lokaliseProjectId: "fake", + }) + .catch((e: OtaApiError) => { + expect(e.message).to.eq("Project not found"); + expect(e.statusCode).to.eq(404); + expect(e.error).to.eq("ENTITY_NOT_FOUND"); + }); + }) + .register(this); + + cassette + .createTest("list", async () => { + const tokens = await lokaliseApiOta.sdkTokens().list({ + teamId: teamId, + lokaliseProjectId: projectId, + }); + + expect(tokens[0].id).to.eq(tokenId); + expect(tokens.length).to.eq(3); + }) + .register(this); + + cassette + .createTest("create", async () => { + const token = await lokaliseApiOta.sdkTokens().create({ + teamId: teamId, + lokaliseProjectId: projectId, + }); + + expect(token.id).to.eq(9433); + expect(token.token).to.eq("c72f9bf9f88e0779275d4832ca0e56933a89"); + expect(token.projectId).to.eq(20984); + expect(token.lokaliseId).to.eq(null); + expect(token.createdAt).to.eq("2023-08-22T15:05:51.227Z"); + }) + .register(this); + + cassette + .createTest("delete", async () => { + const response = await lokaliseApiOta.sdkTokens().delete(tokenId, { + teamId: teamId, + lokaliseProjectId: projectId, + }); + + expect(response.id).to.eq(tokenId); + expect(response.deleted).to.be.true; + }) + .register(this); +}); From f61209cd69afcea205f28614a42d2be83fdd6cd7 Mon Sep 17 00:00:00 2001 From: bodrovis Date: Tue, 22 Aug 2023 21:43:55 +0300 Subject: [PATCH 2/6] ota bundles --- .github/workflows/ci.yml | 2 + dist/interfaces/ota_bundle.d.ts | 4 ++ dist/interfaces/ota_bundle.js | 2 + dist/interfaces/ota_bundle.js.map | 1 + dist/lokalise/lokalise_api_ota.d.ts | 5 +- dist/lokalise/lokalise_api_ota.js | 6 +- dist/lokalise/lokalise_api_ota.js.map | 2 +- dist/lokalise/lokalise_ota_bundles.d.ts | 6 ++ dist/lokalise/lokalise_ota_bundles.js | 14 +++++ dist/lokalise/lokalise_ota_bundles.js.map | 1 + dist/main.d.ts | 4 +- dist/main.js | 4 +- dist/main.js.map | 2 +- dist/models/ota_bundle.d.ts | 6 ++ dist/models/ota_bundle.js | 4 ++ dist/models/ota_bundle.js.map | 1 + dist/ota_collections/ota_bundles.d.ts | 18 ++++++ dist/ota_collections/ota_bundles.js | 15 +++++ dist/ota_collections/ota_bundles.js.map | 1 + package.json | 2 +- src/interfaces/ota_bundle.ts | 4 ++ src/lokalise/lokalise_api_ota.ts | 10 +++- src/lokalise/lokalise_ota_bundles.ts | 16 ++++++ src/main.ts | 10 +++- src/models/ota_bundle.ts | 7 +++ src/ota_collections/ota_bundles.ts | 38 +++++++++++++ test/cassettes/SdkTokens get.cassette | 64 ++++++++++++++++++++++ test/lokalise/lokalise_api_ota.spec.ts | 30 ++++++++++ test/lokalise/lokalise_ota_bundles.spec.ts | 23 ++++++++ test/ota/ota_bundles.spec.ts | 30 ++++++++++ test/ota/ota_tokens.spec.ts | 2 +- 31 files changed, 319 insertions(+), 15 deletions(-) create mode 100644 dist/interfaces/ota_bundle.d.ts create mode 100644 dist/interfaces/ota_bundle.js create mode 100644 dist/interfaces/ota_bundle.js.map create mode 100644 dist/lokalise/lokalise_ota_bundles.d.ts create mode 100644 dist/lokalise/lokalise_ota_bundles.js create mode 100644 dist/lokalise/lokalise_ota_bundles.js.map create mode 100644 dist/models/ota_bundle.d.ts create mode 100644 dist/models/ota_bundle.js create mode 100644 dist/models/ota_bundle.js.map create mode 100644 dist/ota_collections/ota_bundles.d.ts create mode 100644 dist/ota_collections/ota_bundles.js create mode 100644 dist/ota_collections/ota_bundles.js.map create mode 100644 src/interfaces/ota_bundle.ts create mode 100644 src/lokalise/lokalise_ota_bundles.ts create mode 100644 src/models/ota_bundle.ts create mode 100644 src/ota_collections/ota_bundles.ts create mode 100644 test/cassettes/SdkTokens get.cassette create mode 100644 test/lokalise/lokalise_api_ota.spec.ts create mode 100644 test/lokalise/lokalise_ota_bundles.spec.ts create mode 100644 test/ota/ota_bundles.spec.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2bb6245..6f7608e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,8 @@ jobs: env: API_KEY: 123abc OAUTH2_ACCESS_TOKEN: fake + API_JWT: fake + SDK_TOKEN: fake steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/dist/interfaces/ota_bundle.d.ts b/dist/interfaces/ota_bundle.d.ts new file mode 100644 index 00000000..a95baa23 --- /dev/null +++ b/dist/interfaces/ota_bundle.d.ts @@ -0,0 +1,4 @@ +export interface OtaBundle { + url: string; + version: number; +} diff --git a/dist/interfaces/ota_bundle.js b/dist/interfaces/ota_bundle.js new file mode 100644 index 00000000..09d195d5 --- /dev/null +++ b/dist/interfaces/ota_bundle.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ota_bundle.js.map \ No newline at end of file diff --git a/dist/interfaces/ota_bundle.js.map b/dist/interfaces/ota_bundle.js.map new file mode 100644 index 00000000..f1b12513 --- /dev/null +++ b/dist/interfaces/ota_bundle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_bundle.js","sourceRoot":"","sources":["../../src/interfaces/ota_bundle.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lokalise/lokalise_api_ota.d.ts b/dist/lokalise/lokalise_api_ota.d.ts index 8a64076a..97dd628e 100644 --- a/dist/lokalise/lokalise_api_ota.d.ts +++ b/dist/lokalise/lokalise_api_ota.d.ts @@ -1,7 +1,6 @@ -import { ClientParams } from "./lokalise_api.js"; -import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { BaseClient, ClientParams } from "./base_client.js"; import { SdkTokens } from "../ota_collections/sdk_tokens.js"; -export declare class LokaliseApiOta extends LokaliseApiOAuth { +export declare class LokaliseApiOta extends BaseClient { constructor(params: ClientParams); sdkTokens(): SdkTokens; } diff --git a/dist/lokalise/lokalise_api_ota.js b/dist/lokalise/lokalise_api_ota.js index d70d52c9..904f28c4 100644 --- a/dist/lokalise/lokalise_api_ota.js +++ b/dist/lokalise/lokalise_api_ota.js @@ -1,8 +1,10 @@ -import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { BaseClient } from "./base_client.js"; import { SdkTokens } from "../ota_collections/sdk_tokens.js"; -export class LokaliseApiOta extends LokaliseApiOAuth { +export class LokaliseApiOta extends BaseClient { constructor(params) { super(params); + this.clientData.tokenType = params["tokenType"] ?? "Bearer"; + this.clientData.authHeader = "Authorization"; this.clientData.host = this.clientData.host ?? "https://ota.lokalise.com/v3"; } diff --git a/dist/lokalise/lokalise_api_ota.js.map b/dist/lokalise/lokalise_api_ota.js.map index 3baae795..54213e72 100644 --- a/dist/lokalise/lokalise_api_ota.js.map +++ b/dist/lokalise/lokalise_api_ota.js.map @@ -1 +1 @@ -{"version":3,"file":"lokalise_api_ota.js","sourceRoot":"","sources":["../../src/lokalise/lokalise_api_ota.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAClD,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,UAAU,CAAC,IAAI;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,6BAA6B,CAAC;IAC1D,CAAC;IAED,SAAS;QACP,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"lokalise_api_ota.js","sourceRoot":"","sources":["../../src/lokalise/lokalise_api_ota.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC;QAE5D,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,eAAe,CAAC;QAE7C,IAAI,CAAC,UAAU,CAAC,IAAI;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,6BAA6B,CAAC;IAC1D,CAAC;IAED,SAAS;QACP,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"} \ No newline at end of file diff --git a/dist/lokalise/lokalise_ota_bundles.d.ts b/dist/lokalise/lokalise_ota_bundles.d.ts new file mode 100644 index 00000000..3ce99577 --- /dev/null +++ b/dist/lokalise/lokalise_ota_bundles.d.ts @@ -0,0 +1,6 @@ +import { BaseClient, ClientParams } from "./base_client.js"; +import { OtaBundles } from "../ota_collections/ota_bundles.js"; +export declare class LokaliseOtaBundles extends BaseClient { + constructor(params: ClientParams); + otaBundles(): OtaBundles; +} diff --git a/dist/lokalise/lokalise_ota_bundles.js b/dist/lokalise/lokalise_ota_bundles.js new file mode 100644 index 00000000..13adfca6 --- /dev/null +++ b/dist/lokalise/lokalise_ota_bundles.js @@ -0,0 +1,14 @@ +import { BaseClient } from "./base_client.js"; +import { OtaBundles } from "../ota_collections/ota_bundles.js"; +export class LokaliseOtaBundles extends BaseClient { + constructor(params) { + super(params); + this.clientData.authHeader = "x-ota-api-token"; + this.clientData.host = + this.clientData.host ?? "https://ota.lokalise.com/v3"; + } + otaBundles() { + return new OtaBundles(this.clientData); + } +} +//# sourceMappingURL=lokalise_ota_bundles.js.map \ No newline at end of file diff --git a/dist/lokalise/lokalise_ota_bundles.js.map b/dist/lokalise/lokalise_ota_bundles.js.map new file mode 100644 index 00000000..71ddf9dc --- /dev/null +++ b/dist/lokalise/lokalise_ota_bundles.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lokalise_ota_bundles.js","sourceRoot":"","sources":["../../src/lokalise/lokalise_ota_bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAChD,YAAY,MAAoB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,iBAAiB,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,IAAI;YAClB,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,6BAA6B,CAAC;IAC1D,CAAC;IAED,UAAU;QACR,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACF"} \ No newline at end of file diff --git a/dist/main.d.ts b/dist/main.d.ts index 36577fdc..3b093259 100644 --- a/dist/main.d.ts +++ b/dist/main.d.ts @@ -1,6 +1,8 @@ import { LokaliseApi } from "./lokalise/lokalise_api.js"; import { LokaliseApiOAuth } from "./lokalise/lokalise_api_oauth.js"; +import { LokaliseApiOta } from "./lokalise/lokalise_api_ota.js"; +import { LokaliseOtaBundles } from "./lokalise/lokalise_ota_bundles.js"; import { LokaliseAuth } from "./oauth2/lokalise_auth.js"; -export { LokaliseApi, LokaliseAuth, LokaliseApiOAuth }; +export { LokaliseApi, LokaliseAuth, LokaliseApiOAuth, LokaliseApiOta, LokaliseOtaBundles, }; export * from "./interfaces/index.js"; export * from "./types/index.js"; diff --git a/dist/main.js b/dist/main.js index b211fca6..12506560 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1,7 +1,9 @@ import { LokaliseApi } from "./lokalise/lokalise_api.js"; import { LokaliseApiOAuth } from "./lokalise/lokalise_api_oauth.js"; +import { LokaliseApiOta } from "./lokalise/lokalise_api_ota.js"; +import { LokaliseOtaBundles } from "./lokalise/lokalise_ota_bundles.js"; import { LokaliseAuth } from "./oauth2/lokalise_auth.js"; -export { LokaliseApi, LokaliseAuth, LokaliseApiOAuth }; +export { LokaliseApi, LokaliseAuth, LokaliseApiOAuth, LokaliseApiOta, LokaliseOtaBundles, }; export * from "./interfaces/index.js"; export * from "./types/index.js"; //# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/dist/main.js.map b/dist/main.js.map index 5e5bfa83..0aacd5c9 100644 --- a/dist/main.js.map +++ b/dist/main.js.map @@ -1 +1 @@ -{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AACvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"} \ No newline at end of file +{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,kBAAkB,GACnB,CAAC;AACF,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"} \ No newline at end of file diff --git a/dist/models/ota_bundle.d.ts b/dist/models/ota_bundle.d.ts new file mode 100644 index 00000000..c95aa54f --- /dev/null +++ b/dist/models/ota_bundle.d.ts @@ -0,0 +1,6 @@ +import { OtaBundle as OtaBundleInterface } from "../interfaces/ota_bundle.js"; +import { BaseModel } from "./base_model.js"; +export declare class OtaBundle extends BaseModel implements OtaBundleInterface { + url: string; + version: number; +} diff --git a/dist/models/ota_bundle.js b/dist/models/ota_bundle.js new file mode 100644 index 00000000..805db701 --- /dev/null +++ b/dist/models/ota_bundle.js @@ -0,0 +1,4 @@ +import { BaseModel } from "./base_model.js"; +export class OtaBundle extends BaseModel { +} +//# sourceMappingURL=ota_bundle.js.map \ No newline at end of file diff --git a/dist/models/ota_bundle.js.map b/dist/models/ota_bundle.js.map new file mode 100644 index 00000000..31146cd1 --- /dev/null +++ b/dist/models/ota_bundle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_bundle.js","sourceRoot":"","sources":["../../src/models/ota_bundle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,SAAU,SAAQ,SAAS;CAGvC"} \ No newline at end of file diff --git a/dist/ota_collections/ota_bundles.d.ts b/dist/ota_collections/ota_bundles.d.ts new file mode 100644 index 00000000..227d9a4c --- /dev/null +++ b/dist/ota_collections/ota_bundles.d.ts @@ -0,0 +1,18 @@ +import { OtaCollection } from "./ota_collection.js"; +import { OtaBundle } from "../models/ota_bundle.js"; +type RequestBundleParams = { + appVersion: string; + transVersion: number; + prerelease?: boolean; +}; +type OtaProjectFramework = { + lokaliseProjectId: string; + framework: "ios_sdk" | "android_sdk" | "flutter_sdk"; +}; +export declare class OtaBundles extends OtaCollection { + protected static rootElementNameSingular: string; + protected static prefixURI: string; + protected static elementClass: typeof OtaBundle; + get(bundle_params: RequestBundleParams, request_params: OtaProjectFramework): Promise; +} +export {}; diff --git a/dist/ota_collections/ota_bundles.js b/dist/ota_collections/ota_bundles.js new file mode 100644 index 00000000..8cc50a2b --- /dev/null +++ b/dist/ota_collections/ota_bundles.js @@ -0,0 +1,15 @@ +import { OtaCollection } from "./ota_collection.js"; +import { OtaBundle } from "../models/ota_bundle.js"; +export class OtaBundles extends OtaCollection { + static rootElementNameSingular = "data"; + static prefixURI = "lokalise/projects/{!:lokaliseProjectId}/frameworks/{!:framework}"; + static elementClass = OtaBundle; + get(bundle_params, request_params) { + const params = { + ...request_params, + ...bundle_params, + }; + return this.createPromise("GET", params, this.populateObjectFromJsonRoot, this.handleReject, null); + } +} +//# sourceMappingURL=ota_bundles.js.map \ No newline at end of file diff --git a/dist/ota_collections/ota_bundles.js.map b/dist/ota_collections/ota_bundles.js.map new file mode 100644 index 00000000..9c3f1693 --- /dev/null +++ b/dist/ota_collections/ota_bundles.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ota_bundles.js","sourceRoot":"","sources":["../../src/ota_collections/ota_bundles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAapD,MAAM,OAAO,UAAW,SAAQ,aAAa;IACjC,MAAM,CAAC,uBAAuB,GAAG,MAAM,CAAC;IACxC,MAAM,CAAC,SAAS,GACxB,kEAAkE,CAAC;IAC3D,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC;IAE1C,GAAG,CACD,aAAkC,EAClC,cAAmC;QAEnC,MAAM,MAAM,GAAG;YACb,GAAG,cAAc;YACjB,GAAG,aAAa;SACjB,CAAC;QAEF,OAAO,IAAI,CAAC,aAAa,CACvB,KAAK,EACL,MAAM,EACN,IAAI,CAAC,0BAA0B,EAC/B,IAAI,CAAC,YAAY,EACjB,IAAI,CACL,CAAC;IACJ,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 2d7f94b3..4c5f9113 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ ], "scripts": { "build": "tsc", - "test": "tsc && c8 --reporter=lcov ts-mocha -n loader=ts-node/esm -p tsconfig.json --type-check test/ota/ota_tokens.spec.ts --timeout 10000" + "test": "tsc && c8 --reporter=lcov ts-mocha -n loader=ts-node/esm -p tsconfig.json --type-check test/**/*.spec.ts --timeout 10000" }, "devDependencies": { "@types/chai": "^4.2.22", diff --git a/src/interfaces/ota_bundle.ts b/src/interfaces/ota_bundle.ts new file mode 100644 index 00000000..c5e6eab6 --- /dev/null +++ b/src/interfaces/ota_bundle.ts @@ -0,0 +1,4 @@ +export interface OtaBundle { + url: string; + version: number; +} diff --git a/src/lokalise/lokalise_api_ota.ts b/src/lokalise/lokalise_api_ota.ts index 6600d600..1382147a 100644 --- a/src/lokalise/lokalise_api_ota.ts +++ b/src/lokalise/lokalise_api_ota.ts @@ -1,10 +1,14 @@ -import { ClientParams } from "./lokalise_api.js"; -import { LokaliseApiOAuth } from "./lokalise_api_oauth.js"; +import { BaseClient, ClientParams } from "./base_client.js"; import { SdkTokens } from "../ota_collections/sdk_tokens.js"; -export class LokaliseApiOta extends LokaliseApiOAuth { +export class LokaliseApiOta extends BaseClient { constructor(params: ClientParams) { super(params); + + this.clientData.tokenType = params["tokenType"] ?? "Bearer"; + + this.clientData.authHeader = "Authorization"; + this.clientData.host = this.clientData.host ?? "https://ota.lokalise.com/v3"; } diff --git a/src/lokalise/lokalise_ota_bundles.ts b/src/lokalise/lokalise_ota_bundles.ts new file mode 100644 index 00000000..60f89728 --- /dev/null +++ b/src/lokalise/lokalise_ota_bundles.ts @@ -0,0 +1,16 @@ +import { BaseClient, ClientParams } from "./base_client.js"; +import { OtaBundles } from "../ota_collections/ota_bundles.js"; + +export class LokaliseOtaBundles extends BaseClient { + constructor(params: ClientParams) { + super(params); + + this.clientData.authHeader = "x-ota-api-token"; + this.clientData.host = + this.clientData.host ?? "https://ota.lokalise.com/v3"; + } + + otaBundles(): OtaBundles { + return new OtaBundles(this.clientData); + } +} diff --git a/src/main.ts b/src/main.ts index 36577fdc..fafdbe07 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,14 @@ import { LokaliseApi } from "./lokalise/lokalise_api.js"; import { LokaliseApiOAuth } from "./lokalise/lokalise_api_oauth.js"; +import { LokaliseApiOta } from "./lokalise/lokalise_api_ota.js"; +import { LokaliseOtaBundles } from "./lokalise/lokalise_ota_bundles.js"; import { LokaliseAuth } from "./oauth2/lokalise_auth.js"; -export { LokaliseApi, LokaliseAuth, LokaliseApiOAuth }; +export { + LokaliseApi, + LokaliseAuth, + LokaliseApiOAuth, + LokaliseApiOta, + LokaliseOtaBundles, +}; export * from "./interfaces/index.js"; export * from "./types/index.js"; diff --git a/src/models/ota_bundle.ts b/src/models/ota_bundle.ts new file mode 100644 index 00000000..1d6d8ab6 --- /dev/null +++ b/src/models/ota_bundle.ts @@ -0,0 +1,7 @@ +import { OtaBundle as OtaBundleInterface } from "../interfaces/ota_bundle.js"; +import { BaseModel } from "./base_model.js"; + +export class OtaBundle extends BaseModel implements OtaBundleInterface { + declare url: string; + declare version: number; +} diff --git a/src/ota_collections/ota_bundles.ts b/src/ota_collections/ota_bundles.ts new file mode 100644 index 00000000..39aa7fa0 --- /dev/null +++ b/src/ota_collections/ota_bundles.ts @@ -0,0 +1,38 @@ +import { OtaCollection } from "./ota_collection.js"; +import { OtaBundle } from "../models/ota_bundle.js"; + +type RequestBundleParams = { + appVersion: string; + transVersion: number; + prerelease?: boolean; +}; + +type OtaProjectFramework = { + lokaliseProjectId: string; + framework: "ios_sdk" | "android_sdk" | "flutter_sdk"; +}; + +export class OtaBundles extends OtaCollection { + protected static rootElementNameSingular = "data"; + protected static prefixURI = + "lokalise/projects/{!:lokaliseProjectId}/frameworks/{!:framework}"; + protected static elementClass = OtaBundle; + + get( + bundle_params: RequestBundleParams, + request_params: OtaProjectFramework, + ): Promise { + const params = { + ...request_params, + ...bundle_params, + }; + + return this.createPromise( + "GET", + params, + this.populateObjectFromJsonRoot, + this.handleReject, + null, + ); + } +} diff --git a/test/cassettes/SdkTokens get.cassette b/test/cassettes/SdkTokens get.cassette new file mode 100644 index 00000000..5185a6e9 --- /dev/null +++ b/test/cassettes/SdkTokens get.cassette @@ -0,0 +1,64 @@ +[ + { + "scope": "https://ota.lokalise.com:443", + "method": "GET", + "path": "/v3/lokalise/projects/963054665b7c313dd9b323.35886655/frameworks/ios_sdk?appVersion=1.2.3&transVersion=1", + "body": "", + "status": 200, + "response": { + "data": { + "url": "https://ota-bundles.lokalise.com/176692/963054665b7c313dd9b323.35886655/bundles/16622b76-2dff-4860-87be-78429058e866?Expires=1692814501&Key-Pair-Id=KKVN81V83VN6B&Signature=SQXTOqi3~azEsa2dBV1jl0GTtis1G5OLQBdgSTdJ1LFfN5oUhkY0qrdVikfFTGeParG8DxiJfj1gac-LPghu49uKl8UsRHY5CRftQ0iwuLhyeXMuslFEcmyps26LJpck7Dez0nu1KMJDfZKtOnYYuoHpzuk6K2kjPREVzIZ1hkpMLYfOQHqoMI9J09YVfU~ZYGyU7N4E4Ale0WQsDA3ZBmby-pB4c3R9T2wq6w642Yu0rjItLoycsQj-Jvw5RahgkjlOJ1794dmunK0WZU5FDScRgLpYyBu89df2s9-z6jKZsz5qUHW1OfAxKkpeaJj99kuOYburARws0GmUmj6QAw__", + "version": 664155 + } + }, + "rawHeaders": [ + "Date", + "Tue, 22 Aug 2023 18:30:04 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "552", + "Connection", + "close", + "Content-Security-Policy", + "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", + "Cross-Origin-Embedder-Policy", + "require-corp", + "Cross-Origin-Opener-Policy", + "same-origin", + "Cross-Origin-Resource-Policy", + "same-origin", + "X-DNS-Prefetch-Control", + "off", + "X-Frame-Options", + "SAMEORIGIN", + "Strict-Transport-Security", + "max-age=15552000; includeSubDomains", + "X-Download-Options", + "noopen", + "X-Content-Type-Options", + "nosniff", + "Origin-Agent-Cluster", + "?1", + "X-Permitted-Cross-Domain-Policies", + "none", + "Referrer-Policy", + "no-referrer", + "X-XSS-Protection", + "0", + "x-request-id", + "6bf818c2d505770506468eb2add6a61b", + "Access-Control-Allow-Origin", + "*", + "Access-Control-Allow-Credentials", + "true", + "Access-Control-Allow-Methods", + "GET, PUT, POST, DELETE, PATCH, OPTIONS", + "Access-Control-Allow-Headers", + "x-lokalise-api-key,x-lokalise-project-id,x-lokalise-device-language,x-lokalise-app-language,x-lokalise-sdk-build,x-lokalise-app-build,x-lokalise-uid,x-lokalise-prerelease,x-lokalise-current-bundle,x-ota-api-token,x-request-id,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization", + "Access-Control-Max-Age", + "1728000" + ], + "responseIsBinary": false + } +] \ No newline at end of file diff --git a/test/lokalise/lokalise_api_ota.spec.ts b/test/lokalise/lokalise_api_ota.spec.ts new file mode 100644 index 00000000..a8804232 --- /dev/null +++ b/test/lokalise/lokalise_api_ota.spec.ts @@ -0,0 +1,30 @@ +import "../setup.js"; +import { expect } from "chai"; +import { LokaliseApiOta } from "../../src/main.js"; + +describe("LokaliseApiOta", function () { + const token = "fake"; + + it("is expected to throw an error if the API key is not provided", function () { + expect(function () { + new LokaliseApiOta({ apiKey: "" }); + }).to.throw(Error); + }); + + it("is expected to contain clientData", function () { + const client = new LokaliseApiOta({ apiKey: token }); + expect(client.clientData.token).to.eq(token); + expect(client.clientData.tokenType).to.eq("Bearer"); + expect(client.clientData.authHeader).to.eq("Authorization"); + expect(client.clientData.enableCompression).to.be.false; + expect(client.clientData.host).to.eq("https://ota.lokalise.com/v3"); + }); + + it("allows to customize tokenType", function () { + const client = new LokaliseApiOta({ + apiKey: token, + tokenType: "Custom", + }); + expect(client.clientData.tokenType).to.eq("Custom"); + }); +}); diff --git a/test/lokalise/lokalise_ota_bundles.spec.ts b/test/lokalise/lokalise_ota_bundles.spec.ts new file mode 100644 index 00000000..62503c9a --- /dev/null +++ b/test/lokalise/lokalise_ota_bundles.spec.ts @@ -0,0 +1,23 @@ +import "../setup.js"; +import { expect } from "chai"; +import { LokaliseOtaBundles } from "../../src/main.js"; + +describe("LokaliseOtaBundles", function () { + const token = "fake"; + + it("is expected to throw an error if the API key is not provided", function () { + expect(function () { + new LokaliseOtaBundles({ apiKey: "" }); + }).to.throw(Error); + }); + + it("is expected to contain clientData", function () { + const client = new LokaliseOtaBundles({ apiKey: token }); + + expect(client.clientData.token).to.eq(token); + expect(client.clientData.tokenType).to.eq(""); + expect(client.clientData.authHeader).to.eq("x-ota-api-token"); + expect(client.clientData.enableCompression).to.be.false; + expect(client.clientData.host).to.eq("https://ota.lokalise.com/v3"); + }); +}); diff --git a/test/ota/ota_bundles.spec.ts b/test/ota/ota_bundles.spec.ts new file mode 100644 index 00000000..3792e940 --- /dev/null +++ b/test/ota/ota_bundles.spec.ts @@ -0,0 +1,30 @@ +import "../setup.js"; +import { expect } from "chai"; +import { Cassettes } from "mocha-cassettes"; +import { LokaliseOtaBundles } from "../../src/main.js"; + +describe("SdkTokens", function () { + const cassette = new Cassettes("./test/cassettes"); + const lokaliseOtaBundles = new LokaliseOtaBundles({ + apiKey: process.env.SDK_TOKEN, + }); + const projectId = "963054665b7c313dd9b323.35886655"; + + cassette + .createTest("get", async () => { + const bundle = await lokaliseOtaBundles.otaBundles().get( + { + appVersion: "1.2.3", + transVersion: 1, + }, + { + framework: "ios_sdk", + lokaliseProjectId: projectId, + }, + ); + + expect(bundle.url).to.include("ota-bundles.lokalise.com"); + expect(bundle.version).to.eq(664155); + }) + .register(this); +}); diff --git a/test/ota/ota_tokens.spec.ts b/test/ota/ota_tokens.spec.ts index 50db9126..b1ba3b1e 100644 --- a/test/ota/ota_tokens.spec.ts +++ b/test/ota/ota_tokens.spec.ts @@ -1,7 +1,7 @@ import "../setup.js"; import { expect } from "chai"; import { Cassettes } from "mocha-cassettes"; -import { LokaliseApiOta } from "../../src/lokalise/lokalise_api_ota.js"; +import { LokaliseApiOta } from "../../src/main.js"; import { OtaApiError } from "../../src/models/ota_api_error.js"; describe("SdkTokens", function () { From 77d878758697cc43ad39443a57a8ebcd59815f7e Mon Sep 17 00:00:00 2001 From: bodrovis Date: Tue, 22 Aug 2023 22:45:07 +0300 Subject: [PATCH 3/6] docs --- docs/Gemfile | 2 + docs/Gemfile.lock | 2 + docs/_data/ota_items.yml | 21 ++ docs/_includes/nav_ota.html | 21 ++ docs/_includes/nav_ota_full.html | 19 ++ docs/_layouts/default.html | 5 + docs/api/getting-started.md | 2 + docs/index.md | 6 + docs/ota/introduction.md | 101 ++++++++++ docs/ota/ota-bundles.md | 27 +++ docs/ota/sdk-tokens.md | 52 +++++ package-lock.json | 322 ++++++++++++++++++++++++++++++- package.json | 2 +- 13 files changed, 571 insertions(+), 11 deletions(-) create mode 100644 docs/_data/ota_items.yml create mode 100644 docs/_includes/nav_ota.html create mode 100644 docs/_includes/nav_ota_full.html create mode 100644 docs/ota/introduction.md create mode 100644 docs/ota/ota-bundles.md create mode 100644 docs/ota/sdk-tokens.md diff --git a/docs/Gemfile b/docs/Gemfile index 363205c3..838a82b8 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -35,3 +35,5 @@ gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform? # kramdown v2 ships without the gfm parser by default. If you're using # kramdown v1, comment out this line. gem "kramdown-parser-gfm" + +gem "webrick", "~> 1.8" diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index c9c409f7..3d4e8493 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -254,6 +254,7 @@ GEM unf_ext (0.0.8.2) unicode-display_width (1.8.0) wdm (0.1.1) + webrick (1.8.1) zeitwerk (2.6.11) PLATFORMS @@ -269,6 +270,7 @@ DEPENDENCIES tzinfo (~> 1.2) tzinfo-data wdm (~> 0.1.0) + webrick (~> 1.8) BUNDLED WITH 2.4.18 diff --git a/docs/_data/ota_items.yml b/docs/_data/ota_items.yml new file mode 100644 index 00000000..1f8c95bb --- /dev/null +++ b/docs/_data/ota_items.yml @@ -0,0 +1,21 @@ +- title: Introduction + path: introduction + sub_paths: + - title: Managing bundles and tokens + path: managing-bundles-and-tokens + - title: Requesting OTA bundles + path: requesting-ota-bundles +- title: OTA bundles + path: ota-bundles + sub_paths: + - title: Get OTA bundle + path: get-ota-bundle +- title: SDK tokens + path: sdk-tokens + sub_paths: + - title: List tokens + path: list-tokens + - title: Create token + path: create-token + - title: Delete token + path: delete-token \ No newline at end of file diff --git a/docs/_includes/nav_ota.html b/docs/_includes/nav_ota.html new file mode 100644 index 00000000..5d49aff1 --- /dev/null +++ b/docs/_includes/nav_ota.html @@ -0,0 +1,21 @@ +
    + {% for item in site.data.ota_items %} +
  • + {% assign css_class = nil %} + {% if page.url contains item.path %} + {% assign css_class = 'active' %} + {% endif %} + + {% if css_class %} + + {{ item.title }} + + {% else %} + + {{ item.title }} + + {% endif %} +
  • + {% endfor %} +
+ \ No newline at end of file diff --git a/docs/_includes/nav_ota_full.html b/docs/_includes/nav_ota_full.html new file mode 100644 index 00000000..3628961f --- /dev/null +++ b/docs/_includes/nav_ota_full.html @@ -0,0 +1,19 @@ + + \ No newline at end of file diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index 224ae503..284a3109 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -37,6 +37,11 @@

Usage

{% include nav.html %} + +
+## OTA + + + ## Additional info