Skip to content

Commit e26f9f2

Browse files
shahednasserBalu-Varanasi
authored andcommitted
chore: generate and update OAS for translations (medusajs#14281)
* chore: generate and update OAS for translations * support localization header * add locale to all store routes * fixes * small fix
1 parent 97cea57 commit e26f9f2

75 files changed

Lines changed: 2322 additions & 6 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

www/utils/generated/events-output.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,5 +735,44 @@
735735
"refundPaymentWorkflow"
736736
],
737737
"deprecated": false
738+
},
739+
{
740+
"name": "translation.created",
741+
"parentName": "TranslationWorkflowEvents",
742+
"propertyName": "CREATED",
743+
"payload": "```ts\n{\n id, // The ID of the translation\n}\n```",
744+
"description": "Emitted when translations are created.",
745+
"workflows": [
746+
"createTranslationsWorkflow",
747+
"batchTranslationsWorkflow"
748+
],
749+
"since": "2.12.3",
750+
"deprecated": false
751+
},
752+
{
753+
"name": "translation.updated",
754+
"parentName": "TranslationWorkflowEvents",
755+
"propertyName": "UPDATED",
756+
"payload": "```ts\n{\n id, // The ID of the translation\n}\n```",
757+
"description": "Emitted when translations are updated.",
758+
"workflows": [
759+
"updateTranslationsWorkflow",
760+
"batchTranslationsWorkflow"
761+
],
762+
"since": "2.12.3",
763+
"deprecated": false
764+
},
765+
{
766+
"name": "translation.deleted",
767+
"parentName": "TranslationWorkflowEvents",
768+
"propertyName": "DELETED",
769+
"payload": "```ts\n{\n id, // The ID of the translation\n}\n```",
770+
"description": "Emitted when translations are deleted.",
771+
"workflows": [
772+
"deleteTranslationsWorkflow",
773+
"batchTranslationsWorkflow"
774+
],
775+
"since": "2.12.3",
776+
"deprecated": false
738777
}
739778
]

www/utils/generated/oas-output/base/admin.oas.base.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ tags:
209209
url: https://docs.medusajs.com/resources/commerce-modules/user
210210
x-associatedSchema:
211211
$ref: "#/components/schemas/AdminInvite"
212+
- name: Locales
213+
description: >
214+
A locale is a language that content is translated into for customers to view
215+
in a storefront.
216+
217+
Medusa installs locales by default. These API routes allow admin users to retrieve
218+
and view locales.
219+
externalDocs:
220+
description: Learn more about locales and translations.
221+
url: https://docs.medusajs.com/resources/commerce-modules/translation/concepts
222+
x-associatedSchema:
223+
$ref: "#/components/schemas/AdminLocale"
212224
- name: Notifications
213225
description: >
214226
A notification informs an admin user of store changes or status changes of
@@ -221,8 +233,8 @@ tags:
221233
- name: Order Changes
222234
description: >
223235
An order change is a proposed change to an order, such as adding or
224-
removing items, changing shipping methods, and more. They can be associated
225-
with order edits, claims, or exchanges.
236+
removing items, changing shipping methods, and more. They can be
237+
associated with order edits, claims, or exchanges.
226238
227239
These API routes allow admin users to manage order changes.
228240
externalDocs:
@@ -642,6 +654,18 @@ tags:
642654
</Note>
643655
x-associatedSchema:
644656
$ref: "#/components/schemas/AdminTransactionGroup"
657+
- name: Translations
658+
description: >
659+
A translation is a localized version of content in a specific locale. For
660+
example, a product description in French.
661+
662+
These API routes allow admin users to manage translations for different
663+
locales and resources.
664+
externalDocs:
665+
description: Learn more about the Translation Module.
666+
url: https://docs.medusajs.com/resources/commerce-modules/translation
667+
x-associatedSchema:
668+
$ref: "#/components/schemas/AdminTranslation"
645669
- name: Uploads
646670
description: >
647671
Use these API routes to upload files to your Medusa application using the

