chore: improve JS Client TSDoc comments (#5582)

* add oas schema to tsdoc parser

* add tsdoc (part 1)

* Finished tsdoc in js client

* general fixes

* added tsdoc in core medusa package

* parse schema tags in model files

* added maxlevel option

* added more tsdoc

* added tsdoc in core

* added TSDoc in core package

* generated client types

* support featureFlag and expandable tags

* added support for resource feature flag note

* fix api ignore plugin

* added eslint plugin

* support feature flag and expandable badges

* adjusted overview page + generated reference

* revert generated files

* added changeset

* add details about new typedoc options

* fix broken link
This commit is contained in:
Shahed Nasser
2023-11-09 12:51:17 +02:00
committed by GitHub
parent c68da6d685
commit 91615f9c45
748 changed files with 12354 additions and 1684 deletions
+13
View File
@@ -0,0 +1,13 @@
---
"@medusajs/client-types": patch
"medusa-react": patch
"@medusajs/medusa-js": patch
"@medusajs/medusa": patch
"@medusajs/types": patch
---
fix(@medusajs/client-types): Fix types and TSDocs
fix(medusa-react): Fix response type of Publishable API Key's list sales channels.
fix(@medusajs/medusa-js): Fix incorrect parameter and response types.
fix(@medusajs/medusa): Fix incorrect types and add TSDocs
fix(@medusajs/types): Fix incorrect types and add TSDocs
+1 -1
View File
@@ -25,12 +25,12 @@
"typedoc": "0.25.1",
"typedoc-config": "*",
"typedoc-monorepo-link-types": "^0.0.2",
"typedoc-plugin-custom": "*",
"typedoc-plugin-frontmatter": "*",
"typedoc-plugin-markdown": "3.16.0",
"typedoc-plugin-markdown-medusa": "*",
"typedoc-plugin-merge-modules": "5.1.0",
"typedoc-plugin-missing-exports": "^2.1.0",
"typedoc-plugin-modules": "*",
"typedoc-plugin-reference-excluder": "1.1.3",
"typedoc-plugin-rename-defaults": "^0.6.6",
"typescript": "^5.2.2"
@@ -1,4 +1,18 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path")
const pathPrefix = path.join(__dirname, "..", "..", "..")
/** @type {import('typedoc').TypeDocOptions} */
module.exports = {
// extends: [typedocConfig],
plugin: ["typedoc-plugin-markdown-medusa"],
readme: "none",
eslintPathName: path.join(
pathPrefix,
"www/packages/eslint-config-docs/content.js"
),
pluginsResolvePath: path.join(pathPrefix, "www"),
// Uncomment this when debugging
// showConfig: true,
}
@@ -70,10 +70,9 @@ module.exports = ({
...globalTypedocOptions,
entryPoints: [path.join(pathPrefix, entryPointPath)],
out: [path.join(pathPrefix, outPath)],
tsconfig: path.join(
pathPrefix,
tsconfigPath || "packages/types/tsconfig.json"
),
tsconfig: tsconfigPath.length
? path.join(pathPrefix, tsconfigPath)
: path.join(__dirname, "extended-tsconfig", "types.json"),
name: `${moduleName} Reference`,
indexTitle: `${moduleName} Reference`,
entryDocument: "index.md",
@@ -82,7 +81,7 @@ module.exports = ({
hideBreadcrumbs: true,
plugin: [
...globalTypedocOptions.plugin,
"typedoc-plugin-modules",
"typedoc-plugin-custom",
"typedoc-plugin-rename-defaults",
"typedoc-plugin-frontmatter",
],
@@ -8,7 +8,7 @@ module.exports = {
...globalTypedocOptions,
entryPoints: [path.join(pathPrefix, "packages/medusa/src/models/index.ts")],
out: [path.join(pathPrefix, "www/apps/docs/content/references/entities")],
tsconfig: path.join(pathPrefix, "packages/medusa/tsconfig.json"),
tsconfig: path.join(__dirname, "extended-tsconfig", "medusa.json"),
name: "Entities Reference",
indexTitle: "Entities Reference",
entryDocument: "_index.mdx",
@@ -0,0 +1,6 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": [
"../../../../packages/medusa-js/tsconfig.json"
]
}
@@ -0,0 +1,6 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": [
"../../../../packages/medusa/tsconfig.json"
]
}
@@ -0,0 +1,22 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": ["typedoc/tsdoc.json"],
"tagDefinitions": [
{
"tagName": "@featureFlag",
"syntaxKind": "block"
},
{
"tagName": "@expandable",
"syntaxKind": "modifier"
},
{
"tagName": "@schema",
"syntaxKind": "block"
},
{
"tagName": "@apiIgnore",
"syntaxKind": "modifier"
}
]
}
@@ -0,0 +1,6 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": [
"../../../../packages/types/tsconfig.json"
]
}
+34 -20
View File
@@ -4,12 +4,35 @@ const globalTypedocOptions = require("./_base")
const pathPrefix = path.join(__dirname, "..", "..", "..")
const defaultFormattingOptions = {
showCommentsAsHeader: true,
sections: {
member_sources_definedIn: false,
reflection_hierarchy: false,
member_signature_typeParameters: false,
member_signature_sources: false,
member_signature_title: false,
member_signature_returns: false,
},
parameterStyle: "component",
parameterComponent: "ParameterTypes",
mdxImports: [
`import ParameterTypes from "@site/src/components/ParameterTypes"`,
],
reflectionGroups: {
Constructors: false,
},
frontmatterData: {
displayed_sidebar: "jsClientSidebar",
},
}
/** @type {import('typedoc').TypeDocOptions} */
module.exports = {
...globalTypedocOptions,
entryPoints: [path.join(pathPrefix, "packages/medusa-js/src/resources")],
entryPointStrategy: "expand",
out: [path.join(pathPrefix, "www/apps/docs/content/references/js-client")],
tsconfig: path.join(pathPrefix, "packages/medusa-js/tsconfig.json"),
tsconfig: path.join(__dirname, "extended-tsconfig", "js-client.json"),
name: "JS Client Reference",
indexTitle: "JS Client Reference",
entryDocument: "_index.mdx",
@@ -17,35 +40,26 @@ module.exports = {
hideBreadcrumbs: true,
plugin: [
...globalTypedocOptions.plugin,
"typedoc-plugin-reference-excluder",
"typedoc-plugin-frontmatter",
"typedoc-plugin-rename-defaults",
"typedoc-plugin-modules",
"typedoc-plugin-custom",
],
exclude: [
path.join(pathPrefix, "packages/medusa-js/src/resources/base.ts"),
path.join(pathPrefix, "node_modules/**"),
path.join(pathPrefix, "packages/**/node_modules"),
],
excludeConstructors: true,
frontmatterData: {
displayed_sidebar: "jsClientSidebar",
},
internalModule: "internal",
formatting: {
"*": {
showCommentsAsHeader: true,
sections: {
member_sources_definedIn: false,
reflection_hierarchy: false,
"*": defaultFormattingOptions,
"^classes/": {
...defaultFormattingOptions,
frontmatterData: {
...defaultFormattingOptions.frontmatterData,
slug: "/references/js-client/{{alias}}",
},
parameterStyle: "component",
parameterComponent: "ParameterTypes",
mdxImports: [
`import ParameterTypes from "@site/src/components/ParameterTypes"`,
],
},
},
objectLiteralTypeDeclarationStyle: "component",
mdxOutput: true,
maxLevel: 4,
ignoreApi: true,
}
@@ -5,6 +5,9 @@
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"typedoc": "0.25.x"
},
"main": "_base.js",
"version": "0.0.0"
}
@@ -8,7 +8,7 @@ module.exports = {
...globalTypedocOptions,
entryPoints: [path.join(pathPrefix, "packages/medusa/src/services/index.ts")],
out: [path.join(pathPrefix, "www/apps/docs/content/references/services")],
tsconfig: path.join(pathPrefix, "packages/medusa/tsconfig.json"),
tsconfig: path.join(__dirname, "extended-tsconfig", "medusa.json"),
name: "Services Reference",
indexTitle: "Services Reference",
entryDocument: "index.md",
@@ -0,0 +1,44 @@
# typedoc-plugin-custom
A Typedoc plugin that combines utility plugins for documenting references.
## Configurations
### Resolve Reference Configurations
The [`resolve-reference-plugin`](./src/resolve-references-plugin.ts) imitates the [`typedoc-plugin-missing-exports`](https://www.npmjs.com/package/typedoc-plugin-missing-exports) plugin. So, it accepts the same options as the [`typedoc-plugin-missing-exports`](https://www.npmjs.com/package/typedoc-plugin-missing-exports) plugin.
### Frontmatter
`frontmatterData` is an object of key-value pairs. If none provided, no frontmatter variables will be added to the Markdown files.
An example of passing it in a JavaScript configuration file:
```js
frontmatterData: {
displayed_sidebar: "jsClientSidebar",
},
```
### API Ignore
The `ignoreApi` option is a boolean that indicates whether reflections with the `@apiIgnore` tag should be ignored. If enabled, reflections having this tag are removed from the generated documentation. If disabled (which is the default), the `@apiIgnore` tag is removed from the reflection to ensure it's not shown in the generated documentation.
### ESLint
If the `eslintPathName` option is set, code snippets provided in `@example` tag are linted based on the documentation's ESLint rules.
The following options are useful for linting:
- `eslintPathName`: The path to the ESLint configuration file.
- `pluginsResolvePath`: The path to resolve plugins used in the ESLint configuration files.
---
## Build the Plugin
Before using any command that makes use of this plugin, make sure to run the `build` command:
```bash
yarn build
```
@@ -1,5 +1,5 @@
{
"name": "typedoc-plugin-modules",
"name": "typedoc-plugin-custom",
"private": true,
"version": "0.0.0",
"license": "MIT",
@@ -32,7 +32,10 @@
"typedoc"
],
"dependencies": {
"eslint": "^8.53.0",
"glob": "^10.3.10",
"typedoc-plugin-markdown": "^3.16.0"
"typedoc-plugin-markdown": "^3.16.0",
"utils": "*",
"yaml": "^2.3.3"
}
}
@@ -0,0 +1,30 @@
import {
Application,
Context,
Converter,
ParameterType,
ReflectionKind,
} from "typedoc"
export function load(app: Application) {
app.options.addDeclaration({
name: "ignoreApi",
help: "Whether to ignore items with the `@apiIgnore` tag.",
type: ParameterType.Boolean, // The default
defaultValue: false,
})
app.converter.on(Converter.EVENT_RESOLVE_BEGIN, (context: Context) => {
for (const reflection of context.project.getReflectionsByKind(
ReflectionKind.All
)) {
if (reflection.comment?.hasModifier("@apiIgnore")) {
if (app.options.getValue("ignoreApi")) {
context.project.removeReflection(reflection)
} else {
reflection.comment.removeModifier(`@apiIgnore`)
}
}
}
})
}
@@ -0,0 +1,65 @@
import { ESLint } from "eslint"
import {
Application,
Context,
Converter,
ParameterType,
ReflectionKind,
} from "typedoc"
export function load(app: Application) {
app.options.addDeclaration({
name: "eslintPathName",
help: "The path to the ESLint configurations to apply.",
type: ParameterType.String,
})
app.options.addDeclaration({
name: "pluginsResolvePath",
help: "The path to resolve plugins used in the ESLint configurations.",
type: ParameterType.String,
})
app.converter.on(Converter.EVENT_RESOLVE_BEGIN, async (context: Context) => {
const eslintConfigPath = app.options.getValue("eslintPathName") as string
const pluginsResolvePath = app.options.getValue(
"pluginsResolvePath"
) as string
if (!eslintConfigPath) {
return
}
const eslint = new ESLint({
overrideConfigFile: eslintConfigPath,
resolvePluginsRelativeTo: pluginsResolvePath,
fix: true,
})
for (const reflection of context.project.getReflectionsByKind(
ReflectionKind.All
)) {
const example = reflection.comment?.getTag(`@example`)
if (example) {
await Promise.all(
example.content
.filter((exampleContent) => exampleContent.kind === "code")
.map(async (exampleContent) => {
const matchedCodeSnippets = exampleContent.text.matchAll(
/```ts(?<code>[\s\S.]*)```/g
)
for (const matchedCodeSnippet of matchedCodeSnippets) {
if (!matchedCodeSnippet.groups?.code) {
return
}
const result = await eslint.lintText(
matchedCodeSnippet.groups.code
)
exampleContent.text =
result.length > 0 && result[0].output
? "```ts\n" + result[0].output + "```"
: exampleContent.text
}
})
)
}
}
})
}
@@ -0,0 +1,14 @@
import { Application } from "typedoc"
import { load as resolveReferencesPluginLoad } from "./resolve-references-plugin"
import { load as frontmatterPlugin } from "./frontmatter-plugin"
import { load as parseOasSchemaPlugin } from "./parse-oas-schema-plugin"
import { load as apiIgnorePlugin } from "./api-ignore"
import { load as eslintExamplePlugin } from "./eslint-example"
export function load(app: Application) {
resolveReferencesPluginLoad(app)
frontmatterPlugin(app)
parseOasSchemaPlugin(app)
apiIgnorePlugin(app)
eslintExamplePlugin(app)
}
@@ -0,0 +1,234 @@
import {
Application,
Comment,
CommentDisplayPart,
CommentTag,
Context,
Converter,
DeclarationReflection,
Reflection,
ReflectionKind,
SomeType,
} from "typedoc"
import { parse } from "yaml"
import { getTypeChildren } from "utils"
// a simplified schema type
// mainly focusing on properties used
// within this plugin
type Schema = {
description?: string
properties?: SchemaProperties
allOf?: SchemaProperty[]
oneOf?: SchemaProperty[]
}
type SchemaProperties = {
[k: string]: SchemaProperty
}
type SchemaProperty = {
description?: string
"x-expandable"?: string
"x-featureFlag"?: string
default?: string
items?: Schema
properties?: SchemaProperties
allOf?: SchemaProperty[]
oneOf?: SchemaProperty[]
}
export function load(app: Application) {
const definedSchemas = new Map<string, Schema>()
// Since some files, such as models, include the
// `@schema` declaration at the end of the file, i.e. not
// before the related class/type/interface, this extracts
// those schemas and applies them to reflections having the same
// name, if those reflections don't have a schema comment of their own.
const origConvertSymbol = app.converter.convertSymbol
app.converter.convertSymbol = (context, symbol, exportSymbol) => {
if (symbol.valueDeclaration) {
const sourceFile = symbol.valueDeclaration?.getSourceFile()
// find block comments
const blockCommentMatch = sourceFile.text.matchAll(
/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm
)
for (const blockMatch of blockCommentMatch) {
blockMatch.forEach((matched) => {
if (!matched) {
return
}
const schemaStartIndex = matched.indexOf("@schema")
if (schemaStartIndex === -1) {
return
}
// find end index
let schemaEndIndex = matched.indexOf(" * @", schemaStartIndex)
if (schemaEndIndex === -1) {
schemaEndIndex = matched.length
}
const schemaText = matched
.substring(schemaStartIndex, schemaEndIndex)
.replaceAll(" */", "")
.replaceAll("*/", "")
.replaceAll(" * ", "")
const { name: schemaName = "" } =
/@schema (?<name>\w+)/.exec(schemaText)?.groups || {}
if (!schemaName || definedSchemas.has(schemaName)) {
return
}
// attempt to parse schema and save it
try {
const parsedSchema = parse(
schemaText.replace("@schema", "schema:")
) as Schema
definedSchemas.set(schemaName, parsedSchema)
} catch (e) {
// ignore errors as the schema may be malformed.
console.error(`Error parsing schema ${schemaName}: ${e}`)
}
})
}
}
return origConvertSymbol(context, symbol, exportSymbol)
}
app.converter.on(Converter.EVENT_RESOLVE_BEGIN, (context: Context) => {
for (const reflection of context.project.getReflectionsByKind(
ReflectionKind.All
)) {
let schema: Schema | undefined
let { comment } = reflection
const schemaTags = comment?.getTags(`@schema`)
if (schemaTags?.length) {
schemaTags.forEach((part) => {
if (part.content.length) {
const schemaComment = prepareSchemaComment(part.content)
schema = parse(schemaComment)
}
})
reflection.comment?.removeTags("@schema")
} else if (!comment) {
if (definedSchemas.has(reflection.name)) {
schema = definedSchemas.get(reflection.name)
comment = new Comment()
} else if ("type" in reflection && reflection.type) {
const reflectionType = reflection.type as SomeType
if (
"name" in reflectionType &&
definedSchemas.has(reflectionType.name)
) {
schema = definedSchemas.get(reflectionType.name)
comment = new Comment()
}
}
}
if (schema) {
if (schema.description) {
comment?.summary.push({
kind: "text",
text: schema.description,
})
}
if (reflection.kind === ReflectionKind.TypeAlias) {
comment?.modifierTags.add(`@interface`)
}
addComments(schema, reflection)
if (!reflection.comment && comment) {
reflection.comment = comment
}
}
}
})
}
function prepareSchemaComment(commentParts: CommentDisplayPart[]) {
let result = `schema: `
commentParts.forEach((commentPart) => {
result += commentPart.text
})
return result
}
function addComments(schema: Schema, reflection: Reflection) {
if (!schema.properties) {
if (schema.allOf) {
schema.allOf.forEach((valueChild) => {
addComments(valueChild, reflection)
})
} else if (schema.oneOf) {
schema.oneOf.forEach((valueChild) => {
addComments(valueChild, reflection)
})
}
return
}
const children =
"type" in reflection
? getTypeChildren(reflection.type as SomeType, reflection.project)
: "children" in reflection
? (reflection.children as DeclarationReflection[])
: []
Object.entries(schema.properties).forEach(([key, value]) => {
const childItem =
children.find((child) => child.name === key) ||
reflection.getChildByName(key)
if (childItem) {
if (!childItem.comment) {
const comment = new Comment()
comment.summary.push({
kind: "text",
text: value.description || "",
})
childItem.comment = comment
}
if (
value.default !== undefined &&
"defaultValue" in childItem &&
!childItem.defaultValue
) {
childItem.defaultValue = value.default
}
if (value["x-expandable"]) {
childItem.comment.modifierTags.add(`@expandable`)
}
if (value["x-featureFlag"]) {
childItem.comment.blockTags.push(
new CommentTag(`@featureFlag`, [
{
kind: `inline-tag`,
text: value["x-featureFlag"],
tag: `@featureFlag`,
},
])
)
}
if (value.items) {
addComments(value.items, childItem)
}
if (value.properties || value.allOf || value.oneOf) {
addComments(value, childItem)
}
}
})
}
@@ -1,45 +0,0 @@
# typedoc-plugin-frontmatter
A Typedoc plugin that allows inserting frontmatter key-value pairs at the top of the exported Markdown files.
> For more flexibility in what pages to apply the frontmatter data to, for example, to specify different frontmatter for different pages, ues the [`typedoc-plugin-markdown-medusa` plugin's `frontmatterData` option](../typedoc-plugin-markdown-medusa/README.md#configurations)
## Configurations
The following options are optional and can be used to customize the configurations of the plugin.
### frontmatterData
`frontmatterData` is an object of key-value pairs. If none provided, no frontmatter variables will be added to the Markdown files.
An example of passing it in a JavaScript configuration file:
```js
frontmatterData: {
displayed_sidebar: "jsClientSidebar",
},
```
If passing the option in the command line the value should be a JSON object.
### pagesPattern
`pagesPattern` is a string that contains a regular expression. This allows you to limit the pages the frontmatter variables should be added to.
By default, the frontmatter variables will be added to all files.
An example of passing it in a JavaScript configuration file:
```js
frontmatterData: {
pagesPattern: "internal\\.",
},
```
## Build the Plugin
Before using any command that makes use of this plugin, make sure to run the `build` command:
```bash
yarn build
```
@@ -1,37 +0,0 @@
{
"name": "typedoc-plugin-frontmatter",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
},
"version": "0.0.0",
"description": "Plugin to add frontmatter key-values at the top of pages",
"main": "./dist/index.js",
"exports": "./dist/index.js",
"files": [
"dist"
],
"author": "Shahed Nasser",
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"lint": "eslint --ext .ts src"
},
"peerDependencies": {
"typedoc": "0.25.x"
},
"devDependencies": {
"@types/node": "^16.11.10",
"typescript": "^4.6"
},
"keywords": [
"typedocplugin",
"packages",
"monorepo",
"typedoc"
],
"dependencies": {
"yaml": "^2.3.2"
}
}
@@ -23,6 +23,7 @@ Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/
- `frontmatterData`: (optional) an object that will be injected as frontmatter to the pages matching specified pattern.
- `parameterComponent`: (optional) a string indicating the name of a React component to pass the parameters as an object to. This is only used if the `parameterStyle` option is set to `component`. This also must be used with the `mdxOutput` option enabled, and an import string for the component passed to the `mdxImports` option. The React component will receive a `parameters` prop, which is an array of type [Parameter](./src/types.ts#L95).
- `mdxImports`: (optional) an array of strings, each holding an import statement that will be added to the beginning of each page. For example, `["import ParameterTypes from "@site/src/components/ParameterTypes""]`. Must be used along with the `mdxOutput` option enabled.
- `maxLevel`: (optional) a number indicating the maximum level parameters and return types are expanded. Default is `3`.
## Build Plugin
@@ -23,7 +23,8 @@
"devDependencies": {
"@types/node": "^16.11.10",
"copyfiles": "^2.4.1",
"typescript": "^4.6"
"typescript": "^4.6",
"utils": "*"
},
"keywords": [
"typedocplugin",
@@ -109,5 +109,12 @@ export function load(app: Application) {
type: ParameterType.Boolean,
defaultValue: false,
})
app.options.addDeclaration({
help: "[Markdown Plugin] The maximum level to expand when retrieving reflection types.",
name: "maxLevel",
type: ParameterType.Number,
defaultValue: 3,
})
}
export { MarkdownTheme }
@@ -43,6 +43,8 @@ import typeParameterComponentHelper from "./resources/helpers/type-parameter-com
import showPropertiesAsComponentHelper from "./resources/helpers/show-properties-as-component"
import commentTagHelper from "./resources/helpers/comment-tag"
import exampleHelper from "./resources/helpers/example"
import ifFeatureFlagHelper from "./resources/helpers/if-feature-flag"
import featureFlagHelper from "./resources/helpers/feature-flag"
import { MarkdownTheme } from "./theme"
// test
@@ -116,4 +118,6 @@ export function registerHelpers(theme: MarkdownTheme) {
showPropertiesAsComponentHelper(theme)
commentTagHelper(theme)
exampleHelper()
ifFeatureFlagHelper()
featureFlagHelper()
}
@@ -1,6 +1,8 @@
import * as Handlebars from "handlebars"
import { Comment } from "typedoc"
const EXCLUDED_TAGS = ["@returns", "@example", "@featureFlag"]
export default function () {
Handlebars.registerHelper(
"comments",
@@ -18,9 +20,9 @@ export default function () {
}
if (showTags && comment.blockTags?.length) {
const filteredTags = comment.blockTags
.filter((tag) => tag.tag !== "@returns")
.filter((tag) => tag.tag !== "@example")
const filteredTags = comment.blockTags.filter(
(tag) => !EXCLUDED_TAGS.includes(tag.tag)
)
const tags = filteredTags.map((tag) => {
return Handlebars.helpers.commentTag(
tag,
@@ -0,0 +1,21 @@
import * as Handlebars from "handlebars"
import { Comment } from "typedoc"
export default function () {
Handlebars.registerHelper(
"featureFlag",
function (comment: Comment | undefined) {
if (!comment) {
return undefined
}
const featureFlagTag = comment.getTag("@featureFlag")
if (!featureFlagTag) {
return undefined
}
return featureFlagTag.content
.map((tagContent) => tagContent.text)
.join("")
}
)
}
@@ -0,0 +1,13 @@
import * as Handlebars from "handlebars"
import { Reflection } from "typedoc"
export default function () {
Handlebars.registerHelper(
"ifFeatureFlag",
function (this: Reflection, options: Handlebars.HelperOptions) {
return this.comment?.getTag("@featureFlag") !== undefined
? options.fn(this)
: options.inverse(this)
}
)
}
@@ -0,0 +1,13 @@
{{#with model}}
{{#ifFeatureFlag}}
:::note
To use this resource, make sure to [enable its feature flag: {{{featureFlag comment}}}](https://docs.medusajs.com/development/feature-flags/toggle)
:::
{{/ifFeatureFlag}}
{{/with}}
@@ -4,6 +4,8 @@
{{/ifShowPageTitle}}
{{> feature-flag}}
{{#with model}}
{{{reflectionDescription}}}
@@ -56,6 +56,8 @@ export class MarkdownTheme extends Theme {
static URL_PREFIX = /^(http|ftp)s?:\/\//
static MAX_LEVEL = 3
constructor(renderer: Renderer) {
super(renderer)
@@ -85,6 +87,7 @@ export class MarkdownTheme extends Theme {
"formatting"
) as FormattingOptionsType
this.mdxOutput = this.getOption("mdxOutput") as boolean
MarkdownTheme.MAX_LEVEL = this.getOption("maxLevel") as number
this.listenTo(this.owner, {
[RendererEvent.BEGIN]: this.onBeginRenderer,
@@ -74,6 +74,7 @@ export type FormattingOptionType = {
frontmatterData?: Record<string, unknown>
parameterComponent?: string
mdxImports?: string[]
maxLevel?: number
}
export type FormattingOptionsType = {
@@ -98,6 +99,8 @@ export type Parameter = {
optional?: boolean
defaultValue?: string
description?: string
featureFlag?: string
expandable: boolean
children?: Parameter[]
}
@@ -64,6 +64,10 @@ export function stripLineBreaks(str: string) {
: ""
}
export function stripCode(str: string) {
return stripLineBreaks(str.replace("```ts", "").replace("```", ""))
}
export function camelToTitleCase(text: string) {
return (
text.substring(0, 1).toUpperCase() +
@@ -1,17 +1,21 @@
import {
Comment,
DeclarationReflection,
ReflectionKind,
ProjectReflection,
ReflectionType,
SomeType,
} from "typedoc"
import { Comment, ReflectionKind, ReflectionType } from "typedoc"
import * as Handlebars from "handlebars"
import { stripLineBreaks } from "../utils"
import { stripCode, stripLineBreaks } from "../utils"
import { Parameter, ParameterStyle, ReflectionParameterType } from "../types"
import getType, { getReflectionType } from "./type-utils"
import { getTypeChildren } from "utils"
import { MarkdownTheme } from "../theme"
const MAX_LEVEL = 3
const ALLOWED_KINDS: ReflectionKind[] = [
ReflectionKind.EnumMember,
ReflectionKind.TypeParameter,
ReflectionKind.Property,
ReflectionKind.Parameter,
ReflectionKind.TypeAlias,
ReflectionKind.TypeLiteral,
ReflectionKind.Variable,
ReflectionKind.Reference,
]
export default function reflectionFormatter(
reflection: ReflectionParameterType,
@@ -57,7 +61,10 @@ export function reflectionListFormatter(
const hasChildren = "children" in reflection && reflection.children?.length
if ((reflection.type || hasChildren) && level + 1 <= MAX_LEVEL) {
if (
(reflection.type || hasChildren) &&
level + 1 <= MarkdownTheme.MAX_LEVEL
) {
const children = hasChildren
? reflection.children
: getTypeChildren(reflection.type!, reflection.project)
@@ -94,24 +101,32 @@ export function reflectionComponentFormatter(
? getType(reflection.type, "object")
: getReflectionType(reflection, "object"),
description: comments
? stripLineBreaks(Handlebars.helpers.comments(comments))
? stripLineBreaks(Handlebars.helpers.comments(comments, true, false))
: "",
optional,
defaultValue,
expandable: reflection.comment?.hasModifier(`@expandable`) || false,
featureFlag: Handlebars.helpers.featureFlag(reflection.comment),
children: [],
}
const hasChildren = "children" in reflection && reflection.children?.length
if ((reflection.type || hasChildren) && level + 1 <= MAX_LEVEL) {
if (
(reflection.type || hasChildren) &&
level + 1 <= MarkdownTheme.MAX_LEVEL
) {
const children = hasChildren
? reflection.children
: getTypeChildren(reflection.type!, reflection.project)
children?.forEach((childItem) => {
componentItem.children?.push(
reflectionComponentFormatter(childItem, level + 1)
)
})
children
?.filter((childItem) => childItem.kindOf(ALLOWED_KINDS))
.forEach((childItem) => {
componentItem.children?.push(
reflectionComponentFormatter(childItem, level + 1)
)
})
}
return componentItem
@@ -195,11 +210,17 @@ export function getTableHeaders(
export function getDefaultValue(
parameter: ReflectionParameterType
): string | null {
if (!("defaultValue" in parameter)) {
const defaultComment = parameter.comment?.getTag(`@defaultValue`)
if (!("defaultValue" in parameter) && !defaultComment) {
return null
}
return parameter.defaultValue && parameter.defaultValue !== "..."
? `\`${parameter.defaultValue}\``
return "defaultValue" in parameter &&
parameter.defaultValue !== undefined &&
parameter.defaultValue !== "..."
? `${parameter.defaultValue}`
: defaultComment
? defaultComment.content.map((content) => stripCode(content.text)).join()
: null
}
@@ -246,28 +267,3 @@ function getItemExpandText(
return "It accepts the following properties"
}
}
export function getTypeChildren(
reflectionType: SomeType,
project: ProjectReflection
) {
let children: DeclarationReflection[] = []
switch (reflectionType.type) {
case "reference":
// eslint-disable-next-line no-case-declarations
const referencedReflection = project?.getChildByName(reflectionType.name)
if (
referencedReflection instanceof DeclarationReflection &&
referencedReflection.children
) {
children = referencedReflection.children
}
break
case "array":
children = getTypeChildren(reflectionType.elementType, project)
}
return children
}
@@ -12,8 +12,7 @@ import {
getDefaultValue,
reflectionComponentFormatter,
} from "./reflection-formatter"
const MAX_LEVEL = 3
import { MarkdownTheme } from "../theme"
export function returnReflectionComponentFormatter(
reflectionType: SomeType,
@@ -41,9 +40,14 @@ export function returnReflectionComponentFormatter(
) || ""
: "",
description: comment ? getReturnComment(comment) : "",
expandable: comment?.hasModifier(`@expandable`) || false,
featureFlag: Handlebars.helpers.featureFlag(comment),
children: [],
})
if (!isOnlyVoid(reflectionType.typeArguments) && level + 1 <= MAX_LEVEL) {
if (
!isOnlyVoid(reflectionType.typeArguments) &&
level + 1 <= MarkdownTheme.MAX_LEVEL
) {
reflectionType.typeArguments.forEach((typeArg) => {
const typeArgComponent = returnReflectionComponentFormatter(
typeArg,
@@ -95,9 +99,11 @@ export function returnReflectionComponentFormatter(
) || ""
: "",
description: comment ? getReturnComment(comment) : "",
expandable: comment?.hasModifier(`@expandable`) || false,
featureFlag: Handlebars.helpers.featureFlag(comment),
children: [],
})
if (level + 1 <= MAX_LEVEL) {
if (level + 1 <= MarkdownTheme.MAX_LEVEL) {
const elementTypeItem = returnReflectionComponentFormatter(
reflectionType.elementType,
project,
@@ -126,13 +132,15 @@ export function returnReflectionComponentFormatter(
) || ""
: "",
description: comment ? getReturnComment(comment) : "",
expandable: comment?.hasModifier(`@expandable`) || false,
featureFlag: Handlebars.helpers.featureFlag(comment),
children: [],
})
pushTo = componentItem[parentKey - 1].children!
} else {
pushTo = componentItem
}
if (level + 1 <= MAX_LEVEL) {
if (level + 1 <= MarkdownTheme.MAX_LEVEL) {
reflectionType.elements.forEach((element) => {
const elementTypeItem = returnReflectionComponentFormatter(
element,
@@ -159,6 +167,8 @@ export function returnReflectionComponentFormatter(
? getDefaultValue(reflectionType.declaration) || ""
: "",
description: comment ? getReturnComment(comment) : "",
expandable: comment?.hasModifier(`@expandable`) || false,
featureFlag: Handlebars.helpers.featureFlag(comment),
children: [],
})
}
@@ -1,2 +0,0 @@
dist
.yarn
@@ -1,15 +0,0 @@
# typedoc-plugin-modules
A Typedoc plugin that includes helper plugins for documenting modules. The `resolve-reference-plugin` imitates the [`typedoc-plugin-missing-exports`](https://www.npmjs.com/package/typedoc-plugin-missing-exports) plugin.
## Configurations
Accepts the same options as the [`typedoc-plugin-missing-exports`](https://www.npmjs.com/package/typedoc-plugin-missing-exports) plugin.
## Build the Plugin
Before using any command that makes use of this plugin, make sure to run the `build` command:
```bash
yarn build
```
@@ -1,6 +0,0 @@
import { Application } from "typedoc"
import { load as resolveReferencesPluginLoad } from "./resolve-references-plugin"
export function load(app: Application) {
resolveReferencesPluginLoad(app)
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "utils",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"version": "0.0.0",
"scripts": {
"build": "yarn clean && tsc",
"lint": "eslint --ext .ts src",
"clean": "rimraf dist"
},
"peerDependencies": {
"typedoc": "0.25.x"
},
"devDependencies": {
"@types/node": "^16.11.10",
"typescript": "^4.6"
},
"dependencies": {
"rimraf": "^5.0.5"
}
}
@@ -0,0 +1,43 @@
import {
DeclarationReflection,
ProjectReflection,
ReflectionKind,
} from "typedoc"
export function getProjectChild(
project: ProjectReflection,
childName: string
): DeclarationReflection | undefined {
let reflection: DeclarationReflection | undefined = project.getChildByName(
childName
) as DeclarationReflection
const splitChildName = childName.split(".")
if (!reflection && splitChildName.length > 1) {
reflection = getProjectChild(
project,
splitChildName[splitChildName.length - 1]
)
}
if (
!reflection &&
project.parent &&
project.parent instanceof ProjectReflection
) {
reflection = getProjectChild(project.parent, childName)
}
if (!reflection) {
const modules = project.getChildrenByKind(ReflectionKind.Module)
for (const module of modules) {
reflection = module.getChildByName(childName) as DeclarationReflection
if (reflection) {
break
}
}
}
return reflection
}
@@ -0,0 +1,76 @@
import { DeclarationReflection, ProjectReflection, SomeType } from "typedoc"
import { getProjectChild } from "./get-project-child"
export function getTypeChildren(
reflectionType: SomeType,
project: ProjectReflection | undefined
): DeclarationReflection[] {
let children: DeclarationReflection[] = []
switch (reflectionType.type) {
case "intersection":
reflectionType.types.forEach((intersectionType) => {
children.push(...getTypeChildren(intersectionType, project))
})
break
case "reference":
// eslint-disable-next-line no-case-declarations
const referencedReflection =
reflectionType.reflection && "children" in reflectionType.reflection
? reflectionType.reflection
: project
? getProjectChild(project, reflectionType.name)
: undefined
if (referencedReflection instanceof DeclarationReflection) {
if (referencedReflection.children) {
children = referencedReflection.children
} else if (reflectionType.typeArguments?.length) {
reflectionType.typeArguments.forEach((typeArgument, index) => {
if (reflectionType.name === "Omit" && index > 0) {
switch (typeArgument.type) {
case "literal":
removeChild(typeArgument.value?.toString(), children)
break
case "union":
typeArgument.types.forEach((childItem) => {
if (childItem.type === "literal") {
removeChild(childItem.value?.toString(), children)
} else {
getTypeChildren(childItem, project).forEach((child) => {
removeChild(child.name, children)
})
}
})
}
} else {
const typeArgumentChildren = getTypeChildren(
typeArgument,
project
)
children.push(...typeArgumentChildren)
}
})
} else if (referencedReflection.type) {
children = getTypeChildren(referencedReflection.type, project)
}
}
break
case "reflection":
children = reflectionType.declaration.children || [
reflectionType.declaration,
]
break
case "array":
children = getTypeChildren(reflectionType.elementType, project)
}
return children
}
function removeChild(name: unknown, children: DeclarationReflection[]) {
const childIndex = children.findIndex((child) => child.name === name)
if (childIndex !== -1) {
children.splice(childIndex, 1)
}
}
+2
View File
@@ -0,0 +1,2 @@
export * from "./get-type-children"
export * from "./get-project-child"
@@ -2,7 +2,10 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
"rootDir": "./src",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true
},
"include": ["src"]
}
+145 -22
View File
@@ -325,6 +325,23 @@ __metadata:
languageName: node
linkType: hard
"@eslint/eslintrc@npm:^2.1.3":
version: 2.1.3
resolution: "@eslint/eslintrc@npm:2.1.3"
dependencies:
ajv: ^6.12.4
debug: ^4.3.2
espree: ^9.6.0
globals: ^13.19.0
ignore: ^5.2.0
import-fresh: ^3.2.1
js-yaml: ^4.1.0
minimatch: ^3.1.2
strip-json-comments: ^3.1.1
checksum: f4103f4346126292eb15581c5a1d12bef03410fd3719dedbdb92e1f7031d46a5a2d60de8566790445d5d4b70b75ba050876799a11f5fff8265a91ee3fa77dab0
languageName: node
linkType: hard
"@eslint/js@npm:8.50.0":
version: 8.50.0
resolution: "@eslint/js@npm:8.50.0"
@@ -332,6 +349,13 @@ __metadata:
languageName: node
linkType: hard
"@eslint/js@npm:8.53.0":
version: 8.53.0
resolution: "@eslint/js@npm:8.53.0"
checksum: d29f6c207b2f6dc4ef174d16a3c07b0d3a17ca3d805680496ff267edd773e3bac41db4e7dcab622ca1970d892535bd19671e2a756d4eac75e96fd8c8dcdb619b
languageName: node
linkType: hard
"@fastify/busboy@npm:^2.0.0":
version: 2.0.0
resolution: "@fastify/busboy@npm:2.0.0"
@@ -359,6 +383,17 @@ __metadata:
languageName: node
linkType: hard
"@humanwhocodes/config-array@npm:^0.11.13":
version: 0.11.13
resolution: "@humanwhocodes/config-array@npm:0.11.13"
dependencies:
"@humanwhocodes/object-schema": ^2.0.1
debug: ^4.1.1
minimatch: ^3.0.5
checksum: d76ca802d853366094d0e98ff0d0994117fc8eff96649cd357b15e469e428228f597cd2e929d54ab089051684949955f16ee905bb19f7b2f0446fb377157be7a
languageName: node
linkType: hard
"@humanwhocodes/module-importer@npm:^1.0.1":
version: 1.0.1
resolution: "@humanwhocodes/module-importer@npm:1.0.1"
@@ -373,6 +408,13 @@ __metadata:
languageName: node
linkType: hard
"@humanwhocodes/object-schema@npm:^2.0.1":
version: 2.0.1
resolution: "@humanwhocodes/object-schema@npm:2.0.1"
checksum: 9dba24e59fdb4041829d92b693aacb778add3b6f612aaa9c0774f3b650c11a378cc64f042a59da85c11dae33df456580a3c36837b953541aed6ff94294f97fac
languageName: node
linkType: hard
"@isaacs/cliui@npm:^8.0.2":
version: 8.0.2
resolution: "@isaacs/cliui@npm:8.0.2"
@@ -777,6 +819,13 @@ __metadata:
languageName: node
linkType: hard
"@ungap/structured-clone@npm:^1.2.0":
version: 1.2.0
resolution: "@ungap/structured-clone@npm:1.2.0"
checksum: 8209c937cb39119f44eb63cf90c0b73e7c754209a6411c707be08e50e29ee81356dca1a848a405c8bdeebfe2f5e4f831ad310ae1689eeef65e7445c090c6657d
languageName: node
linkType: hard
"acorn-jsx@npm:^5.3.2":
version: 5.3.2
resolution: "acorn-jsx@npm:5.3.2"
@@ -1360,6 +1409,54 @@ __metadata:
languageName: node
linkType: hard
"eslint@npm:^8.53.0":
version: 8.53.0
resolution: "eslint@npm:8.53.0"
dependencies:
"@eslint-community/eslint-utils": ^4.2.0
"@eslint-community/regexpp": ^4.6.1
"@eslint/eslintrc": ^2.1.3
"@eslint/js": 8.53.0
"@humanwhocodes/config-array": ^0.11.13
"@humanwhocodes/module-importer": ^1.0.1
"@nodelib/fs.walk": ^1.2.8
"@ungap/structured-clone": ^1.2.0
ajv: ^6.12.4
chalk: ^4.0.0
cross-spawn: ^7.0.2
debug: ^4.3.2
doctrine: ^3.0.0
escape-string-regexp: ^4.0.0
eslint-scope: ^7.2.2
eslint-visitor-keys: ^3.4.3
espree: ^9.6.1
esquery: ^1.4.2
esutils: ^2.0.2
fast-deep-equal: ^3.1.3
file-entry-cache: ^6.0.1
find-up: ^5.0.0
glob-parent: ^6.0.2
globals: ^13.19.0
graphemer: ^1.4.0
ignore: ^5.2.0
imurmurhash: ^0.1.4
is-glob: ^4.0.0
is-path-inside: ^3.0.3
js-yaml: ^4.1.0
json-stable-stringify-without-jsonify: ^1.0.1
levn: ^0.4.1
lodash.merge: ^4.6.2
minimatch: ^3.1.2
natural-compare: ^1.4.0
optionator: ^0.9.3
strip-ansi: ^6.0.1
text-table: ^0.2.0
bin:
eslint: bin/eslint.js
checksum: c5cd0049488c0463dab7d97466767ca5a1d0b3b59d0a223122683dc8039ecea30b27867fb9e38906b4c1ab9d09ece8a802a6c540d8905016f1cc4b4bb27329af
languageName: node
linkType: hard
"espree@npm:^9.6.0, espree@npm:^9.6.1":
version: 9.6.1
resolution: "espree@npm:9.6.1"
@@ -1596,7 +1693,7 @@ __metadata:
languageName: node
linkType: hard
"glob@npm:^10.3.10":
"glob@npm:^10.3.10, glob@npm:^10.3.7":
version: 10.3.10
resolution: "glob@npm:10.3.10"
dependencies:
@@ -2443,6 +2540,17 @@ __metadata:
languageName: node
linkType: hard
"rimraf@npm:^5.0.5":
version: 5.0.5
resolution: "rimraf@npm:5.0.5"
dependencies:
glob: ^10.3.7
bin:
rimraf: dist/esm/bin.mjs
checksum: d50dbe724f33835decd88395b25ed35995077c60a50ae78ded06e0185418914e555817aad1b4243edbff2254548c2f6ad6f70cc850040bebb4da9e8cc016f586
languageName: node
linkType: hard
"run-applescript@npm:^5.0.0":
version: 5.0.0
resolution: "run-applescript@npm:5.0.0"
@@ -2484,12 +2592,12 @@ __metadata:
typedoc: 0.25.1
typedoc-config: "*"
typedoc-monorepo-link-types: ^0.0.2
typedoc-plugin-custom: "*"
typedoc-plugin-frontmatter: "*"
typedoc-plugin-markdown: 3.16.0
typedoc-plugin-markdown-medusa: "*"
typedoc-plugin-merge-modules: 5.1.0
typedoc-plugin-missing-exports: ^2.1.0
typedoc-plugin-modules: "*"
typedoc-plugin-reference-excluder: 1.1.3
typedoc-plugin-rename-defaults: ^0.6.6
typescript: ^5.2.2
@@ -2875,6 +2983,8 @@ __metadata:
"typedoc-config@*, typedoc-config@workspace:packages/typedoc-config":
version: 0.0.0-use.local
resolution: "typedoc-config@workspace:packages/typedoc-config"
peerDependencies:
typedoc: 0.25.x
languageName: unknown
linkType: soft
@@ -2887,18 +2997,31 @@ __metadata:
languageName: node
linkType: hard
"typedoc-plugin-frontmatter@*, typedoc-plugin-frontmatter@workspace:packages/typedoc-plugin-frontmatter":
"typedoc-plugin-custom@*, typedoc-plugin-custom@workspace:packages/typedoc-plugin-custom":
version: 0.0.0-use.local
resolution: "typedoc-plugin-frontmatter@workspace:packages/typedoc-plugin-frontmatter"
resolution: "typedoc-plugin-custom@workspace:packages/typedoc-plugin-custom"
dependencies:
"@types/node": ^16.11.10
eslint: ^8.53.0
glob: ^10.3.10
typedoc-plugin-markdown: ^3.16.0
typescript: ^4.6
yaml: ^2.3.2
utils: "*"
yaml: ^2.3.3
peerDependencies:
typedoc: 0.25.x
languageName: unknown
linkType: soft
"typedoc-plugin-frontmatter@npm:*":
version: 0.0.2
resolution: "typedoc-plugin-frontmatter@npm:0.0.2"
dependencies:
yaml: ^2.2.2
checksum: bd14645bf613dc58828c69004e53ce141a448e137a3deb5f8994a105d484c9b118731ed5ae3907541dda6cc034b30ab6e665b5d7b16cb9eb222df1c871d2fb21
languageName: node
linkType: hard
"typedoc-plugin-markdown-medusa@*, typedoc-plugin-markdown-medusa@workspace:packages/typedoc-plugin-markdown-medusa":
version: 0.0.0-use.local
resolution: "typedoc-plugin-markdown-medusa@workspace:packages/typedoc-plugin-markdown-medusa"
@@ -2907,6 +3030,7 @@ __metadata:
copyfiles: ^2.4.1
handlebars: ^4.7.8
typescript: ^4.6
utils: "*"
peerDependencies:
typedoc: 0.25.x
languageName: unknown
@@ -2941,19 +3065,6 @@ __metadata:
languageName: node
linkType: hard
"typedoc-plugin-modules@*, typedoc-plugin-modules@workspace:packages/typedoc-plugin-modules":
version: 0.0.0-use.local
resolution: "typedoc-plugin-modules@workspace:packages/typedoc-plugin-modules"
dependencies:
"@types/node": ^16.11.10
glob: ^10.3.10
typedoc-plugin-markdown: ^3.16.0
typescript: ^4.6
peerDependencies:
typedoc: 0.25.x
languageName: unknown
linkType: soft
"typedoc-plugin-reference-excluder@npm:1.1.3":
version: 1.1.3
resolution: "typedoc-plugin-reference-excluder@npm:1.1.3"
@@ -3097,6 +3208,18 @@ __metadata:
languageName: node
linkType: hard
"utils@*, utils@workspace:packages/utils":
version: 0.0.0-use.local
resolution: "utils@workspace:packages/utils"
dependencies:
"@types/node": ^16.11.10
rimraf: ^5.0.5
typescript: ^4.6
peerDependencies:
typedoc: 0.25.x
languageName: unknown
linkType: soft
"uuid@npm:^8.3.2":
version: 8.3.2
resolution: "uuid@npm:8.3.2"
@@ -3219,10 +3342,10 @@ __metadata:
languageName: node
linkType: hard
"yaml@npm:^2.3.2":
version: 2.3.2
resolution: "yaml@npm:2.3.2"
checksum: c2aac464015f037911c5b819475e81e52119e5495e3d43fe7cb82b5a84d59d66a86049dc85d8e90658636c1c04dde177ae196818deaf76c1bda4d34209d5c087
"yaml@npm:^2.2.2, yaml@npm:^2.3.3":
version: 2.3.3
resolution: "yaml@npm:2.3.3"
checksum: a0c56bf682159b0567e9cbbddf23efc2f6806f6450716d9be6ec5eb1af1b941e95c8d3dc9c47da20d1b6883a9d6c61e31cf98bb4b77ebca4396bf772657f2f00
languageName: node
linkType: hard
@@ -19,6 +19,9 @@ export interface AddressPayload {
* Phone Number
*/
phone?: string
/**
* Company
*/
company?: string
/**
* Address line 1
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { User } from "./User"
/**
* The user's details.
*/
export interface AdminAuthRes {
/**
* User details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { BatchJob } from "./BatchJob"
/**
* The batch job's details.
*/
export interface AdminBatchJobRes {
/**
* Batch job details.
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The access token of the user, if they're authenticated successfully.
*/
export interface AdminBearerAuthRes {
/**
* Access token that can be used to send authenticated requests.
@@ -5,6 +5,12 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { ProductCollection } from "./ProductCollection"
/**
* The collection's details.
*/
export interface AdminCollectionsRes {
/**
* Product Collection details.
*/
collection: SetRelation<ProductCollection, "products">
}
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Currency } from "./Currency"
/**
* List of currencies with pagination fields.
*/
export interface AdminCurrenciesListRes {
/**
* An array of currency details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Currency } from "./Currency"
/**
* A currency's details.
*/
export interface AdminCurrenciesRes {
/**
* Currency details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { CustomerGroup } from "./CustomerGroup"
/**
* The customer group's details.
*/
export interface AdminCustomerGroupsRes {
/**
* Customer group details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Customer } from "./Customer"
/**
* The list of customers with pagination fields.
*/
export interface AdminCustomersListRes {
/**
* An array of customer details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Customer } from "./Customer"
/**
* The customer's details.
*/
export interface AdminCustomersRes {
/**
* Customer details.
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The resources to remove.
*/
export interface AdminDeleteDiscountsDiscountConditionsConditionBatchReq {
/**
* The resources to be removed from the discount condition
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* Deletion operation details
*/
export interface AdminDeleteProductsFromCollectionRes {
/**
* The ID of the collection
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* Product types to remove from the tax rates.
*/
export interface AdminDeleteTaxRatesTaxRateProductTypesReq {
/**
* The IDs of the product types to remove their association with this tax rate.
@@ -6,7 +6,13 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Discount } from "./Discount"
import type { DiscountRule } from "./DiscountRule"
/**
* The list of discounts with pagination fields.
*/
export interface AdminDiscountsListRes {
/**
* The list of discounts.
*/
discounts: Array<
Merge<
SetRelation<Discount, "parent_discount" | "regions" | "rule">,
@@ -7,6 +7,9 @@ import type { Discount } from "./Discount"
import type { DiscountRule } from "./DiscountRule"
import type { Region } from "./Region"
/**
* The discount's details.
*/
export interface AdminDiscountsRes {
/**
* Discount details.
@@ -7,6 +7,9 @@ import type { Cart } from "./Cart"
import type { DraftOrder } from "./DraftOrder"
import type { LineItem } from "./LineItem"
/**
* The list of draft orders with pagination fields.
*/
export interface AdminDraftOrdersListRes {
/**
* An array of draft order's details.
@@ -12,6 +12,9 @@ import type { ProductVariant } from "./ProductVariant"
import type { Region } from "./Region"
import type { ShippingMethod } from "./ShippingMethod"
/**
* The list of draft orders.
*/
export interface AdminDraftOrdersRes {
/**
* Draft order's details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { ExtendedStoreDTO } from "./ExtendedStoreDTO"
/**
* The store's details with additional details like payment and tax providers.
*/
export interface AdminExtendedStoresRes {
/**
* Store details.
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The list of fulfillment options in a region.
*/
export interface AdminGetRegionsRegionFulfillmentOptionsRes {
/**
* Fulfillment providers details.
@@ -5,9 +5,12 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { VariantInventory } from "./VariantInventory"
/**
* The variant's inventory details.
*/
export interface AdminGetVariantsVariantInventoryRes {
/**
* The product variant's.
* The product variant's inventory details.
*/
variant?: VariantInventory
}
@@ -6,7 +6,13 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { GiftCard } from "./GiftCard"
import type { Region } from "./Region"
/**
* The list of gift cards with pagination fields.
*/
export interface AdminGiftCardsListRes {
/**
* The list of gift cards.
*/
gift_cards: Array<
Merge<
SetRelation<GiftCard, "order" | "region">,
@@ -6,6 +6,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { GiftCard } from "./GiftCard"
import type { Region } from "./Region"
/**
* The gift card's details.
*/
export interface AdminGiftCardsRes {
/**
* A gift card's details.
@@ -5,12 +5,18 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { InventoryLevelDTO } from "./InventoryLevelDTO"
/**
* Details of inventory items and their associated location levels.
*/
export interface AdminInventoryItemsLocationLevelsRes {
/**
* An inventory item's ID and associated location levels.
*/
inventory_item: {
/**
* The id of the location
*/
id: any
id: string
/**
* List of stock levels at a given location
*/
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { InventoryItemDTO } from "./InventoryItemDTO"
/**
* The inventory item's details.
*/
export interface AdminInventoryItemsRes {
/**
* Inventory Item details
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Invite } from "./Invite"
/**
* The list of invites.
*/
export interface AdminListInvitesRes {
/**
* An array of invites
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Note } from "./Note"
/**
* The list of notes with pagination fields.
*/
export interface AdminNotesListRes {
/**
* An array of notes
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Note } from "./Note"
/**
* The note's details.
*/
export interface AdminNotesRes {
/**
* Note details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Notification } from "./Notification"
/**
* The notification's details.
*/
export interface AdminNotificationsRes {
/**
* Notification details
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The details of deleting order edit item changes.
*/
export interface AdminOrderEditItemChangeDeleteRes {
/**
* The ID of the deleted Order Edit Item Change.
@@ -7,6 +7,9 @@ import type { LineItem } from "./LineItem"
import type { OrderEdit } from "./OrderEdit"
import type { OrderItemChange } from "./OrderItemChange"
/**
* The list of order edits with pagination fields.
*/
export interface AdminOrderEditsListRes {
/**
* An array of order edit details
@@ -7,6 +7,9 @@ import type { LineItem } from "./LineItem"
import type { OrderEdit } from "./OrderEdit"
import type { OrderItemChange } from "./OrderItemChange"
/**
* The order edit details.
*/
export interface AdminOrderEditsRes {
/**
* Order edit details
@@ -18,6 +18,9 @@ import type { ReturnItem } from "./ReturnItem"
import type { ShippingMethod } from "./ShippingMethod"
import type { Swap } from "./Swap"
/**
* The list of orders with pagination fields.
*/
export interface AdminOrdersListRes {
/**
* An array of order details.
@@ -18,6 +18,9 @@ import type { ReturnItem } from "./ReturnItem"
import type { ShippingMethod } from "./ShippingMethod"
import type { Swap } from "./Swap"
/**
* The order's details.
*/
export interface AdminOrdersRes {
/**
* Order details.
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The details of deleting a payment collection.
*/
export interface AdminPaymentCollectionDeleteRes {
/**
* The ID of the deleted Payment Collection.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { PaymentProvider } from "./PaymentProvider"
/**
* The list of payment providers in a store.
*/
export interface AdminPaymentProvidersList {
/**
* An array of payment providers details.
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Payment } from "./Payment"
/**
* The payment's details.
*/
export interface AdminPaymentRes {
/**
* Payment details
@@ -9,7 +9,7 @@ export interface AdminPostDiscountsDiscountConditionsConditionBatchReq {
*/
resources: Array<{
/**
* The id of the item
* The ID of the item
*/
id: string
}>
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { Order } from "./Order"
/**
* The order's details.
*/
export interface AdminPostDraftOrdersDraftOrderRegisterPaymentRes {
/**
* Order's details.
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The attributes to update in an inventory item.
*/
export interface AdminPostInventoryItemsInventoryItemReq {
/**
* The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.
@@ -36,6 +39,18 @@ export interface AdminPostInventoryItemsInventoryItemReq {
* The length of the Inventory Item. May be used in shipping rate calculations.
*/
length?: number
/**
* The inventory item's title.
*/
title?: string
/**
* The inventory item's description.
*/
description?: string
/**
* The inventory item's thumbnail.
*/
thumbnail?: string
/**
* Whether the item requires shipping.
*/
@@ -68,6 +68,18 @@ export interface AdminPostInventoryItemsReq {
* The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.
*/
material?: string
/**
* The inventory item's title.
*/
title?: string
/**
* The inventory item's description.
*/
description?: string
/**
* The inventory item's thumbnail.
*/
thumbnail?: string
/**
* An optional set of key-value pairs with additional information.
*/
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The details of the invite to be accepted.
*/
export interface AdminPostInvitesInviteAcceptReq {
/**
* The token of the invite to accept. This is a unique token generated when the invite was created or resent.
@@ -12,4 +12,8 @@ export interface AdminPostOrdersOrderClaimsClaimFulfillmentsReq {
* If set to `true`, no notification will be sent to the customer related to this Claim.
*/
no_notification?: boolean
/**
* The ID of the fulfillment's location.
*/
location_id?: string
}
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
import type { AddressPayload } from "./AddressPayload"
/**
* The details of the claim to be created.
*/
export interface AdminPostOrdersOrderClaimsReq {
/**
* The type of the Claim. This will determine how the Claim is treated: `replace` Claims will result in a Fulfillment with new items being created, while a `refund` Claim will refund the amount paid for the claimed items.
@@ -98,6 +101,10 @@ export interface AdminPostOrdersOrderClaimsReq {
* If set to true no notification will be send related to this Claim.
*/
no_notification?: boolean
/**
* The ID of the location used for the associated return.
*/
return_location_id?: string
/**
* An optional set of key-value pairs to hold additional information.
*/
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The details of the fulfillment to be created.
*/
export interface AdminPostOrdersOrderFulfillmentsReq {
/**
* The Line Items to include in the Fulfillment.
@@ -17,6 +20,10 @@ export interface AdminPostOrdersOrderFulfillmentsReq {
*/
quantity: number
}>
/**
* The ID of the location where the items will be fulfilled from.
*/
location_id?: string
/**
* If set to `true`, no notification will be sent to the customer related to this fulfillment.
*/
@@ -9,7 +9,7 @@ import type { LineItem } from "./LineItem"
export interface AdminPostOrdersOrderReq {
/**
* the email associated with the order
* The email associated with the order
*/
email?: string
/**
@@ -54,4 +54,8 @@ export interface AdminPostOrdersOrderReturnsReq {
* The amount to refund.
*/
refund?: number
/**
* The ID of the location used for the return.
*/
location_id?: string
}
@@ -3,6 +3,9 @@
/* eslint-disable */
import { SetRelation, Merge } from "../core/ModelUtils"
/**
* The shipping method's details.
*/
export interface AdminPostOrdersOrderShippingMethodsReq {
/**
* The price (excluding VAT) that should be charged for the Shipping Method
@@ -15,5 +18,5 @@ export interface AdminPostOrdersOrderShippingMethodsReq {
/**
* The data required for the Shipping Option to create a Shipping Method. This depends on the Fulfillment Provider.
*/
date?: Record<string, any>
data?: Record<string, any>
}
@@ -51,6 +51,10 @@ export interface AdminPostOrdersOrderSwapsReq {
*/
quantity: number
}>
/**
* The ID of the sales channel associated with the swap.
*/
sales_channel_id?: string
/**
* An array of custom shipping options to potentially create a Shipping Method from to send the additional items.
*/
@@ -68,6 +72,10 @@ export interface AdminPostOrdersOrderSwapsReq {
* If set to `true`, no notification will be sent to the customer related to this Swap.
*/
no_notification?: boolean
/**
* The ID of the location used for the associated return.
*/
return_location_id?: string
/**
* If set to `true`, swaps can be completed with items out of stock
*/
@@ -12,4 +12,8 @@ export interface AdminPostOrdersOrderSwapsSwapFulfillmentsReq {
* If set to `true`, no notification will be sent to the customer related to this swap.
*/
no_notification?: boolean
/**
* The ID of the fulfillment's location.
*/
location_id?: string
}
@@ -214,6 +214,10 @@ export interface AdminPostProductsProductReq {
* The width of the Product.
*/
width?: number
/**
* The Harmonized System code of the product variant.
*/
hs_code?: string
/**
* The country of origin of the Product.
*/
@@ -20,6 +20,10 @@ export interface AdminPostReservationsReq {
* The quantity to reserve.
*/
quantity: number
/**
* The reservation's description.
*/
description?: string
/**
* An optional set of key-value pairs with additional information.
*/
@@ -12,6 +12,10 @@ export interface AdminPostReservationsReservationReq {
* The quantity to reserve.
*/
quantity?: number
/**
* The reservation's description.
*/
description?: string
/**
* An optional set of key-value pairs with additional information.
*/
@@ -21,4 +21,8 @@ export interface AdminPostReturnsReturnReceiveReq {
* The amount to refund.
*/
refund?: number
/**
* The ID of the location to return items from.
*/
location_id?: string
}

Some files were not shown because too many files have changed in this diff Show More