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>
))}
{event.version && (
<Tooltip text={`This event is emitted since v${event.version}`}>
<Badge variant="blue">v{event.version}</Badge>
{event.since && (
<Tooltip text={`This event is emitted since v${event.since}`}>
<Badge variant="blue">v{event.since}</Badge>
</Tooltip>
)}
</div>

View File

@@ -78,12 +78,12 @@ const TagsOperationDescriptionSection = ({
badgeClassName="ml-0.5"
/>
)}
{operation["x-version"] && (
{operation["x-since"] && (
<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">
v{operation["x-version"]}
v{operation["x-since"]}
</Badge>
</Tooltip>
)}

View File

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

View File

@@ -199,4 +199,4 @@ delete:
$ref: ../components/responses/500_error.yaml
x-workflow: deleteDraftOrdersWorkflow
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.
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.
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.
deprecated: false
version: 2.8.0
since: 2.8.0

View File

@@ -47,4 +47,4 @@ post:
$ref: ../components/responses/500_error.yaml
x-workflow: importProductsAsChunksWorkflow
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
'500':
$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
'500':
$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.
deprecated: false
version: 2.8.0
since: 2.8.0
/store/carts/{id}/gift-cards:
post:
operationId: PostCartsIdGiftCards
@@ -8845,7 +8845,7 @@ paths:
```
description: Emitted when a return is marked as received.
deprecated: false
x-version: 2.8.0
x-since: 2.8.0
/store/shipping-options:
get:
operationId: GetShippingOptions

View File

@@ -87,4 +87,4 @@ post:
```
description: Emitted when the customer in the cart is transferred.
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.
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:
- `@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:
- `@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-sidebar-summary"?: string
"x-events"?: OasEvents[]
"x-version"?: string
"x-since"?: string
"x-deprecated_message"?: string
"x-badges"?: {
text: string
@@ -149,5 +149,5 @@ export type OasEvents = {
description?: string
deprecated?: boolean
deprecated_message?: string
version?: string
since?: string
}

View File

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

View File

@@ -57,7 +57,7 @@
* $ref: "#/components/responses/500_error"
* x-workflow: deleteDraftOrdersWorkflow
* 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.
* deprecated: false
* version: 2.8.0
* since: 2.8.0
*
*/

View File

@@ -182,7 +182,7 @@
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $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.
* deprecated: false
* version: 2.8.0
* since: 2.8.0
*
*/

View File

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

View File

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

View File

@@ -55,7 +55,7 @@
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $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.
* 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.
* 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.
*
* @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): {
deprecatedTag: ts.JSDocTag | undefined
versionTag: ts.JSDocTag | undefined
sinceTag: ts.JSDocTag | undefined
featureFlagTag: ts.JSDocTag | undefined
} {
const nodeComments = ts.getJSDocCommentsAndTags(node)
let deprecatedTag: ts.JSDocTag | undefined
let versionTag: ts.JSDocTag | undefined
let sinceTag: ts.JSDocTag | undefined
let featureFlagTag: ts.JSDocTag | undefined
nodeComments.forEach((comment) => {
@@ -622,8 +622,8 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
deprecatedTag = tag
}
if (tag.tagName.getText() === "version") {
versionTag = tag
if (tag.tagName.getText() === "since") {
sinceTag = tag
}
if (tag.tagName.getText() === "featureFlag") {
@@ -634,7 +634,7 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
return {
deprecatedTag,
versionTag,
sinceTag,
featureFlagTag,
}
}

View File

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

View File

@@ -448,7 +448,7 @@ class OasKindGenerator extends FunctionKindGenerator {
}
// check deprecation and version in tags
const { deprecatedTag, versionTag, featureFlagTag } =
const { deprecatedTag, sinceTag, featureFlagTag } =
this.getInformationFromTags(node)
if (deprecatedTag) {
@@ -458,9 +458,9 @@ class OasKindGenerator extends FunctionKindGenerator {
: undefined
}
if (versionTag) {
oas["x-version"] = versionTag.comment
? (versionTag.comment as string)
if (sinceTag) {
oas["x-since"] = sinceTag.comment
? (sinceTag.comment as string)
: undefined
}
@@ -804,7 +804,7 @@ class OasKindGenerator extends FunctionKindGenerator {
}
// check deprecation and version in tags
const { deprecatedTag, versionTag, featureFlagTag } =
const { deprecatedTag, sinceTag, featureFlagTag } =
this.getInformationFromTags(node)
if (deprecatedTag) {
@@ -817,12 +817,12 @@ class OasKindGenerator extends FunctionKindGenerator {
delete oas["x-deprecated_message"]
}
if (versionTag) {
oas["x-version"] = versionTag.comment
? (versionTag.comment as string)
if (sinceTag) {
oas["x-since"] = sinceTag.comment
? (sinceTag.comment as string)
: undefined
} else {
delete oas["x-version"]
delete oas["x-since"]
}
if (featureFlagTag) {
@@ -2807,7 +2807,7 @@ class OasKindGenerator extends FunctionKindGenerator {
description: event.description,
deprecated: event.deprecated,
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-events"?: OasEvent[]
"x-deprecated_message"?: string
"x-version"?: string
"x-since"?: string
"x-featureFlag"?: string
"x-ignoreCleanup"?: boolean
}
@@ -51,5 +51,5 @@ export declare type OasEvent = {
description?: string
deprecated?: boolean
deprecated_message?: string
version?: string
since?: string
}

View File

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

View File

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

View File

@@ -3,17 +3,15 @@ import { Reflection } from "typedoc"
export default function () {
Handlebars.registerHelper("version", function (reflection: Reflection) {
const versionTag = reflection.comment?.blockTags.find(
(tag) => tag.tag === "@version"
const sinceTag = reflection.comment?.blockTags.find(
(tag) => tag.tag === "@since"
)
if (!versionTag) {
if (!sinceTag) {
return ""
}
const tagContent = versionTag.content
.map((content) => content.text)
.join("")
const tagContent = sinceTag.content.map((content) => content.text).join("")
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
.replace("```ts\n", "")
.replace("\n```", "")
const isDeprecatedOrHasVersion = commentContent.length >= 4
const deprecatedIndex = isDeprecatedOrHasVersion
const isDeprecatedOrHasSince = commentContent.length >= 4
const deprecatedIndex = isDeprecatedOrHasSince
? commentContent.slice(3).findIndex((c) => c.trim() === "deprecated")
: -1
const isDeprecated = deprecatedIndex !== -1
const deprecatedText = (
isDeprecated ? commentContent[3 + deprecatedIndex] || "" : ""
).trim()
const version = isDeprecatedOrHasVersion
? commentContent
.slice(3)
.find((c) => c.trim().startsWith("version: "))
const since = isDeprecatedOrHasSince
? commentContent.slice(3).find((c) => c.trim().startsWith("since: "))
: undefined
const versionText = (
version ? version.replace("version: ", "") : ""
).trim()
const sinceText = (since ? since.replace("since: ", "") : "").trim()
if (isDeprecated) {
eventNameFormatted += `\n`
@@ -69,10 +65,10 @@ export default function () {
}
}
if (versionText) {
if (sinceText) {
eventNameFormatted += `\n\n`
eventNameFormatted += `<Tooltip text="This event was added in version v${versionText}">`
eventNameFormatted += `<Badge variant="blue">v${versionText}</Badge>`
eventNameFormatted += `<Tooltip text="This event was added in version v${sinceText}">`
eventNameFormatted += `<Badge variant="blue">v${sinceText}</Badge>`
eventNameFormatted += `</Tooltip>\n`
}

View File

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

View File

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