docs-util: support models implemented with DML in typedoc custom plugins (#7847)

- Support generating reference for models implemented with DML
- Support resolving and generating mermaid diagram for relations

The Currency Module was used an example so its reference is generated to showcase the work of this PR.
This commit is contained in:
Shahed Nasser
2024-07-01 10:34:51 +03:00
committed by GitHub
parent b62f23ea00
commit 1f360a3245
59 changed files with 1455 additions and 1005 deletions

View File

@@ -1888,16 +1888,16 @@ export const filesMap = [
"pathname": "/references/cart_models/classes/cart_models.ShippingMethodTaxLine"
},
{
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.list/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.list"
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCountCurrencies/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCountCurrencies"
},
{
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCount/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCount"
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listCurrencies/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listCurrencies"
},
{
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieve/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieve"
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieveCurrency/page.mdx",
"pathname": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieveCurrency"
},
{
"filePath": "/www/apps/resources/references/currency/IMessageAggregator/methods/currency.IMessageAggregator.clearMessages/page.mdx",
@@ -1959,10 +1959,18 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/currency/interfaces/currency.MessageAggregatorFormat/page.mdx",
"pathname": "/references/currency/interfaces/currency.MessageAggregatorFormat"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.EventMetadata/page.mdx",
"pathname": "/references/currency/types/currency.EventMetadata"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.JoinerRelationship/page.mdx",
"pathname": "/references/currency/types/currency.JoinerRelationship"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.LinkModulesExtraFields/page.mdx",
"pathname": "/references/currency/types/currency.LinkModulesExtraFields"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.Message/page.mdx",
"pathname": "/references/currency/types/currency.Message"
@@ -1971,10 +1979,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/currency/types/currency.MessageBody/page.mdx",
"pathname": "/references/currency/types/currency.MessageBody"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.MessageFormat/page.mdx",
"pathname": "/references/currency/types/currency.MessageFormat"
},
{
"filePath": "/www/apps/resources/references/currency/types/currency.ModuleJoinerConfig/page.mdx",
"pathname": "/references/currency/types/currency.ModuleJoinerConfig"
@@ -1984,8 +1988,12 @@ export const filesMap = [
"pathname": "/references/currency/types/currency.ModuleJoinerRelationship"
},
{
"filePath": "/www/apps/resources/references/currency_models/classes/currency_models.Currency/page.mdx",
"pathname": "/references/currency_models/classes/currency_models.Currency"
"filePath": "/www/apps/resources/references/currency/types/currency.RawMessageFormat/page.mdx",
"pathname": "/references/currency/types/currency.RawMessageFormat"
},
{
"filePath": "/www/apps/resources/references/currency_models/variables/currency_models.Currency/page.mdx",
"pathname": "/references/currency_models/variables/currency_models.Currency"
},
{
"filePath": "/www/apps/resources/references/customer/ICustomerModuleService/methods/customer.ICustomerModuleService.addAddresses/page.mdx",

View File

@@ -936,22 +936,22 @@ export const generatedSidebar = [
{
"loaded": true,
"isPathHref": true,
"path": "/references/currency/list",
"title": "list",
"path": "/references/currency/listAndCountCurrencies",
"title": "listAndCountCurrencies",
"children": []
},
{
"loaded": true,
"isPathHref": true,
"path": "/references/currency/listAndCount",
"title": "listAndCount",
"path": "/references/currency/listCurrencies",
"title": "listCurrencies",
"children": []
},
{
"loaded": true,
"isPathHref": true,
"path": "/references/currency/retrieve",
"title": "retrieve",
"path": "/references/currency/retrieveCurrency",
"title": "retrieveCurrency",
"children": []
}
]
@@ -971,7 +971,7 @@ export const generatedSidebar = [
"isPathHref": true,
"title": "Data Models",
"hasTitleStyling": true,
"autogenerate_path": "/references/currency_models/classes",
"autogenerate_path": "/references/currency_models/variables",
"children": [
{
"loaded": true,

View File

@@ -405,19 +405,19 @@ export const slugChanges = [
"filePath": "/www/apps/resources/references/cart_models/classes/cart_models.ShippingMethodTaxLine/page.mdx"
},
{
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.list",
"newSlug": "/references/currency/list",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.list/page.mdx"
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCountCurrencies",
"newSlug": "/references/currency/listAndCountCurrencies",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCountCurrencies/page.mdx"
},
{
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCount",
"newSlug": "/references/currency/listAndCount",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCount/page.mdx"
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listCurrencies",
"newSlug": "/references/currency/listCurrencies",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.listCurrencies/page.mdx"
},
{
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieve",
"newSlug": "/references/currency/retrieve",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieve/page.mdx"
"origSlug": "/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieveCurrency",
"newSlug": "/references/currency/retrieveCurrency",
"filePath": "/www/apps/resources/references/currency/ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieveCurrency/page.mdx"
},
{
"origSlug": "/references/currency/interfaces/currency.ICurrencyModuleService",
@@ -425,9 +425,9 @@ export const slugChanges = [
"filePath": "/www/apps/resources/references/currency/interfaces/currency.ICurrencyModuleService/page.mdx"
},
{
"origSlug": "/references/currency_models/classes/currency_models.Currency",
"origSlug": "/references/currency_models/variables/currency_models.Currency",
"newSlug": "/references/currency/models/Currency",
"filePath": "/www/apps/resources/references/currency_models/classes/currency_models.Currency/page.mdx"
"filePath": "/www/apps/resources/references/currency_models/variables/currency_models.Currency/page.mdx"
},
{
"origSlug": "/references/customer/ICustomerModuleService/methods/customer.ICustomerModuleService.addAddresses",

View File

@@ -95,24 +95,26 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
module.exports = defineConfig({
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
options: {
providers: [
{
resolve: "./dist/modules/my-auth",
options: {
config: {
"my-auth": {
// provider options...
modules: {
[Modules.AUTH]: {
resolve: "@medusajs/auth",
options: {
providers: [
{
resolve: "./modules/my-auth",
options: {
config: {
"my-auth": {
// provider options...
},
},
},
},
},
],
],
},
},
},
}
}
})
```

View File

@@ -1,27 +1,27 @@
---
displayed_sidebar: currencyReference
slug: /references/currency/retrieve
sidebar_label: retrieve
slug: /references/currency/retrieveCurrency
sidebar_label: retrieveCurrency
---
import { TypeList } from "docs-ui"
# retrieve - Currency Module Reference
# retrieveCurrency - Currency Module Reference
This documentation provides a reference to the `retrieve` method. This belongs to the Currency Module.
This documentation provides a reference to the `retrieveCurrency` method. This belongs to the Currency Module.
This method retrieves a currency by its code and and optionally based on the provided configurations.
## Example
```ts
const currency = await currencyModuleService.retrieve("usd")
const currency = await currencyModuleService.retrieveCurrency("usd")
```
## Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the currency to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../../interfaces/currency.FindConfig/page.mdx)&#60;[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)&#62;","description":"The configurations determining how the currency is retrieved. Its properties, such as `select` or `relations`, accept the\nattributes or relations associated with a currency.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sharedContext","type":"[Context](../../../interfaces/currency.Context/page.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"transactionManager","type":"TManager","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manager","type":"TManager","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enableNestedTransactions","type":"`boolean`","description":"A boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"A string indicating the ID of the group to aggregate the events to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionId","type":"`string`","description":"A string indicating the ID of the current transaction.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"messageAggregator","type":"[IMessageAggregator](../../../interfaces/currency.IMessageAggregator/page.mdx)","description":"An instance of a message aggregator, which is used to aggregate messages to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requestId","type":"`string`","description":"A string indicating the ID of the current request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"idempotencyKey","type":"`string`","description":"A string indicating the idempotencyKey of the current workflow execution.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="retrieve"/>
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the currency to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../../interfaces/currency.FindConfig/page.mdx)&#60;[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)&#62;","description":"The configurations determining how the currency is retrieved. Its properties, such as `select` or `relations`, accept the\nattributes or relations associated with a currency.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, any>`","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sharedContext","type":"[Context](../../../interfaces/currency.Context/page.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"transactionManager","type":"TManager","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manager","type":"TManager","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"enableNestedTransactions","type":"`boolean`","description":"A boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"A string indicating the ID of the group to aggregate the events to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionId","type":"`string`","description":"A string indicating the ID of the current transaction.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"messageAggregator","type":"[IMessageAggregator](../../../interfaces/currency.IMessageAggregator/page.mdx)","description":"An instance of a message aggregator, which is used to aggregate messages to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requestId","type":"`string`","description":"A string indicating the ID of the current request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"idempotencyKey","type":"`string`","description":"A string indicating the idempotencyKey of the current workflow execution.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="retrieveCurrency"/>
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The retrieved currency.","expandable":false,"children":[{"name":"CurrencyDTO","type":"[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)","optional":false,"defaultValue":"","description":"A currency's data.","expandable":false,"children":[{"name":"code","type":"`string`","description":"The ISO 3 character code of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="retrieve"/>
<TypeList types={[{"name":"Promise","type":"Promise&#60;[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The retrieved currency.","expandable":false,"children":[{"name":"CurrencyDTO","type":"[CurrencyDTO](../../../interfaces/currency.CurrencyDTO/page.mdx)","optional":false,"defaultValue":"","description":"A currency's data.","expandable":false,"children":[{"name":"code","type":"`string`","description":"The ISO 3 character code of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="retrieveCurrency"/>

View File

@@ -12,4 +12,4 @@ import { TypeList } from "docs-ui"
## Returns
<TypeList types={[{"name":"Record","type":"`Record<string, [Message](../../../types/currency.Message/page.mdx)[]>`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]},{"name":"Message[]","type":"[Message](../../../types/currency.Message/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"Message","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="getMessages"/>
<TypeList types={[{"name":"Record","type":"`Record<string, [Message](../../../types/currency.Message/page.mdx)[]>`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]},{"name":"Message[]","type":"[Message](../../../types/currency.Message/page.mdx)[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"Message","type":"[MessageBody](../../../types/currency.MessageBody/page.mdx)&#60;TData&#62; & `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="getMessages"/>

View File

@@ -8,7 +8,7 @@ import { TypeList } from "docs-ui"
## Parameters
<TypeList types={[{"name":"messageData","type":"[MessageFormat](../../../types/currency.MessageFormat/page.mdx)&#60;T&#62; \\| [MessageFormat](../../../types/currency.MessageFormat/page.mdx)&#60;T&#62;[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="saveRawMessageData"/>
<TypeList types={[{"name":"messageData","type":"[RawMessageFormat](../../../types/currency.RawMessageFormat/page.mdx)&#60;T&#62; \\| [RawMessageFormat](../../../types/currency.RawMessageFormat/page.mdx)&#60;T&#62;[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="saveRawMessageData"/>
## Returns

View File

@@ -8,4 +8,4 @@ import { TypeList } from "docs-ui"
Filters to apply on a currency.
<TypeList types={[{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$and","type":"([FilterableCurrencyProps](page.mdx) \\| [BaseFilterable](../currency.BaseFilterable/page.mdx)&#60;[FilterableCurrencyProps](page.mdx)&#62;)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"([FilterableCurrencyProps](page.mdx) \\| [BaseFilterable](../currency.BaseFilterable/page.mdx)&#60;[FilterableCurrencyProps](page.mdx)&#62;)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="FilterableCurrencyProps"/>
<TypeList types={[{"name":"q","type":"`string`","description":"Search through currencies using this search term.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$and","type":"([FilterableCurrencyProps](page.mdx) \\| [BaseFilterable](../currency.BaseFilterable/page.mdx)&#60;[FilterableCurrencyProps](page.mdx)&#62;)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"$or","type":"([FilterableCurrencyProps](page.mdx) \\| [BaseFilterable](../currency.BaseFilterable/page.mdx)&#60;[FilterableCurrencyProps](page.mdx)&#62;)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="FilterableCurrencyProps"/>

View File

@@ -13,4 +13,4 @@ which provides correct typing of field names in its properties.
<TypeList types={[{"name":"Entity","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="FindConfig"/>
<TypeList types={[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="FindConfig"/>
<TypeList types={[{"name":"select","type":"(`string` \\| keyof Entity)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"skip","type":"`null` \\| `number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"take","type":"`null` \\| `number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC`\nto sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the\n`SoftDeletableEntity` class.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filters","type":"`Record<string, any>`","description":"Enable ORM specific defined filters","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`Record<string, any>`","description":"Enable ORM specific defined options","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="FindConfig"/>

View File

@@ -13,6 +13,6 @@ The main service interface for the Currency Module.
## Methods
- [retrieve](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieve/page.mdx)
- [list](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.list/page.mdx)
- [listAndCount](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCount/page.mdx)
- [retrieveCurrency](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.retrieveCurrency/page.mdx)
- [listCurrencies](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.listCurrencies/page.mdx)
- [listAndCountCurrencies](../../ICurrencyModuleService/methods/currency.ICurrencyModuleService.listAndCountCurrencies/page.mdx)

View File

@@ -6,4 +6,4 @@ import { TypeList } from "docs-ui"
# JoinerServiceConfig
<TypeList types={[{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKeys","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"alias","type":"[JoinerServiceConfigAlias](../currency.JoinerServiceConfigAlias/page.mdx) \\| [JoinerServiceConfigAlias](../currency.JoinerServiceConfigAlias/page.mdx)[]","description":"Property name to use as entrypoint to the service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fieldAlias","type":"`Record<string, string \\| object>`","description":"alias for deeper nested relationships (e.g. &#123; 'price': 'prices.calculated\\_price\\_set.amount' &#125;)","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relationships","type":"[JoinerRelationship](../../types/currency.JoinerRelationship/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isInternalService","type":"`boolean`","description":"If true, the relationship is an internal service from the medusa core\nTODO: Remove when there are no more \"internal\" services","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"extends","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"relationship","type":"[JoinerRelationship](../../types/currency.JoinerRelationship/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isInternalService","type":"`boolean`","description":"If true, the relationship is an internal service from the medusa core\nTODO: Remove when there are no more \"internal\" services","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="JoinerServiceConfig"/>
<TypeList types={[{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKeys","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"alias","type":"[JoinerServiceConfigAlias](../currency.JoinerServiceConfigAlias/page.mdx) \\| [JoinerServiceConfigAlias](../currency.JoinerServiceConfigAlias/page.mdx)[]","description":"Property name to use as entrypoint to the service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fieldAlias","type":"`Record<string, string \\| object>`","description":"alias for deeper nested relationships (e.g. &#123; 'price': 'prices.calculated\\_price\\_set.amount' &#125;)","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"relationships","type":"[JoinerRelationship](../../types/currency.JoinerRelationship/page.mdx)[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"extends","type":"`object`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"relationship","type":"[JoinerRelationship](../../types/currency.JoinerRelationship/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="JoinerServiceConfig"/>

View File

@@ -0,0 +1,9 @@
---
displayed_sidebar: currencyReference
---
import { TypeList } from "docs-ui"
# EventMetadata
**EventMetadata**: `Record<string, unknown>` & `object`

View File

@@ -10,4 +10,4 @@ import { TypeList } from "docs-ui"
## Properties
<TypeList types={[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isInternalService","type":"`boolean`","description":"If true, the relationship is an internal service from the medusa core\nTODO: Remove when there are no more \"internal\" services","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="JoinerRelationship"/>
<TypeList types={[{"name":"alias","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"args","type":"`Record<string, any>`","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="JoinerRelationship"/>

View File

@@ -0,0 +1,9 @@
---
displayed_sidebar: currencyReference
---
import { TypeList } from "docs-ui"
# LinkModulesExtraFields
**LinkModulesExtraFields**: `Record<string, object>`

View File

@@ -6,8 +6,4 @@ import { TypeList } from "docs-ui"
# Message
**Message**: `Object`
## Properties
<TypeList types={[{"name":"eventName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"[MessageBody](../currency.MessageBody/page.mdx)&#60;T&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"metadata","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"service","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"data","type":"T","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="Message"/>
**Message**: [MessageBody](../currency.MessageBody/page.mdx)&#60;TData&#62; & `object`

View File

@@ -10,4 +10,4 @@ import { TypeList } from "docs-ui"
## Properties
<TypeList types={[{"name":"metadata","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"service","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"data","type":"T","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="MessageBody"/>
<TypeList types={[{"name":"eventName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"TData","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"[EventMetadata](../currency.EventMetadata/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"eventGroupId","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="MessageBody"/>

View File

@@ -1,13 +0,0 @@
---
displayed_sidebar: currencyReference
---
import { TypeList } from "docs-ui"
# MessageFormat
**MessageFormat**: `Object`
## Properties
<TypeList types={[{"name":"eventName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"service","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"eventGroupId","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"data","type":"T \\| T[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="MessageFormat"/>

View File

@@ -0,0 +1,13 @@
---
displayed_sidebar: currencyReference
---
import { TypeList } from "docs-ui"
# RawMessageFormat
**RawMessageFormat**: `Object`
## Properties
<TypeList types={[{"name":"eventName","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"TData","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"source","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"action","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"Pick&#60;[Context](../../interfaces/currency.Context/page.mdx), \"eventGroupId\"&#62;","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"eventGroupId","type":"`string`","description":"A string indicating the ID of the group to aggregate the events to be emitted at a later point.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"`Record<string, any>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="RawMessageFormat"/>

View File

@@ -1,13 +0,0 @@
---
displayed_sidebar: currencyModelReference
slug: /references/currency/models/Currency
sidebar_label: Currency
---
import { TypeList } from "docs-ui"
# Currency - Currency Module Data Models Reference
This documentation provides a reference to the Currency . This belongs to the Currency Module.
<TypeList types={[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="Currency"/>

View File

@@ -0,0 +1,13 @@
---
displayed_sidebar: currencyModelReference
slug: /references/currency/models/Currency
sidebar_label: Currency
---
import { TypeList } from "docs-ui"
# Currency - Currency Module Data Models Reference
This documentation provides a reference to the Currency . This belongs to the Currency Module.
<TypeList types={[{"name":"code","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`NumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`BigNumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="Currency"/>

View File

@@ -101,24 +101,26 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
module.exports = defineConfig({
// ...
[Modules.FILE]: {
resolve: "@medusajs/file",
options: {
providers: [
{
resolve: "./dist/modules/my-file",
options: {
config: {
"my-file": {
// provider options...
modules: {
[Modules.FILE]: {
resolve: "@medusajs/file",
options: {
providers: [
{
resolve: "./modules/my-file",
options: {
config: {
"my-file": {
// provider options...
},
},
},
},
},
],
],
},
},
},
}
}
})
```

View File

@@ -17,7 +17,7 @@ This method creates fulfillment sets.
### Example
```ts
const fulfillmentSets = await fulfillmentModuleService.createFulfillmentSets(
const fulfillmentSets = await fulfillmentModuleService.create(
[
{
name: "Shipping",
@@ -46,7 +46,7 @@ This method creates a fulfillment set.
### Example
```ts
const fulfillmentSet = await fulfillmentModuleService.createFulfillmentSets({
const fulfillmentSet = await fulfillmentModuleService.create({
name: "Shipping",
type: "default",
})

View File

@@ -191,24 +191,26 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
module.exports = defineConfig({
// ...
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
resolve: "./dist/modules/my-fulfillment",
options: {
config: {
"my-fulfillment": {
// provider options...
modules: {
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
resolve: "./modules/my-fulfillment",
options: {
config: {
"my-fulfillment": {
// provider options...
},
},
},
},
},
],
],
},
},
},
}
}
})
```

View File

@@ -57,7 +57,7 @@ medusa.admin.currencies.list({
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of currencies with pagination fields.","expandable":false,"children":[{"name":"AdminCurrenciesListRes","type":"[AdminCurrenciesListRes](../../../medusa/types/medusa.AdminCurrenciesListRes/page.mdx)","optional":false,"defaultValue":"","description":"List of currencies with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[Currency](../../../currency_models/classes/currency_models.Currency/page.mdx)[]","description":"An array of currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of currencies with pagination fields.","expandable":false,"children":[{"name":"AdminCurrenciesListRes","type":"[AdminCurrenciesListRes](../../../medusa/types/medusa.AdminCurrenciesListRes/page.mdx)","optional":false,"defaultValue":"","description":"List of currencies with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[Currency](../../../currency_models/variables/currency_models.Currency/page.mdx)[]","description":"An array of currency details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### update
@@ -83,4 +83,4 @@ medusa.admin.currencies.update(code, {
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the currency's details.","expandable":false,"children":[{"name":"AdminCurrenciesRes","type":"[AdminCurrenciesRes](../../../medusa/types/medusa.AdminCurrenciesRes/page.mdx)","optional":false,"defaultValue":"","description":"A currency's details.","expandable":false,"children":[{"name":"currency","type":"[Currency](../../../currency_models/classes/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the currency's details.","expandable":false,"children":[{"name":"AdminCurrenciesRes","type":"[AdminCurrenciesRes](../../../medusa/types/medusa.AdminCurrenciesRes/page.mdx)","optional":false,"defaultValue":"","description":"A currency's details.","expandable":false,"children":[{"name":"currency","type":"[Currency](../../../currency_models/variables/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`NumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`BigNumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`TextProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`NumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`BigNumberProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"`JSONProperty`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>

View File

@@ -8,4 +8,4 @@ A currency's details.
## Properties
<TypeList types={[{"name":"currency","type":"[Currency](../../../currency_models/classes/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records" sectionTitle="AdminCurrenciesRes"/>
<TypeList types={[{"name":"currency","type":"[Currency](../../../currency_models/variables/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records" sectionTitle="AdminCurrenciesRes"/>

View File

@@ -46,7 +46,7 @@ This property holds essential configurations related to the Medusa backend, such
### database\_database
The name of the database to connect to. If specified in `databaseUrl`, then its not required to include it.
The name of the database to connect to. If specified in `database_url`, then its not required to include it.
Make sure to create the PostgreSQL database before using it. You can check how to create a database in
[PostgreSQL's documentation](https://www.postgresql.org/docs/current/sql-createdatabase.html).
@@ -56,14 +56,15 @@ Make sure to create the PostgreSQL database before using it. You can check how t
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseName: process.env.DATABASE_DATABASE || "medusa-store",
database_database: process.env.DATABASE_DATABASE ||
"medusa-store",
// ...
},
// ...
}
```
### databaseUrl
### database\_url
The connection URL of the database. The format of the connection URL for PostgreSQL is:
@@ -94,28 +95,29 @@ Then, use the value in `medusa-config.js`:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
database_url: process.env.DATABASE_URL,
// ...
},
// ...
}
```
### databaseSchema
### database\_schema
The database schema to connect to. This is not required to provide if youre using the default schema, which is `public`.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseSchema: process.env.DATABASE_SCHEMA || "custom",
database_schema: process.env.DATABASE_SCHEMA ||
"custom",
// ...
},
// ...
}
```
### databaseLogging
### database\_logging
This configuration specifies what database messages to log. Its value can be one of the following:
@@ -130,14 +132,16 @@ If this configuration isn't set, its default value is `false`, meaning no databa
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseLogging: ["query", "error"],
database_logging: [
"query", "error",
],
// ...
},
// ...
}
```
### databaseExtra
### database\_extra
An object that includes additional configurations to pass to the database connection. You can pass any configuration. One defined configuration to pass is
`ssl` which enables support for TLS/SSL connections.
@@ -150,7 +154,7 @@ During development, its recommended not to pass this option.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseExtra:
database_extra:
process.env.NODE_ENV !== "development"
? { ssl: { rejectUnauthorized: false } }
: {},
@@ -162,33 +166,9 @@ module.exports = {
#### Properties
<TypeList
types={[
{
name: "ssl",
type: "`object`",
description: "Configure support for TLS/SSL connection",
optional: false,
defaultValue: "",
expandable: false,
children: [
{
name: "rejectUnauthorized",
type: "`false`",
description:
"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.",
optional: false,
defaultValue: "",
expandable: false,
children: [],
},
],
},
]}
sectionTitle="database_extra"
/>
<TypeList types={[{"name":"ssl","type":"`object`","description":"Configure support for TLS/SSL connection","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"rejectUnauthorized","type":"`false`","description":"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="database_extra"/>
### databaseDriverOptions
### database\_driver\_options
An object that includes additional configurations to pass to the database connection for v2. You can pass any configuration. One defined configuration to pass is
`ssl` which enables support for TLS/SSL connections.
@@ -201,7 +181,7 @@ During development, its recommended not to pass this option.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
databaseDriverOptions:
database_driver_options:
process.env.NODE_ENV !== "development"
? { connection: { ssl: { rejectUnauthorized: false } } }
: {},
@@ -213,43 +193,9 @@ module.exports = {
#### Properties
<TypeList
types={[
{
name: "connection",
type: "`object`",
description: "",
optional: true,
defaultValue: "",
expandable: false,
children: [
{
name: "ssl",
type: "`object`",
description: "Configure support for TLS/SSL connection",
optional: true,
defaultValue: "",
expandable: false,
children: [
{
name: "rejectUnauthorized",
type: "`false`",
description:
"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
],
},
],
},
]}
sectionTitle="database_driver_options"
/>
<TypeList types={[{"name":"connection","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"ssl","type":"`object`","description":"Configure support for TLS/SSL connection","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"rejectUnauthorized","type":"`false`","description":"Whether to fail connection if the server certificate is verified against the list of supplied CAs and the hostname and no match is found.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="database_driver_options"/>
### redisUrl
### redis\_url
Used to specify the URL to connect to Redis. This is only used for scheduled jobs. If you omit this configuration, scheduled jobs won't work.
@@ -272,14 +218,15 @@ For a local Redis installation, the connection URL should be `redis://localhost:
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redisUrl: process.env.REDIS_URL || "redis://localhost:6379",
redis_url: process.env.REDIS_URL ||
"redis://localhost:6379",
// ...
},
// ...
}
```
### redisPrefix
### redis\_prefix
The prefix set on all keys stored in Redis. The default value is `sess:`.
@@ -290,14 +237,15 @@ If this configuration option is provided, it is prepended to `sess:`.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redisPrefix: process.env.REDIS_PREFIX || "medusa:",
redis_prefix: process.env.REDIS_PREFIX ||
"medusa:",
// ...
},
// ...
}
```
### redisOptions
### redis\_options
An object of options to pass ioredis. You can refer to [iorediss RedisOptions documentation](https://redis.github.io/ioredis/index.html#RedisOptions)
for the list of available options.
@@ -307,8 +255,9 @@ for the list of available options.
```js title="medusa-config.js"
module.exports = {
projectConfig: {
redisOptions: {
connectionName: process.env.REDIS_CONNECTION_NAME || "medusa",
redis_options: {
connectionName: process.env.REDIS_CONNECTION_NAME ||
"medusa",
},
// ...
},
@@ -316,7 +265,7 @@ module.exports = {
}
```
### sessionOptions
### session\_options
An object of options to pass to [express-session](https://www.npmjs.com/package/express-session).
@@ -325,8 +274,9 @@ An object of options to pass to [express-session](https://www.npmjs.com/package/
```js title="medusa-config.js"
module.exports = {
projectConfig: {
sessionOptions: {
name: process.env.SESSION_NAME || "custom",
session_options: {
name: process.env.SESSION_NAME ||
"custom",
},
// ...
},
@@ -336,73 +286,9 @@ module.exports = {
#### Properties
<TypeList
types={[
{
name: "name",
type: "`string`",
description:
"The name of the session ID cookie to set in the response (and read from in the request). The default value is `connect.sid`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#name) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "resave",
type: "`boolean`",
description:
"Whether the session should be saved back to the session store, even if the session was never modified during the request. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#resave) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "rolling",
type: "`boolean`",
description:
"Whether the session identifier cookie should be force-set on every response. The default value is `false`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#rolling) for more details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "saveUninitialized",
type: "`boolean`",
description:
'Whether a session that is "uninitialized" is forced to be saved to the store. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#saveUninitialized) for more details.',
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "secret",
type: "`string`",
description:
"The secret to sign the session ID cookie. By default, the value of `cookie_secret` is used.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#secret) for details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "ttl",
type: "`number`",
description:
"Used when calculating the `Expires` `Set-Cookie` attribute of cookies. By default, its value is `10 * 60 * 60 * 1000`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#cookiemaxage) for details.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
]}
sectionTitle="session_options"
/>
<TypeList types={[{"name":"name","type":"`string`","description":"The name of the session ID cookie to set in the response (and read from in the request). The default value is `connect.sid`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#name) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"resave","type":"`boolean`","description":"Whether the session should be saved back to the session store, even if the session was never modified during the request. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#resave) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rolling","type":"`boolean`","description":"Whether the session identifier cookie should be force-set on every response. The default value is `false`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#rolling) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"saveUninitialized","type":"`boolean`","description":"Whether a session that is \"uninitialized\" is forced to be saved to the store. The default value is `true`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#saveUninitialized) for more details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"secret","type":"`string`","description":"The secret to sign the session ID cookie. By default, the value of `cookie_secret` is used.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#secret) for details.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ttl","type":"`number`","description":"Used when calculating the `Expires` `Set-Cookie` attribute of cookies. By default, its value is `10 * 60 * 60 * 1000`.\nRefer to [express-sessions documentation](https://www.npmjs.com/package/express-session#cookiemaxage) for details.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="session_options"/>
### http_compression
### http\_compression
Configure HTTP compression from the application layer. If you have access to the HTTP server, the recommended approach would be to enable it there.
However, some platforms don't offer access to the HTTP layer and in those cases, this is a good alternative.
@@ -434,53 +320,9 @@ module.exports = {
#### Properties
<TypeList
types={[
{
name: "enabled",
type: "`boolean`",
description:
"Whether HTTP compression is enabled. By default, it's `false`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "level",
type: "`number`",
description:
"The level of zlib compression to apply to responses. A higher level will result in better compression but will take longer to complete.\nA lower level will result in less compression but will be much faster. The default value is `6`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "memLevel",
type: "`number`",
description:
"How much memory should be allocated to the internal compression state. It's an integer in the range of 1 (minimum level) and 9 (maximum level).\nThe default value is `8`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
{
name: "threshold",
type: "`string` \\| `number`",
description:
"The minimum response body size that compression is applied on. Its value can be the number of bytes or any string accepted by the\n[bytes](https://www.npmjs.com/package/bytes) module. The default value is `1024`.",
optional: true,
defaultValue: "",
expandable: false,
children: [],
},
]}
sectionTitle="http_compression"
/>
<TypeList types={[{"name":"enabled","type":"`boolean`","description":"Whether HTTP compression is enabled. By default, it's `false`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"level","type":"`number`","description":"The level of zlib compression to apply to responses. A higher level will result in better compression but will take longer to complete.\nA lower level will result in less compression but will be much faster. The default value is `6`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"memLevel","type":"`number`","description":"How much memory should be allocated to the internal compression state. It's an integer in the range of 1 (minimum level) and 9 (maximum level).\nThe default value is `8`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"threshold","type":"`string` \\| `number`","description":"The minimum response body size that compression is applied on. Its value can be the number of bytes or any string accepted by the\n[bytes](https://www.npmjs.com/package/bytes) module. The default value is `1024`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="http_compression"/>
### jobs_batch_size
### jobs\_batch\_size
Configure the number of staged jobs that are polled from the database. Default is `1000`.
@@ -489,14 +331,14 @@ Configure the number of staged jobs that are polled from the database. Default i
```js title="medusa-config.js"
module.exports = {
projectConfig: {
jobs_batch_size: 100,
jobs_batch_size: 100
// ...
},
// ...
}
```
### worker_mode
### worker\_mode
Configure the application's worker mode. Default is `shared`.
@@ -511,7 +353,7 @@ Learn more in [this guide](https://docs.medusajs.com/development/medusa-worker).
```js title="medusa-config.js"
module.exports = {
projectConfig: {
worker_mode: "shared",
worker_mode: "shared"
// ...
},
// ...
@@ -600,8 +442,8 @@ The items in the array can either be:
- A string, which is the name of the plugin to add. You can pass a plugin as a string if it doesnt require any configurations.
- An object having the following properties:
- `resolve`: The name of the plugin.
- `options`: An object that includes the plugins options. These options vary for each plugin, and you should refer to the plugins documentation for available options.
- `resolve`: The name of the plugin.
- `options`: An object that includes the plugins options. These options vary for each plugin, and you should refer to the plugins documentation for available options.
### Example
@@ -612,7 +454,8 @@ module.exports = {
{
resolve: `medusa-my-plugin`,
options: {
apiKey: process.env.MY_API_KEY || `test`,
apiKey: process.env.MY_API_KEY ||
`test`,
},
},
// ...
@@ -621,7 +464,7 @@ module.exports = {
}
```
---
___
## modules
@@ -635,11 +478,11 @@ The keys of the `modules` configuration object refer to the type of module. Its
1. A boolean value indicating whether the module type is enabled;
2. Or a string value indicating the name of the module to be used for the module type. This can be used if the module does not require any options;
3. Or an object having the following properties, but typically you would mainly use the `resolve` and `options` properties only:
1. `resolve`: a string indicating the name of the module.
2. `options`: an object indicating the options to pass to the module. These options vary for each module, and you should refer to the modules documentation for details on them.
3. `resources`: a string indicating whether the module shares the dependency container with the Medusa core. Its value can either be `shared` or `isolated`. Refer to the [Modules documentation](https://docs.medusajs.com/development/modules/create#module-scope) for more details.
4. `alias`: a string indicating a unique alias to register the module under. Other modules cant use the same alias.
5. `main`: a boolean value indicating whether this module is the main registered module. This is useful when an alias is used.
1. `resolve`: a string indicating the name of the module.
2. `options`: an object indicating the options to pass to the module. These options vary for each module, and you should refer to the modules documentation for details on them.
3. `resources`: a string indicating whether the module shares the dependency container with the Medusa core. Its value can either be `shared` or `isolated`. Refer to the [Modules documentation](https://docs.medusajs.com/development/modules/create#module-scope) for more details.
4. `alias`: a string indicating a unique alias to register the module under. Other modules cant use the same alias.
5. `main`: a boolean value indicating whether this module is the main registered module. This is useful when an alias is used.
### Example
@@ -662,7 +505,7 @@ module.exports = {
}
```
---
___
## featureFlags

View File

@@ -61,7 +61,7 @@ export default Currency
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCurrenciesRes","type":"[AdminCurrenciesRes](../../../../medusa/types/medusa.AdminCurrenciesRes/page.mdx)","optional":false,"defaultValue":"","description":"A currency's details.","expandable":false,"children":[{"name":"currency","type":"[Currency](../../../../currency_models/classes/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCurrency"/>
<TypeList types={[{"name":"AdminCurrenciesRes","type":"[AdminCurrenciesRes](../../../../medusa/types/medusa.AdminCurrenciesRes/page.mdx)","optional":false,"defaultValue":"","description":"A currency's details.","expandable":false,"children":[{"name":"currency","type":"[Currency](../../../../currency_models/variables/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCurrency"/>
___
@@ -141,4 +141,4 @@ export default Currencies
#### Query Returned Data
<TypeList types={[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[Currency](../../../../currency_models/classes/currency_models.Currency/page.mdx)[]","description":"An array of currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCurrencies"/>
<TypeList types={[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[Currency](../../../../currency_models/variables/currency_models.Currency/page.mdx)[]","description":"An array of currency details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCurrencies"/>

View File

@@ -18,9 +18,11 @@ import { TypeList } from "docs-ui"
## Type Aliases
- [EventMetadata](../../currency/types/currency.EventMetadata/page.mdx)
- [MessageBody](../../currency/types/currency.MessageBody/page.mdx)
- [Message](../../currency/types/currency.Message/page.mdx)
- [MessageFormat](../../currency/types/currency.MessageFormat/page.mdx)
- [RawMessageFormat](../../currency/types/currency.RawMessageFormat/page.mdx)
- [JoinerRelationship](../../currency/types/currency.JoinerRelationship/page.mdx)
- [LinkModulesExtraFields](../../currency/types/currency.LinkModulesExtraFields/page.mdx)
- [ModuleJoinerConfig](../../currency/types/currency.ModuleJoinerConfig/page.mdx)
- [ModuleJoinerRelationship](../../currency/types/currency.ModuleJoinerRelationship/page.mdx)

View File

@@ -9,6 +9,6 @@ import { TypeList } from "docs-ui"
This documentation provides a reference to the data models in the Currency Module
## Classes
## Data Models
- [Currency](../../currency_models/classes/currency_models.Currency/page.mdx)
- [Currency](../../currency_models/variables/currency_models.Currency/page.mdx)

View File

@@ -79,25 +79,27 @@ const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
module.exports = defineConfig({
// ...
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
options: {
providers: [
{
resolve: "./dist/modules/my-notification",
options: {
config: {
"my-notification": {
channels: ["email"],
// provider options...
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
options: {
providers: [
{
resolve: "./modules/my-notification",
options: {
config: {
"my-notification": {
channels: ["email"],
// provider options...
},
},
},
},
},
],
],
},
},
},
}
}
})
```

View File

@@ -276,7 +276,7 @@ export const sidebar = sidebarAttachHrefCommonOptions([
{
title: "Data Models",
hasTitleStyling: true,
autogenerate_path: "/references/currency_models/classes",
autogenerate_path: "/references/currency_models/variables",
},
],
},

View File

@@ -1,12 +1,12 @@
{
"id": 1856,
"id": 185,
"name": "currency-models",
"variant": "project",
"kind": 1,
"flags": {},
"children": [
{
"id": 1857,
"id": 186,
"name": "Currency",
"variant": "declaration",
"kind": 32,
@@ -24,14 +24,14 @@
{
"type": "reflection",
"declaration": {
"id": 1858,
"id": 187,
"name": "__type",
"variant": "declaration",
"kind": 65536,
"flags": {},
"children": [
{
"id": 1859,
"id": 188,
"name": "code",
"variant": "declaration",
"kind": 1024,
@@ -48,7 +48,7 @@
"defaultValue": "..."
},
{
"id": 1860,
"id": 189,
"name": "symbol",
"variant": "declaration",
"kind": 1024,
@@ -65,7 +65,7 @@
"defaultValue": "..."
},
{
"id": 1861,
"id": 190,
"name": "symbol_native",
"variant": "declaration",
"kind": 1024,
@@ -82,7 +82,7 @@
"defaultValue": "..."
},
{
"id": 1862,
"id": 191,
"name": "name",
"variant": "declaration",
"kind": 1024,
@@ -99,7 +99,7 @@
"defaultValue": "..."
},
{
"id": 1863,
"id": 192,
"name": "decimal_digits",
"variant": "declaration",
"kind": 1024,
@@ -116,7 +116,7 @@
"defaultValue": "..."
},
{
"id": 1864,
"id": 193,
"name": "rounding",
"variant": "declaration",
"kind": 1024,
@@ -137,12 +137,12 @@
{
"title": "Properties",
"children": [
1859,
1860,
1861,
1862,
1863,
1864
188,
189,
190,
191,
192,
193
]
}
]
@@ -151,14 +151,14 @@
{
"type": "reflection",
"declaration": {
"id": 1865,
"id": 194,
"name": "__type",
"variant": "declaration",
"kind": 65536,
"flags": {},
"children": [
{
"id": 1866,
"id": 195,
"name": "code",
"variant": "declaration",
"kind": 1024,
@@ -175,7 +175,7 @@
"defaultValue": "..."
},
{
"id": 1867,
"id": 196,
"name": "symbol",
"variant": "declaration",
"kind": 1024,
@@ -192,7 +192,7 @@
"defaultValue": "..."
},
{
"id": 1868,
"id": 197,
"name": "symbol_native",
"variant": "declaration",
"kind": 1024,
@@ -209,7 +209,7 @@
"defaultValue": "..."
},
{
"id": 1869,
"id": 198,
"name": "name",
"variant": "declaration",
"kind": 1024,
@@ -226,7 +226,7 @@
"defaultValue": "..."
},
{
"id": 1870,
"id": 199,
"name": "decimal_digits",
"variant": "declaration",
"kind": 1024,
@@ -243,7 +243,7 @@
"defaultValue": "..."
},
{
"id": 1871,
"id": 200,
"name": "rounding",
"variant": "declaration",
"kind": 1024,
@@ -264,12 +264,12 @@
{
"title": "Properties",
"children": [
1866,
1867,
1868,
1869,
1870,
1871
195,
196,
197,
198,
199,
200
]
}
]
@@ -278,14 +278,14 @@
{
"type": "reflection",
"declaration": {
"id": 1872,
"id": 201,
"name": "__type",
"variant": "declaration",
"kind": 65536,
"flags": {},
"children": [
{
"id": 1873,
"id": 202,
"name": "raw_rounding",
"variant": "declaration",
"kind": 1024,
@@ -305,7 +305,7 @@
{
"title": "Properties",
"children": [
1873
202
]
}
]
@@ -332,81 +332,81 @@
{
"title": "Variables",
"children": [
1857
186
]
}
],
"packageName": "@medusajs/currency",
"symbolIdMap": {
"1856": {
"185": {
"sourceFileName": "../../../../packages/modules/currency/src/models/index.ts",
"qualifiedName": ""
},
"1857": {
"186": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "default"
},
"1858": {
"187": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object"
},
"1859": {
"188": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.code"
},
"1860": {
"189": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.symbol"
},
"1861": {
"190": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.symbol_native"
},
"1862": {
"191": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.name"
},
"1863": {
"192": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.decimal_digits"
},
"1864": {
"193": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "__object.rounding"
},
"1865": {
"194": {
"sourceFileName": "../../../../packages/core/utils/src/dml/entity-builder.ts",
"qualifiedName": "__type"
},
"1866": {
"195": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "code"
},
"1867": {
"196": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "symbol"
},
"1868": {
"197": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "symbol_native"
},
"1869": {
"198": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "name"
},
"1870": {
"199": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "decimal_digits"
},
"1871": {
"200": {
"sourceFileName": "../../../../packages/modules/currency/src/models/currency.ts",
"qualifiedName": "rounding"
},
"1872": {
"201": {
"sourceFileName": "../../../../packages/core/utils/src/dml/entity-builder.ts",
"qualifiedName": "__type"
},
"1873": {
"202": {
"sourceFileName": "",
"qualifiedName": "raw_rounding"
}
@@ -416,7 +416,7 @@
"1": "../../../../packages/modules/currency/src/models/index.ts"
},
"reflections": {
"1": 1856
"1": 185
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,6 @@ const fileOptions: FormattingOptionsType = {
"^file/.*AbstractFileProviderService": {
reflectionGroups: {
Properties: false,
Constructors: false,
},
reflectionDescription: `In this document, youll learn how to create a file provider module and the methods you must implement in its main service.`,
frontmatterData: {

View File

@@ -4,7 +4,6 @@ const notificationOptions: FormattingOptionsType = {
"^notification/.*AbstractNotificationProviderService": {
reflectionGroups: {
Properties: false,
Constructors: false,
},
reflectionDescription: `In this document, youll learn how to create a notification provider module and the methods you must implement in it.`,
frontmatterData: {

View File

@@ -6,6 +6,7 @@ import { modules } from "./references.js"
import {
customModuleServiceNames,
customModuleTitles,
dmlModules,
} from "./references-details.js"
import { FormattingOptionType } from "types"
import { kebabToCamel, kebabToPascal, kebabToSnake, kebabToTitle } from "utils"
@@ -28,7 +29,12 @@ const mergerOptions: Partial<TypeDocOptions> = {
objectLiteralTypeDeclarationStyle: "component",
mdxOutput: true,
maxLevel: 3,
allReflectionsHaveOwnDocument: [...modules, "dml", "workflows"],
allReflectionsHaveOwnDocument: [
...modules,
...dmlModules.map((module) => `${module}-models`),
"dml",
"workflows",
],
allReflectionsHaveOwnDocumentInNamespace: ["Utilities"],
formatting: {
"*": {
@@ -55,6 +61,8 @@ const mergerOptions: Partial<TypeDocOptions> = {
)
? customModuleServiceNames[moduleName]
: `I${kebabToPascal(moduleName)}ModuleService`
const isDmlModule = dmlModules.includes(moduleName)
return Object.assign(obj, {
// module config
[`^${snakeCaseModuleName}`]: {
@@ -107,11 +115,15 @@ const mergerOptions: Partial<TypeDocOptions> = {
typeParameters: false,
suffix: `- ${titleModuleName} Module Data Models Reference`,
},
reflectionGroups: {
Constructors: false,
Functions: false,
Methods: false,
},
reflectionGroups: isDmlModule
? {
Variables: true,
}
: {
Constructors: false,
Functions: false,
Methods: false,
},
},
[`^modules/${snakeCaseModuleName}_models`]: {
reflectionDescription: `This documentation provides a reference to the data models in the ${titleModuleName} Module`,
@@ -122,6 +134,11 @@ const mergerOptions: Partial<TypeDocOptions> = {
reflectionTitle: {
fullReplacement: `${titleModuleName} Module Data Models Reference`,
},
reflectionGroupRename: isDmlModule
? {
Variables: "Data Models",
}
: {},
},
} as FormattingOptionType)
}, {} as FormattingOptionType),

View File

@@ -23,3 +23,6 @@ export const customModulesOptions: Record<string, Partial<TypeDocOptions>> = {
),
},
}
// a list of modules that now support DML
export const dmlModules = ["currency"]

View File

@@ -18,6 +18,10 @@ export default function getModelOptions({
tsConfigName: `${moduleName}.json`,
generateModelsDiagram: true,
diagramAddToFile: entryPath,
resolveDmlRelations: true,
generateDMLsDiagram: true,
diagramDMLAddToFile: entryPath,
normalizeDmlTypes: true,
...typedocOptions,
})
}

View File

@@ -0,0 +1 @@
export const RELATION_NAMES = ["HasOne", "HasMany", "BelongsTo", "ManyToMany"]

View File

@@ -0,0 +1,111 @@
import {
Application,
Context,
Converter,
DeclarationReflection,
ParameterType,
ReferenceType,
} from "typedoc"
import { getDmlProperties, isDmlEntity } from "utils"
import { RELATION_NAMES } from "./constants"
export class DmlRelationsResolver {
private app: Application
private dmlReflectionsAndProperties: {
reflection: DeclarationReflection
properties: DeclarationReflection[]
}[]
constructor(app: Application) {
this.app = app
this.dmlReflectionsAndProperties = []
this.app.options.addDeclaration({
name: "resolveDmlRelations",
help: "Whether to enable resolving DML relations.",
type: ParameterType.Boolean,
defaultValue: false,
})
this.app.converter.on(
Converter.EVENT_CREATE_DECLARATION,
this.addReflection.bind(this)
)
this.app.converter.on(
Converter.EVENT_RESOLVE_BEGIN,
this.resolveRelations.bind(this)
)
}
addReflection(_context: Context, reflection: DeclarationReflection) {
if (!this.app.options.getValue("resolveDmlRelations")) {
return
}
if (isDmlEntity(reflection)) {
this.dmlReflectionsAndProperties?.push({
reflection,
properties: getDmlProperties(reflection.type as ReferenceType),
})
}
}
resolveRelations(context: Context) {
if (!this.app.options.getValue("resolveDmlRelations")) {
return
}
this.dmlReflectionsAndProperties.forEach(({ properties }) => {
properties.forEach((property) => {
if (
property.type?.type !== "reference" ||
!RELATION_NAMES.includes(property.type.name)
) {
return
}
// try to find the reflection that this relation points to
const relatedReflectionType = property.type.typeArguments?.[0]
if (
relatedReflectionType?.type !== "reflection" ||
!relatedReflectionType.declaration.signatures?.length ||
relatedReflectionType.declaration.signatures[0].type?.type !==
"reference"
) {
return
}
const relatedReflection = this.findReflectionMatchingProperties(
getDmlProperties(relatedReflectionType.declaration.signatures[0].type)
)
if (!relatedReflection) {
return
}
// replace type argument with reference to related reflection
property.type.typeArguments = [
ReferenceType.createResolvedReference(
relatedReflection.name,
relatedReflection,
context.project
),
]
})
})
}
findReflectionMatchingProperties(
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
)
})
})?.reflection
}
}

View File

@@ -0,0 +1,69 @@
import {
Application,
Context,
Converter,
DeclarationReflection,
ParameterType,
ReferenceType,
ReflectionFlag,
ReflectionKind,
} from "typedoc"
import { getDmlProperties, isDmlEntity } from "utils"
export function load(app: Application) {
app.options.addDeclaration({
name: "normalizeDmlTypes",
help: "Whether to normalize DML types.",
type: ParameterType.Boolean,
defaultValue: false,
})
app.converter.on(Converter.EVENT_RESOLVE_BEGIN, (context: Context) => {
if (!app.options.getValue("normalizeDmlTypes")) {
return
}
for (const reflection of context.project.getReflectionsByKind(
ReflectionKind.Variable
)) {
if (
!(reflection instanceof DeclarationReflection) ||
!isDmlEntity(reflection)
) {
break
}
const properties = getDmlProperties(reflection.type as ReferenceType)
properties.forEach((property) => {
if (property.type?.type !== "reference") {
return
}
normalizeNullable(property)
})
}
})
}
function normalizeNullable(property: DeclarationReflection) {
const propertyReference = property.type as ReferenceType
if (
propertyReference.name !== "NullableModifier" ||
!propertyReference.typeArguments ||
propertyReference.typeArguments?.length < 2
) {
return
}
const actualType = propertyReference.typeArguments[1]
if (actualType.type !== "reference") {
return
}
// change the property's type to reference the actual type
property.type = actualType
// set a flag on the property to consider it optional
property.setFlag(ReflectionFlag.Optional)
}

View File

@@ -8,6 +8,9 @@ import { load as signatureModifierPlugin } from "./signature-modifier"
import { MermaidDiagramGenerator } from "./mermaid-diagram-generator"
import { load as parentIgnorePlugin } from "./parent-ignore"
import { GenerateNamespacePlugin } from "./generate-namespace"
import { DmlRelationsResolver } from "./dml-relations-resolver"
import { load as dmlTypesNormalizer } from "./dml-types-normalizer"
import { MermaidDiagramDMLGenerator } from "./mermaid-diagram-dml-generator"
export function load(app: Application) {
resolveReferencesPluginLoad(app)
@@ -17,7 +20,10 @@ export function load(app: Application) {
eslintExamplePlugin(app)
signatureModifierPlugin(app)
parentIgnorePlugin(app)
dmlTypesNormalizer(app)
new GenerateNamespacePlugin(app)
new MermaidDiagramGenerator(app)
new DmlRelationsResolver(app)
new MermaidDiagramDMLGenerator(app)
}

View File

@@ -0,0 +1,251 @@
import path from "path"
import {
Application,
Comment,
Context,
Converter,
DeclarationReflection,
ParameterType,
ReferenceType,
Reflection,
ReflectionKind,
TypeDocOptionMap,
} from "typedoc"
import { RELATION_NAMES } from "./constants"
import { getDmlProperties, isDmlEntity } from "utils"
type Relations = Map<
string,
{
target: string
left: MermaidRelationType
right?: MermaidRelationType
name: string
}[]
>
type PluginOptions = Pick<
TypeDocOptionMap,
"generateModelsDiagram" | "diagramAddToFile"
>
const ALLOWED_RELATION_NAMES = RELATION_NAMES.filter(
(name) => name !== "BelongsTo"
)
type MermaidRelationType =
| "one-to-one"
| "one-to-many"
| "many-to-one"
| "many-to-many"
export class MermaidDiagramDMLGenerator {
private app: Application
private options?: PluginOptions
private mainFileReflection?: Reflection
constructor(app: Application) {
this.app = app
this.app.options.addDeclaration({
name: "generateDMLsDiagram",
help: "Whether to generate a Mermaid.js class diagram for data models in the reference.",
type: ParameterType.Boolean,
defaultValue: false,
})
this.app.options.addDeclaration({
name: "diagramDMLAddToFile",
help: "The file to add the mermaid diagram to. The diagram is added as a package comment.",
type: ParameterType.String,
})
app.converter.on(
Converter.EVENT_CREATE_DECLARATION,
this.setMainFile.bind(this)
)
app.converter.on(
Converter.EVENT_RESOLVE_BEGIN,
this.findRelations.bind(this)
)
}
getPluginOptions(): PluginOptions {
if (this.options) {
return this.options
}
this.options = {
generateModelsDiagram: this.app.options.getValue("generateDMLsDiagram"),
diagramAddToFile: this.app.options.getValue("diagramDMLAddToFile"),
}
return this.options
}
setMainFile(context: Context) {
const options = this.getPluginOptions()
if (
this.mainFileReflection ||
!options.generateModelsDiagram ||
!options.diagramAddToFile
) {
return
}
const mainFilePath = options.diagramAddToFile.startsWith("packages")
? path.resolve("..", "..", "..", "..", options.diagramAddToFile)
: options.diagramAddToFile
const mainFileSource = context.program.getSourceFile(mainFilePath)
if (!mainFileSource) {
return
}
const mainFileSymbol = context.checker.getSymbolAtLocation(mainFileSource)
if (!mainFileSymbol) {
return
}
this.mainFileReflection =
context.project.getReflectionFromSymbol(mainFileSymbol)
}
findRelations(context: Context) {
const options = this.getPluginOptions()
if (
!this.mainFileReflection ||
!options.generateModelsDiagram ||
!options.diagramAddToFile
) {
return
}
const relations: Relations = new Map()
for (const reflection of context.project.getReflectionsByKind(
ReflectionKind.Variable
)) {
if (
!(reflection instanceof DeclarationReflection) ||
!isDmlEntity(reflection)
) {
return
}
const reflectionProperties = getDmlProperties(
reflection.type as ReferenceType
)
// find relations of that reflection
reflectionProperties.forEach((property) => {
if (
property.type?.type !== "reference" ||
!ALLOWED_RELATION_NAMES.includes(property.type.name) ||
property.type.typeArguments?.length !== 1 ||
property.type.typeArguments[0].type !== "reference"
) {
return
}
const targetReflection = property.type.typeArguments[0].reflection
if (!targetReflection) {
return
}
// if entry already exists in relation, don't add anything
const exists =
relations
.get(reflection.name)
?.some((relation) => relation.target === targetReflection.name) ||
relations
.get(targetReflection.name)
?.some((relation) => relation.target === reflection.name)
if (exists) {
return
}
const relationType = this.getMermaidRelation(property.type.name)
if (!relationType) {
return
}
if (!relations.has(reflection.name)) {
relations.set(reflection.name, [])
}
relations.get(reflection.name)?.push({
target: targetReflection.name,
left: relationType,
right: this.getReverseRelationType(relationType),
name: property.name,
})
})
}
if (!relations.size) {
return
}
this.mainFileReflection.comment = new Comment([
{
text: "## Relations Overview\n\n",
kind: "text",
},
{
text: this.buildMermaidDiagram(relations),
kind: "code",
},
])
}
getMermaidRelation(relation: string): MermaidRelationType | undefined {
switch (relation) {
case "HasOne":
return "one-to-one"
case "HasMany":
return "one-to-many"
case "ManyToMany":
return "many-to-many"
}
}
getReverseRelationType(
relationType: MermaidRelationType
): MermaidRelationType {
return relationType.split("-").reverse().join("-") as MermaidRelationType
}
buildMermaidDiagram(relations: Relations): string {
const linePrefix = `\t`
const lineSuffix = `\n`
let diagram = `erDiagram${lineSuffix}`
relations.forEach((itemRelations, itemName) => {
itemRelations.forEach((itemRelation) => {
diagram += `${linePrefix}${itemName} ${this.getRelationTypeSymbol(
itemRelation.left,
"left"
)}--${this.getRelationTypeSymbol(itemRelation.right!, "right")} ${
itemRelation.target
} : ${itemRelation.name}${lineSuffix}`
})
})
return "```mermaid\n" + diagram + "\n```"
}
getRelationTypeSymbol(
relationType: MermaidRelationType,
direction: "left" | "right"
): string {
switch (relationType) {
case "one-to-one":
return "||"
case "one-to-many":
return direction === "left" ? "||" : "|{"
case "many-to-many":
return direction === "left" ? "}|" : "|{"
case "many-to-one":
return direction === "left" ? "}|" : "||"
}
}
}

View File

@@ -64,6 +64,8 @@ import ifShowSeparatorForTitleLevelHelper from "./resources/helpers/if-show-sepa
import shouldExpandPropertiesHelper from "./resources/helpers/should-expand-properties"
import shouldExpandDeclarationChildrenHelper from "./resources/helpers/should-expand-declaration-children"
import startSectionsHelper from "./resources/helpers/start-sections"
import ifDmlEntityHelper from "./resources/helpers/if-dml-entity"
import dmlPropertiesHelper from "./resources/helpers/dml-properties"
import { MarkdownTheme } from "./theme"
const TEMPLATE_PATH = path.join(__dirname, "resources", "templates")
@@ -156,4 +158,6 @@ export function registerHelpers(theme: MarkdownTheme) {
shouldExpandPropertiesHelper(theme)
shouldExpandDeclarationChildrenHelper(theme)
startSectionsHelper(theme)
ifDmlEntityHelper()
dmlPropertiesHelper()
}

View File

@@ -0,0 +1,23 @@
import * as Handlebars from "handlebars"
import { DeclarationReflection, ReferenceType } from "typedoc"
import { getDmlProperties, isDmlEntity } from "utils"
export default function () {
Handlebars.registerHelper(
"dmlProperties",
function (this: DeclarationReflection) {
if (!isDmlEntity(this)) {
return ""
}
const properties = getDmlProperties(this.type as ReferenceType)
// TODO resolve the property types to names/native types
return Handlebars.helpers.typeDeclarationMembers.call(properties, {
hash: {
sectionTitle: this.name,
},
})
}
)
}

View File

@@ -0,0 +1,12 @@
import * as Handlebars from "handlebars"
import { DeclarationReflection } from "typedoc"
import { isDmlEntity } from "utils"
export default function () {
Handlebars.registerHelper(
"ifDmlEntity",
function (this: DeclarationReflection, options: Handlebars.HelperOptions) {
return isDmlEntity(this) ? options.fn(this) : options.inverse(this)
}
)
}

View File

@@ -14,7 +14,8 @@ export default function (theme: MarkdownTheme) {
const md: string[] = []
const { hideInPageTOC } = theme
const { hideTocHeaders } = theme.getFormattingOptionsForLocation()
const { hideTocHeaders, reflectionGroupRename = {} } =
theme.getFormattingOptionsForLocation()
const isVisible = this.groups?.some((group) =>
group.allChildrenHaveOwnDocument()
@@ -36,7 +37,9 @@ export default function (theme: MarkdownTheme) {
}
const headingLevel = hideInPageTOC ? `##` : `###`
this.groups?.forEach((group) => {
const groupTitle = group.title
const groupTitle = Object.hasOwn(reflectionGroupRename, group.title)
? reflectionGroupRename[group.title]
: group.title
if (group.categories) {
group.categories.forEach((category) => {
md.push(`${headingLevel} ${category.title} ${groupTitle}\n\n`)

View File

@@ -27,10 +27,6 @@ export default function (theme: MarkdownTheme) {
[]
) as DeclarationReflection[]
// if (typeof options.hash.sectionTitle !== "string") {
// console.log("here2")
// }
let result = ""
switch (theme.objectLiteralTypeDeclarationStyle) {
case "list": {

View File

@@ -0,0 +1,7 @@
{{#if (sectionEnabled "member_declaration_comment")}}
{{> comment}}
{{/if}}
{{{dmlProperties}}}

View File

@@ -46,8 +46,16 @@
{{#if (sectionEnabled "member_declaration")}}
{{#ifDmlEntity}}
{{> member.dml}}
{{else}}
{{> member.declaration}}
{{/ifDmlEntity}}
{{/if}}
{{/ifIsReference}}

View File

@@ -2,6 +2,7 @@ import {
Comment,
DeclarationReflection,
ProjectReflection,
ReferenceType,
ReflectionKind,
ReflectionType,
} from "typedoc"
@@ -15,6 +16,7 @@ import {
stripLineBreaks,
} from "utils"
import { MarkdownTheme } from "../theme"
import { getDmlProperties, isDmlEntity } from "utils"
const ALLOWED_KINDS: ReflectionKind[] = [
ReflectionKind.EnumMember,
@@ -153,7 +155,18 @@ export function reflectionComponentFormatter({
const hasChildren = "children" in reflection && reflection.children?.length
if (
if (reflection.variant === "declaration" && isDmlEntity(reflection)) {
componentItem.children = getDmlProperties(
reflection.type as ReferenceType
).map((childItem) =>
reflectionComponentFormatter({
reflection: childItem,
level: level + 1,
maxLevel,
project,
})
)
} else if (
(reflection.type || hasChildren) &&
level + 1 <= (maxLevel || MarkdownTheme.MAX_LEVEL)
) {

View File

@@ -2,7 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
"rootDir": "./src",
"lib": ["es2022"]
},
"include": ["src"]
}

View File

@@ -54,6 +54,9 @@ export type FormattingOptionType = {
reflectionGroups?: {
[k: string]: boolean
}
reflectionGroupRename?: {
[k: string]: string
}
reflectionCategories?: {
[k: string]: boolean
}
@@ -234,5 +237,25 @@ export declare module "typedoc" {
* The file to add the mermaid diagram to. The diagram is added as a package comment.
*/
diagramAddToFile: string
/**
* Whether to generate a Mermaid.js class diagram for data models in the reference.
* (Used for DML)
*/
generateDMLsDiagram: boolean
/**
* The file to add the mermaid diagram to. The diagram is added as a package comment.
* (Used for DML)
*/
diagramDMLAddToFile: string
/**
* Whether to enable resolving DML relations.
* @defaultValue false
*/
resolveDmlRelations: boolean
/**
* Whether to normalize DML types.
* @defaultValue false
*/
normalizeDmlTypes: boolean
}
}

View File

@@ -0,0 +1,24 @@
import { DeclarationReflection, ReferenceType, ReflectionType } from "typedoc"
export function isDmlEntity(reflection: DeclarationReflection) {
if (reflection.type?.type !== "reference") {
return false
}
return reflection.type.name === "DmlEntity"
}
export function getDmlProperties(
reflectionType: ReferenceType
): DeclarationReflection[] {
if (
!reflectionType.typeArguments?.length ||
reflectionType.typeArguments[0].type !== "intersection"
) {
return []
}
const schemaType = reflectionType.typeArguments[0].types[0] as ReflectionType
return schemaType.declaration.children || []
}

View File

@@ -1,3 +1,4 @@
export * from "./dml-utils"
export * from "./get-type-children"
export * from "./get-project-child"
export * from "./get-type-str"