docs: generate medusa-react reference (#6004)
* add new plugin for better organization * added handling in theme for mutations and query types * added tsdoc to hooks * added tsdocs to utility functions * added tsdoc to providers * generated reference * general fixes for generated reference * generated api reference specs + general fixes * add missing import react * split utilities into different directories * added overview page * added link to customer authentication section * fix lint errors * added changeset * fix readme * fixed build error * added expand fields + other sections to overview * updated what's new section * general refactoring * remove unnecessary query field * fix links * added ignoreApi option
This commit is contained in:
1 parent
6fc6a9de6a
commit
7d650771d1
2811 files changed
+231485
-454692
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"medusa-react": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa-react): general type fixes related to generating reference documentation
|
||||||
@@ -128,10 +128,10 @@ export default class TypedocManager {
|
|||||||
const signature = mappedSignature.signatures[0]
|
const signature = mappedSignature.signatures[0]
|
||||||
// get the props of the component from the
|
// get the props of the component from the
|
||||||
// first parameter in the signature.
|
// first parameter in the signature.
|
||||||
const props = getTypeChildren(
|
const props = getTypeChildren({
|
||||||
signature.parameters![0].type!,
|
reflectionType: signature.parameters![0].type!,
|
||||||
this.project
|
project: this.project,
|
||||||
)
|
})
|
||||||
|
|
||||||
// this stores props that should be removed from the
|
// this stores props that should be removed from the
|
||||||
// spec
|
// spec
|
||||||
@@ -482,7 +482,10 @@ export default class TypedocManager {
|
|||||||
childName
|
childName
|
||||||
) as DeclarationReflection
|
) as DeclarationReflection
|
||||||
} else if (reflection.type) {
|
} else if (reflection.type) {
|
||||||
getTypeChildren(reflection.type, this.project).some((child) => {
|
getTypeChildren({
|
||||||
|
reflectionType: reflection.type,
|
||||||
|
project: this.project,
|
||||||
|
}).some((child) => {
|
||||||
if (child.name === childName) {
|
if (child.name === childName) {
|
||||||
childReflection = child
|
childReflection = child
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export function generateReference(referenceName: string) {
|
|||||||
formatColoredLog(colorLog, referenceName, chunk.trim())
|
formatColoredLog(colorLog, referenceName, chunk.trim())
|
||||||
})
|
})
|
||||||
typedocProcess.on("exit", (code) => {
|
typedocProcess.on("exit", (code) => {
|
||||||
|
formatColoredLog(colorLog, referenceName, "Finished Generating reference.")
|
||||||
generatedCount++
|
generatedCount++
|
||||||
if (generatedCount >= totalCount && !ranMerger && code !== 1) {
|
if (generatedCount >= totalCount && !ranMerger && code !== 1) {
|
||||||
runMerger()
|
runMerger()
|
||||||
@@ -81,7 +82,6 @@ export function generateReference(referenceName: string) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
formatColoredLog(colorLog, referenceName, "Finished Generating reference.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatColoredLog(
|
function formatColoredLog(
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ module.exports = {
|
|||||||
"stock-location",
|
"stock-location",
|
||||||
"workflows",
|
"workflows",
|
||||||
],
|
],
|
||||||
|
allReflectionsHaveOwnDocumentInNamespace: ["Utilities"],
|
||||||
formatting: {
|
formatting: {
|
||||||
"*": {
|
"*": {
|
||||||
showCommentsAsHeader: true,
|
showCommentsAsHeader: true,
|
||||||
@@ -131,7 +132,7 @@ module.exports = {
|
|||||||
displayed_sidebar: "inventoryReference",
|
displayed_sidebar: "inventoryReference",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"^IInventoryService/methods": {
|
"^inventory/IInventoryService/methods": {
|
||||||
reflectionDescription:
|
reflectionDescription:
|
||||||
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Inventory Module.",
|
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Inventory Module.",
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
@@ -189,29 +190,118 @@ module.exports = {
|
|||||||
"^js_client/.*LineItemsResource": {
|
"^js_client/.*LineItemsResource": {
|
||||||
maxLevel: 3,
|
maxLevel: 3,
|
||||||
},
|
},
|
||||||
"^(js_client/.*modules/.*internal|internal.*/modules)": {
|
|
||||||
reflectionGroups: {
|
// MEDUSA REACT CONFIG
|
||||||
Constructors: false,
|
"^medusa_react": {
|
||||||
"Type Aliases": false,
|
|
||||||
Enumerations: false,
|
|
||||||
"Enumeration Members": false,
|
|
||||||
Classes: false,
|
|
||||||
Functions: false,
|
|
||||||
Interfaces: false,
|
|
||||||
References: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"^internal.*/.*js_client.*": {
|
|
||||||
reflectionGroups: {
|
|
||||||
Constructors: false,
|
|
||||||
},
|
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
displayed_sidebar: "jsClientSidebar",
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
},
|
},
|
||||||
|
parameterComponentExtraProps: {
|
||||||
|
expandUrl:
|
||||||
|
"https://docs.medusajs.com/medusa-react/overview#expanding-fields",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^modules/medusa_react\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
},
|
||||||
|
reflectionGroups: {
|
||||||
|
Variables: false,
|
||||||
|
Functions: false,
|
||||||
|
},
|
||||||
|
reflectionCategories: {
|
||||||
|
Mutations: false,
|
||||||
|
Queries: false,
|
||||||
|
Other: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/(medusa_react\\.Hooks\\.mdx|.*medusa_react\\.Hooks\\.Admin\\.mdx|.*medusa_react\\.Hooks\\.Store\\.mdx|medusa_react\\.Providers\\.mdx)":
|
||||||
|
{
|
||||||
|
reflectionGroups: {
|
||||||
|
Functions: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Providers/.*": {
|
||||||
|
expandMembers: true,
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/providers/{{alias-lower}}",
|
||||||
|
sidebar_label: "{{alias}}",
|
||||||
|
},
|
||||||
|
reflectionTitle: {
|
||||||
|
suffix: " Provider Overview",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/medusa_react\\.Utilities": {
|
||||||
|
expandMembers: true,
|
||||||
|
reflectionTitle: {
|
||||||
|
prefix: "Medusa React ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Utilities/.*": {
|
||||||
|
expandMembers: true,
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/utilities/{{alias}}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/medusa_react\\.Hooks\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/hooks",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/Admin/.*Admin\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/hooks/admin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/Admin/.*": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/hooks/admin/{{alias-lower}}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/Store/.*Store\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/hooks/store",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/Store/.*": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/hooks/store/{{alias-lower}}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/medusa_react\\.Providers\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/providers",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/medusa_react\\.Utilities\\.mdx": {
|
||||||
|
frontmatterData: {
|
||||||
|
displayed_sidebar: "medusaReactSidebar",
|
||||||
|
slug: "/references/medusa-react/utilities",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/.*Admin\\.Inventory_Items": {
|
||||||
|
maxLevel: 4,
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/.*Admin\\.Products": {
|
||||||
|
maxLevel: 4,
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/.*Admin\\.Stock_Locations": {
|
||||||
|
maxLevel: 5,
|
||||||
|
},
|
||||||
|
"^medusa_react/Hooks/.*Admin\\.Users": {
|
||||||
|
maxLevel: 5,
|
||||||
},
|
},
|
||||||
|
|
||||||
// MEDUSA CONFIG
|
// MEDUSA CONFIG
|
||||||
"^medusa": {
|
"^medusa/": {
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
displayed_sidebar: "homepage",
|
displayed_sidebar: "homepage",
|
||||||
},
|
},
|
||||||
@@ -249,13 +339,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// PRICING CONFIG
|
// PRICING CONFIG
|
||||||
"^(pricing|IPricingModuleService)": {
|
"^pricing": {
|
||||||
...modulesOptions,
|
...modulesOptions,
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
displayed_sidebar: "pricingReference",
|
displayed_sidebar: "pricingReference",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"^IPricingModuleService/methods": {
|
"^pricing/IPricingModuleService/methods": {
|
||||||
reflectionDescription:
|
reflectionDescription:
|
||||||
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Pricing Module.",
|
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Pricing Module.",
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
@@ -298,7 +388,7 @@ module.exports = {
|
|||||||
displayed_sidebar: "productReference",
|
displayed_sidebar: "productReference",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"^IProductModuleService/methods": {
|
"^product/IProductModuleService/methods": {
|
||||||
reflectionDescription:
|
reflectionDescription:
|
||||||
"This documentation provides a reference to the {{alias}} {{kind}}. This belongs to the Product Module.",
|
"This documentation provides a reference to the {{alias}} {{kind}}. This belongs to the Product Module.",
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
@@ -349,7 +439,7 @@ module.exports = {
|
|||||||
displayed_sidebar: "stockLocationReference",
|
displayed_sidebar: "stockLocationReference",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"^IStockLocationService/methods": {
|
"^stock-location/IStockLocationService/methods": {
|
||||||
reflectionDescription:
|
reflectionDescription:
|
||||||
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Stock Location Module.",
|
"This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Stock Location Module.",
|
||||||
frontmatterData: {
|
frontmatterData: {
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/tsconfig",
|
||||||
|
"extends": [
|
||||||
|
"../../../../packages/medusa-react/tsconfig.json"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"noImplicitReturns": false,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,18 @@
|
|||||||
{
|
{
|
||||||
"tagName": "@excludeExternal",
|
"tagName": "@excludeExternal",
|
||||||
"syntaxKind": "modifier"
|
"syntaxKind": "modifier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tagName": "@customNamespace",
|
||||||
|
"syntaxKind": "block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tagName": "@namespaceMember",
|
||||||
|
"syntaxKind": "modifier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tagName": "@typeParamDefinition",
|
||||||
|
"syntaxKind": "block"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
const getConfig = require("./utils/get-config")
|
||||||
|
|
||||||
|
module.exports = getConfig({
|
||||||
|
entryPointPath: "packages/medusa-react/src/index.ts",
|
||||||
|
tsConfigName: "medusa-react.json",
|
||||||
|
name: "medusa-react",
|
||||||
|
generateNamespaces: true,
|
||||||
|
ignoreApi: true,
|
||||||
|
})
|
||||||
@@ -35,6 +35,15 @@ The following options are useful for linting:
|
|||||||
- `eslintPathName`: The path to the ESLint configuration file.
|
- `eslintPathName`: The path to the ESLint configuration file.
|
||||||
- `pluginsResolvePath`: The path to resolve plugins used in the ESLint configuration files.
|
- `pluginsResolvePath`: The path to resolve plugins used in the ESLint configuration files.
|
||||||
|
|
||||||
|
### Generate Namespace Plugin
|
||||||
|
|
||||||
|
If the `generateNamespaces` option is enabled, Namespaces are created from reflections having the `@customNamespace` tag. It also attaches categories (using the `@category` tag) of the same reflection to its generated parent namespace.
|
||||||
|
|
||||||
|
It also accepts the following options:
|
||||||
|
|
||||||
|
- `parentNamespace`: The name of a parent namespace to make the generated namespaces as its children.
|
||||||
|
- `namePrefix`: A prefix to add to the name of the generated namespaces.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build the Plugin
|
## Build the Plugin
|
||||||
|
|||||||
@@ -0,0 +1,258 @@
|
|||||||
|
import {
|
||||||
|
Application,
|
||||||
|
Comment,
|
||||||
|
CommentDisplayPart,
|
||||||
|
CommentTag,
|
||||||
|
Context,
|
||||||
|
Converter,
|
||||||
|
DeclarationReflection,
|
||||||
|
ParameterType,
|
||||||
|
ReflectionCategory,
|
||||||
|
ReflectionKind,
|
||||||
|
} from "typedoc"
|
||||||
|
|
||||||
|
type PluginOptions = {
|
||||||
|
generateNamespaces: boolean
|
||||||
|
parentNamespace: string
|
||||||
|
namePrefix: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GenerateNamespacePlugin {
|
||||||
|
private options?: PluginOptions
|
||||||
|
private app: Application
|
||||||
|
private parentNamespace?: DeclarationReflection
|
||||||
|
private currentNamespaceHeirarchy: DeclarationReflection[]
|
||||||
|
private currentContext?: Context
|
||||||
|
private scannedComments = false
|
||||||
|
|
||||||
|
constructor(app: Application) {
|
||||||
|
this.app = app
|
||||||
|
this.currentNamespaceHeirarchy = []
|
||||||
|
this.declareOptions()
|
||||||
|
|
||||||
|
this.app.converter.on(
|
||||||
|
Converter.EVENT_CREATE_DECLARATION,
|
||||||
|
this.handleCreateDeclarationEvent.bind(this)
|
||||||
|
)
|
||||||
|
this.app.converter.on(
|
||||||
|
Converter.EVENT_CREATE_DECLARATION,
|
||||||
|
this.scanComments.bind(this)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
declareOptions() {
|
||||||
|
this.app.options.addDeclaration({
|
||||||
|
name: "generateNamespaces",
|
||||||
|
type: ParameterType.Boolean,
|
||||||
|
defaultValue: false,
|
||||||
|
help: "Whether to enable conversion of categories to namespaces.",
|
||||||
|
})
|
||||||
|
this.app.options.addDeclaration({
|
||||||
|
name: "parentNamespace",
|
||||||
|
type: ParameterType.String,
|
||||||
|
defaultValue: "",
|
||||||
|
help: "Optionally specify a parent namespace to place all generated namespaces in.",
|
||||||
|
})
|
||||||
|
this.app.options.addDeclaration({
|
||||||
|
name: "namePrefix",
|
||||||
|
type: ParameterType.String,
|
||||||
|
defaultValue: "",
|
||||||
|
help: "Optionally specify a name prefix for all namespaces.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
readOptions() {
|
||||||
|
if (this.options) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options = {
|
||||||
|
generateNamespaces: this.app.options.getValue("generateNamespaces"),
|
||||||
|
parentNamespace: this.app.options.getValue("parentNamespace"),
|
||||||
|
namePrefix: this.app.options.getValue("namePrefix"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadNamespace(namespaceName: string): DeclarationReflection {
|
||||||
|
const formattedName = this.formatName(namespaceName)
|
||||||
|
return this.currentContext?.project
|
||||||
|
.getReflectionsByKind(ReflectionKind.Namespace)
|
||||||
|
.find(
|
||||||
|
(m) =>
|
||||||
|
m.name === formattedName &&
|
||||||
|
(!this.currentNamespaceHeirarchy.length ||
|
||||||
|
m.parent?.id ===
|
||||||
|
this.currentNamespaceHeirarchy[
|
||||||
|
this.currentNamespaceHeirarchy.length - 1
|
||||||
|
].id)
|
||||||
|
) as DeclarationReflection
|
||||||
|
}
|
||||||
|
|
||||||
|
createNamespace(namespaceName: string): DeclarationReflection | undefined {
|
||||||
|
if (!this.currentContext) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const formattedName = this.formatName(namespaceName)
|
||||||
|
const namespace = this.currentContext?.createDeclarationReflection(
|
||||||
|
ReflectionKind.Namespace,
|
||||||
|
void 0,
|
||||||
|
void 0,
|
||||||
|
formattedName
|
||||||
|
)
|
||||||
|
|
||||||
|
namespace.children = []
|
||||||
|
|
||||||
|
return namespace
|
||||||
|
}
|
||||||
|
|
||||||
|
formatName(namespaceName: string): string {
|
||||||
|
return `${this.options?.namePrefix}${namespaceName}`
|
||||||
|
}
|
||||||
|
|
||||||
|
generateNamespaceFromTag({
|
||||||
|
tag,
|
||||||
|
summary,
|
||||||
|
}: {
|
||||||
|
tag: CommentTag
|
||||||
|
reflection?: DeclarationReflection
|
||||||
|
summary?: CommentDisplayPart[]
|
||||||
|
}) {
|
||||||
|
const categoryHeirarchy = tag.content[0].text.split(".")
|
||||||
|
categoryHeirarchy.forEach((cat, index) => {
|
||||||
|
// check whether a namespace exists with the category name.
|
||||||
|
let namespace = this.loadNamespace(cat)
|
||||||
|
|
||||||
|
if (!namespace) {
|
||||||
|
// add a namespace for this category
|
||||||
|
namespace = this.createNamespace(cat) || namespace
|
||||||
|
|
||||||
|
namespace.comment = new Comment()
|
||||||
|
if (this.currentNamespaceHeirarchy.length) {
|
||||||
|
namespace.comment.modifierTags.add("@namespaceMember")
|
||||||
|
}
|
||||||
|
if (summary && index === categoryHeirarchy.length - 1) {
|
||||||
|
namespace.comment.summary = summary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.currentContext =
|
||||||
|
this.currentContext?.withScope(namespace) || this.currentContext
|
||||||
|
|
||||||
|
this.currentNamespaceHeirarchy.push(namespace)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create categories in the last namespace if the
|
||||||
|
* reflection has a category
|
||||||
|
*/
|
||||||
|
attachCategories(reflection: DeclarationReflection) {
|
||||||
|
if (!this.currentNamespaceHeirarchy.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const parentNamespace =
|
||||||
|
this.currentNamespaceHeirarchy[this.currentNamespaceHeirarchy.length - 1]
|
||||||
|
reflection.comment?.blockTags
|
||||||
|
.filter((tag) => tag.tag === "@category")
|
||||||
|
.forEach((tag) => {
|
||||||
|
const categoryName = tag.content[0].text
|
||||||
|
if (!parentNamespace.categories) {
|
||||||
|
parentNamespace.categories = []
|
||||||
|
}
|
||||||
|
let category = parentNamespace.categories.find(
|
||||||
|
(category) => category.title === categoryName
|
||||||
|
)
|
||||||
|
if (!category) {
|
||||||
|
category = new ReflectionCategory(categoryName)
|
||||||
|
parentNamespace.categories.push(category)
|
||||||
|
}
|
||||||
|
category.children.push(reflection)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCreateDeclarationEvent(
|
||||||
|
context: Context,
|
||||||
|
reflection: DeclarationReflection
|
||||||
|
) {
|
||||||
|
this.readOptions()
|
||||||
|
if (this.options?.parentNamespace && !this.parentNamespace) {
|
||||||
|
this.parentNamespace =
|
||||||
|
this.loadNamespace(this.options.parentNamespace) ||
|
||||||
|
this.createNamespace(this.options.parentNamespace)
|
||||||
|
}
|
||||||
|
this.currentNamespaceHeirarchy = []
|
||||||
|
if (this.parentNamespace) {
|
||||||
|
this.currentNamespaceHeirarchy.push(this.parentNamespace)
|
||||||
|
}
|
||||||
|
this.currentContext = context
|
||||||
|
reflection.comment?.blockTags
|
||||||
|
.filter((tag) => tag.tag === "@customNamespace")
|
||||||
|
.forEach((tag) => {
|
||||||
|
this.generateNamespaceFromTag({
|
||||||
|
tag,
|
||||||
|
})
|
||||||
|
if (
|
||||||
|
reflection.parent instanceof DeclarationReflection ||
|
||||||
|
reflection.parent?.isProject()
|
||||||
|
) {
|
||||||
|
reflection.parent.children = reflection.parent.children?.filter(
|
||||||
|
(child) => child.id !== reflection.id
|
||||||
|
)
|
||||||
|
}
|
||||||
|
this.currentContext?.addChild(reflection)
|
||||||
|
})
|
||||||
|
|
||||||
|
reflection.comment?.removeTags("@customNamespace")
|
||||||
|
this.attachCategories(reflection)
|
||||||
|
this.currentContext = undefined
|
||||||
|
this.currentNamespaceHeirarchy = []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan all source files for `@customNamespace` tag to generate namespaces
|
||||||
|
* This is mainly helpful to pull summaries of the namespaces.
|
||||||
|
*/
|
||||||
|
scanComments(context: Context) {
|
||||||
|
if (this.scannedComments) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.currentContext = context
|
||||||
|
const fileNames = context.program.getRootFileNames()
|
||||||
|
|
||||||
|
fileNames.forEach((fileName) => {
|
||||||
|
const sourceFile = context.program.getSourceFile(fileName)
|
||||||
|
if (!sourceFile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const comments = context.getFileComment(sourceFile)
|
||||||
|
comments?.blockTags
|
||||||
|
.filter((tag) => tag.tag === "@customNamespace")
|
||||||
|
.forEach((tag) => {
|
||||||
|
this.generateNamespaceFromTag({ tag, summary: comments.summary })
|
||||||
|
if (this.currentNamespaceHeirarchy.length) {
|
||||||
|
// add comments of the file to the last created namespace
|
||||||
|
this.currentNamespaceHeirarchy[
|
||||||
|
this.currentNamespaceHeirarchy.length - 1
|
||||||
|
].comment = comments
|
||||||
|
|
||||||
|
this.currentNamespaceHeirarchy[
|
||||||
|
this.currentNamespaceHeirarchy.length - 1
|
||||||
|
].comment!.blockTags = this.currentNamespaceHeirarchy[
|
||||||
|
this.currentNamespaceHeirarchy.length - 1
|
||||||
|
].comment!.blockTags.filter((tag) => tag.tag !== "@customNamespace")
|
||||||
|
}
|
||||||
|
// reset values
|
||||||
|
this.currentNamespaceHeirarchy = []
|
||||||
|
this.currentContext = context
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
this.scannedComments = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// for debugging
|
||||||
|
printCurrentHeirarchy() {
|
||||||
|
return this.currentNamespaceHeirarchy.map((heirarchy) => heirarchy.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { load as parseOasSchemaPlugin } from "./parse-oas-schema-plugin"
|
|||||||
import { load as apiIgnorePlugin } from "./api-ignore"
|
import { load as apiIgnorePlugin } from "./api-ignore"
|
||||||
import { load as eslintExamplePlugin } from "./eslint-example"
|
import { load as eslintExamplePlugin } from "./eslint-example"
|
||||||
import { load as signatureModifierPlugin } from "./signature-modifier"
|
import { load as signatureModifierPlugin } from "./signature-modifier"
|
||||||
|
import { GenerateNamespacePlugin } from "./generate-namespace"
|
||||||
|
|
||||||
export function load(app: Application) {
|
export function load(app: Application) {
|
||||||
resolveReferencesPluginLoad(app)
|
resolveReferencesPluginLoad(app)
|
||||||
@@ -13,4 +14,6 @@ export function load(app: Application) {
|
|||||||
apiIgnorePlugin(app)
|
apiIgnorePlugin(app)
|
||||||
eslintExamplePlugin(app)
|
eslintExamplePlugin(app)
|
||||||
signatureModifierPlugin(app)
|
signatureModifierPlugin(app)
|
||||||
|
|
||||||
|
new GenerateNamespacePlugin(app)
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,10 @@ function addComments(schema: Schema, reflection: Reflection) {
|
|||||||
}
|
}
|
||||||
const children =
|
const children =
|
||||||
"type" in reflection
|
"type" in reflection
|
||||||
? getTypeChildren(reflection.type as SomeType, reflection.project)
|
? getTypeChildren({
|
||||||
|
reflectionType: reflection.type as SomeType,
|
||||||
|
project: reflection.project,
|
||||||
|
})
|
||||||
: "children" in reflection
|
: "children" in reflection
|
||||||
? (reflection.children as DeclarationReflection[])
|
? (reflection.children as DeclarationReflection[])
|
||||||
: []
|
: []
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ A plugin that forks and customizes the [typedoc-plugin-markdown](https://github.
|
|||||||
|
|
||||||
Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#options), the following options are accepted:
|
Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#options), the following options are accepted:
|
||||||
|
|
||||||
|
- `allReflectionsHaveOwnDocumentInNamespace`: An array of namespace names whose child members should have their own documents.
|
||||||
- `mdxImports`: A boolean value indicating whether the outputted files should be MDX files with the `.mdx` extension.
|
- `mdxImports`: A boolean value indicating whether the outputted files should be MDX files with the `.mdx` extension.
|
||||||
- `formatting`: An object whose keys are string patterns used to target specific files. You can also use the string `*` to target all files. The values are objects having the following properties:
|
- `formatting`: An object whose keys are string patterns used to target specific files. You can also use the string `*` to target all files. The values are objects having the following properties:
|
||||||
- `sections`: (optional) an object whose keys are of type [`SectionKey`](./src/types.ts#L19) and values are boolean. This property is used to enable/disable certain sections in the outputted generated docs.
|
- `sections`: (optional) an object whose keys are of type [`SectionKey`](./src/types.ts#L19) and values are boolean. This property is used to enable/disable certain sections in the outputted generated docs.
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ export function load(app: Application) {
|
|||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.options.addDeclaration({
|
||||||
|
help: "[Markdown Plugin] Specify namespace names where all reflections are outputted into seperate files.",
|
||||||
|
name: "allReflectionsHaveOwnDocumentInNamespace",
|
||||||
|
type: ParameterType.Array,
|
||||||
|
defaultValue: [],
|
||||||
|
})
|
||||||
|
|
||||||
app.options.addDeclaration({
|
app.options.addDeclaration({
|
||||||
help: "[Markdown Plugin] Separator used to format filenames.",
|
help: "[Markdown Plugin] Separator used to format filenames.",
|
||||||
name: "filenameSeparator",
|
name: "filenameSeparator",
|
||||||
|
|||||||
@@ -49,10 +49,17 @@ import decrementCurrentTitleLevelHelper from "./resources/helpers/decrement-curr
|
|||||||
import incrementCurrentTitleLevelHelper from "./resources/helpers/increment-current-title-level"
|
import incrementCurrentTitleLevelHelper from "./resources/helpers/increment-current-title-level"
|
||||||
import hasMoreThanOneSignatureHelper from "./resources/helpers/has-more-than-one-signature"
|
import hasMoreThanOneSignatureHelper from "./resources/helpers/has-more-than-one-signature"
|
||||||
import ifCanShowConstructorsTitleHelper from "./resources/helpers/if-can-show-constructors-title"
|
import ifCanShowConstructorsTitleHelper from "./resources/helpers/if-can-show-constructors-title"
|
||||||
|
import ifReactQueryTypeHelper from "./resources/helpers/if-react-query-type"
|
||||||
|
import ifHasHookParamsHelper from "./resources/helpers/if-has-hook-params"
|
||||||
|
import reactQueryHookParamsHelper from "./resources/helpers/react-query-hook-params"
|
||||||
|
import ifHasMutationParamsHelper from "./resources/helpers/if-has-mutation-params"
|
||||||
|
import reactQueryMutationParamsHelper from "./resources/helpers/react-query-mutation-params"
|
||||||
|
import ifHasMutationReturnHelper from "./resources/helpers/if-has-mutation-return"
|
||||||
|
import reactQueryMutationReturnHelper from "./resources/helpers/react-query-mutation-return"
|
||||||
|
import ifHasQueryReturnHelper from "./resources/helpers/if-has-query-return"
|
||||||
|
import reactQueryQueryReturnHelper from "./resources/helpers/react-query-query-return"
|
||||||
import { MarkdownTheme } from "./theme"
|
import { MarkdownTheme } from "./theme"
|
||||||
|
|
||||||
// test
|
|
||||||
|
|
||||||
const TEMPLATE_PATH = path.join(__dirname, "resources", "templates")
|
const TEMPLATE_PATH = path.join(__dirname, "resources", "templates")
|
||||||
|
|
||||||
export const indexTemplate = Handlebars.compile(
|
export const indexTemplate = Handlebars.compile(
|
||||||
@@ -128,4 +135,13 @@ export function registerHelpers(theme: MarkdownTheme) {
|
|||||||
incrementCurrentTitleLevelHelper(theme)
|
incrementCurrentTitleLevelHelper(theme)
|
||||||
hasMoreThanOneSignatureHelper(theme)
|
hasMoreThanOneSignatureHelper(theme)
|
||||||
ifCanShowConstructorsTitleHelper()
|
ifCanShowConstructorsTitleHelper()
|
||||||
|
ifReactQueryTypeHelper()
|
||||||
|
ifHasHookParamsHelper()
|
||||||
|
reactQueryHookParamsHelper()
|
||||||
|
ifHasMutationParamsHelper(theme)
|
||||||
|
reactQueryMutationParamsHelper(theme)
|
||||||
|
ifHasMutationReturnHelper(theme)
|
||||||
|
reactQueryMutationReturnHelper(theme)
|
||||||
|
ifHasQueryReturnHelper(theme)
|
||||||
|
reactQueryQueryReturnHelper(theme)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
import * as Handlebars from "handlebars"
|
import * as Handlebars from "handlebars"
|
||||||
import { Comment } from "typedoc"
|
import { Comment } from "typedoc"
|
||||||
|
|
||||||
const EXCLUDED_TAGS = ["@returns", "@example", "@featureFlag"]
|
const EXCLUDED_TAGS = [
|
||||||
|
"@returns",
|
||||||
|
"@example",
|
||||||
|
"@featureFlag",
|
||||||
|
"@category",
|
||||||
|
"@typeParamDefinition",
|
||||||
|
]
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getHookParams } from "../../utils/react-query-utils"
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"ifHasHookParams",
|
||||||
|
function (this: SignatureReflection, options: Handlebars.HelperOptions) {
|
||||||
|
return getHookParams(this).length
|
||||||
|
? options.fn(this)
|
||||||
|
: options.inverse(this)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getMutationParams } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"ifHasMutationParams",
|
||||||
|
function (this: SignatureReflection, options: Handlebars.HelperOptions) {
|
||||||
|
return getMutationParams({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
// we only need to check if there are mutation parameters,
|
||||||
|
// so no need to get all the children
|
||||||
|
maxLevel: 1,
|
||||||
|
},
|
||||||
|
}).length
|
||||||
|
? options.fn(this)
|
||||||
|
: options.inverse(this)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getMutationReturn } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"ifHasMutationReturn",
|
||||||
|
function (this: SignatureReflection, options: Handlebars.HelperOptions) {
|
||||||
|
return getMutationReturn({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
// we only need to check if there are mutation returns,
|
||||||
|
// so no need to get all the children
|
||||||
|
maxLevel: 1,
|
||||||
|
},
|
||||||
|
}).length
|
||||||
|
? options.fn(this)
|
||||||
|
: options.inverse(this)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getQueryReturn } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"ifHasQueryReturn",
|
||||||
|
function (this: SignatureReflection, options: Handlebars.HelperOptions) {
|
||||||
|
return getQueryReturn({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
// we only need to check if there are query returns,
|
||||||
|
// so no need to get all the children
|
||||||
|
maxLevel: 1,
|
||||||
|
},
|
||||||
|
}).length
|
||||||
|
? options.fn(this)
|
||||||
|
: options.inverse(this)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import {
|
||||||
|
isReactQueryMutation,
|
||||||
|
isReactQueryQuery,
|
||||||
|
} from "../../utils/react-query-utils"
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"ifReactQueryType",
|
||||||
|
function (this: SignatureReflection, options: Handlebars.HelperOptions) {
|
||||||
|
return isReactQueryMutation(this) || isReactQueryQuery(this)
|
||||||
|
? options.fn(this)
|
||||||
|
: options.inverse(this)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+6
-13
@@ -3,6 +3,7 @@ import { ReflectionParameterType } from "../../types"
|
|||||||
import { parseParams } from "../../utils/params-utils"
|
import { parseParams } from "../../utils/params-utils"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
import { reflectionComponentFormatter } from "../../utils/reflection-formatter"
|
import { reflectionComponentFormatter } from "../../utils/reflection-formatter"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
@@ -21,19 +22,11 @@ export default function (theme: MarkdownTheme) {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
let extraProps: string[] = []
|
return formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
if (parameterComponentExtraProps) {
|
componentItems: parameters,
|
||||||
extraProps = Object.entries(parameterComponentExtraProps).map(
|
extraProps: parameterComponentExtraProps,
|
||||||
([key, value]) => `${key}=${JSON.stringify(value)}`
|
})
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return `<${parameterComponent} parameters={${JSON.stringify(
|
|
||||||
parameters,
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)}} ${extraProps.join(" ")}/>`
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getHookParams } from "../../utils/react-query-utils"
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"reactQueryHookParams",
|
||||||
|
function (this: SignatureReflection) {
|
||||||
|
let parametersStr = ""
|
||||||
|
const hookParameters = getHookParams(this)
|
||||||
|
|
||||||
|
if (hookParameters?.length) {
|
||||||
|
parametersStr = Handlebars.helpers.parameter.call(hookParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
return parametersStr
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getMutationParams } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"reactQueryMutationParams",
|
||||||
|
function (this: SignatureReflection) {
|
||||||
|
const {
|
||||||
|
parameterStyle,
|
||||||
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
} = theme.getFormattingOptionsForLocation()
|
||||||
|
const mutationParameters = getMutationParams({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
maxLevel,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (parameterStyle !== "component") {
|
||||||
|
// TODO maybe handle other cases? But for now it's not important
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
|
componentItems: mutationParameters,
|
||||||
|
extraProps: parameterComponentExtraProps,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getMutationReturn } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"reactQueryMutationReturn",
|
||||||
|
function (this: SignatureReflection) {
|
||||||
|
const {
|
||||||
|
parameterStyle,
|
||||||
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
} = theme.getFormattingOptionsForLocation()
|
||||||
|
const mutationParameters = getMutationReturn({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
maxLevel,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (parameterStyle !== "component") {
|
||||||
|
// TODO maybe handle other cases? But for now it's not important
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
|
componentItems: mutationParameters,
|
||||||
|
extraProps: parameterComponentExtraProps,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
import * as Handlebars from "handlebars"
|
||||||
|
import { SignatureReflection } from "typedoc"
|
||||||
|
import { getQueryReturn } from "../../utils/react-query-utils"
|
||||||
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
|
export default function (theme: MarkdownTheme) {
|
||||||
|
Handlebars.registerHelper(
|
||||||
|
"reactQueryQueryReturn",
|
||||||
|
function (this: SignatureReflection) {
|
||||||
|
const {
|
||||||
|
parameterStyle,
|
||||||
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
} = theme.getFormattingOptionsForLocation()
|
||||||
|
const mutationParameters = getQueryReturn({
|
||||||
|
signatureReflection: this,
|
||||||
|
project: theme.project || this.project,
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
maxLevel,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (parameterStyle !== "component") {
|
||||||
|
// TODO maybe handle other cases? But for now it's not important
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
|
componentItems: mutationParameters,
|
||||||
|
extraProps: parameterComponentExtraProps,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
+9
-2
@@ -3,6 +3,7 @@ import { PageEvent, ParameterReflection, ReflectionKind } from "typedoc"
|
|||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
import { getDisplayName } from "../../utils"
|
import { getDisplayName } from "../../utils"
|
||||||
import { escapeChars } from "utils"
|
import { escapeChars } from "utils"
|
||||||
|
import { replaceTemplateVariables } from "../../utils/reflection-template-strings"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
@@ -12,10 +13,16 @@ export default function (theme: MarkdownTheme) {
|
|||||||
const { reflectionTitle } = theme.getFormattingOptionsForLocation()
|
const { reflectionTitle } = theme.getFormattingOptionsForLocation()
|
||||||
|
|
||||||
if (reflectionTitle?.fullReplacement?.length) {
|
if (reflectionTitle?.fullReplacement?.length) {
|
||||||
return reflectionTitle.fullReplacement
|
return theme.reflection
|
||||||
|
? replaceTemplateVariables(
|
||||||
|
theme.reflection,
|
||||||
|
reflectionTitle.fullReplacement
|
||||||
|
)
|
||||||
|
: reflectionTitle.fullReplacement
|
||||||
}
|
}
|
||||||
|
|
||||||
const title: string[] = [""]
|
const title: string[] = [reflectionTitle?.prefix || ""]
|
||||||
|
|
||||||
if (
|
if (
|
||||||
reflectionTitle?.kind &&
|
reflectionTitle?.kind &&
|
||||||
this.model?.kind &&
|
this.model?.kind &&
|
||||||
|
|||||||
+27
-15
@@ -2,8 +2,9 @@ import * as Handlebars from "handlebars"
|
|||||||
import { Comment, DeclarationReflection, SignatureReflection } from "typedoc"
|
import { Comment, DeclarationReflection, SignatureReflection } from "typedoc"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
import reflectionFormatter from "../../utils/reflection-formatter"
|
import reflectionFormatter from "../../utils/reflection-formatter"
|
||||||
import { returnReflectionComponentFormatter } from "../../utils/return-reflection-formatter"
|
import { getReflectionTypeParameters } from "../../utils/reflection-type-parameters"
|
||||||
import { Parameter } from "../../types"
|
import { Parameter } from "../../types"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
@@ -24,14 +25,18 @@ function getReturnFromType(
|
|||||||
theme: MarkdownTheme,
|
theme: MarkdownTheme,
|
||||||
reflection: SignatureReflection
|
reflection: SignatureReflection
|
||||||
) {
|
) {
|
||||||
const { parameterStyle, parameterComponent, maxLevel } =
|
const {
|
||||||
theme.getFormattingOptionsForLocation()
|
parameterStyle,
|
||||||
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
} = theme.getFormattingOptionsForLocation()
|
||||||
|
|
||||||
if (!reflection.type) {
|
if (!reflection.type) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
const componentItems = returnReflectionComponentFormatter({
|
const componentItems = getReflectionTypeParameters({
|
||||||
reflectionType: reflection.type,
|
reflectionType: reflection.type,
|
||||||
project: reflection.project || theme.project,
|
project: reflection.project || theme.project,
|
||||||
comment: reflection.comment,
|
comment: reflection.comment,
|
||||||
@@ -40,11 +45,11 @@ function getReturnFromType(
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (parameterStyle === "component") {
|
if (parameterStyle === "component") {
|
||||||
return `<${parameterComponent} parameters={${JSON.stringify(
|
return formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
componentItems,
|
componentItems,
|
||||||
null,
|
extraProps: parameterComponentExtraProps,
|
||||||
2
|
})
|
||||||
)}} />`
|
|
||||||
} else {
|
} else {
|
||||||
return formatReturnAsList(componentItems)
|
return formatReturnAsList(componentItems)
|
||||||
}
|
}
|
||||||
@@ -74,8 +79,12 @@ function formatReturnAsList(componentItems: Parameter[], level = 1): string {
|
|||||||
|
|
||||||
function getReturnFromComment(theme: MarkdownTheme, comment: Comment) {
|
function getReturnFromComment(theme: MarkdownTheme, comment: Comment) {
|
||||||
const md: string[] = []
|
const md: string[] = []
|
||||||
const { parameterStyle, parameterComponent, maxLevel } =
|
const {
|
||||||
theme.getFormattingOptionsForLocation()
|
parameterStyle,
|
||||||
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
} = theme.getFormattingOptionsForLocation()
|
||||||
|
|
||||||
if (comment.blockTags?.length) {
|
if (comment.blockTags?.length) {
|
||||||
const tags = comment.blockTags
|
const tags = comment.blockTags
|
||||||
@@ -97,11 +106,14 @@ function getReturnFromComment(theme: MarkdownTheme, comment: Comment) {
|
|||||||
)
|
)
|
||||||
result +=
|
result +=
|
||||||
parameterStyle === "component"
|
parameterStyle === "component"
|
||||||
? `\n\n<${parameterComponent} parameters={${JSON.stringify(
|
? `\n\n${formatParameterComponent({
|
||||||
content,
|
parameterComponent,
|
||||||
null,
|
componentItems: content as Parameter[],
|
||||||
2
|
extraProps: {
|
||||||
)}} title={"${commentPart.target.name}"} />\n\n`
|
...parameterComponentExtraProps,
|
||||||
|
title: commentPart.target.name,
|
||||||
|
},
|
||||||
|
})}\n\n`
|
||||||
: `\n\n<details>\n<summary>\n${
|
: `\n\n<details>\n<summary>\n${
|
||||||
commentPart.target.name
|
commentPart.target.name
|
||||||
}\n</summary>\n\n${content?.join("\n")}\n\n</details>`
|
}\n</summary>\n\n${content?.join("\n")}\n\n</details>`
|
||||||
|
|||||||
+22
-14
@@ -2,15 +2,16 @@ import * as Handlebars from "handlebars"
|
|||||||
import { DeclarationReflection, ReflectionType } from "typedoc"
|
import { DeclarationReflection, ReflectionType } from "typedoc"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
import { parseParams } from "../../utils/params-utils"
|
import { parseParams } from "../../utils/params-utils"
|
||||||
import { ReflectionParameterType } from "../../types"
|
import { Parameter, ReflectionParameterType } from "../../types"
|
||||||
import reflectionFormatter from "../../utils/reflection-formatter"
|
import reflectionFormatter from "../../utils/reflection-formatter"
|
||||||
import { escapeChars, stripLineBreaks } from "utils"
|
import { escapeChars, stripLineBreaks } from "utils"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
"typeDeclarationMembers",
|
"typeDeclarationMembers",
|
||||||
function (this: DeclarationReflection[]) {
|
function (this: DeclarationReflection[]) {
|
||||||
const { parameterComponent, maxLevel } =
|
const { parameterComponent, maxLevel, parameterComponentExtraProps } =
|
||||||
theme.getFormattingOptionsForLocation()
|
theme.getFormattingOptionsForLocation()
|
||||||
const comments = this.map(
|
const comments = this.map(
|
||||||
(param) => !!param.comment?.hasVisibleComponent()
|
(param) => !!param.comment?.hasVisibleComponent()
|
||||||
@@ -30,11 +31,12 @@ export default function (theme: MarkdownTheme) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "component": {
|
case "component": {
|
||||||
result = getComponentMarkdownContent(
|
result = getComponentMarkdownContent({
|
||||||
properties,
|
properties,
|
||||||
parameterComponent,
|
parameterComponent,
|
||||||
maxLevel
|
maxLevel,
|
||||||
)
|
parameterComponentExtraProps,
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "table": {
|
case "table": {
|
||||||
@@ -58,11 +60,17 @@ function getListMarkdownContent(properties: DeclarationReflection[]) {
|
|||||||
return items.join("\n")
|
return items.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
function getComponentMarkdownContent(
|
function getComponentMarkdownContent({
|
||||||
properties: DeclarationReflection[],
|
properties,
|
||||||
parameterComponent?: string,
|
parameterComponent,
|
||||||
|
maxLevel,
|
||||||
|
parameterComponentExtraProps,
|
||||||
|
}: {
|
||||||
|
properties: DeclarationReflection[]
|
||||||
|
parameterComponent?: string
|
||||||
maxLevel?: number | undefined
|
maxLevel?: number | undefined
|
||||||
) {
|
parameterComponentExtraProps?: Record<string, unknown>
|
||||||
|
}) {
|
||||||
const parameters = properties.map((property) =>
|
const parameters = properties.map((property) =>
|
||||||
reflectionFormatter({
|
reflectionFormatter({
|
||||||
reflection: property,
|
reflection: property,
|
||||||
@@ -72,11 +80,11 @@ function getComponentMarkdownContent(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
return `<${parameterComponent} parameters={${JSON.stringify(
|
return formatParameterComponent({
|
||||||
parameters,
|
parameterComponent,
|
||||||
null,
|
componentItems: parameters as Parameter[],
|
||||||
2
|
extraProps: parameterComponentExtraProps,
|
||||||
)}} />`
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableMarkdownContent(
|
function getTableMarkdownContent(
|
||||||
|
|||||||
+7
-6
@@ -2,12 +2,13 @@ import * as Handlebars from "handlebars"
|
|||||||
import { TypeParameterReflection } from "typedoc"
|
import { TypeParameterReflection } from "typedoc"
|
||||||
import { reflectionComponentFormatter } from "../../utils/reflection-formatter"
|
import { reflectionComponentFormatter } from "../../utils/reflection-formatter"
|
||||||
import { MarkdownTheme } from "../../theme"
|
import { MarkdownTheme } from "../../theme"
|
||||||
|
import { formatParameterComponent } from "../../utils/format-parameter-component"
|
||||||
|
|
||||||
export default function (theme: MarkdownTheme) {
|
export default function (theme: MarkdownTheme) {
|
||||||
Handlebars.registerHelper(
|
Handlebars.registerHelper(
|
||||||
"typeParameterComponent",
|
"typeParameterComponent",
|
||||||
function (this: TypeParameterReflection[]) {
|
function (this: TypeParameterReflection[]) {
|
||||||
const { parameterComponent, maxLevel } =
|
const { parameterComponent, maxLevel, parameterComponentExtraProps } =
|
||||||
theme.getFormattingOptionsForLocation()
|
theme.getFormattingOptionsForLocation()
|
||||||
const parameters = this.map((parameter) =>
|
const parameters = this.map((parameter) =>
|
||||||
reflectionComponentFormatter({
|
reflectionComponentFormatter({
|
||||||
@@ -17,11 +18,11 @@ export default function (theme: MarkdownTheme) {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
return `<${parameterComponent} parameters={${JSON.stringify(
|
return formatParameterComponent({
|
||||||
parameters,
|
parameterComponent,
|
||||||
null,
|
componentItems: parameters,
|
||||||
2
|
extraProps: parameterComponentExtraProps,
|
||||||
)}} />`
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
{{incrementCurrentTitleLevel}}
|
{{incrementCurrentTitleLevel}}
|
||||||
|
|
||||||
{{> member.signature showSources=false parent=../type.declaration }}
|
{{> member.signature-wrapper showSources=false parent=../type.declaration }}
|
||||||
|
|
||||||
{{decrementCurrentTitleLevel}}
|
{{decrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{{#with getSignature}}
|
{{#with getSignature}}
|
||||||
|
|
||||||
{{> member.signature accessor="get" showSources=true }}
|
{{> member.signature-wrapper accessor="get" showSources=true }}
|
||||||
|
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
{{#with setSignature}}
|
{{#with setSignature}}
|
||||||
|
|
||||||
{{> member.signature accessor="set" showSources=true }}
|
{{> member.signature-wrapper accessor="set" showSources=true }}
|
||||||
|
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
{{#each signatures}}
|
{{#each signatures}}
|
||||||
|
|
||||||
{{> member.signature showSources=true parent=.. }}
|
{{> member.signature-wrapper showSources=true parent=.. }}
|
||||||
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
@@ -58,9 +58,11 @@
|
|||||||
|
|
||||||
{{#unless @last}}
|
{{#unless @last}}
|
||||||
{{#unless hasOwnDocument}}
|
{{#unless hasOwnDocument}}
|
||||||
|
{{#unless removeSeparator}}
|
||||||
___
|
___
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
{{#unless hasOwnDocument}}
|
{{#unless hasOwnDocument}}
|
||||||
|
|
||||||
|
|||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
{{{signatureTitle accessor parent}}}
|
||||||
|
|
||||||
|
{{#if (getFormattingOption "expandMembers")}}
|
||||||
|
|
||||||
|
{{#if (hasMoreThanOneSignature parent)}}
|
||||||
|
|
||||||
|
{{incrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_comment")}}
|
||||||
|
|
||||||
|
{{#with comment}}
|
||||||
|
|
||||||
|
{{#if hasVisibleComponent}}
|
||||||
|
|
||||||
|
{{{comments this true false}}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/with}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_example")}}
|
||||||
|
|
||||||
|
{{{example this}}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_typeParameters")}}
|
||||||
|
|
||||||
|
{{#if typeParameters}}
|
||||||
|
|
||||||
|
{{{titleLevel}}} Type Parameters
|
||||||
|
|
||||||
|
{{#with typeParameters}}
|
||||||
|
|
||||||
|
{{{typeParameter}}}
|
||||||
|
|
||||||
|
{{/with}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_parameters")}}
|
||||||
|
|
||||||
|
{{#ifHasHookParams}}
|
||||||
|
|
||||||
|
{{{titleLevel}}} Hook Parameters
|
||||||
|
|
||||||
|
{{{reactQueryHookParams}}}
|
||||||
|
|
||||||
|
{{/ifHasHookParams}}
|
||||||
|
|
||||||
|
{{#ifHasMutationParams}}
|
||||||
|
|
||||||
|
{{{titleLevel}}} Mutation Function Parameters
|
||||||
|
|
||||||
|
{{{reactQueryMutationParams}}}
|
||||||
|
|
||||||
|
{{/ifHasMutationParams}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#ifShowReturns}}
|
||||||
|
|
||||||
|
{{#ifHasMutationReturn}}
|
||||||
|
|
||||||
|
{{{titleLevel}}} Mutation Function Returned Data
|
||||||
|
|
||||||
|
{{{reactQueryMutationReturn}}}
|
||||||
|
|
||||||
|
{{/ifHasMutationReturn}}
|
||||||
|
|
||||||
|
{{#ifHasQueryReturn}}
|
||||||
|
|
||||||
|
{{{titleLevel}}} Query Returned Data
|
||||||
|
|
||||||
|
{{{reactQueryQueryReturn}}}
|
||||||
|
|
||||||
|
{{/ifHasQueryReturn}}
|
||||||
|
|
||||||
|
{{/ifShowReturns}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_comment")}}
|
||||||
|
|
||||||
|
{{#with comment}}
|
||||||
|
|
||||||
|
{{#if hasVisibleComponent}}
|
||||||
|
|
||||||
|
{{{comments this false true ..}}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/with}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (sectionEnabled "member_signature_sources")}}
|
||||||
|
|
||||||
|
{{#if showSources}}
|
||||||
|
|
||||||
|
{{incrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
{{> member.sources}}
|
||||||
|
|
||||||
|
{{decrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (getFormattingOption "expandMembers")}}
|
||||||
|
|
||||||
|
{{#if (hasMoreThanOneSignature parent)}}
|
||||||
|
|
||||||
|
{{decrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
{{#ifReactQueryType}}
|
||||||
|
|
||||||
|
{{> member.react-query.signature}}
|
||||||
|
|
||||||
|
{{else}}
|
||||||
|
|
||||||
|
{{> member.signature}}
|
||||||
|
|
||||||
|
{{/ifReactQueryType}}
|
||||||
+1
-1
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
{{#each declaration.signatures}}
|
{{#each declaration.signatures}}
|
||||||
|
|
||||||
{{> member.signature showSources=false parent=../declaration }}
|
{{> member.signature-wrapper showSources=false parent=../declaration }}
|
||||||
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
{{#each categories}}
|
{{#each categories}}
|
||||||
|
|
||||||
|
{{#unless @first}}
|
||||||
|
___
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
{{#unless allChildrenHaveOwnDocument}}
|
{{#unless allChildrenHaveOwnDocument}}
|
||||||
|
|
||||||
{{#unless (getFormattingOption "expandMembers")}}
|
{{#unless (getFormattingOption "expandMembers")}}
|
||||||
@@ -18,7 +22,7 @@
|
|||||||
|
|
||||||
{{#unless hasOwnDocument}}
|
{{#unless hasOwnDocument}}
|
||||||
|
|
||||||
{{> member}}
|
{{> member removeSeparator=true}}
|
||||||
|
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
{{incrementCurrentTitleLevel}}
|
{{incrementCurrentTitleLevel}}
|
||||||
|
|
||||||
{{> member.signature showSources=true }}
|
{{> member.signature-wrapper showSources=true }}
|
||||||
|
|
||||||
{{decrementCurrentTitleLevel}}
|
{{decrementCurrentTitleLevel}}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { Mapping } from "./types"
|
|||||||
|
|
||||||
export class MarkdownTheme extends Theme {
|
export class MarkdownTheme extends Theme {
|
||||||
allReflectionsHaveOwnDocument!: string[]
|
allReflectionsHaveOwnDocument!: string[]
|
||||||
|
allReflectionsHaveOwnDocumentInNamespace: string[]
|
||||||
entryDocument: string
|
entryDocument: string
|
||||||
entryPoints!: string[]
|
entryPoints!: string[]
|
||||||
filenameSeparator!: string
|
filenameSeparator!: string
|
||||||
@@ -66,6 +67,9 @@ export class MarkdownTheme extends Theme {
|
|||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
this.allReflectionsHaveOwnDocument = this.getOption("allReflectionsHaveOwnDocument") as string[]
|
this.allReflectionsHaveOwnDocument = this.getOption("allReflectionsHaveOwnDocument") as string[]
|
||||||
|
this.allReflectionsHaveOwnDocumentInNamespace = this.getOption(
|
||||||
|
"allReflectionsHaveOwnDocumentInNamespace"
|
||||||
|
) as string[]
|
||||||
this.entryDocument = this.getOption("entryDocument") as string
|
this.entryDocument = this.getOption("entryDocument") as string
|
||||||
this.entryPoints = this.getOption("entryPoints") as string[]
|
this.entryPoints = this.getOption("entryPoints") as string[]
|
||||||
this.filenameSeparator = this.getOption("filenameSeparator") as string
|
this.filenameSeparator = this.getOption("filenameSeparator") as string
|
||||||
@@ -143,14 +147,36 @@ export class MarkdownTheme extends Theme {
|
|||||||
return urls
|
return urls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAliasPath(reflection: Reflection): string {
|
||||||
|
return path.join(
|
||||||
|
reflection.parent && !reflection.parent.isProject()
|
||||||
|
? this.getAliasPath(reflection.parent)
|
||||||
|
: "",
|
||||||
|
reflection.getAlias()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
buildUrls(
|
buildUrls(
|
||||||
reflection: DeclarationReflection,
|
reflection: DeclarationReflection,
|
||||||
urls: UrlMapping[]
|
urls: UrlMapping[]
|
||||||
): UrlMapping[] {
|
): UrlMapping[] {
|
||||||
const mapping = this.getMappings(
|
const mapping = this.getMappings(
|
||||||
reflection,
|
reflection,
|
||||||
reflection.parent?.isProject() ? "" : reflection.parent?.getAlias()
|
reflection.parent?.isProject() || !reflection.parent
|
||||||
).find((mapping) => reflection.kindOf(mapping.kind))
|
? ""
|
||||||
|
: this.getAliasPath(reflection.parent)
|
||||||
|
).find(
|
||||||
|
(mapping) =>
|
||||||
|
reflection.kindOf(mapping.kind) &&
|
||||||
|
mapping.modifiers.has.every(
|
||||||
|
(modifier) => reflection.comment?.hasModifier(modifier) || false
|
||||||
|
) &&
|
||||||
|
mapping.modifiers.not.every((modifier) => {
|
||||||
|
return reflection.comment
|
||||||
|
? !reflection.comment.hasModifier(modifier)
|
||||||
|
: true
|
||||||
|
})
|
||||||
|
)
|
||||||
if (mapping) {
|
if (mapping) {
|
||||||
if (!reflection.url || !MarkdownTheme.URL_PREFIX.test(reflection.url)) {
|
if (!reflection.url || !MarkdownTheme.URL_PREFIX.test(reflection.url)) {
|
||||||
const url = this.toUrl(mapping, reflection)
|
const url = this.toUrl(mapping, reflection)
|
||||||
@@ -176,12 +202,23 @@ export class MarkdownTheme extends Theme {
|
|||||||
return (
|
return (
|
||||||
mapping.directory +
|
mapping.directory +
|
||||||
"/" +
|
"/" +
|
||||||
this.getUrl(reflection) +
|
this.getUrl({
|
||||||
|
reflection,
|
||||||
|
directory: mapping.directory,
|
||||||
|
}) +
|
||||||
(this.mdxOutput ? ".mdx" : ".md")
|
(this.mdxOutput ? ".mdx" : ".md")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getUrl(reflection: Reflection, relative?: Reflection): string {
|
getUrl({
|
||||||
|
reflection,
|
||||||
|
directory,
|
||||||
|
relative,
|
||||||
|
}: {
|
||||||
|
reflection: Reflection
|
||||||
|
directory: string
|
||||||
|
relative?: Reflection
|
||||||
|
}): string {
|
||||||
let url = reflection.getAlias()
|
let url = reflection.getAlias()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -189,8 +226,15 @@ export class MarkdownTheme extends Theme {
|
|||||||
reflection.parent !== relative &&
|
reflection.parent !== relative &&
|
||||||
!(reflection.parent instanceof ProjectReflection)
|
!(reflection.parent instanceof ProjectReflection)
|
||||||
) {
|
) {
|
||||||
url =
|
const urlPrefix = this.getUrl({
|
||||||
this.getUrl(reflection.parent, relative) + this.filenameSeparator + url
|
reflection: reflection.parent,
|
||||||
|
directory,
|
||||||
|
relative,
|
||||||
|
})
|
||||||
|
const fileNameSeparator = this.getFileNameSeparator(
|
||||||
|
`${directory}/${urlPrefix}`
|
||||||
|
)
|
||||||
|
url = urlPrefix + fileNameSeparator + url
|
||||||
}
|
}
|
||||||
|
|
||||||
return url.replace(/^_/, "")
|
return url.replace(/^_/, "")
|
||||||
@@ -280,11 +324,14 @@ export class MarkdownTheme extends Theme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getModuleParents(reflection: DeclarationReflection): DeclarationReflection[] {
|
getParentsOfKind(
|
||||||
|
reflection: DeclarationReflection,
|
||||||
|
kind: ReflectionKind
|
||||||
|
): DeclarationReflection[] {
|
||||||
const parents: DeclarationReflection[] = []
|
const parents: DeclarationReflection[] = []
|
||||||
let currentParent = reflection?.parent as DeclarationReflection | undefined
|
let currentParent = reflection?.parent as DeclarationReflection | undefined
|
||||||
do {
|
do {
|
||||||
if (currentParent?.kind === ReflectionKind.Module) {
|
if (currentParent?.kind === kind) {
|
||||||
parents.push(currentParent)
|
parents.push(currentParent)
|
||||||
}
|
}
|
||||||
currentParent = currentParent?.parent as DeclarationReflection | undefined
|
currentParent = currentParent?.parent as DeclarationReflection | undefined
|
||||||
@@ -294,11 +341,28 @@ export class MarkdownTheme extends Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAllReflectionsHaveOwnDocument(reflection: DeclarationReflection): boolean {
|
getAllReflectionsHaveOwnDocument(reflection: DeclarationReflection): boolean {
|
||||||
const moduleParents = this.getModuleParents(reflection)
|
const moduleParents = this.getParentsOfKind(
|
||||||
|
reflection,
|
||||||
return moduleParents.some((parent) =>
|
ReflectionKind.Module
|
||||||
this.allReflectionsHaveOwnDocument.includes(parent.name)
|
|
||||||
)
|
)
|
||||||
|
const namespaceParents = this.getParentsOfKind(
|
||||||
|
reflection,
|
||||||
|
ReflectionKind.Namespace
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
moduleParents.some((parent) =>
|
||||||
|
this.allReflectionsHaveOwnDocument.includes(parent.name)
|
||||||
|
) ||
|
||||||
|
namespaceParents.some((parent) =>
|
||||||
|
this.allReflectionsHaveOwnDocumentInNamespace.includes(parent.name)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
getFileNameSeparator(pathPrefix: string): string {
|
||||||
|
const formattingOptions = this.getFormattingOptions(pathPrefix)
|
||||||
|
return formattingOptions.fileNameSeparator || this.filenameSeparator
|
||||||
}
|
}
|
||||||
|
|
||||||
getMappings(
|
getMappings(
|
||||||
@@ -308,36 +372,60 @@ export class MarkdownTheme extends Theme {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Module],
|
kind: [ReflectionKind.Module],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: false,
|
isLeaf: false,
|
||||||
directory: path.join(directoryPrefix || "", "modules"),
|
directory: path.join(directoryPrefix || "", "modules"),
|
||||||
template: this.getReflectionTemplate(),
|
template: this.getReflectionTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Namespace],
|
kind: [ReflectionKind.Namespace],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: false,
|
isLeaf: false,
|
||||||
directory: path.join(directoryPrefix || "", "modules"),
|
directory: path.join(directoryPrefix || ""),
|
||||||
template: this.getReflectionTemplate(),
|
template: this.getReflectionTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Enum],
|
kind: [ReflectionKind.Enum],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: false,
|
isLeaf: false,
|
||||||
directory: path.join(directoryPrefix || "", "enums"),
|
directory: path.join(directoryPrefix || "", "enums"),
|
||||||
template: this.getReflectionTemplate(),
|
template: this.getReflectionTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Class],
|
kind: [ReflectionKind.Class],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: false,
|
isLeaf: false,
|
||||||
directory: path.join(directoryPrefix || "", "classes"),
|
directory: path.join(directoryPrefix || "", "classes"),
|
||||||
template: this.getReflectionTemplate(),
|
template: this.getReflectionTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Interface],
|
kind: [ReflectionKind.Interface],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: false,
|
isLeaf: false,
|
||||||
directory: path.join(directoryPrefix || "", "interfaces"),
|
directory: path.join(directoryPrefix || "", "interfaces"),
|
||||||
template: this.getReflectionTemplate(),
|
template: this.getReflectionTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.TypeAlias],
|
kind: [ReflectionKind.TypeAlias],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: true,
|
isLeaf: true,
|
||||||
directory: path.join(directoryPrefix || "", "types"),
|
directory: path.join(directoryPrefix || "", "types"),
|
||||||
template: this.getReflectionMemberTemplate(),
|
template: this.getReflectionMemberTemplate(),
|
||||||
@@ -346,18 +434,30 @@ export class MarkdownTheme extends Theme {
|
|||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Variable],
|
kind: [ReflectionKind.Variable],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: true,
|
isLeaf: true,
|
||||||
directory: path.join(directoryPrefix || "", "variables"),
|
directory: path.join(directoryPrefix || "", "variables"),
|
||||||
template: this.getReflectionMemberTemplate(),
|
template: this.getReflectionMemberTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Function],
|
kind: [ReflectionKind.Function],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: true,
|
isLeaf: true,
|
||||||
directory: path.join(directoryPrefix || "", "functions"),
|
directory: path.join(directoryPrefix || "", "functions"),
|
||||||
template: this.getReflectionMemberTemplate(),
|
template: this.getReflectionMemberTemplate(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: [ReflectionKind.Method],
|
kind: [ReflectionKind.Method],
|
||||||
|
modifiers: {
|
||||||
|
has: [],
|
||||||
|
not: [],
|
||||||
|
},
|
||||||
isLeaf: true,
|
isLeaf: true,
|
||||||
directory: path.join(directoryPrefix || "", "methods"),
|
directory: path.join(directoryPrefix || "", "methods"),
|
||||||
template: this.getReflectionMemberTemplate(),
|
template: this.getReflectionMemberTemplate(),
|
||||||
@@ -393,6 +493,25 @@ export class MarkdownTheme extends Theme {
|
|||||||
page.model instanceof ProjectReflection
|
page.model instanceof ProjectReflection
|
||||||
) {
|
) {
|
||||||
this.removeGroups(page.model)
|
this.removeGroups(page.model)
|
||||||
|
this.removeCategories(page.model)
|
||||||
|
this.sortCategories(page.model)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.reflection instanceof DeclarationReflection &&
|
||||||
|
this.reflection.parent instanceof ProjectReflection
|
||||||
|
) {
|
||||||
|
const namespacesGroup = this.reflection.groups?.find(
|
||||||
|
(group) => group.title === "Namespaces"
|
||||||
|
)
|
||||||
|
if (namespacesGroup) {
|
||||||
|
// remove the namespaces that have the `@namespaceMember` modifier
|
||||||
|
namespacesGroup.children = namespacesGroup.children.filter((child) => {
|
||||||
|
return child.comment
|
||||||
|
? !child.comment.hasModifier("@namespaceMember")
|
||||||
|
: true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -428,6 +547,34 @@ export class MarkdownTheme extends Theme {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected removeCategories(
|
||||||
|
model?: DeclarationReflection | ProjectReflection
|
||||||
|
) {
|
||||||
|
if (!model?.categories) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = this.getFormattingOptionsForLocation()
|
||||||
|
|
||||||
|
model.categories = model.categories.filter((category) => {
|
||||||
|
return (
|
||||||
|
!options.reflectionCategories ||
|
||||||
|
!(category.title in options.reflectionCategories) ||
|
||||||
|
options.reflectionCategories[category.title]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
protected sortCategories(model?: DeclarationReflection | ProjectReflection) {
|
||||||
|
if (!model?.categories) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
model.categories.sort((categoryA, categoryB) => {
|
||||||
|
return categoryA.title.localeCompare(categoryB.title)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
get globalsFile() {
|
get globalsFile() {
|
||||||
return `modules.${this.mdxOutput ? "mdx" : "md"}`
|
return `modules.${this.mdxOutput ? "mdx" : "md"}`
|
||||||
}
|
}
|
||||||
@@ -441,10 +588,14 @@ export class MarkdownTheme extends Theme {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.getFormattingOptions(this.location)
|
||||||
|
}
|
||||||
|
|
||||||
|
getFormattingOptions(location: string): FormattingOptionType {
|
||||||
const applicableOptions: FormattingOptionType[] = []
|
const applicableOptions: FormattingOptionType[] = []
|
||||||
|
|
||||||
Object.keys(this.formattingOptions).forEach((key) => {
|
Object.keys(this.formattingOptions).forEach((key) => {
|
||||||
if (key === "*" || new RegExp(key).test(this.location)) {
|
if (key === "*" || new RegExp(key).test(location)) {
|
||||||
applicableOptions.push(this.formattingOptions[key])
|
applicableOptions.push(this.formattingOptions[key])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export type ReflectionParameterType =
|
|||||||
|
|
||||||
export type Mapping = {
|
export type Mapping = {
|
||||||
kind: ReflectionKind[]
|
kind: ReflectionKind[]
|
||||||
|
modifiers: {
|
||||||
|
has: `@${string}`[]
|
||||||
|
not: `@${string}`[]
|
||||||
|
}
|
||||||
isLeaf: boolean
|
isLeaf: boolean
|
||||||
directory: string
|
directory: string
|
||||||
template: (pageEvent: PageEvent<ContainerReflection>) => string
|
template: (pageEvent: PageEvent<ContainerReflection>) => string
|
||||||
|
|||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
import { Parameter } from "../types"
|
||||||
|
|
||||||
|
type FormatParameterComponentProps = {
|
||||||
|
parameterComponent: string | undefined
|
||||||
|
componentItems: Parameter[]
|
||||||
|
extraProps?: Record<string, unknown>
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function passed to an a Parameter array's sort method. It sorts
|
||||||
|
* parameter items by whether they're optional or not. So, required items
|
||||||
|
* are placed first in the array.
|
||||||
|
*/
|
||||||
|
function componentItemsSorter(a: Parameter, b: Parameter): number {
|
||||||
|
if (a.optional) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if (b.optional) {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that goes through items and their children to apply the
|
||||||
|
* {@link componentItemsSorter} function on them and sort the items.
|
||||||
|
*/
|
||||||
|
function sortComponentItems(items: Parameter[]): Parameter[] {
|
||||||
|
items.sort(componentItemsSorter)
|
||||||
|
items = items.map((item) => {
|
||||||
|
if (item.children) {
|
||||||
|
item.children = sortComponentItems(item.children)
|
||||||
|
}
|
||||||
|
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatParameterComponent({
|
||||||
|
parameterComponent,
|
||||||
|
componentItems,
|
||||||
|
extraProps,
|
||||||
|
}: FormatParameterComponentProps): string {
|
||||||
|
let extraPropsArr: string[] = []
|
||||||
|
if (extraProps) {
|
||||||
|
extraPropsArr = Object.entries(extraProps).map(
|
||||||
|
([key, value]) => `${key}=${JSON.stringify(value)}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// reorder component items to show required items first
|
||||||
|
componentItems = sortComponentItems(componentItems)
|
||||||
|
return `<${parameterComponent} parameters={${JSON.stringify(
|
||||||
|
componentItems
|
||||||
|
)}} ${extraPropsArr.join(" ")}/>`
|
||||||
|
}
|
||||||
@@ -0,0 +1,263 @@
|
|||||||
|
import {
|
||||||
|
Comment,
|
||||||
|
ParameterReflection,
|
||||||
|
ProjectReflection,
|
||||||
|
ReferenceType,
|
||||||
|
SignatureReflection,
|
||||||
|
SomeType,
|
||||||
|
} from "typedoc"
|
||||||
|
import { Parameter } from "../types"
|
||||||
|
import {
|
||||||
|
GetReflectionTypeParametersParams,
|
||||||
|
getReflectionTypeParameters,
|
||||||
|
} from "./reflection-type-parameters"
|
||||||
|
|
||||||
|
const MUTATION_PARAM_TYPE_NAME = "UseMutationOptions"
|
||||||
|
const MUTATION_RETURN_TYPE_NAME = "UseMutationResult"
|
||||||
|
const QUERY_PARAM_TYPE_NAME = "UseQueryOptionsWrapper"
|
||||||
|
const BLACKLISTED_PARAM_NAMES = ["constructor", "void"]
|
||||||
|
|
||||||
|
export function isReactQueryMutation(
|
||||||
|
signatureReflection: SignatureReflection
|
||||||
|
): boolean {
|
||||||
|
return (
|
||||||
|
signatureReflection.type?.type === "reference" &&
|
||||||
|
signatureReflection.type.name === MUTATION_RETURN_TYPE_NAME
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getReactQueryQueryParameterType(
|
||||||
|
signatureReflection: SignatureReflection
|
||||||
|
): ReferenceType | undefined {
|
||||||
|
let parameterType: ReferenceType | undefined
|
||||||
|
signatureReflection.parameters?.some((parameter) => {
|
||||||
|
if (
|
||||||
|
parameter.type?.type === "reference" &&
|
||||||
|
parameter.type.name === QUERY_PARAM_TYPE_NAME
|
||||||
|
) {
|
||||||
|
parameterType = parameter.type
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
return parameterType
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isReactQueryQuery(
|
||||||
|
signatureReflection: SignatureReflection
|
||||||
|
): boolean {
|
||||||
|
return getReactQueryQueryParameterType(signatureReflection) !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some parameter types are declared as classes which shows their constructor as
|
||||||
|
* an accepted parameter. This removes the constructor from the list of parameters.
|
||||||
|
*/
|
||||||
|
export function cleanUpParameterTypes(parameters: Parameter[]): Parameter[] {
|
||||||
|
return parameters.filter((parameter, index) => {
|
||||||
|
const keep = !BLACKLISTED_PARAM_NAMES.includes(parameter.name)
|
||||||
|
|
||||||
|
if (keep && parameter.children) {
|
||||||
|
parameters[index].children = cleanUpParameterTypes(parameter.children)
|
||||||
|
}
|
||||||
|
|
||||||
|
return keep
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getHookParams(
|
||||||
|
signatureReflection: SignatureReflection
|
||||||
|
): ParameterReflection[] {
|
||||||
|
let hookParameters: ParameterReflection[] = []
|
||||||
|
if (isReactQueryMutation(signatureReflection)) {
|
||||||
|
/**
|
||||||
|
* check parameters before the options parameter having the {@link MUTATION_PARAM_TYPE_NAME} type
|
||||||
|
*/
|
||||||
|
hookParameters =
|
||||||
|
signatureReflection.parameters?.filter((parameter) => {
|
||||||
|
return (
|
||||||
|
parameter.type?.type !== "reference" ||
|
||||||
|
parameter.type.name !== MUTATION_PARAM_TYPE_NAME
|
||||||
|
)
|
||||||
|
}) || []
|
||||||
|
} else if (isReactQueryQuery(signatureReflection)) {
|
||||||
|
/**
|
||||||
|
* check parameters before the options parameter having the {@link QUERY_PARAM_TYPE_NAME} type
|
||||||
|
*/
|
||||||
|
hookParameters =
|
||||||
|
signatureReflection.parameters?.filter((parameter) => {
|
||||||
|
return (
|
||||||
|
parameter.type?.type !== "reference" ||
|
||||||
|
parameter.type.name !== QUERY_PARAM_TYPE_NAME
|
||||||
|
)
|
||||||
|
}) || []
|
||||||
|
}
|
||||||
|
|
||||||
|
return hookParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load comments of a type param from the signature's comments if it has the
|
||||||
|
* `@typeParamDefinition` tag.
|
||||||
|
*/
|
||||||
|
function loadTypeComments(
|
||||||
|
signatureReflection: SignatureReflection,
|
||||||
|
typeName: string
|
||||||
|
): Comment | undefined {
|
||||||
|
const tagRegex = /^(?<typeName>\w+) - (?<typeDef>.*)$/
|
||||||
|
const typeComment = new Comment()
|
||||||
|
signatureReflection.comment?.blockTags
|
||||||
|
.filter((tag) => tag.tag === "@typeParamDefinition")
|
||||||
|
.some((tag) => {
|
||||||
|
return tag.content.some((tagContent) => {
|
||||||
|
const match = tagContent.text.match(tagRegex)
|
||||||
|
if (match?.groups?.typeName === typeName && match?.groups?.typeDef) {
|
||||||
|
typeComment.summary.push({
|
||||||
|
kind: "text",
|
||||||
|
text: match.groups.typeDef,
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return typeComment.summary.length > 0 ? typeComment : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetMutationParamsParams = {
|
||||||
|
signatureReflection: SignatureReflection
|
||||||
|
project: ProjectReflection
|
||||||
|
reflectionTypeGetterOptions?: Partial<GetReflectionTypeParametersParams>
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetParamsOptions = GetMutationParamsParams & {
|
||||||
|
reflectionType: SomeType
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParams({
|
||||||
|
signatureReflection,
|
||||||
|
reflectionType,
|
||||||
|
reflectionTypeGetterOptions,
|
||||||
|
...rest
|
||||||
|
}: GetParamsOptions): Parameter[] {
|
||||||
|
const comment =
|
||||||
|
"name" in reflectionType
|
||||||
|
? loadTypeComments(signatureReflection, reflectionType.name)
|
||||||
|
: reflectionTypeGetterOptions?.comment
|
||||||
|
|
||||||
|
return cleanUpParameterTypes(
|
||||||
|
getReflectionTypeParameters({
|
||||||
|
reflectionType,
|
||||||
|
comment,
|
||||||
|
isReturn: false,
|
||||||
|
...reflectionTypeGetterOptions,
|
||||||
|
...rest,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMutationParams({
|
||||||
|
signatureReflection,
|
||||||
|
reflectionTypeGetterOptions,
|
||||||
|
project,
|
||||||
|
}: GetMutationParamsParams): Parameter[] {
|
||||||
|
let mutationParameters: Parameter[] = []
|
||||||
|
if (isReactQueryMutation(signatureReflection)) {
|
||||||
|
const mutationOptionParam = signatureReflection.parameters?.find(
|
||||||
|
(parameter) => {
|
||||||
|
return (
|
||||||
|
parameter.type?.type === "reference" &&
|
||||||
|
parameter.type.name === MUTATION_PARAM_TYPE_NAME
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
mutationOptionParam?.type?.type === "reference" &&
|
||||||
|
(mutationOptionParam.type.typeArguments?.length || 0) >= 3
|
||||||
|
) {
|
||||||
|
mutationParameters = getParams({
|
||||||
|
signatureReflection,
|
||||||
|
project,
|
||||||
|
reflectionType: mutationOptionParam.type.typeArguments![2],
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
...reflectionTypeGetterOptions,
|
||||||
|
wrapObject:
|
||||||
|
mutationOptionParam.type.typeArguments![2].type === "reference",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mutationParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasResponseTypeArgument(type: ReferenceType): boolean {
|
||||||
|
return (
|
||||||
|
(type.typeArguments?.length || 0) >= 1 &&
|
||||||
|
type.typeArguments![0].type === "reference" &&
|
||||||
|
type.typeArguments![0].name === "Response" &&
|
||||||
|
(type.typeArguments![0].typeArguments?.length || 0) >= 1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetMutationReturnParams = GetMutationParamsParams
|
||||||
|
|
||||||
|
export function getMutationReturn({
|
||||||
|
signatureReflection,
|
||||||
|
reflectionTypeGetterOptions,
|
||||||
|
project,
|
||||||
|
}: GetMutationReturnParams): Parameter[] {
|
||||||
|
let returnParams: Parameter[] = []
|
||||||
|
if (!isReactQueryMutation(signatureReflection)) {
|
||||||
|
return returnParams
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnType = signatureReflection.type! as ReferenceType
|
||||||
|
|
||||||
|
if (hasResponseTypeArgument(returnType)) {
|
||||||
|
returnParams = getParams({
|
||||||
|
signatureReflection,
|
||||||
|
project,
|
||||||
|
reflectionType: (returnType.typeArguments![0] as ReferenceType)
|
||||||
|
.typeArguments![0],
|
||||||
|
reflectionTypeGetterOptions: {
|
||||||
|
...reflectionTypeGetterOptions,
|
||||||
|
wrapObject:
|
||||||
|
(returnType.typeArguments![0] as ReferenceType).typeArguments![0]
|
||||||
|
.type === "reference",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnParams
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetQueryReturnParams = GetMutationParamsParams
|
||||||
|
|
||||||
|
export function getQueryReturn({
|
||||||
|
signatureReflection,
|
||||||
|
reflectionTypeGetterOptions,
|
||||||
|
project,
|
||||||
|
}: GetQueryReturnParams): Parameter[] {
|
||||||
|
let returnParams: Parameter[] = []
|
||||||
|
|
||||||
|
const parameterType = getReactQueryQueryParameterType(signatureReflection)
|
||||||
|
|
||||||
|
if (parameterType && hasResponseTypeArgument(parameterType)) {
|
||||||
|
returnParams = getParams({
|
||||||
|
signatureReflection,
|
||||||
|
project,
|
||||||
|
reflectionType: (parameterType.typeArguments![0] as ReferenceType)
|
||||||
|
.typeArguments![0],
|
||||||
|
reflectionTypeGetterOptions,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnParams
|
||||||
|
}
|
||||||
@@ -85,7 +85,10 @@ export function reflectionListFormatter({
|
|||||||
) {
|
) {
|
||||||
const children = hasChildren
|
const children = hasChildren
|
||||||
? reflection.children
|
? reflection.children
|
||||||
: getTypeChildren(reflection.type!, reflection.project)
|
: getTypeChildren({
|
||||||
|
reflectionType: reflection.type!,
|
||||||
|
project: reflection.project,
|
||||||
|
})
|
||||||
const itemChildren: string[] = []
|
const itemChildren: string[] = []
|
||||||
let itemChildrenKind: ReflectionKind | null = null
|
let itemChildrenKind: ReflectionKind | null = null
|
||||||
children?.forEach((childItem: DeclarationReflection) => {
|
children?.forEach((childItem: DeclarationReflection) => {
|
||||||
@@ -156,7 +159,11 @@ export function reflectionComponentFormatter({
|
|||||||
) {
|
) {
|
||||||
const children = hasChildren
|
const children = hasChildren
|
||||||
? reflection.children
|
? reflection.children
|
||||||
: getTypeChildren(reflection.type!, project || reflection.project)
|
: getTypeChildren({
|
||||||
|
reflectionType: reflection.type!,
|
||||||
|
project: project || reflection.project,
|
||||||
|
maxLevel,
|
||||||
|
})
|
||||||
|
|
||||||
children
|
children
|
||||||
?.filter((childItem: DeclarationReflection) =>
|
?.filter((childItem: DeclarationReflection) =>
|
||||||
|
|||||||
+10
@@ -10,6 +10,16 @@ export function replaceTemplateVariables(
|
|||||||
|
|
||||||
return text
|
return text
|
||||||
.replaceAll("{{alias}}", reflection.getAlias())
|
.replaceAll("{{alias}}", reflection.getAlias())
|
||||||
|
.replaceAll("{{alias-lower}}", reflection.getAlias().toLowerCase())
|
||||||
|
.replaceAll("{{parent.alias}}", reflection.parent?.getAlias() || "")
|
||||||
|
.replaceAll(
|
||||||
|
"{{parent.alias-lower}}",
|
||||||
|
reflection.parent?.getAlias().toLowerCase() || ""
|
||||||
|
)
|
||||||
|
.replaceAll(
|
||||||
|
"{{parent.parent.alias}}",
|
||||||
|
reflection.parent?.parent?.getAlias() || ""
|
||||||
|
)
|
||||||
.replaceAll("{{kind}}", getKindAsText(reflection.kind))
|
.replaceAll("{{kind}}", getKindAsText(reflection.kind))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+115
-100
@@ -15,21 +15,25 @@ import {
|
|||||||
import { MarkdownTheme } from "../theme"
|
import { MarkdownTheme } from "../theme"
|
||||||
import { getProjectChild, getType, getTypeChildren } from "utils"
|
import { getProjectChild, getType, getTypeChildren } from "utils"
|
||||||
|
|
||||||
type ReturnReflectionComponentFormatterParams = {
|
export type GetReflectionTypeParametersParams = {
|
||||||
reflectionType: SomeType
|
reflectionType: SomeType
|
||||||
project: ProjectReflection
|
project: ProjectReflection
|
||||||
comment?: Comment
|
comment?: Comment
|
||||||
level: number
|
level?: number
|
||||||
maxLevel?: number | undefined
|
maxLevel?: number | undefined
|
||||||
|
wrapObject?: boolean
|
||||||
|
isReturn?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function returnReflectionComponentFormatter({
|
export function getReflectionTypeParameters({
|
||||||
reflectionType,
|
reflectionType,
|
||||||
project,
|
project,
|
||||||
comment,
|
comment,
|
||||||
level = 1,
|
level = 1,
|
||||||
maxLevel,
|
maxLevel,
|
||||||
}: ReturnReflectionComponentFormatterParams): Parameter[] {
|
wrapObject = false,
|
||||||
|
isReturn = true,
|
||||||
|
}: GetReflectionTypeParametersParams): Parameter[] {
|
||||||
const typeName = getType({
|
const typeName = getType({
|
||||||
reflectionType,
|
reflectionType,
|
||||||
collapse: "object",
|
collapse: "object",
|
||||||
@@ -39,11 +43,6 @@ export function returnReflectionComponentFormatter({
|
|||||||
project,
|
project,
|
||||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||||
})
|
})
|
||||||
// if (
|
|
||||||
// typeName === "Record<string, unknown> \\| PaymentProcessorError"
|
|
||||||
// ) {
|
|
||||||
// console.log(reflectionType)
|
|
||||||
// }
|
|
||||||
const type = getType({
|
const type = getType({
|
||||||
reflectionType: reflectionType,
|
reflectionType: reflectionType,
|
||||||
collapse: "object",
|
collapse: "object",
|
||||||
@@ -51,11 +50,9 @@ export function returnReflectionComponentFormatter({
|
|||||||
escape: true,
|
escape: true,
|
||||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||||
})
|
})
|
||||||
const componentItem: Parameter[] = []
|
|
||||||
const canRetrieveChildren = level + 1 <= (maxLevel || MarkdownTheme.MAX_LEVEL)
|
const formatParameter = () => {
|
||||||
if (reflectionType.type === "reference") {
|
return {
|
||||||
if (reflectionType.typeArguments || reflectionType.refersToTypeParameter) {
|
|
||||||
const parentKey = componentItem.push({
|
|
||||||
name: "name" in reflectionType ? reflectionType.name : typeName,
|
name: "name" in reflectionType ? reflectionType.name : typeName,
|
||||||
type,
|
type,
|
||||||
optional:
|
optional:
|
||||||
@@ -68,11 +65,24 @@ export function returnReflectionComponentFormatter({
|
|||||||
reflectionType.declaration as DeclarationReflection
|
reflectionType.declaration as DeclarationReflection
|
||||||
) || ""
|
) || ""
|
||||||
: "",
|
: "",
|
||||||
description: comment ? getReturnComment(comment) : "",
|
description: comment
|
||||||
|
? isReturn
|
||||||
|
? getReturnComment(comment)
|
||||||
|
: Handlebars.helpers.comment(comment.summary)
|
||||||
|
: !comment && !isReturn
|
||||||
|
? loadComment(typeName, project)
|
||||||
|
: "",
|
||||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
expandable: comment?.hasModifier(`@expandable`) || false,
|
||||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
featureFlag: Handlebars.helpers.featureFlag(comment),
|
||||||
children: [],
|
children: [],
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const componentItem: Parameter[] = []
|
||||||
|
const canRetrieveChildren = level + 1 <= (maxLevel || MarkdownTheme.MAX_LEVEL)
|
||||||
|
if (reflectionType.type === "reference") {
|
||||||
|
if (reflectionType.typeArguments || reflectionType.refersToTypeParameter) {
|
||||||
|
const parentKey = componentItem.push(formatParameter())
|
||||||
const typeArgs = reflectionType.typeArguments
|
const typeArgs = reflectionType.typeArguments
|
||||||
? reflectionType.typeArguments
|
? reflectionType.typeArguments
|
||||||
: "typeParameters" in reflectionType
|
: "typeParameters" in reflectionType
|
||||||
@@ -89,7 +99,7 @@ export function returnReflectionComponentFormatter({
|
|||||||
if (!reflectionTypeArg) {
|
if (!reflectionTypeArg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const typeArgComponent = returnReflectionComponentFormatter({
|
const typeArgComponent = getReflectionTypeParameters({
|
||||||
reflectionType: reflectionTypeArg,
|
reflectionType: reflectionTypeArg,
|
||||||
project,
|
project,
|
||||||
level: level + 1,
|
level: level + 1,
|
||||||
@@ -102,75 +112,53 @@ export function returnReflectionComponentFormatter({
|
|||||||
} else {
|
} else {
|
||||||
const reflection = (reflectionType.reflection ||
|
const reflection = (reflectionType.reflection ||
|
||||||
getProjectChild(project, reflectionType.name)) as DeclarationReflection
|
getProjectChild(project, reflectionType.name)) as DeclarationReflection
|
||||||
|
const parentKey = wrapObject
|
||||||
|
? componentItem.push(formatParameter())
|
||||||
|
: undefined
|
||||||
if (reflection) {
|
if (reflection) {
|
||||||
const reflectionChildren = canRetrieveChildren
|
const reflectionChildren = canRetrieveChildren
|
||||||
? reflection.children ||
|
? reflection.children ||
|
||||||
getTypeChildren(reflectionType, project, level)
|
getTypeChildren({
|
||||||
|
reflectionType,
|
||||||
|
project,
|
||||||
|
level,
|
||||||
|
maxLevel,
|
||||||
|
})
|
||||||
: undefined
|
: undefined
|
||||||
if (reflectionChildren?.length) {
|
if (reflectionChildren?.length) {
|
||||||
reflectionChildren.forEach((childItem) => {
|
reflectionChildren.forEach((childItem) => {
|
||||||
componentItem.push(
|
const childParameter = reflectionComponentFormatter({
|
||||||
reflectionComponentFormatter({
|
|
||||||
reflection: childItem as DeclarationReflection,
|
reflection: childItem as DeclarationReflection,
|
||||||
level,
|
level,
|
||||||
maxLevel,
|
maxLevel,
|
||||||
project,
|
project,
|
||||||
})
|
})
|
||||||
)
|
parentKey
|
||||||
|
? componentItem[parentKey - 1].children?.push(childParameter)
|
||||||
|
: componentItem.push(childParameter)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
componentItem.push(
|
const childParameter = reflectionComponentFormatter({
|
||||||
reflectionComponentFormatter({
|
|
||||||
reflection,
|
reflection,
|
||||||
level,
|
level,
|
||||||
maxLevel,
|
maxLevel,
|
||||||
project,
|
project,
|
||||||
})
|
})
|
||||||
)
|
|
||||||
|
parentKey
|
||||||
|
? componentItem[parentKey - 1].children?.push(childParameter)
|
||||||
|
: componentItem.push(childParameter)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
componentItem.push({
|
parentKey
|
||||||
name: "name" in reflectionType ? reflectionType.name : typeName,
|
? componentItem[parentKey - 1].children?.push(formatParameter())
|
||||||
type,
|
: componentItem.push(formatParameter())
|
||||||
optional:
|
|
||||||
"flags" in reflectionType
|
|
||||||
? (reflectionType.flags as ReflectionFlags).isOptional
|
|
||||||
: false,
|
|
||||||
defaultValue:
|
|
||||||
"declaration" in reflectionType
|
|
||||||
? getDefaultValue(
|
|
||||||
reflectionType.declaration as DeclarationReflection
|
|
||||||
) || ""
|
|
||||||
: "",
|
|
||||||
description: comment ? getReturnComment(comment) : "",
|
|
||||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
|
||||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
|
||||||
children: [],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (reflectionType.type === "array") {
|
} else if (reflectionType.type === "array") {
|
||||||
const parentKey = componentItem.push({
|
const parentKey = componentItem.push(formatParameter())
|
||||||
name:
|
|
||||||
"name" in reflectionType ? (reflectionType.name as string) : typeName,
|
|
||||||
type,
|
|
||||||
optional:
|
|
||||||
"flags" in reflectionType
|
|
||||||
? (reflectionType.flags as ReflectionFlags).isOptional
|
|
||||||
: false,
|
|
||||||
defaultValue:
|
|
||||||
"declaration" in reflectionType
|
|
||||||
? getDefaultValue(
|
|
||||||
reflectionType.declaration as DeclarationReflection
|
|
||||||
) || ""
|
|
||||||
: "",
|
|
||||||
description: comment ? getReturnComment(comment) : "",
|
|
||||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
|
||||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
|
||||||
children: [],
|
|
||||||
})
|
|
||||||
if (canRetrieveChildren) {
|
if (canRetrieveChildren) {
|
||||||
const elementTypeItem = returnReflectionComponentFormatter({
|
const elementTypeItem = getReflectionTypeParameters({
|
||||||
reflectionType: reflectionType.elementType,
|
reflectionType: reflectionType.elementType,
|
||||||
project,
|
project,
|
||||||
level: level + 1,
|
level: level + 1,
|
||||||
@@ -181,32 +169,19 @@ export function returnReflectionComponentFormatter({
|
|||||||
} else if (reflectionType.type === "tuple") {
|
} else if (reflectionType.type === "tuple") {
|
||||||
let pushTo: Parameter[] = []
|
let pushTo: Parameter[] = []
|
||||||
if (level === 1) {
|
if (level === 1) {
|
||||||
const parentKey = componentItem.push({
|
const parentKey = componentItem.push(formatParameter())
|
||||||
name:
|
|
||||||
"name" in reflectionType ? (reflectionType.name as string) : typeName,
|
|
||||||
type,
|
|
||||||
optional:
|
|
||||||
"flags" in reflectionType
|
|
||||||
? (reflectionType.flags as ReflectionFlags).isOptional
|
|
||||||
: false,
|
|
||||||
defaultValue:
|
|
||||||
"declaration" in reflectionType
|
|
||||||
? getDefaultValue(
|
|
||||||
reflectionType.declaration as DeclarationReflection
|
|
||||||
) || ""
|
|
||||||
: "",
|
|
||||||
description: comment ? getReturnComment(comment) : "",
|
|
||||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
|
||||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
|
||||||
children: [],
|
|
||||||
})
|
|
||||||
pushTo = componentItem[parentKey - 1].children!
|
pushTo = componentItem[parentKey - 1].children!
|
||||||
} else {
|
} else {
|
||||||
pushTo = componentItem
|
const parentKey = wrapObject
|
||||||
|
? componentItem.push(formatParameter())
|
||||||
|
: undefined
|
||||||
|
pushTo = parentKey
|
||||||
|
? componentItem[parentKey - 1].children!
|
||||||
|
: componentItem
|
||||||
}
|
}
|
||||||
if (canRetrieveChildren) {
|
if (canRetrieveChildren) {
|
||||||
reflectionType.elements.forEach((element) => {
|
reflectionType.elements.forEach((element) => {
|
||||||
const elementTypeItem = returnReflectionComponentFormatter({
|
const elementTypeItem = getReflectionTypeParameters({
|
||||||
reflectionType: element,
|
reflectionType: element,
|
||||||
project,
|
project,
|
||||||
level: level + 1,
|
level: level + 1,
|
||||||
@@ -215,24 +190,47 @@ export function returnReflectionComponentFormatter({
|
|||||||
pushTo.push(...elementTypeItem)
|
pushTo.push(...elementTypeItem)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else if (reflectionType.type === "intersection") {
|
||||||
// put type as the only component.
|
const parentKey = wrapObject
|
||||||
componentItem.push({
|
? componentItem.push(formatParameter())
|
||||||
name: "name" in reflectionType ? reflectionType.name : typeName,
|
: undefined
|
||||||
type,
|
reflectionType.types.forEach((childType) => {
|
||||||
optional:
|
const childParameter = getReflectionTypeParameters({
|
||||||
"flags" in reflectionType
|
reflectionType: childType,
|
||||||
? (reflectionType.flags as ReflectionFlags).isOptional
|
project,
|
||||||
: true,
|
level: level + 1,
|
||||||
defaultValue:
|
maxLevel,
|
||||||
"declaration" in reflectionType
|
|
||||||
? getDefaultValue(reflectionType.declaration) || ""
|
|
||||||
: "",
|
|
||||||
description: comment ? getReturnComment(comment) : "",
|
|
||||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
|
||||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
|
||||||
children: [],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
parentKey
|
||||||
|
? componentItem[parentKey - 1].children?.push(...childParameter)
|
||||||
|
: componentItem.push(...childParameter)
|
||||||
|
})
|
||||||
|
} else if (reflectionType.type === "reflection") {
|
||||||
|
const parentKey =
|
||||||
|
type === "`object`" && typeName === "object"
|
||||||
|
? undefined
|
||||||
|
: componentItem.push(formatParameter())
|
||||||
|
reflectionType.declaration.children?.forEach((childItem) => {
|
||||||
|
const childParameter = reflectionComponentFormatter({
|
||||||
|
reflection: childItem as DeclarationReflection,
|
||||||
|
level,
|
||||||
|
maxLevel,
|
||||||
|
project,
|
||||||
|
})
|
||||||
|
|
||||||
|
parentKey
|
||||||
|
? componentItem[parentKey - 1].children?.push(childParameter)
|
||||||
|
: componentItem.push(childParameter)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const parentKey = wrapObject
|
||||||
|
? componentItem.push(formatParameter())
|
||||||
|
: undefined
|
||||||
|
// put type as the only component.
|
||||||
|
parentKey
|
||||||
|
? componentItem[parentKey - 1].children?.push(formatParameter())
|
||||||
|
: componentItem.push(formatParameter())
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentItem
|
return componentItem
|
||||||
@@ -249,6 +247,23 @@ export function getReturnComment(comment: Comment): string {
|
|||||||
.join("\n\n")
|
.join("\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function loadComment(
|
||||||
|
reflectionTypeName: string,
|
||||||
|
project: ProjectReflection
|
||||||
|
): string {
|
||||||
|
// try to load reflection from project
|
||||||
|
const reflection = getProjectChild(project, reflectionTypeName)
|
||||||
|
if (reflection) {
|
||||||
|
return (
|
||||||
|
reflection.comment?.summary
|
||||||
|
.map((summaryPart) => summaryPart.text)
|
||||||
|
.join("\n\n") || ""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
export function isOnlyVoid(reflectionTypes: SomeType[]) {
|
export function isOnlyVoid(reflectionTypes: SomeType[]) {
|
||||||
return reflectionTypes.every(
|
return reflectionTypes.every(
|
||||||
(type) => type.type === "intrinsic" && type.name === "void"
|
(type) => type.type === "intrinsic" && type.name === "void"
|
||||||
+27
@@ -50,9 +50,13 @@ export type FormattingOptionType = {
|
|||||||
reflectionGroups?: {
|
reflectionGroups?: {
|
||||||
[k: string]: boolean
|
[k: string]: boolean
|
||||||
}
|
}
|
||||||
|
reflectionCategories?: {
|
||||||
|
[k: string]: boolean
|
||||||
|
}
|
||||||
reflectionTitle?: {
|
reflectionTitle?: {
|
||||||
kind: boolean
|
kind: boolean
|
||||||
typeParameters: boolean
|
typeParameters: boolean
|
||||||
|
prefix?: string
|
||||||
suffix?: string
|
suffix?: string
|
||||||
fullReplacement?: string
|
fullReplacement?: string
|
||||||
}
|
}
|
||||||
@@ -66,6 +70,7 @@ export type FormattingOptionType = {
|
|||||||
parameterComponentExtraProps?: Record<string, unknown>
|
parameterComponentExtraProps?: Record<string, unknown>
|
||||||
mdxImports?: string[]
|
mdxImports?: string[]
|
||||||
maxLevel?: number
|
maxLevel?: number
|
||||||
|
fileNameSeparator?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare module "typedoc" {
|
export declare module "typedoc" {
|
||||||
@@ -178,5 +183,27 @@ export declare module "typedoc" {
|
|||||||
* @defaultValue true
|
* @defaultValue true
|
||||||
*/
|
*/
|
||||||
outputModules: boolean
|
outputModules: boolean
|
||||||
|
/**
|
||||||
|
* Whether to enable category to namespace conversion.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
generateNamespaces: boolean
|
||||||
|
/**
|
||||||
|
* Optionally specify a parent namespace to place all generated namespaces in.
|
||||||
|
*/
|
||||||
|
parentNamespace: string
|
||||||
|
/**
|
||||||
|
* Optionally specify a name prefix for all generated namespaces.
|
||||||
|
*/
|
||||||
|
namePrefix: string
|
||||||
|
/**
|
||||||
|
* Whether to enable the React Query manipulator.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
enableReactQueryManipulator: boolean
|
||||||
|
/**
|
||||||
|
* Namespace names whose child members should have their own documents.
|
||||||
|
*/
|
||||||
|
allReflectionsHaveOwnDocumentInNamespace: string[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,37 @@
|
|||||||
|
/* eslint-disable no-case-declarations */
|
||||||
import { DeclarationReflection, ProjectReflection, SomeType } from "typedoc"
|
import { DeclarationReflection, ProjectReflection, SomeType } from "typedoc"
|
||||||
import { getProjectChild } from "./get-project-child"
|
import { getProjectChild } from "./get-project-child"
|
||||||
|
|
||||||
const MAX_LEVEL = 3
|
type GetTypeChildrenOptions = {
|
||||||
|
reflectionType: SomeType
|
||||||
|
project: ProjectReflection | undefined
|
||||||
|
level?: number
|
||||||
|
maxLevel?: number
|
||||||
|
}
|
||||||
|
|
||||||
export function getTypeChildren(
|
export function getTypeChildren({
|
||||||
reflectionType: SomeType,
|
reflectionType,
|
||||||
project: ProjectReflection | undefined,
|
project,
|
||||||
level = 1
|
level = 1,
|
||||||
): DeclarationReflection[] {
|
maxLevel = 3,
|
||||||
|
}: GetTypeChildrenOptions): DeclarationReflection[] {
|
||||||
let children: DeclarationReflection[] = []
|
let children: DeclarationReflection[] = []
|
||||||
|
|
||||||
if (level > MAX_LEVEL) {
|
if (level > maxLevel) {
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (reflectionType.type) {
|
switch (reflectionType.type) {
|
||||||
case "intersection":
|
case "intersection":
|
||||||
reflectionType.types.forEach((intersectionType) => {
|
reflectionType.types.forEach((intersectionType) => {
|
||||||
children.push(...getTypeChildren(intersectionType, project, level + 1))
|
children.push(
|
||||||
|
...getTypeChildren({
|
||||||
|
reflectionType: intersectionType,
|
||||||
|
project,
|
||||||
|
level: level + 1,
|
||||||
|
maxLevel,
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "reference":
|
case "reference":
|
||||||
@@ -36,13 +50,16 @@ export function getTypeChildren(
|
|||||||
if (referencedReflection.children) {
|
if (referencedReflection.children) {
|
||||||
children = referencedReflection.children
|
children = referencedReflection.children
|
||||||
} else if (referencedReflection.type) {
|
} else if (referencedReflection.type) {
|
||||||
children = getTypeChildren(
|
children = getTypeChildren({
|
||||||
referencedReflection.type,
|
reflectionType: referencedReflection.type,
|
||||||
project,
|
project,
|
||||||
level + 1
|
level: level + 1,
|
||||||
)
|
maxLevel,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else if (reflectionType.typeArguments?.length) {
|
} else if (reflectionType.typeArguments?.length) {
|
||||||
|
// Only useful if the reflection type is `Pick<...>`.
|
||||||
|
const toKeepChildren: string[] = []
|
||||||
reflectionType.typeArguments.forEach((typeArgument, index) => {
|
reflectionType.typeArguments.forEach((typeArgument, index) => {
|
||||||
if (reflectionType.name === "Omit" && index > 0) {
|
if (reflectionType.name === "Omit" && index > 0) {
|
||||||
switch (typeArgument.type) {
|
switch (typeArgument.type) {
|
||||||
@@ -54,23 +71,69 @@ export function getTypeChildren(
|
|||||||
if (childItem.type === "literal") {
|
if (childItem.type === "literal") {
|
||||||
removeChild(childItem.value?.toString(), children)
|
removeChild(childItem.value?.toString(), children)
|
||||||
} else {
|
} else {
|
||||||
getTypeChildren(childItem, project, level + 1).forEach(
|
getTypeChildren({
|
||||||
(child) => {
|
reflectionType: childItem,
|
||||||
|
project,
|
||||||
|
level: level + 1,
|
||||||
|
maxLevel,
|
||||||
|
}).forEach((child) => {
|
||||||
removeChild(child.name, children)
|
removeChild(child.name, children)
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else if (reflectionType.name === "Pick") {
|
||||||
const typeArgumentChildren = getTypeChildren(
|
if (index === 0 && !children.length) {
|
||||||
typeArgument,
|
children = getTypeChildren({
|
||||||
|
reflectionType: typeArgument,
|
||||||
project,
|
project,
|
||||||
level + 1
|
level: level + 1,
|
||||||
)
|
maxLevel,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
switch (typeArgument.type) {
|
||||||
|
case "literal":
|
||||||
|
if (typeArgument.value) {
|
||||||
|
toKeepChildren.push(typeArgument.value?.toString())
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "union":
|
||||||
|
typeArgument.types.forEach((childItem) => {
|
||||||
|
if (childItem.type === "literal") {
|
||||||
|
if (childItem.value) {
|
||||||
|
toKeepChildren.push(childItem.value?.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getTypeChildren({
|
||||||
|
reflectionType: childItem,
|
||||||
|
project,
|
||||||
|
level: level + 1,
|
||||||
|
maxLevel,
|
||||||
|
}).forEach((child) => {
|
||||||
|
if (child.name) {
|
||||||
|
toKeepChildren.push(child.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const typeArgumentChildren = getTypeChildren({
|
||||||
|
reflectionType: typeArgument,
|
||||||
|
project,
|
||||||
|
level: level + 1,
|
||||||
|
maxLevel,
|
||||||
|
})
|
||||||
children.push(...typeArgumentChildren)
|
children.push(...typeArgumentChildren)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (toKeepChildren.length) {
|
||||||
|
children = children.filter((child) =>
|
||||||
|
toKeepChildren.includes(child.name)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "reflection":
|
case "reflection":
|
||||||
@@ -79,7 +142,12 @@ export function getTypeChildren(
|
|||||||
]
|
]
|
||||||
break
|
break
|
||||||
case "array":
|
case "array":
|
||||||
children = getTypeChildren(reflectionType.elementType, project, level + 1)
|
children = getTypeChildren({
|
||||||
|
reflectionType: reflectionType.elementType,
|
||||||
|
project,
|
||||||
|
level: level + 1,
|
||||||
|
maxLevel,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterChildren(children)
|
return filterChildren(children)
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
+6095
-5043
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+27250
-24516
File diff suppressed because it is too large.
Load diff
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The customers to remove from the customer group.
|
||||||
|
*/
|
||||||
export interface AdminDeleteCustomerGroupsGroupCustomerBatchReq {
|
export interface AdminDeleteCustomerGroupsGroupCustomerBatchReq {
|
||||||
/**
|
/**
|
||||||
* The ids of the customers to remove
|
* The ids of the customers to remove
|
||||||
|
|||||||
+4
-1
@@ -3,9 +3,12 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the prices to delete.
|
||||||
|
*/
|
||||||
export interface AdminDeletePriceListPricesPricesReq {
|
export interface AdminDeletePriceListPricesPricesReq {
|
||||||
/**
|
/**
|
||||||
* The price IDs of the Money Amounts to delete.
|
* The IDs of the prices to delete.
|
||||||
*/
|
*/
|
||||||
price_ids?: Array<string>
|
price_ids?: Array<string>
|
||||||
}
|
}
|
||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the products' prices to delete.
|
||||||
|
*/
|
||||||
export interface AdminDeletePriceListsPriceListProductsPricesBatchReq {
|
export interface AdminDeletePriceListsPriceListProductsPricesBatchReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the products to delete their associated prices.
|
* The IDs of the products to delete their associated prices.
|
||||||
|
|||||||
+4
-1
@@ -3,9 +3,12 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the products to delete from the product category.
|
||||||
|
*/
|
||||||
export interface AdminDeleteProductCategoriesCategoryProductsBatchReq {
|
export interface AdminDeleteProductCategoriesCategoryProductsBatchReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the products to delete from the Product Category.
|
* The IDs of the products to delete from the product category.
|
||||||
*/
|
*/
|
||||||
product_ids: Array<{
|
product_ids: Array<{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the products to remove from the collection.
|
||||||
|
*/
|
||||||
export interface AdminDeleteProductsFromCollectionReq {
|
export interface AdminDeleteProductsFromCollectionReq {
|
||||||
/**
|
/**
|
||||||
* An array of Product IDs to remove from the Product Collection.
|
* An array of Product IDs to remove from the Product Collection.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the sales channels to remove from the publishable API key.
|
||||||
|
*/
|
||||||
export interface AdminDeletePublishableApiKeySalesChannelsBatchReq {
|
export interface AdminDeletePublishableApiKeySalesChannelsBatchReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the sales channels to remove from the publishable API key
|
* The IDs of the sales channels to remove from the publishable API key
|
||||||
|
|||||||
+4
-1
@@ -3,9 +3,12 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the products to delete from the sales channel.
|
||||||
|
*/
|
||||||
export interface AdminDeleteSalesChannelsChannelProductsBatchReq {
|
export interface AdminDeleteSalesChannelsChannelProductsBatchReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the products to remove from the Sales Channel.
|
* The IDs of the products to remove from the sales channel.
|
||||||
*/
|
*/
|
||||||
product_ids: Array<{
|
product_ids: Array<{
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the products to remove their associated with the tax rate.
|
||||||
|
*/
|
||||||
export interface AdminDeleteTaxRatesTaxRateProductsReq {
|
export interface AdminDeleteTaxRatesTaxRateProductsReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the products to remove their association with this tax rate.
|
* The IDs of the products to remove their association with this tax rate.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the shipping options to remove their associate with the tax rate.
|
||||||
|
*/
|
||||||
export interface AdminDeleteTaxRatesTaxRateShippingOptionsReq {
|
export interface AdminDeleteTaxRatesTaxRateShippingOptionsReq {
|
||||||
/**
|
/**
|
||||||
* The IDs of the shipping options to remove their association with this tax rate.
|
* The IDs of the shipping options to remove their association with this tax rate.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the file to delete.
|
||||||
|
*/
|
||||||
export interface AdminDeleteUploadsReq {
|
export interface AdminDeleteUploadsReq {
|
||||||
/**
|
/**
|
||||||
* key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly.
|
* key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly.
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
|
|||||||
import type { PaymentCollection } from "./PaymentCollection"
|
import type { PaymentCollection } from "./PaymentCollection"
|
||||||
import type { Region } from "./Region"
|
import type { Region } from "./Region"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The payment collection's details.
|
||||||
|
*/
|
||||||
export interface AdminPaymentCollectionsRes {
|
export interface AdminPaymentCollectionsRes {
|
||||||
/**
|
/**
|
||||||
* Payment Collection details.
|
* Payment Collection details.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The admin's credentials used to log in.
|
||||||
|
*/
|
||||||
export interface AdminPostAuthReq {
|
export interface AdminPostAuthReq {
|
||||||
/**
|
/**
|
||||||
* The user's email.
|
* The user's email.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the batch job to create.
|
||||||
|
*/
|
||||||
export interface AdminPostBatchesReq {
|
export interface AdminPostBatchesReq {
|
||||||
/**
|
/**
|
||||||
* The type of batch job to start, which is defined by the `batchType` property of the associated batch job strategy.
|
* The type of batch job to start, which is defined by the `batchType` property of the associated batch job strategy.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The product collection's details to update.
|
||||||
|
*/
|
||||||
export interface AdminPostCollectionsCollectionReq {
|
export interface AdminPostCollectionsCollectionReq {
|
||||||
/**
|
/**
|
||||||
* The title of the collection.
|
* The title of the collection.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The product collection's details.
|
||||||
|
*/
|
||||||
export interface AdminPostCollectionsReq {
|
export interface AdminPostCollectionsReq {
|
||||||
/**
|
/**
|
||||||
* The title of the collection.
|
* The title of the collection.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update in the currency
|
||||||
|
*/
|
||||||
export interface AdminPostCurrenciesCurrencyReq {
|
export interface AdminPostCurrenciesCurrencyReq {
|
||||||
/**
|
/**
|
||||||
* Tax included in prices of currency.
|
* Tax included in prices of currency.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The customers to add to the customer group.
|
||||||
|
*/
|
||||||
export interface AdminPostCustomerGroupsGroupCustomersBatchReq {
|
export interface AdminPostCustomerGroupsGroupCustomersBatchReq {
|
||||||
/**
|
/**
|
||||||
* The ids of the customers to add
|
* The ids of the customers to add
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update in the customer group.
|
||||||
|
*/
|
||||||
export interface AdminPostCustomerGroupsGroupReq {
|
export interface AdminPostCustomerGroupsGroupReq {
|
||||||
/**
|
/**
|
||||||
* Name of the customer group
|
* Name of the customer group
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the customer group to create.
|
||||||
|
*/
|
||||||
export interface AdminPostCustomerGroupsReq {
|
export interface AdminPostCustomerGroupsReq {
|
||||||
/**
|
/**
|
||||||
* Name of the customer group
|
* Name of the customer group
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the customer to update.
|
||||||
|
*/
|
||||||
export interface AdminPostCustomersCustomerReq {
|
export interface AdminPostCustomersCustomerReq {
|
||||||
/**
|
/**
|
||||||
* The Customer's email. You can't update the email of a registered customer.
|
* The Customer's email. You can't update the email of a registered customer.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the customer to create.
|
||||||
|
*/
|
||||||
export interface AdminPostCustomersReq {
|
export interface AdminPostCustomersReq {
|
||||||
/**
|
/**
|
||||||
* The customer's email.
|
* The customer's email.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the resources to add.
|
||||||
|
*/
|
||||||
export interface AdminPostDiscountsDiscountConditionsConditionBatchReq {
|
export interface AdminPostDiscountsDiscountConditionsConditionBatchReq {
|
||||||
/**
|
/**
|
||||||
* The resources to be added to the discount condition
|
* The resources to be added to the discount condition
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the dynamic discount to create.
|
||||||
|
*/
|
||||||
export interface AdminPostDiscountsDiscountDynamicCodesReq {
|
export interface AdminPostDiscountsDiscountDynamicCodesReq {
|
||||||
/**
|
/**
|
||||||
* A unique code that will be used to redeem the Discount
|
* A unique code that will be used to redeem the Discount
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the discount to update.
|
||||||
|
*/
|
||||||
export interface AdminPostDiscountsDiscountReq {
|
export interface AdminPostDiscountsDiscountReq {
|
||||||
/**
|
/**
|
||||||
* A unique code that will be used to redeem the discount
|
* A unique code that will be used to redeem the discount
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the discount to create.
|
||||||
|
*/
|
||||||
export interface AdminPostDiscountsReq {
|
export interface AdminPostDiscountsReq {
|
||||||
/**
|
/**
|
||||||
* A unique code that will be used to redeem the discount
|
* A unique code that will be used to redeem the discount
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update of the line item.
|
||||||
|
*/
|
||||||
export interface AdminPostDraftOrdersDraftOrderLineItemsItemReq {
|
export interface AdminPostDraftOrdersDraftOrderLineItemsItemReq {
|
||||||
/**
|
/**
|
||||||
* The custom price of the line item. If a `variant_id` is supplied, the price provided here will override the variant's price.
|
* The custom price of the line item. If a `variant_id` is supplied, the price provided here will override the variant's price.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the line item to create.
|
||||||
|
*/
|
||||||
export interface AdminPostDraftOrdersDraftOrderLineItemsReq {
|
export interface AdminPostDraftOrdersDraftOrderLineItemsReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the Product Variant associated with the line item. If the line item is custom, the `variant_id` should be omitted.
|
* The ID of the Product Variant associated with the line item. If the line item is custom, the `variant_id` should be omitted.
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
|
|||||||
|
|
||||||
import type { AddressPayload } from "./AddressPayload"
|
import type { AddressPayload } from "./AddressPayload"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order to update.
|
||||||
|
*/
|
||||||
export interface AdminPostDraftOrdersDraftOrderReq {
|
export interface AdminPostDraftOrdersDraftOrderReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the Region to create the Draft Order in.
|
* The ID of the Region to create the Draft Order in.
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { SetRelation, Merge } from "../core/ModelUtils"
|
|||||||
|
|
||||||
import type { AddressPayload } from "./AddressPayload"
|
import type { AddressPayload } from "./AddressPayload"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order to create.
|
||||||
|
*/
|
||||||
export interface AdminPostDraftOrdersReq {
|
export interface AdminPostDraftOrdersReq {
|
||||||
/**
|
/**
|
||||||
* The status of the draft order. The draft order's default status is `open`. It's changed to `completed` when its payment is marked as paid.
|
* The status of the draft order. The draft order's default status is `open`. It's changed to `completed` when its payment is marked as paid.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update of the gift card.
|
||||||
|
*/
|
||||||
export interface AdminPostGiftCardsGiftCardReq {
|
export interface AdminPostGiftCardsGiftCardReq {
|
||||||
/**
|
/**
|
||||||
* The value (excluding VAT) that the Gift Card should represent.
|
* The value (excluding VAT) that the Gift Card should represent.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the gift card to create.
|
||||||
|
*/
|
||||||
export interface AdminPostGiftCardsReq {
|
export interface AdminPostGiftCardsReq {
|
||||||
/**
|
/**
|
||||||
* The value (excluding VAT) that the Gift Card should represent.
|
* The value (excluding VAT) that the Gift Card should represent.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the location level to create.
|
||||||
|
*/
|
||||||
export interface AdminPostInventoryItemsItemLocationLevelsReq {
|
export interface AdminPostInventoryItemsItemLocationLevelsReq {
|
||||||
/**
|
/**
|
||||||
* the ID of the stock location
|
* the ID of the stock location
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the inventory item to create.
|
||||||
|
*/
|
||||||
export interface AdminPostInventoryItemsReq {
|
export interface AdminPostInventoryItemsReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the variant to create the inventory item for.
|
* The ID of the variant to create the inventory item for.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update of the note.
|
||||||
|
*/
|
||||||
export interface AdminPostNotesNoteReq {
|
export interface AdminPostNotesNoteReq {
|
||||||
/**
|
/**
|
||||||
* The description of the Note.
|
* The description of the Note.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the note to be created.
|
||||||
|
*/
|
||||||
export interface AdminPostNotesReq {
|
export interface AdminPostNotesReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the resource which the Note relates to. For example, an order ID.
|
* The ID of the resource which the Note relates to. For example, an order ID.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resend details.
|
||||||
|
*/
|
||||||
export interface AdminPostNotificationsNotificationResendReq {
|
export interface AdminPostNotificationsNotificationResendReq {
|
||||||
/**
|
/**
|
||||||
* A new address or user identifier that the Notification should be sent to. If not provided, the previous `to` field of the notification will be used.
|
* A new address or user identifier that the Notification should be sent to. If not provided, the previous `to` field of the notification will be used.
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to create or update of the line item change.
|
||||||
|
*/
|
||||||
export interface AdminPostOrderEditsEditLineItemsLineItemReq {
|
export interface AdminPostOrderEditsEditLineItemsLineItemReq {
|
||||||
/**
|
/**
|
||||||
* The quantity to update
|
* The quantity to update
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the line item change to create.
|
||||||
|
*/
|
||||||
export interface AdminPostOrderEditsEditLineItemsReq {
|
export interface AdminPostOrderEditsEditLineItemsReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the product variant associated with the item.
|
* The ID of the product variant associated with the item.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update of the order edit.
|
||||||
|
*/
|
||||||
export interface AdminPostOrderEditsOrderEditReq {
|
export interface AdminPostOrderEditsOrderEditReq {
|
||||||
/**
|
/**
|
||||||
* An optional note to create or update in the order edit.
|
* An optional note to create or update in the order edit.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the order edit to create.
|
||||||
|
*/
|
||||||
export interface AdminPostOrderEditsReq {
|
export interface AdminPostOrderEditsReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the order to create the edit for.
|
* The ID of the order to create the edit for.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the order refund.
|
||||||
|
*/
|
||||||
export interface AdminPostOrdersOrderRefundsReq {
|
export interface AdminPostOrdersOrderRefundsReq {
|
||||||
/**
|
/**
|
||||||
* The amount to refund. It should be less than or equal the `refundable_amount` of the order.
|
* The amount to refund. It should be less than or equal the `refundable_amount` of the order.
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import type { AddressPayload } from "./AddressPayload"
|
|||||||
import type { Discount } from "./Discount"
|
import type { Discount } from "./Discount"
|
||||||
import type { LineItem } from "./LineItem"
|
import type { LineItem } from "./LineItem"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details to update of the order.
|
||||||
|
*/
|
||||||
export interface AdminPostOrdersOrderReq {
|
export interface AdminPostOrdersOrderReq {
|
||||||
/**
|
/**
|
||||||
* The email associated with the order
|
* The email associated with the order
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the requested return.
|
||||||
|
*/
|
||||||
export interface AdminPostOrdersOrderReturnsReq {
|
export interface AdminPostOrdersOrderReturnsReq {
|
||||||
/**
|
/**
|
||||||
* The line items that will be returned.
|
* The line items that will be returned.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the shipment to create.
|
||||||
|
*/
|
||||||
export interface AdminPostOrdersOrderShipmentReq {
|
export interface AdminPostOrdersOrderShipmentReq {
|
||||||
/**
|
/**
|
||||||
* The ID of the Fulfillment.
|
* The ID of the Fulfillment.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the swap to create.
|
||||||
|
*/
|
||||||
export interface AdminPostOrdersOrderSwapsReq {
|
export interface AdminPostOrdersOrderSwapsReq {
|
||||||
/**
|
/**
|
||||||
* The Line Items to associate with the swap's return.
|
* The Line Items to associate with the swap's return.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the refund to create.
|
||||||
|
*/
|
||||||
export interface AdminPostPaymentRefundsReq {
|
export interface AdminPostPaymentRefundsReq {
|
||||||
/**
|
/**
|
||||||
* The amount to refund.
|
* The amount to refund.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { SetRelation, Merge } from "../core/ModelUtils"
|
import { SetRelation, Merge } from "../core/ModelUtils"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the prices to add.
|
||||||
|
*/
|
||||||
export interface AdminPostPriceListPricesPricesReq {
|
export interface AdminPostPriceListPricesPricesReq {
|
||||||
/**
|
/**
|
||||||
* The prices to update or add.
|
* The prices to update or add.
|
||||||
|
|||||||
Loaded 100 of 2811 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user