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 07:34:51 +00:00
committed by GitHub
parent b62f23ea00
commit 1f360a3245
59 changed files with 1455 additions and 1005 deletions
@@ -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