nextemos 4.0.0 → 4.0.2
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.js +0 -2
- package/dist/hooks/useFetch.js +1 -1
- package/dist/interfaces/environment.d.ts +31 -0
- package/dist/interfaces/environment.js +2 -0
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/keycloack.d.ts +8 -0
- package/dist/interfaces/keycloack.js +2 -0
- package/dist/services/environment/environment.types.d.ts +23 -0
- package/dist/services/environment/environment.types.js +2 -0
- package/dist/services/environment/index.d.ts +2 -0
- package/dist/services/environment/index.js +75 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +5 -1
- package/dist/services/keycloak/index.d.ts +2 -0
- package/dist/services/keycloak/index.js +29 -0
- package/dist/services/keycloak/keycloak.types.d.ts +13 -0
- package/dist/services/keycloak/keycloak.types.js +2 -0
- package/dist/services/urls.d.ts +5 -0
- package/dist/services/urls.js +5 -0
- package/package.json +1 -1
|
@@ -37,8 +37,6 @@ const fetchRequest = () => {
|
|
|
37
37
|
const apiURL = new URL(url);
|
|
38
38
|
if (params)
|
|
39
39
|
Object.keys(params).forEach(key => apiURL.searchParams.append(key, params[key]));
|
|
40
|
-
if (method === __1.HTTPMethod.POST)
|
|
41
|
-
options.headers = Object.assign(Object.assign({}, options.headers), { ['Content-Type']: 'application/json' });
|
|
42
40
|
console.log(`Fetch Request: ${method} - ${apiURL} - ${JSON.stringify(options)}`);
|
|
43
41
|
try {
|
|
44
42
|
const response = yield fetch(apiURL.toString(), Object.assign(Object.assign({}, options), { method }));
|
package/dist/hooks/useFetch.js
CHANGED
|
@@ -75,7 +75,7 @@ const useFetch = ({ method = "GET", url, requestOptions = {} }) => {
|
|
|
75
75
|
fetchData();
|
|
76
76
|
// Cleanup function to abort the fetch request if the component unmounts or the dependencies change.
|
|
77
77
|
return () => controller.abort();
|
|
78
|
-
}, [url,
|
|
78
|
+
}, [url, reload]);
|
|
79
79
|
// Return the response, loading state, error, and refetch function.
|
|
80
80
|
return {
|
|
81
81
|
response,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IResponse } from './response';
|
|
2
|
+
export interface IInitEnvironmentResponse extends IResponse {
|
|
3
|
+
environment: string;
|
|
4
|
+
}
|
|
5
|
+
export interface IReadEnvironmentResponse extends IResponse {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
version: number;
|
|
8
|
+
parameters: IEnvironmentParameters;
|
|
9
|
+
}
|
|
10
|
+
export interface IUpdateEnvironmentResponse extends IResponse {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
environment: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IEnvironmentParameters {
|
|
15
|
+
UserName: string;
|
|
16
|
+
PriceTypeId: string;
|
|
17
|
+
ShoppingCartId: string;
|
|
18
|
+
PlatformId: string;
|
|
19
|
+
CurrId: string;
|
|
20
|
+
Channel: string;
|
|
21
|
+
Country: string;
|
|
22
|
+
AddressZone: string;
|
|
23
|
+
ESp: string;
|
|
24
|
+
TenantName: string;
|
|
25
|
+
Timezone: string;
|
|
26
|
+
Coupon: string;
|
|
27
|
+
MemberIntegrationCode: string;
|
|
28
|
+
PaymentType: string;
|
|
29
|
+
Member: string;
|
|
30
|
+
MemberType: string;
|
|
31
|
+
}
|
|
@@ -9,6 +9,8 @@ export * from './member';
|
|
|
9
9
|
export * from './address';
|
|
10
10
|
export * from './prediction';
|
|
11
11
|
export * from './localization';
|
|
12
|
+
export * from './environment';
|
|
13
|
+
export * from './keycloack';
|
|
12
14
|
export * from '../services/banner/banner.types';
|
|
13
15
|
export * from '../services/blog/blog.types';
|
|
14
16
|
export * from '../services/product/product.types';
|
package/dist/interfaces/index.js
CHANGED
|
@@ -26,6 +26,8 @@ __exportStar(require("./member"), exports);
|
|
|
26
26
|
__exportStar(require("./address"), exports);
|
|
27
27
|
__exportStar(require("./prediction"), exports);
|
|
28
28
|
__exportStar(require("./localization"), exports);
|
|
29
|
+
__exportStar(require("./environment"), exports);
|
|
30
|
+
__exportStar(require("./keycloack"), exports);
|
|
29
31
|
/// service types
|
|
30
32
|
__exportStar(require("../services/banner/banner.types"), exports);
|
|
31
33
|
__exportStar(require("../services/blog/blog.types"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IEnvironmentParameters, IInitEnvironmentResponse, IReadEnvironmentResponse, IUpdateEnvironmentResponse } from '../../';
|
|
2
|
+
import { IApiResponse, IRequestInit } from '../..';
|
|
3
|
+
export interface IInitEnvironmentRequest {
|
|
4
|
+
platform: 'desktop' | 'mobile';
|
|
5
|
+
countryCode: string;
|
|
6
|
+
language?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IReadEnvironmentRequest {
|
|
9
|
+
environment: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IUpdateEnvironmentRequest {
|
|
13
|
+
environment: string;
|
|
14
|
+
parameters: IEnvironmentParameters;
|
|
15
|
+
language?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IEnvironmentService {
|
|
18
|
+
ServiceUrl: string;
|
|
19
|
+
Prefix: string;
|
|
20
|
+
Init: (data: IInitEnvironmentRequest, options?: IRequestInit) => Promise<IApiResponse<IInitEnvironmentResponse>>;
|
|
21
|
+
Read: (data: IReadEnvironmentRequest, options?: IRequestInit) => Promise<IApiResponse<IReadEnvironmentResponse>>;
|
|
22
|
+
Update: (data: IUpdateEnvironmentRequest, options?: IRequestInit) => Promise<IApiResponse<IUpdateEnvironmentResponse>>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.EnvironmentService = void 0;
|
|
36
|
+
const urls_1 = __importStar(require("../urls"));
|
|
37
|
+
const __1 = require("../..");
|
|
38
|
+
// Environment servisi
|
|
39
|
+
exports.EnvironmentService = {
|
|
40
|
+
ServiceUrl: "http://environment.emosv2service.svc.cluster.local",
|
|
41
|
+
Prefix: '/api/environment',
|
|
42
|
+
Init: function (data, options) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return yield (0, __1.fetchRequest)().post((0, urls_1.getUrl)({
|
|
45
|
+
serviceUrl: this.ServiceUrl,
|
|
46
|
+
prefix: this.Prefix,
|
|
47
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
48
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
49
|
+
methodName: urls_1.default.Environment.Init,
|
|
50
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
Read: function (data, options) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield (0, __1.fetchRequest)().post((0, urls_1.getUrl)({
|
|
56
|
+
serviceUrl: this.ServiceUrl,
|
|
57
|
+
prefix: this.Prefix,
|
|
58
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
59
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
60
|
+
methodName: urls_1.default.Environment.Read,
|
|
61
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
Update: function (data, options) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return yield (0, __1.fetchRequest)().post((0, urls_1.getUrl)({
|
|
67
|
+
serviceUrl: this.ServiceUrl,
|
|
68
|
+
prefix: this.Prefix,
|
|
69
|
+
isClient: options === null || options === void 0 ? void 0 : options.useClient,
|
|
70
|
+
language: data === null || data === void 0 ? void 0 : data.language,
|
|
71
|
+
methodName: urls_1.default.Environment.Update,
|
|
72
|
+
}), Object.assign(Object.assign({}, options), { body: JSON.stringify(data) }));
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
package/dist/services/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export declare const Service: {
|
|
|
8
8
|
Member: import("..").IMemberService;
|
|
9
9
|
Prediction: import("..").IPredictionService;
|
|
10
10
|
Localization: import("..").ILocalizationService;
|
|
11
|
+
Environment: import("./environment/environment.types").IEnvironmentService;
|
|
12
|
+
Keycloak: import("./keycloak/keycloak.types").IKeycloakService;
|
|
11
13
|
};
|
package/dist/services/index.js
CHANGED
|
@@ -5,6 +5,8 @@ exports.Service = void 0;
|
|
|
5
5
|
const address_1 = require("./address");
|
|
6
6
|
const banner_1 = require("./banner");
|
|
7
7
|
const blog_1 = require("./blog");
|
|
8
|
+
const environment_1 = require("./environment");
|
|
9
|
+
const keycloak_1 = require("./keycloak");
|
|
8
10
|
const localization_1 = require("./localization");
|
|
9
11
|
const member_1 = require("./member");
|
|
10
12
|
const prediction_1 = require("./prediction");
|
|
@@ -20,5 +22,7 @@ exports.Service = {
|
|
|
20
22
|
Stock: stock_1.StockService,
|
|
21
23
|
Member: member_1.MemberService,
|
|
22
24
|
Prediction: prediction_1.PredictionService,
|
|
23
|
-
Localization: localization_1.LocalizationService
|
|
25
|
+
Localization: localization_1.LocalizationService,
|
|
26
|
+
Environment: environment_1.EnvironmentService,
|
|
27
|
+
Keycloak: keycloak_1.KeycloakService
|
|
24
28
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.KeycloakService = void 0;
|
|
13
|
+
const __1 = require("../..");
|
|
14
|
+
// Environment servisi
|
|
15
|
+
exports.KeycloakService = {
|
|
16
|
+
ServiceUrl: "https://keycloak.proj-e.com",
|
|
17
|
+
Token: function (data, options) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
// request
|
|
20
|
+
const urlencoded = new URLSearchParams();
|
|
21
|
+
urlencoded.append('client_id', data.client_id);
|
|
22
|
+
urlencoded.append('client_secret', data.client_secret);
|
|
23
|
+
urlencoded.append('grant_type', data.grant_type);
|
|
24
|
+
return yield (0, __1.fetchRequest)().post(`${this.ServiceUrl}/realms/{REALM_KEY}/protocol/openid-connect/token`.replace(/{REALM_KEY}/g, data.project), Object.assign(Object.assign({}, options), { headers: {
|
|
25
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
26
|
+
}, body: urlencoded }));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IKeycloakTokenResponse } from '../../';
|
|
2
|
+
import { IApiResponse, IRequestInit } from '../..';
|
|
3
|
+
export interface IKeycloakTokenRequest {
|
|
4
|
+
client_id: string;
|
|
5
|
+
client_secret: string;
|
|
6
|
+
grant_type: string;
|
|
7
|
+
project: string;
|
|
8
|
+
language?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IKeycloakService {
|
|
11
|
+
ServiceUrl: string;
|
|
12
|
+
Token: (data: IKeycloakTokenRequest, options?: IRequestInit) => Promise<IApiResponse<IKeycloakTokenResponse>>;
|
|
13
|
+
}
|
package/dist/services/urls.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ declare const _default: {
|
|
|
57
57
|
AllByLanguage: string;
|
|
58
58
|
LocalizedText: string;
|
|
59
59
|
};
|
|
60
|
+
Environment: {
|
|
61
|
+
Init: string;
|
|
62
|
+
Read: string;
|
|
63
|
+
Update: string;
|
|
64
|
+
};
|
|
60
65
|
};
|
|
61
66
|
export default _default;
|
|
62
67
|
export declare const getUrl: ({ isClient, language, methodName, serviceUrl, prefix, id }: {
|
package/dist/services/urls.js
CHANGED
|
@@ -63,6 +63,11 @@ exports.default = {
|
|
|
63
63
|
AllByLanguage: '/LocalizedText/v1/{language}/all',
|
|
64
64
|
LocalizedText: '/LocalizedText/v1/{language}',
|
|
65
65
|
},
|
|
66
|
+
Environment: {
|
|
67
|
+
Init: '/{language}/Environment/v1/Init',
|
|
68
|
+
Read: '/{language}/Environment/v1/Read',
|
|
69
|
+
Update: '/{language}/Environment/v1/Update',
|
|
70
|
+
},
|
|
66
71
|
};
|
|
67
72
|
const getUrl = ({ isClient = false, language = process.env.DEFAULT_LANGUAGE || "tr", methodName, serviceUrl, prefix, id = '' }) => {
|
|
68
73
|
let url = serviceUrl;
|