www/utils/generated/oas-output/base/store.oas.base.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ tags:
8181
</Note>
8282
x-associatedSchema:
8383
$ref: "#/components/schemas/StoreGiftCard"
84+
- name: Locales
85+
description: >
86+
A locale is a language that content is translated into for customers to view
87+
in a storefront.
88+
89+
Medusa installs locales by default. These API routes allow you to retrieve
90+
supported locales in the store.
91+
externalDocs:
92+
description: Learn more about locales and translations.
93+
url: https://docs.medusajs.com/resources/commerce-modules/translation/concepts
94+
x-associatedSchema:
95+
$ref: "#/components/schemas/StoreLocale"
8496
- name: Orders
8597
description: |
8698
Guest and registered customers can view orders they placed.
@@ -192,8 +204,9 @@ tags:
192204
- name: Store Credit Accounts
193205
x-associatedSchema:
194206
description: >
195-
A store credit account is a way for customers to manage their store credit balance.
196-
Customers can use their store credit to pay for orders, and view their store credit balance.
207+
A store credit account is a way for customers to manage their store
208+
credit balance. Customers can use their store credit to pay for orders,
209+
and view their store credit balance.
197210
198211
These API routes allow customers to view their store credit accounts.
199212
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/**
2+
* @oas [get] /admin/locales
3+
* operationId: GetLocales
4+
* summary: List Locales
5+
* description: Retrieve a list of locales. The locales can be filtered by fields such as `code`. The locales can also be sorted or paginated.
6+
* x-authenticated: true
7+
* parameters:
8+
* - name: q
9+
* in: query
10+
* description: Search query to filter locales by code or other fields.
11+
* required: false
12+
* schema:
13+
* type: string
14+
* title: q
15+
* description: Search query to filter locales by code or other fields.
16+
* - name: code
17+
* in: query
18+
* required: false
19+
* schema:
20+
* oneOf:
21+
* - type: string
22+
* title: code
23+
* description: Filter locales by a code.
24+
* - type: array
25+
* description: Filter locales by multiple codes.
26+
* items:
27+
* type: string
28+
* title: code
29+
* description: A locale code.
30+
* - name: limit
31+
* in: query
32+
* description: Limit the number of items returned in the list.
33+
* required: false
34+
* schema:
35+
* type: number
36+
* title: limit
37+
* description: Limit the number of items returned in the list.
38+
* externalDocs:
39+
* url: "#pagination"
40+
* - name: offset
41+
* in: query
42+
* description: The number of items to skip when retrieving a list.
43+
* required: false
44+
* schema:
45+
* type: number
46+
* title: offset
47+
* description: The number of items to skip when retrieving a list.
48+
* externalDocs:
49+
* url: "#pagination"
50+
* - name: order
51+
* in: query
52+
* description: The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
53+
* required: false
54+
* schema:
55+
* type: string
56+
* title: order
57+
* description: The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
58+
* externalDocs:
59+
* url: "#pagination"
60+
* - name: with_deleted
61+
* in: query
62+
* description: The locale's with deleted.
63+
* required: false
64+
* schema:
65+
* type: boolean
66+
* title: with_deleted
67+
* description: The locale's with deleted.
68+
* - name: fields
69+
* in: query
70+
* description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
71+
* fields. Without prefix it will replace the entire default fields.
72+
* required: false
73+
* schema:
74+
* type: string
75+
* title: fields
76+
* description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
77+
* fields. Without prefix it will replace the entire default fields.
78+
* externalDocs:
79+
* url: "#select-fields-and-relations"
80+
* - name: $and
81+
* in: query
82+
* description: Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
83+
* required: false
84+
* schema:
85+
* type: array
86+
* description: Join query parameters with an AND condition. Each object's content is the same type as the expected query parameters.
87+
* items:
88+
* type: object
89+
* title: $and
90+
* - name: $or
91+
* in: query
92+
* description: Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
93+
* required: false
94+
* schema:
95+
* type: array
96+
* description: Join query parameters with an OR condition. Each object's content is the same type as the expected query parameters.
97+
* items:
98+
* type: object
99+
* title: $or
100+
* security:
101+
* - api_token: []
102+
* - cookie_auth: []
103+
* - jwt_token: []
104+
* x-codeSamples:
105+
* - lang: JavaScript
106+
* label: JS SDK
107+
* source: |-
108+
* import Medusa from "@medusajs/js-sdk"
109+
*
110+
* export const sdk = new Medusa({
111+
* baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
112+
* debug: import.meta.env.DEV,
113+
* auth: {
114+
* type: "session",
115+
* },
116+
* })
117+
*
118+
* sdk.admin.locale.list()
119+
* .then(({ locales, count, limit, offset }) => {
120+
* console.log(locales)
121+
* })
122+
* - lang: Shell
123+
* label: cURL
124+
* source: |-
125+
* curl '{backend_url}/admin/locales' \
126+
* -H 'Authorization: Bearer {access_token}'
127+
* tags:
128+
* - Locales
129+
* responses:
130+
* "200":
131+
* description: OK
132+
* content:
133+
* application/json:
134+
* schema:
135+
* $ref: "#/components/schemas/AdminLocaleListResponse"
136+
* "400":
137+
* $ref: "#/components/responses/400_error"
138+
* "401":
139+
* $ref: "#/components/responses/unauthorized"
140+
* "404":
141+
* $ref: "#/components/responses/not_found_error"
142+
* "409":
143+
* $ref: "#/components/responses/invalid_state_error"
144+
* "422":
145+
* $ref: "#/components/responses/invalid_request_error"
146+
* "500":
147+
* $ref: "#/components/responses/500_error"
148+
* x-since: 2.12.3
149+
* x-featureFlag: translation
150+
*
151+
*/
152+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* @oas [get] /admin/locales/{code}
3+
* operationId: GetLocalesCode
4+
* summary: Get a Locale
5+
* x-sidebar-summary: Get Locale
6+
* description: Retrieve a locale by its code. You can expand the locale's relations or select the fields that should be returned.
7+
* x-authenticated: true
8+
* parameters:
9+
* - name: code
10+
* in: path
11+
* description: The locale's code in [BCP 47 format](https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1).
12+
* example: fr-FR
13+
* required: true
14+
* schema:
15+
* type: string
16+
* - name: fields
17+
* in: query
18+
* description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
19+
* fields. Without prefix it will replace the entire default fields.
20+
* required: false
21+
* schema:
22+
* type: string
23+
* title: fields
24+
* description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
25+
* fields. Without prefix it will replace the entire default fields.
26+
* externalDocs:
27+
* url: "#select-fields-and-relations"
28+
* security:
29+
* - api_token: []
30+
* - cookie_auth: []
31+
* - jwt_token: []
32+
* x-codeSamples:
33+
* - lang: JavaScript
34+
* label: JS SDK
35+
* source: |-
36+
* import Medusa from "@medusajs/js-sdk"
37+
*
38+
* export const sdk = new Medusa({
39+
* baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
40+
* debug: import.meta.env.DEV,
41+
* auth: {
42+
* type: "session",
43+
* },
44+
* })
45+
*
46+
* sdk.admin.locale.retrieve("en-US")
47+
* .then(({ locale }) => {
48+
* console.log(locale)
49+
* })
50+
* - lang: Shell
51+
* label: cURL
52+
* source: |-
53+
* curl '{backend_url}/admin/locales/fr-FR' \
54+
* -H 'Authorization: Bearer {access_token}'
55+
* tags:
56+
* - Locales
57+
* responses:
58+
* "200":
59+
* description: OK
60+
* content:
61+
* application/json:
62+
* schema:
63+
* $ref: "#/components/schemas/AdminLocaleResponse"
64+
* "400":
65+
* $ref: "#/components/responses/400_error"
66+
* "401":
67+
* $ref: "#/components/responses/unauthorized"
68+
* "404":
69+
* $ref: "#/components/responses/not_found_error"
70+
* "409":
71+
* $ref: "#/components/responses/invalid_state_error"
72+
* "422":
73+
* $ref: "#/components/responses/invalid_request_error"
74+
* "500":
75+
* $ref: "#/components/responses/500_error"
76+
* x-since: 2.12.3
77+
* x-featureFlag: translation
78+
*
79+
*/
80+

0 commit comments

Comments
 (0)