docs: change from detecting version to since tag (#13127)

* update everything from version to since

* update events

* regenerate oas
This commit is contained in:
Shahed Nasser
2025-08-01 18:22:42 +03:00
committed by GitHub
parent 57ad8fc755
commit 522fc12d7a
36 changed files with 94 additions and 101 deletions

View File

@@ -108,9 +108,9 @@ const TagsOperationDescriptionSectionEvent = ({
) : ( ) : (
<Badge variant="orange">Deprecated</Badge> <Badge variant="orange">Deprecated</Badge>
))} ))}
{event.version && ( {event.since && (
<Tooltip text={`This event is emitted since v${event.version}`}> <Tooltip text={`This event is emitted since v${event.since}`}>
<Badge variant="blue">v{event.version}</Badge> <Badge variant="blue">v{event.since}</Badge>
</Tooltip> </Tooltip>
)} )}
</div> </div>

View File

@@ -78,12 +78,12 @@ const TagsOperationDescriptionSection = ({
badgeClassName="ml-0.5" badgeClassName="ml-0.5"
/> />
)} )}
{operation["x-version"] && ( {operation["x-since"] && (
<Tooltip <Tooltip
text={`This API route is available since v${operation["x-version"]}`} text={`This API route is available since v${operation["x-since"]}`}
> >
<Badge variant="blue" className="ml-0.5"> <Badge variant="blue" className="ml-0.5">
v{operation["x-version"]} v{operation["x-since"]}
</Badge> </Badge>
</Tooltip> </Tooltip>
)} )}

View File

@@ -15024,7 +15024,7 @@ paths:
$ref: '#/components/responses/500_error' $ref: '#/components/responses/500_error'
x-workflow: deleteDraftOrdersWorkflow x-workflow: deleteDraftOrdersWorkflow
x-events: [] x-events: []
x-version: 2.8.4 x-since: 2.8.4
/admin/draft-orders/{id}/convert-to-order: /admin/draft-orders/{id}/convert-to-order:
post: post:
operationId: PostDraftOrdersIdConvertToOrder operationId: PostDraftOrdersIdConvertToOrder
@@ -22738,7 +22738,7 @@ paths:
``` ```
description: Emitted when an order edit request is canceled. description: Emitted when an order edit request is canceled.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0
/admin/order-edits/{id}/confirm: /admin/order-edits/{id}/confirm:
post: post:
operationId: PostOrderEditsIdConfirm operationId: PostOrderEditsIdConfirm
@@ -22812,7 +22812,7 @@ paths:
``` ```
description: Emitted when an order edit request is confirmed. description: Emitted when an order edit request is confirmed.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0
/admin/order-edits/{id}/items: /admin/order-edits/{id}/items:
post: post:
operationId: PostOrderEditsIdItems operationId: PostOrderEditsIdItems
@@ -23208,7 +23208,7 @@ paths:
``` ```
description: Emitted when an order edit is requested. description: Emitted when an order edit is requested.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0
/admin/order-edits/{id}/shipping-method: /admin/order-edits/{id}/shipping-method:
post: post:
operationId: PostOrderEditsIdShippingMethod operationId: PostOrderEditsIdShippingMethod
@@ -33277,7 +33277,7 @@ paths:
$ref: '#/components/responses/500_error' $ref: '#/components/responses/500_error'
x-workflow: importProductsAsChunksWorkflow x-workflow: importProductsAsChunksWorkflow
x-events: [] x-events: []
x-version: 2.8.5 x-since: 2.8.5
/admin/products/imports/{transaction_id}/confirm: /admin/products/imports/{transaction_id}/confirm:
post: post:
operationId: PostProductsImportsTransaction_idConfirm operationId: PostProductsImportsTransaction_idConfirm
@@ -33335,7 +33335,7 @@ paths:
$ref: '#/components/responses/invalid_request_error' $ref: '#/components/responses/invalid_request_error'
'500': '500':
$ref: '#/components/responses/500_error' $ref: '#/components/responses/500_error'
x-version: 2.8.5 x-since: 2.8.5
/admin/products/{id}: /admin/products/{id}:
get: get:
operationId: GetProductsId operationId: GetProductsId
@@ -48956,7 +48956,7 @@ paths:
$ref: '#/components/responses/invalid_request_error' $ref: '#/components/responses/invalid_request_error'
'500': '500':
$ref: '#/components/responses/500_error' $ref: '#/components/responses/500_error'
x-version: 2.8.0 x-since: 2.8.0
/admin/tax-rates: /admin/tax-rates:
get: get:
operationId: GetTaxRates operationId: GetTaxRates

