nextemos 2.1.7 → 2.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,12 @@
1
- import { IApiResponse } from '../';
2
- import { HTTPMethod as httpMethods } from '../';
3
- type HTTPMethod = httpMethods;
4
- interface RequestOptions extends RequestInit {
5
- url: string;
6
- method: HTTPMethod;
7
- params?: Record<string, any>;
8
- }
1
+ import { IApiResponse, RequestOptions } from '../';
9
2
  /**
10
3
  * Creates a HTTP client for making requests.
11
4
  * @returns {object} HTTP client with methods for making requests.
12
5
  */
13
6
  declare const fetchRequest: () => {
14
- get: <T>(url: string, options?: Omit<RequestOptions, 'method'>) => Promise<IApiResponse<T>>;
15
- post: <T_1>(url: string, data: any, options?: Omit<RequestOptions, 'method'>) => Promise<IApiResponse<T_1>>;
16
- put: <T_2>(url: string, data: any, options?: Omit<RequestOptions, 'method'>) => Promise<IApiResponse<T_2>>;
17
- delete: <T_3>(url: string, options?: Omit<RequestOptions, 'method'>) => Promise<IApiResponse<T_3>>;
7
+ get: <T>(url: string, options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<T>>;
8
+ post: <T_1>(url: string, data: any, options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<T_1>>;
9
+ put: <T_2>(url: string, data: any, options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<T_2>>;
10
+ delete: <T_3>(url: string, options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<T_3>>;
18
11
  };
19
12
  export default fetchRequest;
@@ -20,7 +20,6 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- // enums
24
23
  const __1 = require("../");
25
24
  /**
26
25
  * Creates a HTTP client for making requests.
@@ -34,13 +33,13 @@ const fetchRequest = () => {
34
33
  * @returns {Promise<IApiResponse<T>>} Response from the API.
35
34
  */
36
35
  const request = (_a) => __awaiter(void 0, void 0, void 0, function* () {
37
- var { url, method, params } = _a, requestOptions = __rest(_a, ["url", "method", "params"]);
36
+ var { url, method, params } = _a, options = __rest(_a, ["url", "method", "params"]);
38
37
  const apiURL = new URL(url); // Assuming url already contains apiUrl and apiVersion
39
38
  if (params) {
40
39
  Object.keys(params).forEach(key => apiURL.searchParams.append(key, params[key]));
41
40
  }
42
41
  try {
43
- const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, requestOptions), { method }));
42
+ const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, options), { method }));
44
43
  const responseData = yield response.json().catch(() => ({}));
45
44
  if (!response.ok) {
46
45
  const errorMessage = (responseData === null || responseData === void 0 ? void 0 : responseData.message) || 'Something went wrong!';
@@ -1,3 +1,33 @@
1
+ import { HTTPMethod as httpMethods } from '../';
2
+ /**
3
+ * HTTPMethod türü, HTTP istek yöntemlerini temsil eder (GET, POST, PUT, DELETE vb.).
4
+ * */
5
+ type HTTPMethod = httpMethods;
6
+ /**
7
+ * RequestParams arayüzü, istek parametrelerini tanımlar.
8
+ * 'language' alanı zorunludur.
9
+ */
10
+ interface RequestParams extends Record<string, any> {
11
+ language: string;
12
+ }
13
+ /**
14
+ * RequestOptions arayüzü, bir HTTP isteğinin seçeneklerini tanımlar.
15
+ */
16
+ export interface RequestOptions extends RequestInit {
17
+ /**
18
+ * apiUrl ve apiVersion dahil tam URL adresi.
19
+ */
20
+ url: string;
21
+ /**
22
+ * Kullanılacak HTTP istek yöntemi (GET, POST, PUT, DELETE vb.).
23
+ */
24
+ method: HTTPMethod;
25
+ /**
26
+ * Gönderilecek parametreler.
27
+ * 'language' alanı zorunludur.
28
+ */
29
+ params: RequestParams;
30
+ }
1
31
  /**
2
32
  * APIResponse arayüzü, genel API yanıtlarını temsil eder.
3
33
  *
@@ -84,3 +114,4 @@ export interface IResponsePaging extends IResponse {
84
114
  */
85
115
  currentPage: number;
86
116
  }
117
+ export {};
@@ -1,33 +1,35 @@
1
- import { IApiResponse, IBannerResponse, IBannersResponse } from '../';
1
+ import { IApiResponse, IBannerResponse, IBannersResponse, RequestOptions } from '../';
2
2
  /**
3
- * BannerService arayüzü, Banner ile ilgili API çağrılarını temsil eder.
4
- * Banner ile ilgili çeşitli verileri almak için kullanılabilecek metotlar içerir.
3
+ * BannerService arayüzü, banner verilerini almak için kullanılabilecek metodları tanımlar.
5
4
  */
6
5
  interface BannerService {
7
6
  /**
8
- * Belirli bir ID'ye sahip banner'ı getirir.
9
- * @returns Belirli bir ID'ye sahip banner verilerini içeren bir API yanıtı.
7
+ * Verilen ID'ye sahip banner'ı getirir.
8
+ * @param options - RequestOptions'dan 'url' ve 'method' çıkarılmış hali.
9
+ * @returns IBannerResponse tipinde bir API yanıtı.
10
10
  */
11
- GetBannerById: () => Promise<IApiResponse<IBannerResponse>>;
11
+ GetBannerById: (options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<IBannerResponse>>;
12
12
  /**
13
- * Belirli bir isme sahip banner'ı getirir.
14
- * @returns Belirli bir isme sahip banner verilerini içeren bir API yanıtı.
13
+ * Verilen isme sahip banner'ı getirir.
14
+ * @param options - RequestOptions'dan 'url' ve 'method' çıkarılmış hali.
15
+ * @returns IBannerResponse tipinde bir API yanıtı.
15
16
  */
16
- GetBannerByName: () => Promise<IApiResponse<IBannerResponse>>;
17
+ GetBannerByName: (options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<IBannerResponse>>;
17
18
  /**
18
- * Belirli bir anahtara sahip banner'ı getirir.
19
- * @returns Belirli bir anahtara sahip banner verilerini içeren bir API yanıtı.
19
+ * Verilen anahtara sahip banner'ı getirir.
20
+ * @param options - RequestOptions'dan 'url' ve 'method' çıkarılmış hali.
21
+ * @returns IBannerResponse tipinde bir API yanıtı.
20
22
  */
21
- GetBannerByKey: () => Promise<IApiResponse<IBannerResponse>>;
23
+ GetBannerByKey: (options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<IBannerResponse>>;
22
24
  /**
23
- * Banner listesini getirir.
24
- * @returns Banner listesini içeren bir API yanıtı.
25
+ * Tüm banner'ların listesini getirir.
26
+ * @param options - RequestOptions'dan 'url' ve 'method' çıkarılmış hali.
27
+ * @returns IBannersResponse tipinde bir API yanıtı.
25
28
  */
26
- GetBannerList: () => Promise<IApiResponse<IBannersResponse>>;
29
+ GetBannerList: (options: Omit<RequestOptions, 'url' | 'method'>) => Promise<IApiResponse<IBannersResponse>>;
27
30
  }
28
31
  /**
29
- * @constant Banner
30
- * @description Banner ile ilgili hizmetleri sağlayan nesne. BannerService arayüzünü uygular.
32
+ * BannerService, banner verilerini almak için çeşitli metodları sağlar.
31
33
  */
32
- export declare const Banner: BannerService;
34
+ export declare const BannerService: BannerService;
33
35
  export {};
@@ -12,38 +12,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Banner = void 0;
15
+ exports.BannerService = void 0;
16
16
  // URL'lerin bulunduğu dosyayı içe aktarır
17
17
  const urls_1 = __importDefault(require("./urls"));
18
- // Yardımcı fonksiyonları içe aktarır
19
18
  const __1 = require("../");
20
19
  /**
21
- * @constant Banner
22
- * @description Banner ile ilgili hizmetleri sağlayan nesne. BannerService arayüzünü uygular.
20
+ * BannerService, banner verilerini almak için çeşitli metodları sağlar.
23
21
  */
24
- exports.Banner = {
22
+ exports.BannerService = {
25
23
  /**
26
- * @method
27
- * @description Belirli bir ID'ye sahip banner'ı getirir.
28
- * @returns {Promise<IApiResponse<IBannerResponse>>} Belirli bir ID'ye sahip banner verilerini içeren bir API yanıtı.
24
+ * Verilen ID'ye sahip banner'ı getirir.
25
+ * @param options - Ekstra istek seçenekleri.
26
+ * @returns IBannerResponse tipinde bir API yanıtı.
29
27
  */
30
- GetBannerById: () => __awaiter(void 0, void 0, void 0, function* () { return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerById); }),
28
+ GetBannerById: (options) => __awaiter(void 0, void 0, void 0, function* () {
29
+ return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerById, options);
30
+ }),
31
31
  /**
32
- * @method
33
- * @description Belirli bir isme sahip banner'ı getirir.
34
- * @returns {Promise<IApiResponse<IBannerResponse>>} Belirli bir isme sahip banner verilerini içeren bir API yanıtı.
32
+ * Verilen isme sahip banner'ı getirir.
33
+ * @param options - Ekstra istek seçenekleri.
34
+ * @returns IBannerResponse tipinde bir API yanıtı.
35
35
  */
36
- GetBannerByName: () => __awaiter(void 0, void 0, void 0, function* () { return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerByName); }),
36
+ GetBannerByName: (options) => __awaiter(void 0, void 0, void 0, function* () {
37
+ return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerByName, options);
38
+ }),
37
39
  /**
38
- * @method
39
- * @description Belirli bir anahtara sahip banner'ı getirir.
40
- * @returns {Promise<IApiResponse<IBannerResponse>>} Belirli bir anahtara sahip banner verilerini içeren bir API yanıtı.
40
+ * Verilen anahtara sahip banner'ı getirir.
41
+ * @param options - Ekstra istek seçenekleri.
42
+ * @returns IBannerResponse tipinde bir API yanıtı.
41
43
  */
42
- GetBannerByKey: () => __awaiter(void 0, void 0, void 0, function* () { return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerByKey); }),
44
+ GetBannerByKey: (options) => __awaiter(void 0, void 0, void 0, function* () {
45
+ return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerByKey, options);
46
+ }),
43
47
  /**
44
- * @method
45
- * @description Banner listesini getirir.
46
- * @returns {Promise<IApiResponse<IBannersResponse>>} Banner listesini içeren bir API yanıtı.
48
+ * Tüm banner'ların listesini getirir.
49
+ * @param options - Ekstra istek seçenekleri.
50
+ * @returns IBannersResponse tipinde bir API yanıtı.
47
51
  */
