mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
feat: removed name from tag and stricter slugification for tag endpoint
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
|
||||||
|
import { TableName } from "../schemas";
|
||||||
|
|
||||||
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
const hasNameField = await knex.schema.hasColumn(TableName.SecretTag, "name");
|
||||||
|
if (hasNameField) {
|
||||||
|
await knex.schema.alterTable(TableName.SecretTag, (t) => {
|
||||||
|
t.dropColumn("name");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
const hasNameField = await knex.schema.hasColumn(TableName.SecretTag, "name");
|
||||||
|
if (!hasNameField) {
|
||||||
|
await knex.schema.alterTable(TableName.SecretTag, (t) => {
|
||||||
|
t.string("name");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ import { TImmutableDBKeys } from "./models";
|
|||||||
|
|
||||||
export const SecretTagsSchema = z.object({
|
export const SecretTagsSchema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
name: z.string(),
|
|
||||||
slug: z.string(),
|
slug: z.string(),
|
||||||
color: z.string().nullable().optional(),
|
color: z.string().nullable().optional(),
|
||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
|
|||||||
+4
-4
@@ -124,9 +124,9 @@ export const secretApprovalRequestSecretDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagJnId",
|
key: "tagJnId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagName: name, tagSlug: slug, tagColor: color }) => ({
|
mapper: ({ tagId: id, tagSlug: slug, tagColor: color }) => ({
|
||||||
id,
|
id,
|
||||||
name,
|
name: slug,
|
||||||
slug,
|
slug,
|
||||||
color
|
color
|
||||||
})
|
})
|
||||||
@@ -292,9 +292,9 @@ export const secretApprovalRequestSecretDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagJnId",
|
key: "tagJnId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagName: name, tagSlug: slug, tagColor: color }) => ({
|
mapper: ({ tagId: id, tagSlug: slug, tagColor: color }) => ({
|
||||||
id,
|
id,
|
||||||
name,
|
name: slug,
|
||||||
slug,
|
slug,
|
||||||
color
|
color
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -377,9 +377,9 @@ export const snapshotDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagVersionId",
|
key: "tagVersionId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagName: name, tagSlug: slug, tagColor: color, tagVersionId: vId }) => ({
|
mapper: ({ tagId: id, tagSlug: slug, tagColor: color, tagVersionId: vId }) => ({
|
||||||
id,
|
id,
|
||||||
name,
|
name: slug,
|
||||||
slug,
|
slug,
|
||||||
color,
|
color,
|
||||||
vId
|
vId
|
||||||
@@ -532,9 +532,9 @@ export const snapshotDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagVersionId",
|
key: "tagVersionId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagName: name, tagSlug: slug, tagColor: color, tagVersionId: vId }) => ({
|
mapper: ({ tagId: id, tagSlug: slug, tagColor: color, tagVersionId: vId }) => ({
|
||||||
id,
|
id,
|
||||||
name,
|
name: slug,
|
||||||
slug,
|
slug,
|
||||||
color,
|
color,
|
||||||
vId
|
vId
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import slugify from "@sindresorhus/slugify";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { SecretTagsSchema } from "@app/db/schemas";
|
import { SecretTagsSchema } from "@app/db/schemas";
|
||||||
@@ -49,7 +50,8 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
workspaceTag: SecretTagsSchema
|
// akhilmhdh: for terraform backward compatiability
|
||||||
|
workspaceTag: SecretTagsSchema.extend({ name: z.string() })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -79,7 +81,7 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
workspaceTag: SecretTagsSchema
|
workspaceTag: SecretTagsSchema.extend({ name: z.string() })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -108,8 +110,14 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
projectId: z.string().trim().describe(SECRET_TAGS.CREATE.projectId)
|
projectId: z.string().trim().describe(SECRET_TAGS.CREATE.projectId)
|
||||||
}),
|
}),
|
||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().trim().describe(SECRET_TAGS.CREATE.name),
|
slug: z
|
||||||
slug: z.string().trim().describe(SECRET_TAGS.CREATE.slug),
|
.string()
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.describe(SECRET_TAGS.CREATE.slug)
|
||||||
|
.refine((v) => slugify(v) === v, {
|
||||||
|
message: "Invalid slug. Should contain only characters, numbers and hyphen."
|
||||||
|
}),
|
||||||
color: z.string().trim().describe(SECRET_TAGS.CREATE.color)
|
color: z.string().trim().describe(SECRET_TAGS.CREATE.color)
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
@@ -144,8 +152,14 @@ export const registerSecretTagRouter = async (server: FastifyZodProvider) => {
|
|||||||
tagId: z.string().trim().describe(SECRET_TAGS.UPDATE.tagId)
|
tagId: z.string().trim().describe(SECRET_TAGS.UPDATE.tagId)
|
||||||
}),
|
}),
|
||||||
body: z.object({
|
body: z.object({
|
||||||
name: z.string().trim().describe(SECRET_TAGS.UPDATE.name),
|
slug: z
|
||||||
slug: z.string().trim().describe(SECRET_TAGS.UPDATE.slug),
|
.string()
|
||||||
|
.toLowerCase()
|
||||||
|
.trim()
|
||||||
|
.describe(SECRET_TAGS.UPDATE.slug)
|
||||||
|
.refine((v) => slugify(v) === v, {
|
||||||
|
message: "Invalid slug. Should contain only characters, numbers and hyphen."
|
||||||
|
}),
|
||||||
color: z.string().trim().describe(SECRET_TAGS.UPDATE.color)
|
color: z.string().trim().describe(SECRET_TAGS.UPDATE.color)
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
|
|||||||
@@ -22,16 +22,7 @@ type TSecretTagServiceFactoryDep = {
|
|||||||
export type TSecretTagServiceFactory = ReturnType<typeof secretTagServiceFactory>;
|
export type TSecretTagServiceFactory = ReturnType<typeof secretTagServiceFactory>;
|
||||||
|
|
||||||
export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSecretTagServiceFactoryDep) => {
|
export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSecretTagServiceFactoryDep) => {
|
||||||
const createTag = async ({
|
const createTag = async ({ slug, actor, color, actorId, actorOrgId, actorAuthMethod, projectId }: TCreateTagDTO) => {
|
||||||
name,
|
|
||||||
slug,
|
|
||||||
actor,
|
|
||||||
color,
|
|
||||||
actorId,
|
|
||||||
actorOrgId,
|
|
||||||
actorAuthMethod,
|
|
||||||
projectId
|
|
||||||
}: TCreateTagDTO) => {
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(
|
||||||
actor,
|
actor,
|
||||||
actorId,
|
actorId,
|
||||||
@@ -46,7 +37,6 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
|
|
||||||
const newTag = await secretTagDAL.create({
|
const newTag = await secretTagDAL.create({
|
||||||
projectId,
|
projectId,
|
||||||
name,
|
|
||||||
slug,
|
slug,
|
||||||
color,
|
color,
|
||||||
createdBy: actorId,
|
createdBy: actorId,
|
||||||
@@ -55,7 +45,7 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
return newTag;
|
return newTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTag = async ({ actorId, actor, actorOrgId, actorAuthMethod, id, name, color, slug }: TUpdateTagDTO) => {
|
const updateTag = async ({ actorId, actor, actorOrgId, actorAuthMethod, id, color, slug }: TUpdateTagDTO) => {
|
||||||
const tag = await secretTagDAL.findById(id);
|
const tag = await secretTagDAL.findById(id);
|
||||||
if (!tag) throw new BadRequestError({ message: "Tag doesn't exist" });
|
if (!tag) throw new BadRequestError({ message: "Tag doesn't exist" });
|
||||||
|
|
||||||
@@ -73,7 +63,7 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Edit, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
const updatedTag = await secretTagDAL.updateById(tag.id, { name, color, slug });
|
const updatedTag = await secretTagDAL.updateById(tag.id, { color, slug });
|
||||||
return updatedTag;
|
return updatedTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,7 +97,7 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
return tag;
|
return { ...tag, name: tag.slug };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTagBySlug = async ({ actorId, actor, actorOrgId, actorAuthMethod, slug, projectId }: TGetTagBySlugDTO) => {
|
const getTagBySlug = async ({ actorId, actor, actorOrgId, actorAuthMethod, slug, projectId }: TGetTagBySlugDTO) => {
|
||||||
@@ -123,7 +113,7 @@ export const secretTagServiceFactory = ({ secretTagDAL, permissionService }: TSe
|
|||||||
);
|
);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
|
||||||
|
|
||||||
return tag;
|
return { ...tag, name: tag.slug };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getProjectTags = async ({ actor, actorId, actorOrgId, actorAuthMethod, projectId }: TListProjectTagsDTO) => {
|
const getProjectTags = async ({ actor, actorId, actorOrgId, actorAuthMethod, projectId }: TListProjectTagsDTO) => {
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import { TProjectPermission } from "@app/lib/types";
|
import { TProjectPermission } from "@app/lib/types";
|
||||||
|
|
||||||
export type TCreateTagDTO = {
|
export type TCreateTagDTO = {
|
||||||
name: string;
|
|
||||||
color: string;
|
color: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
} & TProjectPermission;
|
} & TProjectPermission;
|
||||||
|
|
||||||
export type TUpdateTagDTO = {
|
export type TUpdateTagDTO = {
|
||||||
id: string;
|
id: string;
|
||||||
name?: string;
|
|
||||||
slug?: string;
|
slug?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
} & Omit<TProjectPermission, "projectId">;
|
} & Omit<TProjectPermission, "projectId">;
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"))
|
|
||||||
.orderBy("id", "asc");
|
.orderBy("id", "asc");
|
||||||
|
|
||||||
const data = sqlNestRelationships({
|
const data = sqlNestRelationships({
|
||||||
@@ -147,11 +146,11 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -169,14 +168,13 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
.where({ [`${TableName.SecretV2}Id` as const]: secretId })
|
.where({ [`${TableName.SecretV2}Id` as const]: secretId })
|
||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"));
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"));
|
|
||||||
|
|
||||||
return tags.map((el) => ({
|
return tags.map((el) => ({
|
||||||
id: el.tagId,
|
id: el.tagId,
|
||||||
color: el.tagColor,
|
color: el.tagColor,
|
||||||
slug: el.tagSlug,
|
slug: el.tagSlug,
|
||||||
name: el.tagName
|
name: el.tagSlug
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "get secret tags" });
|
throw new DatabaseError({ error, name: "get secret tags" });
|
||||||
@@ -210,7 +208,6 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"))
|
|
||||||
.orderBy("id", "asc");
|
.orderBy("id", "asc");
|
||||||
|
|
||||||
const data = sqlNestRelationships({
|
const data = sqlNestRelationships({
|
||||||
@@ -221,11 +218,11 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -350,8 +347,7 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
.select(selectAllTableCols(TableName.SecretV2))
|
.select(selectAllTableCols(TableName.SecretV2))
|
||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"));
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"));
|
|
||||||
const docs = sqlNestRelationships({
|
const docs = sqlNestRelationships({
|
||||||
data: rawDocs,
|
data: rawDocs,
|
||||||
key: "id",
|
key: "id",
|
||||||
@@ -360,11 +356,11 @@ export const secretV2BridgeDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"))
|
|
||||||
.orderBy("id", "asc");
|
.orderBy("id", "asc");
|
||||||
const data = sqlNestRelationships({
|
const data = sqlNestRelationships({
|
||||||
data: secs,
|
data: secs,
|
||||||
@@ -133,11 +132,11 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -155,14 +154,13 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
.where({ [`${TableName.Secret}Id` as const]: secretId })
|
.where({ [`${TableName.Secret}Id` as const]: secretId })
|
||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"));
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"));
|
|
||||||
|
|
||||||
return tags.map((el) => ({
|
return tags.map((el) => ({
|
||||||
id: el.tagId,
|
id: el.tagId,
|
||||||
color: el.tagColor,
|
color: el.tagColor,
|
||||||
slug: el.tagSlug,
|
slug: el.tagSlug,
|
||||||
name: el.tagName
|
name: el.tagSlug
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new DatabaseError({ error, name: "get secret tags" });
|
throw new DatabaseError({ error, name: "get secret tags" });
|
||||||
@@ -188,7 +186,6 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
.select(db.ref("id").withSchema(TableName.SecretTag).as("tagId"))
|
||||||
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
.select(db.ref("color").withSchema(TableName.SecretTag).as("tagColor"))
|
||||||
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
.select(db.ref("slug").withSchema(TableName.SecretTag).as("tagSlug"))
|
||||||
.select(db.ref("name").withSchema(TableName.SecretTag).as("tagName"))
|
|
||||||
.orderBy("id", "asc");
|
.orderBy("id", "asc");
|
||||||
const data = sqlNestRelationships({
|
const data = sqlNestRelationships({
|
||||||
data: secs,
|
data: secs,
|
||||||
@@ -198,11 +195,11 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -328,11 +325,11 @@ export const secretDALFactory = (db: TDbClient) => {
|
|||||||
{
|
{
|
||||||
key: "tagId",
|
key: "tagId",
|
||||||
label: "tags" as const,
|
label: "tags" as const,
|
||||||
mapper: ({ tagId: id, tagColor: color, tagSlug: slug, tagName: name }) => ({
|
mapper: ({ tagId: id, tagColor: color, tagSlug: slug }) => ({
|
||||||
id,
|
id,
|
||||||
color,
|
color,
|
||||||
slug,
|
slug,
|
||||||
name
|
name: slug
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -370,7 +370,6 @@ export const decryptSecretRaw = (
|
|||||||
id: string;
|
id: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
color?: string | null;
|
color?: string | null;
|
||||||
name: string;
|
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
key: string
|
key: string
|
||||||
@@ -412,7 +411,7 @@ export const decryptSecretRaw = (
|
|||||||
_id: secret.id,
|
_id: secret.id,
|
||||||
id: secret.id,
|
id: secret.id,
|
||||||
user: secret.userId,
|
user: secret.userId,
|
||||||
tags: secret.tags,
|
tags: secret.tags?.map((el) => ({ ...el, name: el.slug })),
|
||||||
skipMultilineEncoding: secret.skipMultilineEncoding,
|
skipMultilineEncoding: secret.skipMultilineEncoding,
|
||||||
secretReminderRepeatDays: secret.secretReminderRepeatDays,
|
secretReminderRepeatDays: secret.secretReminderRepeatDays,
|
||||||
secretReminderNote: secret.secretReminderNote,
|
secretReminderNote: secret.secretReminderNote,
|
||||||
|
|||||||
@@ -2086,7 +2086,7 @@ export const secretServiceFactory = ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...updatedSecret[0],
|
...updatedSecret[0],
|
||||||
tags: [...existingSecretTags, ...tags].map((t) => ({ id: t.id, slug: t.slug, name: t.name, color: t.color }))
|
tags: [...existingSecretTags, ...tags].map((t) => ({ id: t.id, slug: t.slug, color: t.color }))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user