View File

@@ -199,4 +199,4 @@ delete:
$ref: ../components/responses/500_error.yaml $ref: ../components/responses/500_error.yaml
x-workflow: deleteDraftOrdersWorkflow x-workflow: deleteDraftOrdersWorkflow
x-events: [] x-events: []
x-version: 2.8.4 x-since: 2.8.4

View File

@@ -75,4 +75,4 @@ delete:
``` ```
description: Emitted when an order edit request is canceled. description: Emitted when an order edit request is canceled.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0

View File

@@ -56,4 +56,4 @@ post:
``` ```
description: Emitted when an order edit request is confirmed. description: Emitted when an order edit request is confirmed.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0

View File

@@ -56,4 +56,4 @@ post:
``` ```
description: Emitted when an order edit is requested. description: Emitted when an order edit is requested.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0

View File

@@ -47,4 +47,4 @@ post:
$ref: ../components/responses/500_error.yaml $ref: ../components/responses/500_error.yaml
x-workflow: importProductsAsChunksWorkflow x-workflow: importProductsAsChunksWorkflow
x-events: [] x-events: []
x-version: 2.8.5 x-since: 2.8.5

View File

@@ -44,4 +44,4 @@ post:
$ref: ../components/responses/invalid_request_error.yaml $ref: ../components/responses/invalid_request_error.yaml
'500': '500':
$ref: ../components/responses/500_error.yaml $ref: ../components/responses/500_error.yaml
x-version: 2.8.5 x-since: 2.8.5

View File

@@ -192,4 +192,4 @@ get:
$ref: ../components/responses/invalid_request_error.yaml $ref: ../components/responses/invalid_request_error.yaml
'500': '500':
$ref: ../components/responses/500_error.yaml $ref: ../components/responses/500_error.yaml
x-version: 2.8.0 x-since: 2.8.0

View File

@@ -1360,7 +1360,7 @@ paths:
``` ```
description: Emitted when the customer in the cart is transferred. description: Emitted when the customer in the cart is transferred.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0
/store/carts/{id}/gift-cards: /store/carts/{id}/gift-cards:
post: post:
operationId: PostCartsIdGiftCards operationId: PostCartsIdGiftCards
@@ -8845,7 +8845,7 @@ paths:
``` ```
description: Emitted when a return is marked as received. description: Emitted when a return is marked as received.
deprecated: false deprecated: false
x-version: 2.8.0 x-since: 2.8.0
/store/shipping-options: /store/shipping-options:
get: get:
operationId: GetShippingOptions operationId: GetShippingOptions

View File

@@ -87,4 +87,4 @@ post:
``` ```
description: Emitted when the customer in the cart is transferred. description: Emitted when the customer in the cart is transferred.
deprecated: false deprecated: false
version: 2.8.0 since: 2.8.0

View File

@@ -67,4 +67,4 @@ post:
``` ```
description: Emitted when a return is marked as received. description: Emitted when a return is marked as received.
deprecated: false deprecated: false
x-version: 2.8.0 x-since: 2.8.0

View File