48
- GetBannerList: () => __awaiter(void 0, void 0, void 0, function* () { return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerList); }),
52
+ GetBannerList: (options) => __awaiter(void 0, void 0, void 0, function* () {
53
+ return yield (0, __1.fetchRequest)().get(urls_1.default.Banner.GetBannerList, options);
54
+ }),
49
55
  };
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const API_URL = process.env.API_URL;
3
4
  exports.default = {
4
5
  Banner: {
5
- GetBannerById: '/api/banner/{language}/Banner/v1/GetBannerById',
6
- GetBannerByName: '/api/banner/{language}/Banner/v1/GetBannerByName',
7
- GetBannerByKey: '/api/banner/{language}/Banner/v1/GetBannerByKey',
8
- GetBannerList: '/api/banner/{language}/Banner/v1/GetBannerList',
9
- GetBannerContainerList: '/api/banner/{language}/Banner/v1/GetBannerContainerList',
6
+ GetBannerById: API_URL + '/api/banner/{language}/Banner/v1/GetBannerById',
7
+ GetBannerByName: API_URL + '/api/banner/{language}/Banner/v1/GetBannerByName',
8
+ GetBannerByKey: API_URL + '/api/banner/{language}/Banner/v1/GetBannerByKey',
9
+ GetBannerList: API_URL + '/api/banner/{language}/Banner/v1/GetBannerList',
10
+ GetBannerContainerList: API_URL + '/api/banner/{language}/Banner/v1/GetBannerContainerList',
10
11
  }
11
12
  };
package/dist/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export default function test(): void;
package/dist/test.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const services_1 = require("./services");
4
+ function test() {
5
+ const res = services_1.BannerService.GetBannerById({
6
+ cache: 'force-cache', params: {
7
+ bannerId: 1,
8
+ language: 'tr'
9
+ }
10
+ });
11
+ return;
12
+ }
13
+ exports.default = test;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextemos",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "For helpers and hooks used in NextJS projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,6 +25,7 @@
25
25
  "author": "PROJE-INC",
26
26
  "license": "ISC",
27
27
  "devDependencies": {
28
+ "@types/node": "^20.14.2",
28
29
  "@types/react": "^18.3.3",
29
30
  "react": "^18.3.1",
30
31
  "react-dom": "^18.3.1",