feat: changed all licence type to license

This commit is contained in:
=
2024-08-30 10:52:46 +05:30
parent 66ded779fc
commit 0dec602729
5 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
// TODO(akhilmhdh): Fix this when licence service gets it type // TODO(akhilmhdh): Fix this when license service gets it type
import { z } from "zod"; import { z } from "zod";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
@@ -32,4 +32,4 @@ export const getDefaultOnPremFeatures = () => {
}; };
}; };
export const setupLicenceRequestWithStore = () => {}; export const setupLicenseRequestWithStore = () => {};
@@ -49,15 +49,15 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
pkiEst: false pkiEst: false
}); });
export const setupLicenceRequestWithStore = (baseURL: string, refreshUrl: string, licenseKey: string) => { export const setupLicenseRequestWithStore = (baseURL: string, refreshUrl: string, licenseKey: string) => {
let token: string; let token: string;
const licenceReq = axios.create({ const licenseReq = axios.create({
baseURL, baseURL,
timeout: 35 * 1000 timeout: 35 * 1000
// signal: AbortSignal.timeout(60 * 1000) // signal: AbortSignal.timeout(60 * 1000)
}); });
const refreshLicence = async () => { const refreshLicense = async () => {
const appCfg = getConfig(); const appCfg = getConfig();
const { const {
data: { token: authToken } data: { token: authToken }
@@ -75,7 +75,7 @@ export const setupLicenceRequestWithStore = (baseURL: string, refreshUrl: string
return token; return token;
}; };
licenceReq.interceptors.request.use( licenseReq.interceptors.request.use(
(config) => { (config) => {
if (token && config.headers) { if (token && config.headers) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
@@ -86,7 +86,7 @@ export const setupLicenceRequestWithStore = (baseURL: string, refreshUrl: string
(err) => Promise.reject(err) (err) => Promise.reject(err)
); );
licenceReq.interceptors.response.use( licenseReq.interceptors.response.use(
(response) => response, (response) => response,
async (err) => { async (err) => {
const originalRequest = (err as AxiosError).config; const originalRequest = (err as AxiosError).config;
@@ -97,15 +97,15 @@ export const setupLicenceRequestWithStore = (baseURL: string, refreshUrl: string
(originalRequest as any)._retry = true; // injected (originalRequest as any)._retry = true; // injected
// refresh // refresh
await refreshLicence(); await refreshLicense();
licenceReq.defaults.headers.common.Authorization = `Bearer ${token}`; licenseReq.defaults.headers.common.Authorization = `Bearer ${token}`;
return licenceReq(originalRequest!); return licenseReq(originalRequest!);
} }
return Promise.reject(err); return Promise.reject(err);
} }
); );
return { request: licenceReq, refreshLicence }; return { request: licenseReq, refreshLicense };
}; };
@@ -17,7 +17,7 @@ import { TOrgDALFactory } from "@app/services/org/org-dal";
import { OrgPermissionActions, OrgPermissionSubjects } from "../permission/org-permission"; import { OrgPermissionActions, OrgPermissionSubjects } from "../permission/org-permission";
import { TPermissionServiceFactory } from "../permission/permission-service"; import { TPermissionServiceFactory } from "../permission/permission-service";
import { TLicenseDALFactory } from "./license-dal"; import { TLicenseDALFactory } from "./license-dal";
import { getDefaultOnPremFeatures, setupLicenceRequestWithStore } from "./license-fns"; import { getDefaultOnPremFeatures, setupLicenseRequestWithStore } from "./license-fns";
import { import {
InstanceType, InstanceType,
TAddOrgPmtMethodDTO, TAddOrgPmtMethodDTO,
@@ -64,13 +64,13 @@ export const licenseServiceFactory = ({
let onPremFeatures: TFeatureSet = getDefaultOnPremFeatures(); let onPremFeatures: TFeatureSet = getDefaultOnPremFeatures();
const appCfg = getConfig(); const appCfg = getConfig();
const licenseServerCloudApi = setupLicenceRequestWithStore( const licenseServerCloudApi = setupLicenseRequestWithStore(
appCfg.LICENSE_SERVER_URL || "", appCfg.LICENSE_SERVER_URL || "",
LICENSE_SERVER_CLOUD_LOGIN, LICENSE_SERVER_CLOUD_LOGIN,
appCfg.LICENSE_SERVER_KEY || "" appCfg.LICENSE_SERVER_KEY || ""
); );
const licenseServerOnPremApi = setupLicenceRequestWithStore( const licenseServerOnPremApi = setupLicenseRequestWithStore(
appCfg.LICENSE_SERVER_URL || "", appCfg.LICENSE_SERVER_URL || "",
LICENSE_SERVER_ON_PREM_LOGIN, LICENSE_SERVER_ON_PREM_LOGIN,
appCfg.LICENSE_KEY || "" appCfg.LICENSE_KEY || ""
@@ -79,7 +79,7 @@ export const licenseServiceFactory = ({
const init = async () => { const init = async () => {
try { try {
if (appCfg.LICENSE_SERVER_KEY) { if (appCfg.LICENSE_SERVER_KEY) {
const token = await licenseServerCloudApi.refreshLicence(); const token = await licenseServerCloudApi.refreshLicense();
if (token) instanceType = InstanceType.Cloud; if (token) instanceType = InstanceType.Cloud;
logger.info(`Instance type: ${InstanceType.Cloud}`); logger.info(`Instance type: ${InstanceType.Cloud}`);
isValidLicense = true; isValidLicense = true;
@@ -87,7 +87,7 @@ export const licenseServiceFactory = ({
} }
if (appCfg.LICENSE_KEY) { if (appCfg.LICENSE_KEY) {
const token = await licenseServerOnPremApi.refreshLicence(); const token = await licenseServerOnPremApi.refreshLicense();
if (token) { if (token) {
const { const {
data: { currentPlan } data: { currentPlan }
@@ -482,7 +482,7 @@ export const secretServiceFactory = ({
projectId, projectId,
environmentSlug: folder.environment.slug environmentSlug: folder.environment.slug
}); });
// TODO(akhilmhdh-pg): licence check, posthog service and snapshot // TODO(akhilmhdh-pg): license check, posthog service and snapshot
return { ...deletedSecret[0], _id: deletedSecret[0].id, workspace: projectId, environment, secretPath: path }; return { ...deletedSecret[0], _id: deletedSecret[0].id, workspace: projectId, environment, secretPath: path };
}; };