mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 04:58:28 +00:00
feat: updated more types to avoid infer
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
import { ormify, TOrmify } from "@app/lib/knex";
|
||||
|
||||
export type TTrustedIpDALFactory = ReturnType<typeof trustedIpDALFactory>;
|
||||
export type TTrustedIpDALFactory = TOrmify<TableName.TrustedIps>;
|
||||
|
||||
export const trustedIpDALFactory = (db: TDbClient) => {
|
||||
export const trustedIpDALFactory = (db: TDbClient): TTrustedIpDALFactory => {
|
||||
const trustedIpOrm = ormify(db, TableName.TrustedIps);
|
||||
return trustedIpOrm;
|
||||
};
|
||||
|
||||
@@ -3,14 +3,13 @@ import { ForbiddenError } from "@casl/ability";
|
||||
import { ActionProjectType } from "@app/db/schemas";
|
||||
import { BadRequestError } from "@app/lib/errors";
|
||||
import { extractIPDetails, isValidIpOrCidr } from "@app/lib/ip";
|
||||
import { TProjectPermission } from "@app/lib/types";
|
||||
import { TProjectDALFactory } from "@app/services/project/project-dal";
|
||||
|
||||
import { TLicenseServiceFactory } from "../license/license-service";
|
||||
import { TPermissionServiceFactory } from "../permission/permission-service";
|
||||
import { TPermissionServiceFactory } from "../permission/permission-service-types";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub } from "../permission/project-permission";
|
||||
import { TTrustedIpDALFactory } from "./trusted-ip-dal";
|
||||
import { TCreateIpDTO, TDeleteIpDTO, TUpdateIpDTO } from "./trusted-ip-types";
|
||||
import { TTrustedIpServiceFactory } from "./trusted-ip-types";
|
||||
|
||||
type TTrustedIpServiceFactoryDep = {
|
||||
trustedIpDAL: TTrustedIpDALFactory;
|
||||
@@ -19,15 +18,19 @@ type TTrustedIpServiceFactoryDep = {
|
||||
projectDAL: Pick<TProjectDALFactory, "findById">;
|
||||
};
|
||||
|
||||
export type TTrustedIpServiceFactory = ReturnType<typeof trustedIpServiceFactory>;
|
||||
|
||||
export const trustedIpServiceFactory = ({
|
||||
trustedIpDAL,
|
||||
permissionService,
|
||||
licenseService,
|
||||
projectDAL
|
||||
}: TTrustedIpServiceFactoryDep) => {
|
||||
const listIpsByProjectId = async ({ projectId, actor, actorId, actorAuthMethod, actorOrgId }: TProjectPermission) => {
|
||||
}: TTrustedIpServiceFactoryDep): TTrustedIpServiceFactory => {
|
||||
const listIpsByProjectId: TTrustedIpServiceFactory["listIpsByProjectId"] = async ({
|
||||
projectId,
|
||||
actor,
|
||||
actorId,
|
||||
actorAuthMethod,
|
||||
actorOrgId
|
||||
}) => {
|
||||
const { permission } = await permissionService.getProjectPermission({
|
||||
actor,
|
||||
actorId,
|
||||
@@ -43,7 +46,7 @@ export const trustedIpServiceFactory = ({
|
||||
return trustedIps;
|
||||
};
|
||||
|
||||
const addProjectIp = async ({
|
||||
const addProjectIp: TTrustedIpServiceFactory["addProjectIp"] = async ({
|
||||
projectId,
|
||||
actorId,
|
||||
actorAuthMethod,
|
||||
@@ -52,7 +55,7 @@ export const trustedIpServiceFactory = ({
|
||||
ipAddress: ip,
|
||||
comment,
|
||||
isActive
|
||||
}: TCreateIpDTO) => {
|
||||
}) => {
|
||||
const { permission } = await permissionService.getProjectPermission({
|
||||
actor,
|
||||
actorId,
|
||||
@@ -89,7 +92,7 @@ export const trustedIpServiceFactory = ({
|
||||
return { trustedIp, project }; // for audit log
|
||||
};
|
||||
|
||||
const updateProjectIp = async ({
|
||||
const updateProjectIp: TTrustedIpServiceFactory["updateProjectIp"] = async ({
|
||||
projectId,
|
||||
actorId,
|
||||
actor,
|
||||
@@ -98,7 +101,7 @@ export const trustedIpServiceFactory = ({
|
||||
ipAddress: ip,
|
||||
comment,
|
||||
trustedIpId
|
||||
}: TUpdateIpDTO) => {
|
||||
}) => {
|
||||
const { permission } = await permissionService.getProjectPermission({
|
||||
actor,
|
||||
actorId,
|
||||
@@ -137,14 +140,14 @@ export const trustedIpServiceFactory = ({
|
||||
return { trustedIp, project }; // for audit log
|
||||
};
|
||||
|
||||
const deleteProjectIp = async ({
|
||||
const deleteProjectIp: TTrustedIpServiceFactory["deleteProjectIp"] = async ({
|
||||
projectId,
|
||||
actorId,
|
||||
actor,
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
trustedIpId
|
||||
}: TDeleteIpDTO) => {
|
||||
}) => {
|
||||
const { permission } = await permissionService.getProjectPermission({
|
||||
actor,
|
||||
actorId,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { TProjects, TTrustedIps } from "@app/db/schemas";
|
||||
import { TProjectPermission } from "@app/lib/types";
|
||||
|
||||
export type TCreateIpDTO = TProjectPermission & {
|
||||
@@ -15,3 +16,19 @@ export type TUpdateIpDTO = TProjectPermission & {
|
||||
export type TDeleteIpDTO = TProjectPermission & {
|
||||
trustedIpId: string;
|
||||
};
|
||||
|
||||
export type TTrustedIpServiceFactory = {
|
||||
listIpsByProjectId: (arg: TProjectPermission) => Promise<TTrustedIps[]>;
|
||||
addProjectIp: (arg: TCreateIpDTO) => Promise<{
|
||||
trustedIp: TTrustedIps;
|
||||
project: TProjects;
|
||||
}>;
|
||||
updateProjectIp: (arg: TUpdateIpDTO) => Promise<{
|
||||
trustedIp: TTrustedIps;
|
||||
project: TProjects;
|
||||
}>;
|
||||
deleteProjectIp: (arg: TDeleteIpDTO) => Promise<{
|
||||
trustedIp: TTrustedIps;
|
||||
project: TProjects;
|
||||
}>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user