docs-util: fix incorrect relations in data model references + other fixes (#12487)

* fix price model incorrect relations

* fix events that don't have workflows showing

* fix notification example
This commit is contained in:
Shahed Nasser
2025-05-15 10:47:45 +03:00
committed by GitHub
parent 3ddcd872a0
commit 30aa317ff1
11 changed files with 2874 additions and 2854 deletions
@@ -148,11 +148,15 @@ export default async function userCreatedHandler({
const notificationModuleService = container.resolve(
Modules.NOTIFICATION
)
const userModule = container.resolve(
Modules.USER
)
const query = container.resolve("query")
const user = await userModule.retrieveUser(data.id)
const { data: [user] } = await query.graph({
entity: "user",
fields: ["*"],
filters: {
id: data.id,
}
})
await notificationModuleService.createNotifications({
to: user.email,
@@ -137,14 +137,16 @@ export class DmlRelationsResolver {
properties: DeclarationReflection[]
): DeclarationReflection | undefined {
return this.dmlReflectionsAndProperties.find(({ properties: refProps }) => {
return properties.every((property) => {
return refProps.find(
(refProp) =>
refProp.name === property.name &&
(refProp.type as ReferenceType).name ===
(property.type as ReferenceType).name
)
})
return (
properties.every((property) => {
return refProps.find(
(refProp) =>
refProp.name === property.name &&
(refProp.type as ReferenceType).name ===
(property.type as ReferenceType).name
)
}) && properties.length === refProps.length
)
})?.reflection
}
@@ -15,7 +15,8 @@ export default function () {
const showHeader = (this.children?.length ?? 0) > 1
function parseChildren(children: DeclarationReflection[]) {
children?.forEach((child, index) => {
let count = 0
children.forEach((child, index) => {
content.push(
formatEventsType(child as DeclarationReflection, {
subtitleLevel,
@@ -27,13 +28,16 @@ export default function () {
content.push("---")
content.push("")
}
count++
})
return count
}
if (this.kind === ReflectionKind.Module) {
this.children?.forEach((child, index) => {
parseChildren(child.children || [])
if (index < this.children!.length - 1) {
const count = parseChildren(child.children || [])
if (count > 0 && index < this.children!.length - 1) {
content.push("")
content.push("---")
content.push("")
@@ -71,7 +75,9 @@ function formatEventsType(
}
content.push("")
const eventProperties = eventVariable.type.declaration.children || []
const eventProperties = (
eventVariable.type.declaration.children || []
).filter((child) => (getEventWorkflows(child)?.length || 0) > 0)
content.push(`${subHeaderPrefix} Summary`)
content.push("")
@@ -154,11 +160,7 @@ function formatEventsType(
.find((tag) => tag.tag === "@eventPayload")
?.content.map((content) => content.text)
.join("")
const workflows = event.comment?.blockTags
.find((tag) => tag.tag === "@workflows")
?.content.map((content) => content.text)
.join("")
.split(", ")
const workflows = getEventWorkflows(event)
const deprecatedTag = event.comment?.blockTags.find(
(tag) => tag.tag === "@deprecated"
)
@@ -258,3 +260,11 @@ function getEventHeading({
function getEventNameSlug(eventName: string) {
return slugify(eventName.replace(".", ""), { lower: true })
}
function getEventWorkflows(event: DeclarationReflection): string[] | undefined {
return event.comment?.blockTags
.find((tag) => tag.tag === "@workflows")
?.content.map((content) => content.text)
.join("")
.split(", ")
}