@@ -107,7 +107,7 @@ npx medusa db:migrate
In the Medusa codebase, our team uses the following [TSDoc](https://tsdoc.org/) tags to indicate changes made in the latest version for a specific piece of code: In the Medusa codebase, our team uses the following [TSDoc](https://tsdoc.org/) tags to indicate changes made in the latest version for a specific piece of code:
- `@deprecated`: Indicates that a piece of code is deprecated and will be removed in a future version. The tag's message will include details on what to use instead. However, our updates are always backward-compatible, allowing you to update your codebase at your own pace. - `@deprecated`: Indicates that a piece of code is deprecated and will be removed in a future version. The tag's message will include details on what to use instead. However, our updates are always backward-compatible, allowing you to update your codebase at your own pace.
- `@version`: Indicates the version when a piece of code was available from. A piece of code that has this tag will only be available starting from the specified version. - `@since`: Indicates the version when a piece of code was available from. A piece of code that has this tag will only be available starting from the specified version.
--- ---

View File

@@ -23247,7 +23247,7 @@ npx medusa db:migrate
In the Medusa codebase, our team uses the following [TSDoc](https://tsdoc.org/) tags to indicate changes made in the latest version for a specific piece of code: In the Medusa codebase, our team uses the following [TSDoc](https://tsdoc.org/) tags to indicate changes made in the latest version for a specific piece of code:
- `@deprecated`: Indicates that a piece of code is deprecated and will be removed in a future version. The tag's message will include details on what to use instead. However, our updates are always backward-compatible, allowing you to update your codebase at your own pace. - `@deprecated`: Indicates that a piece of code is deprecated and will be removed in a future version. The tag's message will include details on what to use instead. However, our updates are always backward-compatible, allowing you to update your codebase at your own pace.
- `@version`: Indicates the version when a piece of code was available from. A piece of code that has this tag will only be available starting from the specified version. - `@since`: Indicates the version when a piece of code was available from. A piece of code that has this tag will only be available starting from the specified version.
*** ***

View File

@@ -23,7 +23,7 @@ export type Operation = OpenAPIV3.OperationObject<{
"x-workflow"?: string "x-workflow"?: string
"x-sidebar-summary"?: string "x-sidebar-summary"?: string
"x-events"?: OasEvents[] "x-events"?: OasEvents[]
"x-version"?: string "x-since"?: string
"x-deprecated_message"?: string "x-deprecated_message"?: string
"x-badges"?: { "x-badges"?: {
text: string text: string
@@ -149,5 +149,5 @@ export type OasEvents = {
description?: string description?: string
deprecated?: boolean deprecated?: boolean
deprecated_message?: string deprecated_message?: string
version?: string since?: string
} }

View File

@@ -44,7 +44,7 @@
"workflows": [ "workflows": [
"transferCartCustomerWorkflow" "transferCartCustomerWorkflow"
], ],
"version": "2.8.0", "since": "2.8.0",
"deprecated": false "deprecated": false
}, },
{ {
@@ -227,7 +227,7 @@
"workflows": [ "workflows": [
"requestOrderEditRequestWorkflow" "requestOrderEditRequestWorkflow"
], ],
"version": "2.8.0", "since": "2.8.0",
"deprecated": false "deprecated": false
}, },
{ {
@@ -239,7 +239,7 @@
"workflows": [ "workflows": [
"confirmOrderEditRequestWorkflow" "confirmOrderEditRequestWorkflow"
], ],
"version": "2.8.0", "since": "2.8.0",
"deprecated": false "deprecated": false
}, },
{ {
@@ -251,7 +251,7 @@
"workflows": [ "workflows": [
"cancelBeginOrderEditWorkflow" "cancelBeginOrderEditWorkflow"
], ],
"version": "2.8.0", "since": "2.8.0",
"deprecated": false "deprecated": false
}, },
{ {

View File

@@ -57,7 +57,7 @@
* $ref: "#/components/responses/500_error" * $ref: "#/components/responses/500_error"
* x-workflow: deleteDraftOrdersWorkflow * x-workflow: deleteDraftOrdersWorkflow
* x-events: [] * x-events: []
* x-version: 2.8.4 * x-since: 2.8.4
* *
*/ */

View File

@@ -90,7 +90,7 @@
* ``` * ```
* description: Emitted when an order edit request is canceled. * description: Emitted when an order edit request is canceled.
* deprecated: false * deprecated: false
* version: 2.8.0 * since: 2.8.0
* *
*/ */

View File

@@ -182,7 +182,7 @@
* $ref: "#/components/responses/invalid_request_error" * $ref: "#/components/responses/invalid_request_error"
* "500": * "500":
* $ref: "#/components/responses/500_error" * $ref: "#/components/responses/500_error"
* x-version: 2.8.0 * x-since: 2.8.0
* *
*/ */

View File

@@ -71,7 +71,7 @@
* ``` * ```
* description: Emitted when an order edit request is confirmed. * description: Emitted when an order edit request is confirmed.
* deprecated: false * deprecated: false
* version: 2.8.0 * since: 2.8.0
* *
*/ */

View File

@@ -71,7 +71,7 @@
* ``` * ```
* description: Emitted when an order edit is requested. * description: Emitted when an order edit is requested.
* deprecated: false * deprecated: false
* version: 2.8.0 * since: 2.8.0
* *
*/ */

View File

@@ -69,7 +69,7 @@
* $ref: "#/components/responses/500_error" * $ref: "#/components/responses/500_error"
* x-workflow: importProductsAsChunksWorkflow * x-workflow: importProductsAsChunksWorkflow
* x-events: [] * x-events: []
* x-version: 2.8.5 * x-since: 2.8.5
* *
*/ */

View File

@@ -55,7 +55,7 @@
* $ref: "#/components/responses/invalid_request_error" * $ref: "#/components/responses/invalid_request_error"
* "500": * "500":
* $ref: "#/components/responses/500_error" * $ref: "#/components/responses/500_error"
* x-version: 2.8.5 * x-since: 2.8.5
* *
*/ */

View File

@@ -97,7 +97,7 @@
* ``` * ```
* description: Emitted when the customer in the cart is transferred. * description: Emitted when the customer in the cart is transferred.
* deprecated: false * deprecated: false
* version: 2.8.0 * since: 2.8.0
* *
*/ */

View File

@@ -85,7 +85,7 @@
* ``` * ```
* description: Emitted when a return is marked as received. * description: Emitted when a return is marked as received.
* deprecated: false * deprecated: false
* x-version: 2.8.0 * x-since: 2.8.0
* *
*/ */

View File

@@ -600,16 +600,16 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
* Retrieve information from the tags of a node. * Retrieve information from the tags of a node.
* *
* @param node - The node to retrieve the information from. * @param node - The node to retrieve the information from.
* @returns An object containing the deprecated and version tags, if available. * @returns An object containing the deprecated and since tags, if available.
*/ */
getInformationFromTags(node: ts.Node): { getInformationFromTags(node: ts.Node): {
deprecatedTag: ts.JSDocTag | undefined deprecatedTag: ts.JSDocTag | undefined
versionTag: ts.JSDocTag | undefined sinceTag: ts.JSDocTag | undefined
featureFlagTag: ts.JSDocTag | undefined featureFlagTag: ts.JSDocTag | undefined
} { } {
const nodeComments = ts.getJSDocCommentsAndTags(node) const nodeComments = ts.getJSDocCommentsAndTags(node)
let deprecatedTag: ts.JSDocTag | undefined let deprecatedTag: ts.JSDocTag | undefined
let versionTag: ts.JSDocTag | undefined let sinceTag: ts.JSDocTag | undefined
let featureFlagTag: ts.JSDocTag | undefined let featureFlagTag: ts.JSDocTag | undefined
nodeComments.forEach((comment) => { nodeComments.forEach((comment) => {
@@ -622,8 +622,8 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
deprecatedTag = tag deprecatedTag = tag
} }
if (tag.tagName.getText() === "version") { if (tag.tagName.getText() === "since") {
versionTag = tag sinceTag = tag
} }
if (tag.tagName.getText() === "featureFlag") { if (tag.tagName.getText() === "featureFlag") {
@@ -634,7 +634,7 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
return { return {
deprecatedTag, deprecatedTag,
versionTag, sinceTag,
featureFlagTag, featureFlagTag,
} }
} }

View File

@@ -50,7 +50,7 @@ class EventsKindGenerator extends DefaultKindGenerator<ts.VariableDeclaration> {
const commentsAndTags = ts.getJSDocCommentsAndTags(propertyAssignment) const commentsAndTags = ts.getJSDocCommentsAndTags(propertyAssignment)
let payloadTag: ts.JSDocTag | undefined let payloadTag: ts.JSDocTag | undefined
let versionTag: ts.JSDocTag | undefined let sinceTag: ts.JSDocTag | undefined
let deprecatedTag: ts.JSDocTag | undefined let deprecatedTag: ts.JSDocTag | undefined
let description: string | undefined let description: string | undefined
commentsAndTags.forEach((comment) => { commentsAndTags.forEach((comment) => {
@@ -67,8 +67,8 @@ class EventsKindGenerator extends DefaultKindGenerator<ts.VariableDeclaration> {
payloadTag = tag payloadTag = tag
} }
if (tag.tagName.getText() === "version") { if (tag.tagName.getText() === "since") {
versionTag = tag sinceTag = tag
} }
if (tag.tagName.getText() === "deprecated") { if (tag.tagName.getText() === "deprecated") {
@@ -84,7 +84,7 @@ class EventsKindGenerator extends DefaultKindGenerator<ts.VariableDeclaration> {
payload: (payloadTag?.comment as string) ?? "", payload: (payloadTag?.comment as string) ?? "",
description, description,
workflows, workflows,
version: versionTag?.comment as string, since: sinceTag?.comment as string,
deprecated: deprecatedTag !== undefined, deprecated: deprecatedTag !== undefined,
deprecated_message: deprecatedTag?.comment as string, deprecated_message: deprecatedTag?.comment as string,
} }

View File

@@ -448,7 +448,7 @@ class OasKindGenerator extends FunctionKindGenerator {
} }
// check deprecation and version in tags // check deprecation and version in tags
const { deprecatedTag, versionTag, featureFlagTag } = const { deprecatedTag, sinceTag, featureFlagTag } =
this.getInformationFromTags(node) this.getInformationFromTags(node)
if (deprecatedTag) { if (deprecatedTag) {
@@ -458,9 +458,9 @@ class OasKindGenerator extends FunctionKindGenerator {
: undefined : undefined
} }
if (versionTag) { if (sinceTag) {
oas["x-version"] = versionTag.comment oas["x-since"] = sinceTag.comment
? (versionTag.comment as string) ? (sinceTag.comment as string)
: undefined : undefined
} }
@@ -804,7 +804,7 @@ class OasKindGenerator extends FunctionKindGenerator {
} }
// check deprecation and version in tags // check deprecation and version in tags
const { deprecatedTag, versionTag, featureFlagTag } = const { deprecatedTag, sinceTag, featureFlagTag } =
this.getInformationFromTags(node) this.getInformationFromTags(node)
if (deprecatedTag) { if (deprecatedTag) {
@@ -817,12 +817,12 @@ class OasKindGenerator extends FunctionKindGenerator {
delete oas["x-deprecated_message"] delete oas["x-deprecated_message"]
} }
if (versionTag) { if (sinceTag) {
oas["x-version"] = versionTag.comment oas["x-since"] = sinceTag.comment
? (versionTag.comment as string) ? (sinceTag.comment as string)
: undefined : undefined
} else { } else {
delete oas["x-version"] delete oas["x-since"]
} }
if (featureFlagTag) { if (featureFlagTag) {
@@ -2807,7 +2807,7 @@ class OasKindGenerator extends FunctionKindGenerator {
description: event.description, description: event.description,
deprecated: event.deprecated, deprecated: event.deprecated,
deprecated_message: event.deprecated_message, deprecated_message: event.deprecated_message,
version: event.version, since: event.since,
})) }))
) )
} }

View File

@@ -12,7 +12,7 @@ export declare type OpenApiOperation = Partial<OpenAPIV3.OperationObject> & {
"x-workflow"?: string "x-workflow"?: string
"x-events"?: OasEvent[] "x-events"?: OasEvent[]
"x-deprecated_message"?: string "x-deprecated_message"?: string
"x-version"?: string "x-since"?: string
"x-featureFlag"?: string "x-featureFlag"?: string
"x-ignoreCleanup"?: boolean "x-ignoreCleanup"?: boolean
} }
@@ -51,5 +51,5 @@ export declare type OasEvent = {
description?: string description?: string
deprecated?: boolean deprecated?: boolean
deprecated_message?: string deprecated_message?: string
version?: string since?: string
} }

View File

@@ -7,7 +7,7 @@ const EXCLUDED_TAGS = [
"@featureFlag", "@featureFlag",
"@category", "@category",
"@typeParamDefinition", "@typeParamDefinition",
"@version", "@since",
"@tags", "@tags",
"@summary", "@summary",
"@workflowEvent", "@workflowEvent",

View File

@@ -119,18 +119,18 @@ function formatEventsType(
} }
} }
const versionTag = event.comment?.blockTags.find( const sinceTag = event.comment?.blockTags.find(
(tag) => tag.tag === "@version" (tag) => tag.tag === "@since"
) )
if (versionTag) { if (sinceTag) {
eventName += `\n` eventName += `\n`
const versionText = versionTag.content const sinceText = sinceTag.content
.map((content) => content.text) .map((content) => content.text)
.join("") .join("")
.trim() .trim()
eventName += `<Tooltip text="This event was added in version v${versionText}">` eventName += `<Tooltip text="This event was added in version v${sinceText}">`
eventName += `<Badge variant="blue">v${versionText}</Badge>` eventName += `<Badge variant="blue">v${sinceText}</Badge>`
eventName += `</Tooltip>` eventName += `</Tooltip>`
} }
@@ -166,8 +166,8 @@ function formatEventsType(
.join("") .join("")
.trim() .trim()
const versionTag = event.comment?.blockTags.find( const sinceTag = event.comment?.blockTags.find(
(tag) => tag.tag === "@version" (tag) => tag.tag === "@since"
) )
content.push( content.push(
@@ -177,8 +177,8 @@ function formatEventsType(
payload: eventPayload || "", payload: eventPayload || "",
deprecated: !!deprecatedTag, deprecated: !!deprecatedTag,
deprecatedMessage, deprecatedMessage,
version: versionTag since: sinceTag
? versionTag.content ? sinceTag.content
.map((content) => content.text) .map((content) => content.text)
.join("") .join("")
.trim() .trim()
@@ -215,14 +215,14 @@ function getEventHeading({
payload, payload,
deprecated = false, deprecated = false,
deprecatedMessage, deprecatedMessage,
version, since,
}: { }: {
titleLevel: number titleLevel: number
eventName: string eventName: string
payload: string payload: string
deprecated?: boolean deprecated?: boolean
deprecatedMessage?: string deprecatedMessage?: string
version?: string since?: string
}) { }) {
const heading = [eventName] const heading = [eventName]
if (deprecated) { if (deprecated) {
@@ -236,12 +236,12 @@ function getEventHeading({
heading.push(`</Tooltip>`) heading.push(`</Tooltip>`)
} }
} }
if (version) { if (since) {
if (deprecated) { if (deprecated) {
heading.push(`\n`) heading.push(`\n`)
} }
heading.push(`<Tooltip text="This event was added in version v${version}">`) heading.push(`<Tooltip text="This event was added in version v${since}">`)
heading.push(`<Badge variant="blue">v${version}</Badge>`) heading.push(`<Badge variant="blue">v${since}</Badge>`)
heading.push(`</Tooltip>`) heading.push(`</Tooltip>`)
} }
return `<EventHeader headerLvl="${titleLevel}" headerProps={{ id: "${getEventNameSlug( return `<EventHeader headerLvl="${titleLevel}" headerProps={{ id: "${getEventNameSlug(

View File

@@ -3,17 +3,15 @@ import { Reflection } from "typedoc"
export default function () { export default function () {
Handlebars.registerHelper("version", function (reflection: Reflection) { Handlebars.registerHelper("version", function (reflection: Reflection) {
const versionTag = reflection.comment?.blockTags.find( const sinceTag = reflection.comment?.blockTags.find(
(tag) => tag.tag === "@version" (tag) => tag.tag === "@since"
) )
if (!versionTag) { if (!sinceTag) {
return "" return ""
} }
const tagContent = versionTag.content const tagContent = sinceTag.content.map((content) => content.text).join("")
.map((content) => content.text)
.join("")
return `:::note\n\nThis is only available after Medusa \`v${tagContent}\`.\n\n:::` return `:::note\n\nThis is only available after Medusa \`v${tagContent}\`.\n\n:::`
}) })

View File

@@ -41,22 +41,18 @@ export default function () {
const eventPayloadFormatted = eventPayload const eventPayloadFormatted = eventPayload
.replace("```ts\n", "") .replace("```ts\n", "")
.replace("\n```", "") .replace("\n```", "")
const isDeprecatedOrHasVersion = commentContent.length >= 4 const isDeprecatedOrHasSince = commentContent.length >= 4
const deprecatedIndex = isDeprecatedOrHasVersion const deprecatedIndex = isDeprecatedOrHasSince
? commentContent.slice(3).findIndex((c) => c.trim() === "deprecated") ? commentContent.slice(3).findIndex((c) => c.trim() === "deprecated")
: -1 : -1
const isDeprecated = deprecatedIndex !== -1 const isDeprecated = deprecatedIndex !== -1
const deprecatedText = ( const deprecatedText = (
isDeprecated ? commentContent[3 + deprecatedIndex] || "" : "" isDeprecated ? commentContent[3 + deprecatedIndex] || "" : ""
).trim() ).trim()
const version = isDeprecatedOrHasVersion const since = isDeprecatedOrHasSince
? commentContent ? commentContent.slice(3).find((c) => c.trim().startsWith("since: "))
.slice(3)
.find((c) => c.trim().startsWith("version: "))
: undefined : undefined
const versionText = ( const sinceText = (since ? since.replace("since: ", "") : "").trim()
version ? version.replace("version: ", "") : ""
).trim()
if (isDeprecated) { if (isDeprecated) {
eventNameFormatted += `\n` eventNameFormatted += `\n`
@@ -69,10 +65,10 @@ export default function () {
} }
} }
if (versionText) { if (sinceText) {
eventNameFormatted += `\n\n` eventNameFormatted += `\n\n`
eventNameFormatted += `<Tooltip text="This event was added in version v${versionText}">` eventNameFormatted += `<Tooltip text="This event was added in version v${sinceText}">`
eventNameFormatted += `<Badge variant="blue">v${versionText}</Badge>` eventNameFormatted += `<Badge variant="blue">v${sinceText}</Badge>`
eventNameFormatted += `</Tooltip>\n` eventNameFormatted += `</Tooltip>\n`
} }

View File

@@ -928,8 +928,8 @@ class WorkflowsPlugin {
commentText += ` -- ${event.deprecated_message}` commentText += ` -- ${event.deprecated_message}`
} }
} }
if (event.version) { if (event.since) {
commentText += ` -- version: ${event.version}` commentText += ` -- since: ${event.since}`
} }
return new CommentTag(`@workflowEvent`, [ return new CommentTag(`@workflowEvent`, [
{ {

View File

@@ -344,8 +344,7 @@ export declare type MedusaEvent = {
payload: string payload: string
description?: string description?: string
workflows: string[] workflows: string[]
version?: string since?: string
deprecated?: boolean deprecated?: boolean
deprecated_message?: string deprecated_message?: string
version?: string
} }