mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-20 23:16:55 +00:00
feat(infisical-pg): added slug for org and project, resolved build error
This commit is contained in:
@@ -10,7 +10,9 @@ export async function up(knex: Knex): Promise<void> {
|
||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||
t.string("name").notNullable();
|
||||
t.string("customerId");
|
||||
t.string("slug").notNullable();
|
||||
// does not need update trigger we will do it manually
|
||||
t.unique("slug");
|
||||
t.timestamps(true, true, true);
|
||||
});
|
||||
await knex.schema.alterTable(TableName.AuthTokens, (t) => {
|
||||
|
||||
@@ -8,10 +8,12 @@ export async function up(knex: Knex): Promise<void> {
|
||||
await knex.schema.createTable(TableName.Project, (t) => {
|
||||
t.string("id", 36).primary().defaultTo(knex.fn.uuid());
|
||||
t.string("name").notNullable();
|
||||
t.string("slug").notNullable();
|
||||
t.boolean("autoCapitalization").defaultTo(true);
|
||||
t.uuid("orgId").notNullable();
|
||||
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
||||
t.timestamps(true, true, true);
|
||||
t.unique(["orgId", "slug"]);
|
||||
});
|
||||
}
|
||||
await createOnUpdateTrigger(knex, TableName.Project);
|
||||
|
||||
@@ -11,8 +11,9 @@ export const OrganizationsSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string(),
|
||||
customerId: z.string().nullable().optional(),
|
||||
slug: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
updatedAt: z.date()
|
||||
});
|
||||
|
||||
export type TOrganizations = z.infer<typeof OrganizationsSchema>;
|
||||
|
||||
@@ -10,6 +10,7 @@ import { TImmutableDBKeys } from "./models";
|
||||
export const ProjectsSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
slug: z.string(),
|
||||
autoCapitalization: z.boolean().default(true).nullable().optional(),
|
||||
orgId: z.string().uuid(),
|
||||
createdAt: z.date(),
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
export {
|
||||
DisableRotationErrors,
|
||||
secretRotationQueueFactory,
|
||||
TSecretRotationQueueFactory
|
||||
} from "./secret-rotation-queue";
|
||||
export type { TSecretRotationQueueFactory } from "./secret-rotation-queue";
|
||||
export { DisableRotationErrors, secretRotationQueueFactory } from "./secret-rotation-queue";
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
export {
|
||||
QueueJobs,
|
||||
QueueName,
|
||||
queueServiceFactory,
|
||||
TQueueJobTypes,
|
||||
TQueueServiceFactory
|
||||
} from "./queue-service";
|
||||
export type { TQueueJobTypes, TQueueServiceFactory } from "./queue-service";
|
||||
export { QueueJobs, QueueName, queueServiceFactory } from "./queue-service";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ForbiddenError } from "@casl/ability";
|
||||
import slugify from "@sindresorhus/slugify";
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
import { OrgMembershipRole, OrgMembershipStatus } from "@app/db/schemas";
|
||||
@@ -13,6 +14,7 @@ import { getConfig } from "@app/lib/config/env";
|
||||
import { generateAsymmetricKeyPair } from "@app/lib/crypto";
|
||||
import { generateSymmetricKey, infisicalSymmetricEncypt } from "@app/lib/crypto/encryption";
|
||||
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
|
||||
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||
import { isDisposableEmail } from "@app/lib/validator";
|
||||
|
||||
import { AuthMethod, AuthTokenType } from "../auth/auth-type";
|
||||
@@ -128,7 +130,11 @@ export const orgServiceFactory = ({
|
||||
|
||||
const customerId = await licenseService.generateOrgCustomerId(orgName, userEmail);
|
||||
const organization = await orgDAL.transaction(async (tx) => {
|
||||
const org = await orgDAL.create({ name: orgName, customerId }, tx);
|
||||
// akhilmhdh: for now this is auto created. in future we can input from user and for previous users just modifiy
|
||||
const org = await orgDAL.create(
|
||||
{ name: orgName, customerId, slug: slugify(`${orgName}-${alphaNumericNanoId(4)}`) },
|
||||
tx
|
||||
);
|
||||
await orgDAL.createMembership(
|
||||
{
|
||||
userId,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ForbiddenError } from "@casl/ability";
|
||||
import slugify from "@sindresorhus/slugify";
|
||||
|
||||
import { ProjectMembershipRole } from "@app/db/schemas";
|
||||
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
import { createSecretBlindIndex } from "@app/lib/crypto";
|
||||
import { BadRequestError } from "@app/lib/errors";
|
||||
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||
|
||||
import { TProjectEnvDALFactory } from "../project-env/project-env-dal";
|
||||
import { TProjectMembershipDALFactory } from "../project-membership/project-membership-dal";
|
||||
@@ -73,7 +75,10 @@ export const projectServiceFactory = ({
|
||||
}
|
||||
|
||||
const newProject = projectDAL.transaction(async (tx) => {
|
||||
const project = await projectDAL.create({ name: workspaceName, orgId }, tx);
|
||||
const project = await projectDAL.create(
|
||||
{ name: workspaceName, orgId, slug: slugify(`${workspaceName}-${alphaNumericNanoId(4)}`) },
|
||||
tx
|
||||
);
|
||||
// set user as admin member for proeject
|
||||
await projectMembershipDAL.create(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user