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.
- package/dist/helpers/fetchRequest.d.ts +5 -12
- package/dist/helpers/fetchRequest.js +2 -3
- package/dist/interfaces/response.d.ts +31 -0
- package/dist/services/banner.d.ts +20 -18
- package/dist/services/banner.js +27 -21
- package/dist/services/urls.js +6 -5
- package/dist/test.d.ts +1 -0
- package/dist/test.js +13 -0
- package/package.json +2 -1
|
@@ -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
|
|
15
|
-
post: <T_1>(url: string, data: any, options
|
|
16
|
-
put: <T_2>(url: string, data: any, options
|
|
17
|
-
delete: <T_3>(url: string, options
|
|
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,
|
|
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({},
|
|
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ü,
|
|
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
|
-
*
|
|
9
|
-
* @
|
|
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
|
-
*
|
|
14
|
-
* @
|
|
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
|
-
*
|
|
19
|
-
* @
|
|
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
|
-
*
|
|
24
|
-
* @
|
|
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
|
-
*
|
|
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
|
|
34
|
+
export declare const BannerService: BannerService;
|
|
33
35
|
export {};
|
package/dist/services/banner.js
CHANGED
|
@@ -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.
|
|
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
|
-
*
|
|
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.
|
|
22
|
+
exports.BannerService = {
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
* @returns
|
|
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* () {
|
|
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
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @returns
|
|
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* () {
|
|
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
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns
|
|
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* () {
|
|
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
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
* @returns
|
|
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* () {
|
|
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
|
};
|
package/dist/services/urls.js
CHANGED
|
@@ -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.
|
|
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",
|