Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,47 +71,47 @@ export class KnowledgeBaseWordpress {
databaseId: number;

@Field()
informationTitle: string;
knowledgeBaseTitle: string;

@Field()
informationContent: string;
knowledgeBaseContent: string;

@Field()
informationSearchKeywords: string;
knowledgeBaseSearchKeywords: string;

@Field()
informationType: 'content' | 'internal_link' | 'external_link';
knowledgeBaseType: 'content' | 'internal_link' | 'external_link';

@Field()
informationChildDisplay: 'card' | 'list';
knowledgeBaseChildDisplay: 'card' | 'list';

@Field()
informationLink: string;
knowledgeBaseLink: string;

@Field()
informationPosition: number;
knowledgeBasePosition: number;

@Field()
informationAccessRestriction: 'ALLOW' | 'DISALLOW' | 'NONE';
knowledgeBaseAccessRestriction: 'ALLOW' | 'DISALLOW' | 'NONE';

@Field(() => KnowledgeBaseRolesWordpress)
informationRoles: KnowledgeBaseRolesWordpress;
knowledgeBaseRoles: KnowledgeBaseRolesWordpress;

@Field(() => [KnowledgeBaseTranslationsWordpress])
translations: KnowledgeBaseTranslationsWordpress[];

@Field(() => KnowledgeBaseParentNodeWordpress, { nullable: true })
informationParent: KnowledgeBaseParentNodeWordpress | null;
knowledgeBaseParent: KnowledgeBaseParentNodeWordpress | null;

@Field(() => KnowledgeBaseImageNodeWordpress, { nullable: true })
informationCoverImage: KnowledgeBaseImageNodeWordpress | null;
knowledgeBaseCoverImage: KnowledgeBaseImageNodeWordpress | null;

@Field()
informationPhone: string;
knowledgeBasePhone: string;

@Field()
informationAddress: string;
knowledgeBaseAddress: string;

@Field()
informationEmail: string;
knowledgeBaseEmail: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ export class KnowledgeBaseWordpressService {
): KnowledgeBase {
const frTranslation: KnowledgeBaseTranslations = {
languagesCode: FRENCH_CODE.toLowerCase(),
title: knowledgeBase.informationTitle,
content: knowledgeBase.informationContent,
title: knowledgeBase.knowledgeBaseTitle,
content: knowledgeBase.knowledgeBaseContent,
searchKeywords:
knowledgeBase.informationSearchKeywords &&
knowledgeBase.informationSearchKeywords?.trim() !== ''
? knowledgeBase.informationSearchKeywords
knowledgeBase.knowledgeBaseSearchKeywords &&
knowledgeBase.knowledgeBaseSearchKeywords?.trim() !== ''
? knowledgeBase.knowledgeBaseSearchKeywords
.split(',')
.filter((keyword) => keyword.trim() !== '')
: null,
Expand All @@ -101,12 +101,12 @@ export class KnowledgeBaseWordpressService {
...(knowledgeBase.translations?.map(
(translation: KnowledgeBaseTranslationsWordpress) => ({
languagesCode: translation.language.code.toLowerCase(),
title: translation.informationTitle,
content: translation.informationContent,
title: translation.knowledgeBaseTitle,
content: translation.knowledgeBaseContent,
searchKeywords:
translation.informationSearchKeywords &&
translation.informationSearchKeywords?.trim() !== ''
? translation.informationSearchKeywords
translation.knowledgeBaseSearchKeywords &&
translation.knowledgeBaseSearchKeywords?.trim() !== ''
? translation.knowledgeBaseSearchKeywords
.split(',')
.filter((keyword) => keyword.trim() !== '')
: null,
Expand All @@ -115,33 +115,33 @@ export class KnowledgeBaseWordpressService {
];

const roles =
knowledgeBase.informationRoles?.nodes.length > 0
? knowledgeBase.informationRoles.nodes.map((role) => role.roleCode)
knowledgeBase.knowledgeBaseRoles?.nodes.length > 0
? knowledgeBase.knowledgeBaseRoles.nodes.map((role) => role.roleCode)
: [];

return {
id: knowledgeBase.databaseId.toString(),
type: knowledgeBase.informationType,
childDisplay: knowledgeBase.informationChildDisplay || null,
link: normalizeEmptyStringToNull(knowledgeBase.informationLink),
position: knowledgeBase.informationPosition || 0,
type: knowledgeBase.knowledgeBaseType,
childDisplay: knowledgeBase.knowledgeBaseChildDisplay || null,
link: normalizeEmptyStringToNull(knowledgeBase.knowledgeBaseLink),
position: knowledgeBase.knowledgeBasePosition || 0,
authorization:
knowledgeBase.informationAccessRestriction &&
knowledgeBase.informationAccessRestriction !== 'NONE'
knowledgeBase.knowledgeBaseAccessRestriction &&
knowledgeBase.knowledgeBaseAccessRestriction !== 'NONE'
? {
type: knowledgeBase.informationAccessRestriction,
type: knowledgeBase.knowledgeBaseAccessRestriction,
roles,
}
: null,
translations,
parentId:
knowledgeBase.informationParent?.node?.databaseId?.toString() || null,
knowledgeBase.knowledgeBaseParent?.node?.databaseId?.toString() || null,
coverImage: normalizeEmptyStringToNull(
knowledgeBase.informationCoverImage?.node.mediaItemUrl.toString(),
knowledgeBase.knowledgeBaseCoverImage?.node.mediaItemUrl.toString(),
),
phone: normalizeEmptyStringToNull(knowledgeBase.informationPhone),
address: normalizeEmptyStringToNull(knowledgeBase.informationAddress),
email: normalizeEmptyStringToNull(knowledgeBase.informationEmail),
phone: normalizeEmptyStringToNull(knowledgeBase.knowledgeBasePhone),
address: normalizeEmptyStringToNull(knowledgeBase.knowledgeBaseAddress),
email: normalizeEmptyStringToNull(knowledgeBase.knowledgeBaseEmail),
};
}

Expand All @@ -159,37 +159,37 @@ export class KnowledgeBaseWordpressService {
knowledgeBases(first: 100, where: {language: ${FRENCH_CODE}}) {
nodes {
databaseId
informationTitle
informationContent
informationType
informationChildDisplay
informationLink
informationPosition
informationAccessRestriction
informationRoles(first: 100) {
knowledgeBaseTitle
knowledgeBaseContent
knowledgeBaseType
knowledgeBaseChildDisplay
knowledgeBaseLink
knowledgeBasePosition
knowledgeBaseAccessRestriction
knowledgeBaseRoles(first: 100) {
nodes {
databaseId
roleCode
roleDescription
}
}
informationSearchKeywords
informationPhone
informationAddress
informationEmail
informationCoverImage {
knowledgeBaseSearchKeywords
knowledgeBasePhone
knowledgeBaseAddress
knowledgeBaseEmail
knowledgeBaseCoverImage {
node {
databaseId
sourceUrl
mediaItemUrl
altText
}
}
informationParent {
knowledgeBaseParent {
node {
databaseId
informationAccessRestriction
informationRoles(first: 100) {
knowledgeBaseAccessRestriction
knowledgeBaseRoles(first: 100) {
nodes {
databaseId
roleCode
Expand All @@ -205,9 +205,9 @@ export class KnowledgeBaseWordpressService {
name
locale
}
informationTitle
informationContent
informationSearchKeywords
knowledgeBaseTitle
knowledgeBaseContent
knowledgeBaseSearchKeywords
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ export class WidgetsTranslationsWordpress extends BaseTranslationsWordpress {
@ObjectType()
export class KnowledgeBaseTranslationsWordpress extends BaseTranslationsWordpress {
@Field()
informationContent: string;
knowledgeBaseContent: string;

@Field()
informationTitle: string;
knowledgeBaseTitle: string;

@Field()
informationSearchKeywords: string;
knowledgeBaseSearchKeywords: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const KnowledgeBaseSchema = z.object({
id: IdSchema,
type: z.enum(['content', 'internal_link', 'external_link']),
childDisplay: z.enum(['card', 'list']).nullable(),
link: z.string().min(1, 'Information link cannot be empty string').nullable(),
link: z.string().min(1, 'Knowledge-Base link cannot be empty string').nullable(),
position: z.number().int().default(0),
authorization: AuthorizationSchema.nullable(),
translations: z
Expand All @@ -53,9 +53,9 @@ export const KnowledgeBaseSchema = z.object({
parentId: z.string().min(1, 'ID must be a non-empty string').nullable(),
coverImage: z
.string()
.min(1, 'Information cover image cannot be empty string')
.min(1, 'Knowledge-Base cover image cannot be empty string')
.nullable(),
phone: z.string().min(1, 'Information phone cannot be empty').nullable(),
address: z.string().min(1, 'Information address cannot be empty').nullable(),
email: z.string().min(1, 'Information email cannot be empty').nullable(),
phone: z.string().min(1, 'Knowledge-Base phone cannot be empty').nullable(),
address: z.string().min(1, 'Knowledge-Base address cannot be empty').nullable(),
email: z.string().min(1, 'Knowledge-Base email cannot be empty').nullable(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ export const WidgetsTranslationsSchema = BaseTranslationsSchema.extend({
});

export const KnowledgeBaseTranslationsSchema = BaseTranslationsSchema.extend({
title: z.string().min(1, 'Information title cannot be empty string'),
title: z.string().min(1, 'Knowledge-base title cannot be empty string'),
content: z.string().nullable(),
searchKeywords: z
.array(
z.string().min(1, 'Information search keywords cannot be empty array'),
z.string().min(1, 'Knowledge-base search keywords cannot be empty array'),
)
.nullable(),
});
Loading