diff --git a/README.md b/README.md
index b123a48..cd0ff62 100644
--- a/README.md
+++ b/README.md
@@ -9,23 +9,11 @@
-
-
+
-
-
-
-
-
-
-[//]: # '
'
-[//]: # ' '
-[//]: # '
'
-[//]: # '
'
-[//]: # '
'
-
-
+
+
# 📦 Localazy API Client
diff --git a/docs/api-client-reference.md b/docs/api-client-reference.md
index 65e8b6f..d04e217 100644
--- a/docs/api-client-reference.md
+++ b/docs/api-client-reference.md
@@ -43,10 +43,9 @@
Create a new instance of ApiClient and pass in your project token.
-| Arguments | Type | Description |
-| ----------------- | --------------------------------------------------------------- | :-------------------- |
-| options | [`ApiClientOptions`](../src/types/api-client-options.ts) | Api client options. |
-| config `optional` | [`CreateAxiosDefaults`](https://axios-http.com/docs/req_config) | Axios request config. |
+| Arguments | Type | Description |
+| --------- | -------------------------------------------------------- | :------------------ |
+| options | [`ApiClientOptions`](../src/types/api-client-options.ts) | Api client options. |
| Returns | Type |
| ----------- | :------------------------------------- |
@@ -69,7 +68,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/projects#list-projects)
| Arguments | Type | Description |
| ----------------- | -------------------------------------------------------------- | :---------------------------- |
| request | [`ProjectsListRequest`](../src/types/projects-list-request.ts) | Projects list request config. |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) | Axios request config. |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) | Request config. |
| Returns | Type |
| -------------------- | :----------------------------------- |
@@ -93,7 +92,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/projects#list-projects)
| Arguments | Type | Description |
| ----------------- | -------------------------------------------------------------- | :---------------------------- |
| request | [`ProjectsListRequest`](../src/types/projects-list-request.ts) | Projects list request config. |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) | Axios request config. |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) | Request config. |
| Returns | Type |
| ------------------ | :----------------------------------- |
@@ -114,10 +113,10 @@ List all [files](../src/types/file.ts) in the project.
See: [Localazy API Docs](https://localazy.com/docs/api/files#list-files-in-project)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`FilesListRequest`](../src/types/files-list-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | -------------------------------------------------------- |
+| request | [`FilesListRequest`](../src/types/files-list-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ----------------- | :----------------------------- |
@@ -137,10 +136,10 @@ First [file](../src/types/file.ts) in the project.
See: [Localazy API Docs](https://localazy.com/docs/api/files#list-files-in-project)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`FilesListRequest`](../src/types/files-list-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | -------------------------------------------------------- |
+| request | [`FilesListRequest`](../src/types/files-list-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| --------------- | :----------------------------- |
@@ -161,7 +160,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/files#retrieve-a-list-of-
| Arguments | Type |
| ----------------- | --------------------------------------------------------------- |
| request | [`FileListKeysRequest`](../src/types/file-list-keys-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ---------------- | :--------------------------- |
@@ -186,7 +185,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/files#retrieve-a-list-of-
| Arguments | Type |
| ----------------- | --------------------------------------------------------------- |
| request | [`FileListKeysRequest`](../src/types/file-list-keys-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ------------------------ | :------------------------------------------------ |
@@ -218,7 +217,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/files#list-file-content)
| Arguments | Type |
| ----------------- | -------------------------------------------------------------------- |
| request | [`FileGetContentRequest`](../src/types/file-get-contents-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| --------------- | :-------------------------------------------------------------- |
@@ -242,10 +241,10 @@ Update [key](../src/types/key.ts).
See: [Localazy API Docs](https://localazy.com/docs/api/source-keys#update-source-key)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`KeyUpdateRequest`](../src/types/key-update-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | -------------------------------------------------------- |
+| request | [`KeyUpdateRequest`](../src/types/key-update-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -268,10 +267,10 @@ Delete [key](../src/types/key.ts).
See: [Localazy API Docs](https://localazy.com/docs/api/source-keys#delete-source-key)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`KeyDeleteRequest`](../src/types/key-delete-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | -------------------------------------------------------- |
+| request | [`KeyDeleteRequest`](../src/types/key-delete-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -292,10 +291,10 @@ Import JSON object as source keys.
See: [Localazy API Docs](https://localazy.com/docs/api/import#import-content-to-a-project)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`ImportJsonRequest`](../src/types/import-json-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | ---------------------------------------------------------- |
+| request | [`ImportJsonRequest`](../src/types/import-json-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| --------------- | :----------------------------- |
@@ -332,10 +331,10 @@ const file = await api.import.json({
Export translated keys as JSON object.
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| request | [`ExportJsonRequest`](../src/types/export-json-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | ---------------------------------------------------------- |
+| request | [`ExportJsonRequest`](../src/types/export-json-request.ts) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ------------------- | :-------------------------------------- |
@@ -359,9 +358,9 @@ List all [formats](../src/types/format.ts) and related options.
See: [Localazy API Docs](https://localazy.com/docs/api/import#list-available-file-types)
-| Arguments | Type |
-| ----------------- | -------------------------------------------------------------- |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| Arguments | Type |
+| ----------------- | ------------------------------------------------- |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ------------------- | :--------------------------------- |
@@ -382,7 +381,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#lis
| Arguments | Type |
| ----------------- | -------------------------------------------------------------------- |
| request | [`ScreenshotsListRequest`](../src/types/screenshots-list-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ----------------------- | :----------------------------------------- |
@@ -403,7 +402,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#lis
| Arguments | Type |
| ----------------- | ----------------------------------------------------------------------------- |
| request | [`ScreenshotsListTagsRequest`](../src/types/screenshots-list-tags-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| -------------------------- | :------------------------------------------------ |
@@ -424,7 +423,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#cre
| Arguments | Type |
| ----------------- | ---------------------------------------------------------------------- |
| request | [`ScreenshotCreateRequest`](../src/types/screenshot-create-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ----------------- | :------------- |
@@ -446,7 +445,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#upd
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------------------------------ |
| request | [`ScreenshotUpdateImageDataRequest`](../src/types/screenshot-update-image-data-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -469,7 +468,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#upd
| Arguments | Type |
| ----------------- | ---------------------------------------------------------------------- |
| request | [`ScreenshotUpdateRequest`](../src/types/screenshot-update-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -493,7 +492,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/screenshot-management#del
| Arguments | Type |
| ----------------- | ---------------------------------------------------------------------- |
| request | [`ScreenshotDeleteRequest`](../src/types/screenshot-delete-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -517,7 +516,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/glossary#list-all-glossar
| Arguments | Type |
| ----------------- | -------------------------------------------------------------- |
| request | [`GlossaryListRequest`](../src/types/glossary-list-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| --------------------------- | :-------------------------------------------------- |
@@ -538,7 +537,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/glossary#get-glossary-ter
| Arguments | Type |
| ----------------- | -------------------------------------------------------------- |
| request | [`GlossaryFindRequest`](../src/types/glossary-find-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ------------------------- | :-------------------------------------------------- |
@@ -560,7 +559,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/glossary#create-new-gloss
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------ |
| request | [`GlossaryCreateRequest`](../src/types/glossary-create-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ----------------- | :----------------- |
@@ -587,7 +586,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/glossary#update-glossary-
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------ |
| request | [`GlossaryUpdateRequest`](../src/types/glossary-update-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -615,7 +614,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/glossary#delete-glossary-
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------ |
| request | [`GlossaryDeleteRequest`](../src/types/glossary-delete-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -639,7 +638,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/webhooks-api#list-webhook
| Arguments | Type |
| ----------------- | -------------------------------------------------------------- |
| request | [`WebhooksListRequest`](../src/types/webhooks-list-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| -------------------- | :----------------------------------- |
@@ -660,7 +659,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/webhooks-api#update-webho
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------ |
| request | [`WebhooksUpdateRequest`](../src/types/webhooks-update-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns |
| --------------- |
@@ -692,7 +691,7 @@ See: [Localazy API Docs](https://localazy.com/docs/api/webhooks-api#webhook-secr
| Arguments | Type |
| ----------------- | ------------------------------------------------------------------------- |
| request | [`WebhooksGetSecretRequest`](../src/types/webhooks-get-secret-request.ts) |
-| config `optional` | [`AxiosRequestConfig`](https://axios-http.com/docs/req_config) |
+| config `optional` | [`RequestConfig`](../src/types/request-config.ts) |
| Returns | Type |
| ------------------------- | :-------------------------------------------------- |
diff --git a/package-lock.json b/package-lock.json
index dda3cd8..cd0d03e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,6 @@
"license": "MIT",
"dependencies": {
"@localazy/languages": "^0.1.6",
- "axios": "^1.6.8",
"lodash-es": "^4.17.21"
},
"devDependencies": {
@@ -22,7 +21,6 @@
"@typescript-eslint/parser": "^7.2.0",
"@vitest/coverage-v8": "^1.4.0",
"@vitest/ui": "^1.4.0",
- "axios-mock-adapter": "^1.22.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
@@ -2521,11 +2519,6 @@
"dev": true,
"peer": true
},
- "node_modules/asynckit": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
- "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
- },
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
@@ -2551,29 +2544,6 @@
"node": ">=4"
}
},
- "node_modules/axios": {
- "version": "1.6.8",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
- "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
- "dependencies": {
- "follow-redirects": "^1.15.6",
- "form-data": "^4.0.0",
- "proxy-from-env": "^1.1.0"
- }
- },
- "node_modules/axios-mock-adapter": {
- "version": "1.22.0",
- "resolved": "https://registry.npmjs.org/axios-mock-adapter/-/axios-mock-adapter-1.22.0.tgz",
- "integrity": "sha512-dmI0KbkyAhntUR05YY96qg2H6gg0XMl2+qTW0xmYg6Up+BFBAJYRLROMXRdDEL06/Wqwa0TJThAYvFtSFdRCZw==",
- "dev": true,
- "dependencies": {
- "fast-deep-equal": "^3.1.3",
- "is-buffer": "^2.0.5"
- },
- "peerDependencies": {
- "axios": ">= 0.17.0"
- }
- },
"node_modules/axobject-query": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
@@ -3075,17 +3045,6 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
- "node_modules/combined-stream": {
- "version": "1.0.8",
- "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
- "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
- "dependencies": {
- "delayed-stream": "~1.0.0"
- },
- "engines": {
- "node": ">= 0.8"
- }
- },
"node_modules/commander": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
@@ -3375,14 +3334,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/delayed-stream": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
- "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
- "engines": {
- "node": ">=0.4.0"
- }
- },
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
@@ -4660,25 +4611,6 @@
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"dev": true
},
- "node_modules/follow-redirects": {
- "version": "1.15.6",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
- "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
- "funding": [
- {
- "type": "individual",
- "url": "https://github.com/sponsors/RubenVerborgh"
- }
- ],
- "engines": {
- "node": ">=4.0"
- },
- "peerDependenciesMeta": {
- "debug": {
- "optional": true
- }
- }
- },
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
@@ -4704,19 +4636,6 @@
"url": "https://github.com/sponsors/isaacs"
}
},
- "node_modules/form-data": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
- "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
- "dependencies": {
- "asynckit": "^0.4.0",
- "combined-stream": "^1.0.8",
- "mime-types": "^2.1.12"
- },
- "engines": {
- "node": ">= 6"
- }
- },
"node_modules/fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
@@ -5346,29 +5265,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/is-buffer": {
- "version": "2.0.5",
- "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
- "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==",
- "dev": true,
- "funding": [
- {
- "type": "github",
- "url": "https://github.com/sponsors/feross"
- },
- {
- "type": "patreon",
- "url": "https://www.patreon.com/feross"
- },
- {
- "type": "consulting",
- "url": "https://feross.org/support"
- }
- ],
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/is-callable": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
@@ -6200,25 +6096,6 @@
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true
},
- "node_modules/mime-db": {
- "version": "1.52.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
- "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
- "engines": {
- "node": ">= 0.6"
- }
- },
- "node_modules/mime-types": {
- "version": "2.1.35",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
- "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
- "dependencies": {
- "mime-db": "1.52.0"
- },
- "engines": {
- "node": ">= 0.6"
- }
- },
"node_modules/mimic-fn": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
@@ -7023,11 +6900,6 @@
"dev": true,
"peer": true
},
- "node_modules/proxy-from-env": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
- "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
- },
"node_modules/public-encrypt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz",
diff --git a/package.json b/package.json
index 8416ee8..635ffe1 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,6 @@
},
"dependencies": {
"@localazy/languages": "^0.1.6",
- "axios": "^1.6.8",
"lodash-es": "^4.17.21"
},
"devDependencies": {
@@ -80,7 +79,6 @@
"@typescript-eslint/parser": "^7.2.0",
"@vitest/coverage-v8": "^1.4.0",
"@vitest/ui": "^1.4.0",
- "axios-mock-adapter": "^1.22.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
diff --git a/src/api/api-client.ts b/src/api/api-client.ts
index cb95480..7988402 100644
--- a/src/api/api-client.ts
+++ b/src/api/api-client.ts
@@ -1,4 +1,4 @@
-import { CreateAxiosDefaults } from 'axios';
+import { FetchHttpAdapter } from '@/http/fetch-http-adapter';
import { ApiExport } from '@/api/methods/api-export';
import { ApiFiles } from '@/api/methods/api-files';
import { ApiFormats } from '@/api/methods/api-formats';
@@ -8,7 +8,6 @@ import { ApiKeys } from '@/api/methods/api-keys';
import { ApiProjects } from '@/api/methods/api-projects';
import { ApiScreenshots } from '@/api/methods/api-screenshots';
import { ApiWebhooks } from '@/api/methods/api-webhooks';
-import { AxiosHttpAdapter } from '@/http/axios-http-adapter';
import { IHttpAdapter } from '@/http/i-http-adapter';
import { ApiClientOptions } from '@/types/api-client-options';
@@ -33,8 +32,8 @@ export class ApiClient {
public screenshots: ApiScreenshots;
- constructor(options: ApiClientOptions, config?: CreateAxiosDefaults) {
- this.client = new AxiosHttpAdapter(options, config);
+ constructor(options: ApiClientOptions) {
+ this.client = new FetchHttpAdapter(options);
this.projects = new ApiProjects(this);
this.import = new ApiImport(this);
diff --git a/src/api/methods/api-export.ts b/src/api/methods/api-export.ts
index 00ba397..2375b38 100644
--- a/src/api/methods/api-export.ts
+++ b/src/api/methods/api-export.ts
@@ -1,5 +1,5 @@
import { Locales } from '@localazy/languages';
-import { AxiosRequestConfig } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { ExportJsonRequest } from '@/types/export-json-request';
import { I18nJson } from '@/types/i18n-json';
@@ -11,9 +11,9 @@ export class ApiExport extends ApiBase {
* Export translated keys as JSON object.
*
* @param request Export JSON request config.
- * @param config Axios request config.
+ * @param config Request config.
*/
- public async json(request: ExportJsonRequest, config?: AxiosRequestConfig): Promise {
+ public async json(request: ExportJsonRequest, config?: RequestConfig): Promise {
const { project, file, langs }: ExportJsonRequest = request;
const result: Key[][] = await Promise.all(
diff --git a/src/api/methods/api-files.ts b/src/api/methods/api-files.ts
index 9f74cde..133d367 100644
--- a/src/api/methods/api-files.ts
+++ b/src/api/methods/api-files.ts
@@ -1,5 +1,5 @@
-import { AxiosRequestConfig } from 'axios';
import { Blob } from 'node:buffer';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { File } from '@/types/file';
import { FileGetContentsRequest } from '@/types/file-get-contents-request';
@@ -13,27 +13,27 @@ export class ApiFiles extends ApiBase {
* List all {@link File files} in the project.
*
* @param request Files list request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/files#list-files-in-project Localazy API Docs}
*/
- public async list(request: FilesListRequest, config?: AxiosRequestConfig): Promise {
+ public async list(request: FilesListRequest, config?: RequestConfig): Promise {
const { project }: FilesListRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- return this.api.client.get(`/projects/${projectId}/files`, config);
+ return (await this.api.client.get(`/projects/${projectId}/files`, config)) as Promise;
}
/**
* First {@link File file} in the project.
*
* @param request Files list request config.
- * @param config Axios request config.
+ * @param config Request config.
* @throws Error At least one file must exist, otherwise an error is thrown.
*
* @see {@link https://localazy.com/docs/api/files#list-files-in-project Localazy API Docs}
*/
- public async first(request: FilesListRequest, config?: AxiosRequestConfig): Promise {
+ public async first(request: FilesListRequest, config?: RequestConfig): Promise {
const files: File[] = await this.list(request, config);
if (files.length === 0) {
@@ -47,12 +47,12 @@ export class ApiFiles extends ApiBase {
* List all {@link Key keys} for the language in the {@link File file}.
*
* @param request File list keys request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file
* | Localazy API Docs}
*/
- public async listKeys(request: FileListKeysRequest, config?: AxiosRequestConfig): Promise {
+ public async listKeys(request: FileListKeysRequest, config?: RequestConfig): Promise {
const keys: Key[] = [];
let pageResult: KeysPaginated = {
keys: [],
@@ -72,37 +72,38 @@ export class ApiFiles extends ApiBase {
* List all {@link Key keys} for the language in the {@link File file}. Result is paginated.
*
* @param request File list keys request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/files#retrieve-a-list-of-keys-and-translations-from-file
* | Localazy API Docs}
*/
- public async listKeysPage(request: FileListKeysRequest, config?: AxiosRequestConfig): Promise {
+ public async listKeysPage(request: FileListKeysRequest, config?: RequestConfig): Promise {
const { project, file, lang, ...params }: FileListKeysRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const fileId: string = ApiBase.getId(file, 'file');
- return this.api.client.get(`/projects/${projectId}/files/${fileId}/keys/${lang}`, { ...config, params });
+ return (await this.api.client.get(`/projects/${projectId}/files/${fileId}/keys/${lang}`, {
+ ...config,
+ params,
+ })) as KeysPaginated;
}
/**
* Get the contents of the {@link File file}.
*
* @param request File get contents request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/files#list-file-content Localazy API Docs}
*/
- public async getContents(request: FileGetContentsRequest, config?: AxiosRequestConfig): Promise {
+ public async getContents(request: FileGetContentsRequest, config?: RequestConfig): Promise {
const { project, file, lang }: FileGetContentsRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const fileId: string = ApiBase.getId(file, 'file');
- const buffer: Uint8Array = await this.api.client.get(`/projects/${projectId}/files/${fileId}/download/${lang}`, {
+ return (await this.api.client.get(`/projects/${projectId}/files/${fileId}/download/${lang}`, {
...config,
- responseType: 'arraybuffer',
- });
-
- return new Blob([buffer]);
+ responseType: 'blob',
+ })) as Blob;
}
}
diff --git a/src/api/methods/api-formats.ts b/src/api/methods/api-formats.ts
index 88cc7ec..777db54 100644
--- a/src/api/methods/api-formats.ts
+++ b/src/api/methods/api-formats.ts
@@ -1,16 +1,16 @@
-import { AxiosRequestConfig } from 'axios';
import { ApiBase } from '@/api/methods/api-base';
import { Format } from '@/types/format';
+import { RequestConfig } from '@/types/request-config';
export class ApiFormats extends ApiBase {
/**
* List all {@link Format formats} and related options.
*
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/import#list-available-file-types Localazy API Docs}
*/
- public async list(config?: AxiosRequestConfig): Promise {
- return this.api.client.get('/import/formats', config);
+ public async list(config?: RequestConfig): Promise {
+ return (await this.api.client.get('/import/formats', config)) as Format[];
}
}
diff --git a/src/api/methods/api-glossary.ts b/src/api/methods/api-glossary.ts
index b1c458d..91a9539 100644
--- a/src/api/methods/api-glossary.ts
+++ b/src/api/methods/api-glossary.ts
@@ -1,4 +1,4 @@
-import { AxiosRequestConfig, AxiosResponseTransformer } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { GlossaryCreateRequest } from '@/types/glossary-create-request';
import { GlossaryDeleteRequest } from '@/types/glossary-delete-request';
@@ -12,35 +12,35 @@ export class ApiGlossary extends ApiBase {
* List all {@link GlossaryRecord glossary records} in the project.
*
* @param request Glossary records list request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/glossary#list-all-glossary-terms Localazy API Docs}
*/
- public async list(request: GlossaryListRequest, config?: AxiosRequestConfig): Promise {
+ public async list(request: GlossaryListRequest, config?: RequestConfig): Promise {
const { project }: GlossaryListRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- const transformResponse: AxiosResponseTransformer = (data: string): GlossaryRecord[] => {
- const json: { glossaries: GlossaryRecord[] } = JSON.parse(data);
- return json.glossaries;
- };
+ const response: { glossaries: GlossaryRecord[] } = (await this.api.client.get(
+ `/projects/${projectId}/glossary`,
+ config,
+ )) as { glossaries: GlossaryRecord[] };
- return this.api.client.get(`/projects/${projectId}/glossary`, { transformResponse, ...config });
+ return response.glossaries;
}
/**
* Find {@link GlossaryRecord glossary record} specified by `id`.
*
* @param request Glossary record find request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/glossary#get-glossary-term Localazy API Docs}
*/
- public async find(request: GlossaryFindRequest, config?: AxiosRequestConfig): Promise {
+ public async find(request: GlossaryFindRequest, config?: RequestConfig): Promise {
const { project, glossaryRecord }: GlossaryFindRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const id: string = typeof glossaryRecord === 'string' ? glossaryRecord : glossaryRecord.id;
- return this.api.client.get(`/projects/${projectId}/glossary/${id}`, config);
+ return (await this.api.client.get(`/projects/${projectId}/glossary/${id}`, config)) as GlossaryRecord;
}
/**
@@ -48,30 +48,31 @@ export class ApiGlossary extends ApiBase {
* There is a limit of 1000 glossary records per project.
*
* @param request Glossary record create request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/glossary#create-new-glossary-term Localazy API Docs}
*/
- public async create(request: GlossaryCreateRequest, config?: AxiosRequestConfig): Promise {
+ public async create(request: GlossaryCreateRequest, config?: RequestConfig): Promise {
const { project, ...data }: GlossaryCreateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- const transformResponse: AxiosResponseTransformer = (d: string): string => {
- const json: { result: string } = JSON.parse(d);
- return json.result;
- };
+ const response: { result: string } = (await this.api.client.post(
+ `/projects/${projectId}/glossary`,
+ data,
+ config,
+ )) as { result: string };
- return this.api.client.post(`/projects/${projectId}/glossary`, data, { transformResponse, ...config });
+ return response.result;
}
/**
* Update {@link GlossaryRecord glossary record} specified by `id`.
*
* @param request Glossary record update request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/glossary#update-glossary-term Localazy API Docs}
*/
- public async update(request: GlossaryUpdateRequest, config?: AxiosRequestConfig): Promise {
+ public async update(request: GlossaryUpdateRequest, config?: RequestConfig): Promise {
const { project, glossaryRecord, ...data }: GlossaryUpdateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const id: string = typeof glossaryRecord === 'string' ? glossaryRecord : glossaryRecord.id;
@@ -83,11 +84,11 @@ export class ApiGlossary extends ApiBase {
* Delete {@link GlossaryRecord glossary record} specified by `id`.
*
* @param request Glossary record delete request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/glossary#delete-glossary-term Localazy API Docs}
*/
- public async delete(request: GlossaryDeleteRequest, config?: AxiosRequestConfig): Promise {
+ public async delete(request: GlossaryDeleteRequest, config?: RequestConfig): Promise {
const { project, glossaryRecord }: GlossaryDeleteRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const id: string = typeof glossaryRecord === 'string' ? glossaryRecord : glossaryRecord.id;
diff --git a/src/api/methods/api-import.ts b/src/api/methods/api-import.ts
index d5a36e2..f51ec56 100644
--- a/src/api/methods/api-import.ts
+++ b/src/api/methods/api-import.ts
@@ -1,4 +1,4 @@
-import { AxiosRequestConfig } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { File } from '@/types/file';
import { I18nJson } from '@/types/i18n-json';
@@ -15,17 +15,21 @@ export class ApiImport extends ApiBase {
* Import source keys from JSON object.
*
* @param request Import JSON request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/import#import-content-to-a-project Localazy API Docs}
*/
- public async json(request: ImportJsonRequest, config?: AxiosRequestConfig): Promise {
+ public async json(request: ImportJsonRequest, config?: RequestConfig): Promise {
const { project, json }: ImportJsonRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const chunks: I18nJson[] = JsonUtils.slice(json);
const data: ImportData = importDataFactory(request, chunks);
- const { result } = await this.api.client.post(`/projects/${projectId}/import`, data, config);
+ const { result }: { result: string } = (await this.api.client.post(
+ `/projects/${projectId}/import`,
+ data,
+ config,
+ )) as { result: string };
await delay();
diff --git a/src/api/methods/api-keys.ts b/src/api/methods/api-keys.ts
index 3fd8cc5..882c672 100644
--- a/src/api/methods/api-keys.ts
+++ b/src/api/methods/api-keys.ts
@@ -1,18 +1,18 @@
-import { AxiosRequestConfig } from 'axios';
import { ApiBase } from '@/api/methods/api-base';
import { KeyDeleteRequest } from '@/types/key-delete-request';
import { KeyUpdateRequest } from '@/types/key-update-request';
+import { RequestConfig } from '@/types/request-config';
export class ApiKeys extends ApiBase {
/**
* Update {@link Key key}.
*
* @param request Key update request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/source-keys#update-source-key Localazy API Docs}
*/
- public async update(request: KeyUpdateRequest, config?: AxiosRequestConfig): Promise {
+ public async update(request: KeyUpdateRequest, config?: RequestConfig): Promise {
const { project, key, ...data }: KeyUpdateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const keyId: string = ApiBase.getId(key, 'key');
@@ -24,11 +24,11 @@ export class ApiKeys extends ApiBase {
* Delete {@link Key key}.
*
* @param request Key delete request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/source-keys#delete-source-key Localazy API Docs}
*/
- public async delete(request: KeyDeleteRequest, config?: AxiosRequestConfig): Promise {
+ public async delete(request: KeyDeleteRequest, config?: RequestConfig): Promise {
const { project, key }: KeyDeleteRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const keyId: string = ApiBase.getId(key, 'key');
diff --git a/src/api/methods/api-projects.ts b/src/api/methods/api-projects.ts
index 031d639..3367c80 100644
--- a/src/api/methods/api-projects.ts
+++ b/src/api/methods/api-projects.ts
@@ -1,4 +1,4 @@
-import { AxiosRequestConfig } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { Project } from '@/types/project';
import { ProjectsListRequest } from '@/types/projects-list-request';
@@ -8,24 +8,24 @@ export class ApiProjects extends ApiBase {
* List all {@link Project projects}.
*
* @param request Projects list request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/projects#list-projects Localazy API Docs}
*/
- public async list(request?: ProjectsListRequest, config?: AxiosRequestConfig): Promise {
- return this.api.client.get('/projects', { ...config, params: request });
+ public async list(request?: ProjectsListRequest, config?: RequestConfig): Promise {
+ return (await this.api.client.get('/projects', { ...config, params: request })) as Project[];
}
/**
* First {@link Project project}.
*
* @param request Projects list request config.
- * @param config Axios request config.
+ * @param config Request config.
* @throws Error At least one project must exist, otherwise an error is thrown.
*
* @see {@link https://localazy.com/docs/api/projects#list-projects Localazy API Docs}
*/
- public async first(request?: ProjectsListRequest, config?: AxiosRequestConfig): Promise {
+ public async first(request?: ProjectsListRequest, config?: RequestConfig): Promise {
const projects: Project[] = await this.list(request, config);
if (projects.length === 0) {
diff --git a/src/api/methods/api-screenshots.ts b/src/api/methods/api-screenshots.ts
index 4ecd5fa..273bb65 100644
--- a/src/api/methods/api-screenshots.ts
+++ b/src/api/methods/api-screenshots.ts
@@ -1,4 +1,4 @@
-import { AxiosRequestConfig, AxiosResponseTransformer } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { Screenshot } from '@/types/screenshot';
import { ScreenshotCreateRequest } from '@/types/screenshot-create-request';
@@ -14,64 +14,62 @@ export class ApiScreenshots extends ApiBase {
* List all {@link Screenshot screenshots} in the project.
*
* @param request Screenshots list request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#list-screenshots Localazy API Docs}
*/
- public async list(request: ScreenshotsListRequest, config?: AxiosRequestConfig): Promise {
+ public async list(request: ScreenshotsListRequest, config?: RequestConfig): Promise {
const { project }: ScreenshotsListRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- return this.api.client.get(`/projects/${projectId}/screenshots`, config);
+ return (await this.api.client.get(`/projects/${projectId}/screenshots`, config)) as Screenshot[];
}
/**
* List all {@link ScreenshotTag screenshots tags} in the project.
*
* @param request Screenshots list tags request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#list-screenshots-tags Localazy API Docs}
*/
- public async listTags(request: ScreenshotsListTagsRequest, config?: AxiosRequestConfig): Promise {
+ public async listTags(request: ScreenshotsListTagsRequest, config?: RequestConfig): Promise {
const { project }: ScreenshotsListTagsRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- return this.api.client.get(`/projects/${projectId}/screenshots/tags`, config);
+ return (await this.api.client.get(`/projects/${projectId}/screenshots/tags`, config)) as ScreenshotTag[];
}
/**
* Create {@link Screenshot screenshot}.
*
* @param request Screenshot create request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#create-a-new-screenshot Localazy API Docs}
*/
- public async create(request: ScreenshotCreateRequest, config?: AxiosRequestConfig): Promise {
+ public async create(request: ScreenshotCreateRequest, config?: RequestConfig): Promise {
const { project }: ScreenshotCreateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- const transformResponse: AxiosResponseTransformer = (d: string): string => {
- const json: { id: string } = JSON.parse(d);
- return json.id;
- };
+ const response: { id: string } = (await this.api.client.post(
+ `/projects/${projectId}/screenshots`,
+ request.encodedData,
+ config,
+ )) as { id: string };
- return this.api.client.post(`/projects/${projectId}/screenshots`, request.encodedData, {
- transformResponse,
- ...config,
- });
+ return response.id;
}
/**
* Update the image data of {@link Screenshot screenshot}.
*
* @param request Screenshot update image data request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#update-the-image-of-an-existing-screenshot
* | Localazy API Docs}
*/
- public async updateImageData(request: ScreenshotUpdateImageDataRequest, config?: AxiosRequestConfig): Promise {
+ public async updateImageData(request: ScreenshotUpdateImageDataRequest, config?: RequestConfig): Promise {
const { project, screenshot }: ScreenshotUpdateImageDataRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const screenshotId: string = ApiBase.getId(screenshot, 'screenshot');
@@ -84,11 +82,11 @@ export class ApiScreenshots extends ApiBase {
* Image data are updated with `screenshots.updateImageData`.
*
* @param request Screenshot update request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#update-an-existing-screenshot Localazy API Docs}
*/
- public async update(request: ScreenshotUpdateRequest, config?: AxiosRequestConfig): Promise {
+ public async update(request: ScreenshotUpdateRequest, config?: RequestConfig): Promise {
const { project, screenshot, ...data }: ScreenshotUpdateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const screenshotId: string = ApiBase.getId(screenshot, 'screenshot');
@@ -100,11 +98,11 @@ export class ApiScreenshots extends ApiBase {
* Delete {@link Screenshot screenshot}.
*
* @param request Screenshot delete request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/screenshot-management#delete-a-screenshot Localazy API Docs}
*/
- public async delete(request: ScreenshotDeleteRequest, config?: AxiosRequestConfig): Promise {
+ public async delete(request: ScreenshotDeleteRequest, config?: RequestConfig): Promise {
const { project, screenshot }: ScreenshotDeleteRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
const screenshotId: string = ApiBase.getId(screenshot, 'screenshot');
diff --git a/src/api/methods/api-webhooks.ts b/src/api/methods/api-webhooks.ts
index 1fe7b1c..cd229d5 100644
--- a/src/api/methods/api-webhooks.ts
+++ b/src/api/methods/api-webhooks.ts
@@ -1,4 +1,4 @@
-import { AxiosRequestConfig, AxiosResponseTransformer } from 'axios';
+import { RequestConfig } from '@/types/request-config';
import { ApiBase } from '@/api/methods/api-base';
import { Webhook } from '@/types/webhook';
import { WebhooksGetSecretRequest } from '@/types/webhooks-get-secret-request';
@@ -11,30 +11,29 @@ export class ApiWebhooks extends ApiBase {
* List all {@link Webhook webhooks} in the project.
*
* @param request Webhooks list request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/webhooks-api#list-webhooks-configuration Localazy API Docs}
*/
- public async list(request: WebhooksListRequest, config?: AxiosRequestConfig): Promise {
+ public async list(request: WebhooksListRequest, config?: RequestConfig): Promise {
const { project }: WebhooksListRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- const transformResponse: AxiosResponseTransformer = (data: string): Webhook[] => {
- const json: { items: Webhook[] } = JSON.parse(data);
- return json.items;
+ const response: { items: Webhook[] } = (await this.api.client.get(`/projects/${projectId}/webhooks`, config)) as {
+ items: Webhook[];
};
- return this.api.client.get(`/projects/${projectId}/webhooks`, { transformResponse, ...config });
+ return response.items;
}
/**
* Update all {@link Webhook webhooks} in the project.
*
* @param request Webhooks update request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/webhooks-api#update-webhooks-configuration Localazy API Docs}
*/
- public async update(request: WebhooksUpdateRequest, config?: AxiosRequestConfig): Promise {
+ public async update(request: WebhooksUpdateRequest, config?: RequestConfig): Promise {
const { project, ...data }: WebhooksUpdateRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
@@ -47,18 +46,18 @@ export class ApiWebhooks extends ApiBase {
* {@link https://localazy.com/docs/api/webhooks-api#security}.
*
* @param request Webhooks get secret request config.
- * @param config Axios request config.
+ * @param config Request config.
*
* @see {@link https://localazy.com/docs/api/webhooks-api#webhook-secrets Localazy API Docs}
*/
- public async getSecret(request: WebhooksGetSecretRequest, config?: AxiosRequestConfig): Promise {
+ public async getSecret(request: WebhooksGetSecretRequest, config?: RequestConfig): Promise {
const { project }: WebhooksGetSecretRequest = request;
const projectId: string = ApiBase.getId(project, 'project');
- const transformResponse: AxiosResponseTransformer = (data: string): WebhooksSecret => {
- const json: { secret: WebhooksSecret } = JSON.parse(data);
- return json.secret;
- };
+ const response: { secret: string } = (await this.api.client.get(
+ `/projects/${projectId}/webhooks/secret`,
+ config,
+ )) as { secret: string };
- return this.api.client.get(`/projects/${projectId}/webhooks/secret`, { transformResponse, ...config });
+ return response.secret;
}
}
diff --git a/src/errors/localazy-error.ts b/src/errors/localazy-error.ts
deleted file mode 100644
index 40ef237..0000000
--- a/src/errors/localazy-error.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export class LocalazyError extends Error {
- public code: number;
-
- constructor(message: string, code: number, options?: ErrorOptions) {
- super(message, options);
-
- this.name = 'LocalazyError';
- this.code = code;
- }
-}
diff --git a/src/http/axios-http-adapter.ts b/src/http/axios-http-adapter.ts
deleted file mode 100644
index 5d4ca54..0000000
--- a/src/http/axios-http-adapter.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults } from 'axios';
-import { isNumber, isPlainObject, isString } from 'lodash-es';
-import { LocalazyError } from '@/errors/localazy-error';
-import { IHttpAdapter } from '@/http/i-http-adapter';
-import { ApiClientOptions } from '@/types/api-client-options';
-
-export class AxiosHttpAdapter implements IHttpAdapter {
- public client: AxiosInstance;
-
- constructor(options: ApiClientOptions, config?: CreateAxiosDefaults) {
- this.client = AxiosHttpAdapter.clientFactory(
- options.apiUrl || 'https://api.localazy.com',
- options.authToken,
- config,
- );
- }
-
- protected static clientFactory(baseURL: string, authToken: string, config?: CreateAxiosDefaults): AxiosInstance {
- const client: AxiosInstance = axios.create({
- ...config,
- baseURL,
- headers: {
- common: {
- Authorization: `Bearer ${authToken}`,
- Accept: `application/json`,
- },
- },
- });
-
- client.interceptors.response.use(
- (response: AxiosResponse) => response.data,
- (err: any): Promise => {
- const data = err.response?.data;
- if (isPlainObject(data) && isNumber(data.code) && isString(data.error)) {
- return Promise.reject(new LocalazyError(data.error, data.code, { cause: err }));
- }
- return Promise.reject(err);
- },
- );
-
- return client;
- }
-
- post(url: string, data?: D, config?: AxiosRequestConfig): Promise {
- return this.client.post(url, data, config);
- }
-
- put(url: string, data?: D, config?: AxiosRequestConfig): Promise {
- return this.client.put(url, data, config);
- }
-
- get(url: string, config?: AxiosRequestConfig): Promise {
- return this.client.get(url, config);
- }
-
- delete(url: string, config?: AxiosRequestConfig): Promise {
- return this.client.delete(url, config);
- }
-}
diff --git a/src/http/fetch-http-adapter.ts b/src/http/fetch-http-adapter.ts
new file mode 100644
index 0000000..6002df6
--- /dev/null
+++ b/src/http/fetch-http-adapter.ts
@@ -0,0 +1,88 @@
+import { IHttpAdapter } from '@/http/i-http-adapter';
+import { ApiClientOptions } from '@/types/api-client-options';
+import { RequestConfig } from '@/types/request-config';
+
+export class FetchHttpAdapter implements IHttpAdapter {
+ protected apiUrl: string;
+
+ protected authToken: string;
+
+ constructor(options: ApiClientOptions) {
+ this.apiUrl = options.apiUrl || 'https://api.localazy.com';
+ this.authToken = options.authToken;
+ }
+
+ async get(url: string, config?: RequestConfig): Promise