From 7dac50635577143d4f7ef1bd16cf7a45c3119e45 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Fri, 27 Dec 2024 14:48:38 +0530 Subject: [PATCH 1/2] docs: fix stonecrop documentation generation --- common/reviews/api/stonecrop.api.md | 156 +++++++++-- docs/stonecrop/stonecrop.baseschema.md | 17 ++ docs/stonecrop/stonecrop.cellcontext.md | 21 ++ .../stonecrop.doctypemeta._constructor_.md | 105 +++++++ .../stonecrop.doctypemeta.actions.md | 13 + .../stonecrop.doctypemeta.component.md | 13 + .../stonecrop.doctypemeta.doctype.md | 13 + docs/stonecrop/stonecrop.doctypemeta.md | 198 ++++++++++++++ .../stonecrop/stonecrop.doctypemeta.schema.md | 13 + docs/stonecrop/stonecrop.doctypemeta.slug.md | 13 + .../stonecrop.doctypemeta.workflow.md | 13 + docs/stonecrop/stonecrop.fieldsetschema.md | 19 ++ docs/stonecrop/stonecrop.formschema.md | 23 ++ docs/stonecrop/stonecrop.immutabledoctype.md | 19 ++ docs/stonecrop/stonecrop.installoptions.md | 19 ++ docs/stonecrop/stonecrop.md | 257 ++++++++++++++++++ docs/stonecrop/stonecrop.mutabledoctype.md | 19 ++ .../stonecrop.registry._constructor_.md | 63 +++++ docs/stonecrop/stonecrop.registry._root.md | 13 + .../stonecrop.registry.adddoctype.md | 55 ++++ docs/stonecrop/stonecrop.registry.getmeta.md | 13 + docs/stonecrop/stonecrop.registry.md | 203 ++++++++++++++ docs/stonecrop/stonecrop.registry.name.md | 13 + docs/stonecrop/stonecrop.registry.registry.md | 13 + docs/stonecrop/stonecrop.registry.router.md | 13 + docs/stonecrop/stonecrop.schema.md | 18 ++ docs/stonecrop/stonecrop.schematypes.md | 15 + docs/stonecrop/stonecrop.stonecrop.md | 38 +++ docs/stonecrop/stonecrop.stonecropreturn.md | 16 ++ docs/stonecrop/stonecrop.tablecolumn.md | 29 ++ docs/stonecrop/stonecrop.tableconfig.md | 16 ++ docs/stonecrop/stonecrop.tablerow.md | 17 ++ docs/stonecrop/stonecrop.tableschema.md | 19 ++ docs/stonecrop/stonecrop.usestonecrop.md | 59 ++++ .../default/config/api-extractor-task.json | 3 +- stonecrop/config/heft.json | 22 -- stonecrop/package.json | 4 +- stonecrop/src/composable.ts | 13 +- stonecrop/src/doctype.ts | 45 ++- stonecrop/src/index.ts | 7 +- stonecrop/src/plugins/index.ts | 28 ++ stonecrop/src/registry.ts | 34 +++ stonecrop/src/stonecrop.ts | 127 +++++---- stonecrop/src/types/index.ts | 16 ++ 44 files changed, 1734 insertions(+), 109 deletions(-) create mode 100644 docs/stonecrop/stonecrop.baseschema.md create mode 100644 docs/stonecrop/stonecrop.cellcontext.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta._constructor_.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.actions.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.component.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.doctype.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.schema.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.slug.md create mode 100644 docs/stonecrop/stonecrop.doctypemeta.workflow.md create mode 100644 docs/stonecrop/stonecrop.fieldsetschema.md create mode 100644 docs/stonecrop/stonecrop.formschema.md create mode 100644 docs/stonecrop/stonecrop.immutabledoctype.md create mode 100644 docs/stonecrop/stonecrop.installoptions.md create mode 100644 docs/stonecrop/stonecrop.mutabledoctype.md create mode 100644 docs/stonecrop/stonecrop.registry._constructor_.md create mode 100644 docs/stonecrop/stonecrop.registry._root.md create mode 100644 docs/stonecrop/stonecrop.registry.adddoctype.md create mode 100644 docs/stonecrop/stonecrop.registry.getmeta.md create mode 100644 docs/stonecrop/stonecrop.registry.md create mode 100644 docs/stonecrop/stonecrop.registry.name.md create mode 100644 docs/stonecrop/stonecrop.registry.registry.md create mode 100644 docs/stonecrop/stonecrop.registry.router.md create mode 100644 docs/stonecrop/stonecrop.schema.md create mode 100644 docs/stonecrop/stonecrop.schematypes.md create mode 100644 docs/stonecrop/stonecrop.stonecrop.md create mode 100644 docs/stonecrop/stonecrop.stonecropreturn.md create mode 100644 docs/stonecrop/stonecrop.tablecolumn.md create mode 100644 docs/stonecrop/stonecrop.tableconfig.md create mode 100644 docs/stonecrop/stonecrop.tablerow.md create mode 100644 docs/stonecrop/stonecrop.tableschema.md create mode 100644 docs/stonecrop/stonecrop.usestonecrop.md delete mode 100644 stonecrop/config/heft.json diff --git a/common/reviews/api/stonecrop.api.md b/common/reviews/api/stonecrop.api.md index c1903c05..af4befe6 100644 --- a/common/reviews/api/stonecrop.api.md +++ b/common/reviews/api/stonecrop.api.md @@ -4,30 +4,154 @@ ```ts -import DoctypeMeta from '@/doctype'; -import { ImmutableDoctype } from '@/types'; -import { InstallOptions } from '@/types'; -import { MutableDoctype } from '@/types'; -import Registry from '@/registry'; -import { Schema } from '@/types'; -import Stonecrop from '@/plugins'; -import { useStonecrop } from '@/composable'; +import { Component } from 'vue'; +import { List } from 'immutable'; +import { MachineConfig } from 'xstate'; +import { Map as Map_2 } from 'immutable'; +import { Plugin as Plugin_2 } from 'vue'; +import { Ref } from 'vue'; +import { Router } from 'vue-router'; +import { StateMachine } from 'xstate'; +import { StoreDefinition } from 'pinia'; -export { DoctypeMeta } +// @public +export type BaseSchema = { + fieldname: string; + component?: string; + value?: any; +}; -export { ImmutableDoctype } +// @public +export type CellContext = { + row: TableRow; + column: TableColumn; + table: { + [key: string]: any; + }; +}; -export { InstallOptions } +// @public +export class DoctypeMeta { + constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component); + readonly actions: ImmutableDoctype['actions']; + readonly component?: Component; + readonly doctype: string; + readonly schema: ImmutableDoctype['schema']; + get slug(): string; + readonly workflow: ImmutableDoctype['workflow']; +} -export { MutableDoctype } +// @public +export type FieldsetSchema = BaseSchema & { + label?: string; + schema?: (FormSchema | TableSchema)[]; + collapsible?: boolean; +}; -export { Registry } +// @public +export type FormSchema = BaseSchema & { + align?: string; + edit?: boolean; + fieldtype?: string; + label?: string; + name?: string; + width?: string; + mask?: string; +}; -export { Schema } +// @public +export type ImmutableDoctype = { + readonly schema?: List; + readonly workflow: StateMachine; + readonly actions?: Map_2; +}; -export { Stonecrop } +// @public +export type InstallOptions = { + router?: Router; + components?: Record; + getMeta?: (doctype?: string) => DoctypeMeta | Promise; +}; -export { useStonecrop } +// @public +export type MutableDoctype = { + schema?: SchemaTypes[]; + workflow: MachineConfig; + actions?: Record; +}; + +// @public +export class Registry { + constructor(router: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise); + addDoctype(doctype: DoctypeMeta): void; + getMeta?: (doctype: string) => DoctypeMeta | Promise; + name: string; + registry: Record; + static _root: Registry; + router: Router; +} + +// @public +export type Schema = { + doctype: string; + schema: List; +}; + +// @public +export type SchemaTypes = FormSchema | TableSchema | FieldsetSchema; + +// @public +export const Stonecrop: Plugin_2; + +// @public +export type StonecropReturn = { + stonecrop: Ref; + isReady: Ref; +}; + +// @public +export type TableColumn = { + name: string; + align?: CanvasTextAlign; + edit?: boolean; + label?: string; + type?: string; + width?: string; + pinned?: boolean; + cellComponent?: string; + cellComponentProps?: Record; + modalComponent?: string | ((context: CellContext) => string); + modalComponentExtraProps?: Record; + format?: string | ((value: any, context: CellContext) => string); + mask?: (value: any) => any; +}; + +// @public +export type TableConfig = { + view?: 'uncounted' | 'list' | 'list-expansion' | 'tree'; + fullWidth?: boolean; +}; + +// @public +export type TableRow = { + [key: string]: any; + indent?: number; + parent?: number; +}; + +// @public +export type TableSchema = BaseSchema & { + columns?: TableColumn[]; + config?: TableConfig; + rows?: TableRow[]; +}; + +// @public +export function useStonecrop(registry?: Registry): StonecropReturn; + +// Warnings were encountered during analysis: +// +// src/composable.ts:12:2 - (ae-forgotten-export) The symbol "Stonecrop_2" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/docs/stonecrop/stonecrop.baseschema.md b/docs/stonecrop/stonecrop.baseschema.md new file mode 100644 index 00000000..43d2aa31 --- /dev/null +++ b/docs/stonecrop/stonecrop.baseschema.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [BaseSchema](./stonecrop.baseschema.md) + +## BaseSchema type + +Basic field structure for AForm schemas + +**Signature:** + +```typescript +export type BaseSchema = { + fieldname: string; + component?: string; + value?: any; +}; +``` diff --git a/docs/stonecrop/stonecrop.cellcontext.md b/docs/stonecrop/stonecrop.cellcontext.md new file mode 100644 index 00000000..3704d071 --- /dev/null +++ b/docs/stonecrop/stonecrop.cellcontext.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [CellContext](./stonecrop.cellcontext.md) + +## CellContext type + +Table cell context definition. + +**Signature:** + +```typescript +export type CellContext = { + row: TableRow; + column: TableColumn; + table: { + [key: string]: any; + }; +}; +``` +**References:** [TableRow](./stonecrop.tablerow.md), [TableColumn](./stonecrop.tablecolumn.md) + diff --git a/docs/stonecrop/stonecrop.doctypemeta._constructor_.md b/docs/stonecrop/stonecrop.doctypemeta._constructor_.md new file mode 100644 index 00000000..1c3849d9 --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta._constructor_.md @@ -0,0 +1,105 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [(constructor)](./stonecrop.doctypemeta._constructor_.md) + +## DoctypeMeta.(constructor) + +Constructs a new instance of the `DoctypeMeta` class + +**Signature:** + +```typescript +constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component); +``` + +## Parameters + + + + + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +doctype + + + + +string + + + + + +
+ +schema + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['schema'\] + + + + + +
+ +workflow + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['workflow'\] + + + + + +
+ +actions + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['actions'\] + + + + + +
+ +component + + + + +Component + + + + +_(Optional)_ + + +
diff --git a/docs/stonecrop/stonecrop.doctypemeta.actions.md b/docs/stonecrop/stonecrop.doctypemeta.actions.md new file mode 100644 index 00000000..63045454 --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.actions.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [actions](./stonecrop.doctypemeta.actions.md) + +## DoctypeMeta.actions property + +The doctype actions + +**Signature:** + +```typescript +readonly actions: ImmutableDoctype['actions']; +``` diff --git a/docs/stonecrop/stonecrop.doctypemeta.component.md b/docs/stonecrop/stonecrop.doctypemeta.component.md new file mode 100644 index 00000000..5db4f62e --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.component.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [component](./stonecrop.doctypemeta.component.md) + +## DoctypeMeta.component property + +The doctype component + +**Signature:** + +```typescript +readonly component?: Component; +``` diff --git a/docs/stonecrop/stonecrop.doctypemeta.doctype.md b/docs/stonecrop/stonecrop.doctypemeta.doctype.md new file mode 100644 index 00000000..0e47122e --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.doctype.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [doctype](./stonecrop.doctypemeta.doctype.md) + +## DoctypeMeta.doctype property + +The doctype name + +**Signature:** + +```typescript +readonly doctype: string; +``` diff --git a/docs/stonecrop/stonecrop.doctypemeta.md b/docs/stonecrop/stonecrop.doctypemeta.md new file mode 100644 index 00000000..093d690b --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.md @@ -0,0 +1,198 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) + +## DoctypeMeta class + +Doctype Meta class + +**Signature:** + +```typescript +export default class DoctypeMeta +``` + +## Constructors + + + +
+ +Constructor + + + + +Modifiers + + + + +Description + + +
+ +[(constructor)(doctype, schema, workflow, actions, component)](./stonecrop.doctypemeta._constructor_.md) + + + + + + + +Constructs a new instance of the `DoctypeMeta` class + + +
+ +## Properties + + + + + + + + +
+ +Property + + + + +Modifiers + + + + +Type + + + + +Description + + +
+ +[actions](./stonecrop.doctypemeta.actions.md) + + + + +`readonly` + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['actions'\] + + + + +The doctype actions + + +
+ +[component?](./stonecrop.doctypemeta.component.md) + + + + +`readonly` + + + + +Component + + + + +_(Optional)_ The doctype component + + +
+ +[doctype](./stonecrop.doctypemeta.doctype.md) + + + + +`readonly` + + + + +string + + + + +The doctype name + + +
+ +[schema](./stonecrop.doctypemeta.schema.md) + + + + +`readonly` + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['schema'\] + + + + +The doctype schema + + +
+ +[slug](./stonecrop.doctypemeta.slug.md) + + + + +`readonly` + + + + +string + + + + +Converts the registered doctype to a slug (kebab-case) + + +
+ +[workflow](./stonecrop.doctypemeta.workflow.md) + + + + +`readonly` + + + + +[ImmutableDoctype](./stonecrop.immutabledoctype.md)\['workflow'\] + + + + +The doctype workflow + + +
diff --git a/docs/stonecrop/stonecrop.doctypemeta.schema.md b/docs/stonecrop/stonecrop.doctypemeta.schema.md new file mode 100644 index 00000000..f493f89e --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.schema.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [schema](./stonecrop.doctypemeta.schema.md) + +## DoctypeMeta.schema property + +The doctype schema + +**Signature:** + +```typescript +readonly schema: ImmutableDoctype['schema']; +``` diff --git a/docs/stonecrop/stonecrop.doctypemeta.slug.md b/docs/stonecrop/stonecrop.doctypemeta.slug.md new file mode 100644 index 00000000..bcad0152 --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.slug.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [slug](./stonecrop.doctypemeta.slug.md) + +## DoctypeMeta.slug property + +Converts the registered doctype to a slug (kebab-case) + +**Signature:** + +```typescript +get slug(): string; +``` diff --git a/docs/stonecrop/stonecrop.doctypemeta.workflow.md b/docs/stonecrop/stonecrop.doctypemeta.workflow.md new file mode 100644 index 00000000..57b5f7ef --- /dev/null +++ b/docs/stonecrop/stonecrop.doctypemeta.workflow.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [DoctypeMeta](./stonecrop.doctypemeta.md) > [workflow](./stonecrop.doctypemeta.workflow.md) + +## DoctypeMeta.workflow property + +The doctype workflow + +**Signature:** + +```typescript +readonly workflow: ImmutableDoctype['workflow']; +``` diff --git a/docs/stonecrop/stonecrop.fieldsetschema.md b/docs/stonecrop/stonecrop.fieldsetschema.md new file mode 100644 index 00000000..6572e01c --- /dev/null +++ b/docs/stonecrop/stonecrop.fieldsetschema.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [FieldsetSchema](./stonecrop.fieldsetschema.md) + +## FieldsetSchema type + +Schema structure for defining fieldsets inside AForm + +**Signature:** + +```typescript +export type FieldsetSchema = BaseSchema & { + label?: string; + schema?: (FormSchema | TableSchema)[]; + collapsible?: boolean; +}; +``` +**References:** [BaseSchema](./stonecrop.baseschema.md), [FormSchema](./stonecrop.formschema.md), [TableSchema](./stonecrop.tableschema.md) + diff --git a/docs/stonecrop/stonecrop.formschema.md b/docs/stonecrop/stonecrop.formschema.md new file mode 100644 index 00000000..62ebf850 --- /dev/null +++ b/docs/stonecrop/stonecrop.formschema.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [FormSchema](./stonecrop.formschema.md) + +## FormSchema type + +Schema structure for defining forms inside AForm + +**Signature:** + +```typescript +export type FormSchema = BaseSchema & { + align?: string; + edit?: boolean; + fieldtype?: string; + label?: string; + name?: string; + width?: string; + mask?: string; +}; +``` +**References:** [BaseSchema](./stonecrop.baseschema.md) + diff --git a/docs/stonecrop/stonecrop.immutabledoctype.md b/docs/stonecrop/stonecrop.immutabledoctype.md new file mode 100644 index 00000000..c1af0a64 --- /dev/null +++ b/docs/stonecrop/stonecrop.immutabledoctype.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [ImmutableDoctype](./stonecrop.immutabledoctype.md) + +## ImmutableDoctype type + +Immutable Doctype type for Stonecrop instances + +**Signature:** + +```typescript +export type ImmutableDoctype = { + readonly schema?: List; + readonly workflow: StateMachine; + readonly actions?: Map; +}; +``` +**References:** [SchemaTypes](./stonecrop.schematypes.md) + diff --git a/docs/stonecrop/stonecrop.installoptions.md b/docs/stonecrop/stonecrop.installoptions.md new file mode 100644 index 00000000..a676683c --- /dev/null +++ b/docs/stonecrop/stonecrop.installoptions.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [InstallOptions](./stonecrop.installoptions.md) + +## InstallOptions type + +Install options for Stonecrop Vue plugin + +**Signature:** + +```typescript +export type InstallOptions = { + router?: Router; + components?: Record; + getMeta?: (doctype?: string) => DoctypeMeta | Promise; +}; +``` +**References:** [DoctypeMeta](./stonecrop.doctypemeta.md) + diff --git a/docs/stonecrop/stonecrop.md b/docs/stonecrop/stonecrop.md index aaeae1f8..bac6889c 100644 --- a/docs/stonecrop/stonecrop.md +++ b/docs/stonecrop/stonecrop.md @@ -4,3 +4,260 @@ ## stonecrop package +## Classes + + + + +
+ +Class + + + + +Description + + +
+ +[DoctypeMeta](./stonecrop.doctypemeta.md) + + + + +Doctype Meta class + + +
+ +[Registry](./stonecrop.registry.md) + + + + +Stonecrop Registry class + + +
+ +## Functions + + + +
+ +Function + + + + +Description + + +
+ +[useStonecrop(registry)](./stonecrop.usestonecrop.md) + + + + +Stonecrop composable + + +
+ +## Variables + + + +
+ +Variable + + + + +Description + + +
+ +[Stonecrop](./stonecrop.stonecrop.md) + + + + +Stonecrop Vue plugin + + +
+ +## Type Aliases + + + + + + + + + + + + + + + + +
+ +Type Alias + + + + +Description + + +
+ +[BaseSchema](./stonecrop.baseschema.md) + + + + +Basic field structure for AForm schemas + + +
+ +[CellContext](./stonecrop.cellcontext.md) + + + + +Table cell context definition. + + +
+ +[FieldsetSchema](./stonecrop.fieldsetschema.md) + + + + +Schema structure for defining fieldsets inside AForm + + +
+ +[FormSchema](./stonecrop.formschema.md) + + + + +Schema structure for defining forms inside AForm + + +
+ +[ImmutableDoctype](./stonecrop.immutabledoctype.md) + + + + +Immutable Doctype type for Stonecrop instances + + +
+ +[InstallOptions](./stonecrop.installoptions.md) + + + + +Install options for Stonecrop Vue plugin + + +
+ +[MutableDoctype](./stonecrop.mutabledoctype.md) + + + + +Mutable Doctype type for Stonecrop instances + + +
+ +[Schema](./stonecrop.schema.md) + + + + +Schema type for Stonecrop instances + + +
+ +[SchemaTypes](./stonecrop.schematypes.md) + + + + +Superset of all schema types for AForm + + +
+ +[StonecropReturn](./stonecrop.stonecropreturn.md) + + + + +Stonecrop composable return type + + +
+ +[TableColumn](./stonecrop.tablecolumn.md) + + + + +Table column definition. + + +
+ +[TableConfig](./stonecrop.tableconfig.md) + + + + +Table configuration definition. + + +
+ +[TableRow](./stonecrop.tablerow.md) + + + + +Table row definition. + + +
+ +[TableSchema](./stonecrop.tableschema.md) + + + + +Schema structure for defining tables inside AForm + + +
diff --git a/docs/stonecrop/stonecrop.mutabledoctype.md b/docs/stonecrop/stonecrop.mutabledoctype.md new file mode 100644 index 00000000..c17d61e9 --- /dev/null +++ b/docs/stonecrop/stonecrop.mutabledoctype.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [MutableDoctype](./stonecrop.mutabledoctype.md) + +## MutableDoctype type + +Mutable Doctype type for Stonecrop instances + +**Signature:** + +```typescript +export type MutableDoctype = { + schema?: SchemaTypes[]; + workflow: MachineConfig; + actions?: Record; +}; +``` +**References:** [SchemaTypes](./stonecrop.schematypes.md) + diff --git a/docs/stonecrop/stonecrop.registry._constructor_.md b/docs/stonecrop/stonecrop.registry._constructor_.md new file mode 100644 index 00000000..c9c2d0ec --- /dev/null +++ b/docs/stonecrop/stonecrop.registry._constructor_.md @@ -0,0 +1,63 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [(constructor)](./stonecrop.registry._constructor_.md) + +## Registry.(constructor) + +Constructs a new instance of the `Registry` class + +**Signature:** + +```typescript +constructor(router: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise); +``` + +## Parameters + + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +router + + + + +Router + + + + + +
+ +getMeta + + + + +(doctype: string) => [DoctypeMeta](./stonecrop.doctypemeta.md) \| Promise<[DoctypeMeta](./stonecrop.doctypemeta.md)> + + + + +_(Optional)_ + + +
diff --git a/docs/stonecrop/stonecrop.registry._root.md b/docs/stonecrop/stonecrop.registry._root.md new file mode 100644 index 00000000..a8575a99 --- /dev/null +++ b/docs/stonecrop/stonecrop.registry._root.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [\_root](./stonecrop.registry._root.md) + +## Registry.\_root property + +The root Registry instance + +**Signature:** + +```typescript +static _root: Registry; +``` diff --git a/docs/stonecrop/stonecrop.registry.adddoctype.md b/docs/stonecrop/stonecrop.registry.adddoctype.md new file mode 100644 index 00000000..714687ac --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.adddoctype.md @@ -0,0 +1,55 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [addDoctype](./stonecrop.registry.adddoctype.md) + +## Registry.addDoctype() method + +Get doctype metadata + +**Signature:** + +```typescript +addDoctype(doctype: DoctypeMeta): void; +``` + +## Parameters + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +doctype + + + + +[DoctypeMeta](./stonecrop.doctypemeta.md) + + + + +The doctype to fetch metadata for + + +
+**Returns:** + +void + +The doctype metadata + diff --git a/docs/stonecrop/stonecrop.registry.getmeta.md b/docs/stonecrop/stonecrop.registry.getmeta.md new file mode 100644 index 00000000..16bfb922 --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.getmeta.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [getMeta](./stonecrop.registry.getmeta.md) + +## Registry.getMeta property + +The getMeta function fetches doctype metadata from an API + +**Signature:** + +```typescript +getMeta?: (doctype: string) => DoctypeMeta | Promise; +``` diff --git a/docs/stonecrop/stonecrop.registry.md b/docs/stonecrop/stonecrop.registry.md new file mode 100644 index 00000000..5b4738cf --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.md @@ -0,0 +1,203 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) + +## Registry class + +Stonecrop Registry class + +**Signature:** + +```typescript +export default class Registry +``` + +## Constructors + + + +
+ +Constructor + + + + +Modifiers + + + + +Description + + +
+ +[(constructor)(router, getMeta)](./stonecrop.registry._constructor_.md) + + + + + + + +Constructs a new instance of the `Registry` class + + +
+ +## Properties + + + + + + + +
+ +Property + + + + +Modifiers + + + + +Type + + + + +Description + + +
+ +[\_root](./stonecrop.registry._root.md) + + + + +`static` + + + + +[Registry](./stonecrop.registry.md) + + + + +The root Registry instance + + +
+ +[getMeta?](./stonecrop.registry.getmeta.md) + + + + + + + +(doctype: string) => [DoctypeMeta](./stonecrop.doctypemeta.md) \| Promise<[DoctypeMeta](./stonecrop.doctypemeta.md)> + + + + +_(Optional)_ The getMeta function fetches doctype metadata from an API + + +
+ +[name](./stonecrop.registry.name.md) + + + + + + + +string + + + + +The name of the Registry instance + + +
+ +[registry](./stonecrop.registry.registry.md) + + + + + + + +Record<string, [DoctypeMeta](./stonecrop.doctypemeta.md)> + + + + +The registry property contains a collection of doctypes + + +
+ +[router](./stonecrop.registry.router.md) + + + + + + + +Router + + + + +The Vue router instance + + +
+ +## Methods + + + +
+ +Method + + + + +Modifiers + + + + +Description + + +
+ +[addDoctype(doctype)](./stonecrop.registry.adddoctype.md) + + + + + + + +Get doctype metadata + + +
diff --git a/docs/stonecrop/stonecrop.registry.name.md b/docs/stonecrop/stonecrop.registry.name.md new file mode 100644 index 00000000..9e1bfa64 --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.name.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [name](./stonecrop.registry.name.md) + +## Registry.name property + +The name of the Registry instance + +**Signature:** + +```typescript +name: string; +``` diff --git a/docs/stonecrop/stonecrop.registry.registry.md b/docs/stonecrop/stonecrop.registry.registry.md new file mode 100644 index 00000000..cbce7989 --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.registry.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [registry](./stonecrop.registry.registry.md) + +## Registry.registry property + +The registry property contains a collection of doctypes + +**Signature:** + +```typescript +registry: Record; +``` diff --git a/docs/stonecrop/stonecrop.registry.router.md b/docs/stonecrop/stonecrop.registry.router.md new file mode 100644 index 00000000..c8902dd7 --- /dev/null +++ b/docs/stonecrop/stonecrop.registry.router.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Registry](./stonecrop.registry.md) > [router](./stonecrop.registry.router.md) + +## Registry.router property + +The Vue router instance + +**Signature:** + +```typescript +router: Router; +``` diff --git a/docs/stonecrop/stonecrop.schema.md b/docs/stonecrop/stonecrop.schema.md new file mode 100644 index 00000000..38fff20b --- /dev/null +++ b/docs/stonecrop/stonecrop.schema.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Schema](./stonecrop.schema.md) + +## Schema type + +Schema type for Stonecrop instances + +**Signature:** + +```typescript +export type Schema = { + doctype: string; + schema: List; +}; +``` +**References:** [SchemaTypes](./stonecrop.schematypes.md) + diff --git a/docs/stonecrop/stonecrop.schematypes.md b/docs/stonecrop/stonecrop.schematypes.md new file mode 100644 index 00000000..f322500d --- /dev/null +++ b/docs/stonecrop/stonecrop.schematypes.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [SchemaTypes](./stonecrop.schematypes.md) + +## SchemaTypes type + +Superset of all schema types for AForm + +**Signature:** + +```typescript +export type SchemaTypes = FormSchema | TableSchema | FieldsetSchema; +``` +**References:** [FormSchema](./stonecrop.formschema.md), [TableSchema](./stonecrop.tableschema.md), [FieldsetSchema](./stonecrop.fieldsetschema.md) + diff --git a/docs/stonecrop/stonecrop.stonecrop.md b/docs/stonecrop/stonecrop.stonecrop.md new file mode 100644 index 00000000..005af91a --- /dev/null +++ b/docs/stonecrop/stonecrop.stonecrop.md @@ -0,0 +1,38 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [Stonecrop](./stonecrop.stonecrop.md) + +## Stonecrop variable + +Stonecrop Vue plugin + +**Signature:** + +```typescript +plugin: Plugin +``` + +## Example + + +```ts + +import { createApp } from 'vue' +import Stonecrop from 'stonecrop' + +import App from './App.vue' + +const app = createApp(App) +app.use(Stonecrop, { + router, + components: { + // register custom components + }, + getMeta: async (doctype: string) => { + // fetch doctype meta from API + }, +}) + +app.mount('#app') +``` + diff --git a/docs/stonecrop/stonecrop.stonecropreturn.md b/docs/stonecrop/stonecrop.stonecropreturn.md new file mode 100644 index 00000000..4ec4ea4f --- /dev/null +++ b/docs/stonecrop/stonecrop.stonecropreturn.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [StonecropReturn](./stonecrop.stonecropreturn.md) + +## StonecropReturn type + +Stonecrop composable return type + +**Signature:** + +```typescript +export type StonecropReturn = { + stonecrop: Ref; + isReady: Ref; +}; +``` diff --git a/docs/stonecrop/stonecrop.tablecolumn.md b/docs/stonecrop/stonecrop.tablecolumn.md new file mode 100644 index 00000000..760b37e5 --- /dev/null +++ b/docs/stonecrop/stonecrop.tablecolumn.md @@ -0,0 +1,29 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [TableColumn](./stonecrop.tablecolumn.md) + +## TableColumn type + +Table column definition. + +**Signature:** + +```typescript +export type TableColumn = { + name: string; + align?: CanvasTextAlign; + edit?: boolean; + label?: string; + type?: string; + width?: string; + pinned?: boolean; + cellComponent?: string; + cellComponentProps?: Record; + modalComponent?: string | ((context: CellContext) => string); + modalComponentExtraProps?: Record; + format?: string | ((value: any, context: CellContext) => string); + mask?: (value: any) => any; +}; +``` +**References:** [CellContext](./stonecrop.cellcontext.md) + diff --git a/docs/stonecrop/stonecrop.tableconfig.md b/docs/stonecrop/stonecrop.tableconfig.md new file mode 100644 index 00000000..5cbf6dd8 --- /dev/null +++ b/docs/stonecrop/stonecrop.tableconfig.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [TableConfig](./stonecrop.tableconfig.md) + +## TableConfig type + +Table configuration definition. + +**Signature:** + +```typescript +export type TableConfig = { + view?: 'uncounted' | 'list' | 'list-expansion' | 'tree'; + fullWidth?: boolean; +}; +``` diff --git a/docs/stonecrop/stonecrop.tablerow.md b/docs/stonecrop/stonecrop.tablerow.md new file mode 100644 index 00000000..03b3f123 --- /dev/null +++ b/docs/stonecrop/stonecrop.tablerow.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [TableRow](./stonecrop.tablerow.md) + +## TableRow type + +Table row definition. + +**Signature:** + +```typescript +export type TableRow = { + [key: string]: any; + indent?: number; + parent?: number; +}; +``` diff --git a/docs/stonecrop/stonecrop.tableschema.md b/docs/stonecrop/stonecrop.tableschema.md new file mode 100644 index 00000000..e2f70125 --- /dev/null +++ b/docs/stonecrop/stonecrop.tableschema.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [TableSchema](./stonecrop.tableschema.md) + +## TableSchema type + +Schema structure for defining tables inside AForm + +**Signature:** + +```typescript +export type TableSchema = BaseSchema & { + columns?: TableColumn[]; + config?: TableConfig; + rows?: TableRow[]; +}; +``` +**References:** [BaseSchema](./stonecrop.baseschema.md), [TableColumn](./stonecrop.tablecolumn.md), [TableConfig](./stonecrop.tableconfig.md), [TableRow](./stonecrop.tablerow.md) + diff --git a/docs/stonecrop/stonecrop.usestonecrop.md b/docs/stonecrop/stonecrop.usestonecrop.md new file mode 100644 index 00000000..c7b5bde2 --- /dev/null +++ b/docs/stonecrop/stonecrop.usestonecrop.md @@ -0,0 +1,59 @@ + + +[Home](./index.md) > [@stonecrop/stonecrop](./stonecrop.md) > [useStonecrop](./stonecrop.usestonecrop.md) + +## useStonecrop() function + +Stonecrop composable + +**Signature:** + +```typescript +export declare function useStonecrop(registry?: Registry): StonecropReturn; +``` + +## Parameters + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +registry + + + + +[Registry](./stonecrop.registry.md) + + + + +_(Optional)_ An existing Stonecrop Registry instance + + +
+**Returns:** + +[StonecropReturn](./stonecrop.stonecropreturn.md) + +The Stonecrop instance and a boolean indicating if Stonecrop is setup and ready + +## Exceptions + +Error if the Stonecrop plugin is not enabled before using the composable + diff --git a/rigs/stonecrop-rig/profiles/default/config/api-extractor-task.json b/rigs/stonecrop-rig/profiles/default/config/api-extractor-task.json index 56721e9b..ecc329c2 100644 --- a/rigs/stonecrop-rig/profiles/default/config/api-extractor-task.json +++ b/rigs/stonecrop-rig/profiles/default/config/api-extractor-task.json @@ -1,4 +1,3 @@ { - "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/api-extractor-task.schema.json", - "useProjectTypescriptVersion": true + "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/api-extractor-task.schema.json" } diff --git a/stonecrop/config/heft.json b/stonecrop/config/heft.json deleted file mode 100644 index 99244526..00000000 --- a/stonecrop/config/heft.json +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Defines configuration used by core Heft. - */ -{ - "$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json", - - "phasesByName": { - "build": { - "phaseDescription": "This phase compiles the project source code.", - - "cleanFiles": [{ "sourcePath": "dist" }], - - "tasksByName": { - "typescript": { - "taskPlugin": { - "pluginPackage": "@rushstack/heft-typescript-plugin" - } - } - } - } - } -} diff --git a/stonecrop/package.json b/stonecrop/package.json index 825427c7..27c13de1 100644 --- a/stonecrop/package.json +++ b/stonecrop/package.json @@ -31,8 +31,8 @@ "src/*" ], "scripts": { - "prepublish": "heft build && vite build", - "build": "heft build && vite build", + "prepublish": "heft build && vite build && rushx docs", + "build": "heft build && vite build && rushx docs", "docs": "api-documenter markdown -i temp -o ../docs/stonecrop", "lint": "eslint . --ext .ts,.vue", "preview": "vite preview" diff --git a/stonecrop/src/composable.ts b/stonecrop/src/composable.ts index 43e39215..090d201a 100644 --- a/stonecrop/src/composable.ts +++ b/stonecrop/src/composable.ts @@ -4,11 +4,22 @@ import Registry from './registry' import { Stonecrop } from './stonecrop' import { useDataStore } from './stores/data' -type StonecropReturn = { +/** + * Stonecrop composable return type + * @public + */ +export type StonecropReturn = { stonecrop: Ref isReady: Ref } +/** + * Stonecrop composable + * @param registry - An existing Stonecrop Registry instance + * @returns The Stonecrop instance and a boolean indicating if Stonecrop is setup and ready + * @throws Error if the Stonecrop plugin is not enabled before using the composable + * @public + */ export function useStonecrop(registry?: Registry): StonecropReturn { if (!registry) { registry = inject('$registry') diff --git a/stonecrop/src/doctype.ts b/stonecrop/src/doctype.ts index 050b5316..3b67d3ba 100644 --- a/stonecrop/src/doctype.ts +++ b/stonecrop/src/doctype.ts @@ -2,14 +2,47 @@ import { Component } from 'vue' import type { ImmutableDoctype } from './types' +/** + * Doctype Meta class + * @public + */ export default class DoctypeMeta { + /** + * The doctype name + * @public + * @readonly + */ readonly doctype: string + + /** + * The doctype schema + * @public + * @readonly + */ readonly schema: ImmutableDoctype['schema'] + + /** + * The doctype workflow + * @public + * @readonly + */ readonly workflow: ImmutableDoctype['workflow'] + + /** + * The doctype actions + * @public + * @readonly + */ readonly actions: ImmutableDoctype['actions'] + + /** + * The doctype component + * @public + * @readonly + */ + readonly component?: Component // TODO: allow different components for different views; probably // should be defined in the schema instead? - readonly component?: Component constructor( doctype: string, @@ -25,15 +58,15 @@ export default class DoctypeMeta { this.component = component } + /** + * Converts the registered doctype to a slug (kebab-case) + * @returns The slugified doctype string + * @public + */ get slug() { - // kebab case return this.doctype .replace(/([a-z])([A-Z])/g, '$1-$2') .replace(/[\s_]+/g, '-') .toLowerCase() } - - get __typename() { - return this.doctype - } } diff --git a/stonecrop/src/index.ts b/stonecrop/src/index.ts index e9192138..04294f8d 100644 --- a/stonecrop/src/index.ts +++ b/stonecrop/src/index.ts @@ -1,7 +1,10 @@ -import { useStonecrop } from './composable' +export type { BaseSchema, FieldsetSchema, FormSchema, SchemaTypes, TableSchema } from '@stonecrop/aform' +export type { CellContext, TableColumn, TableConfig, TableRow } from '@stonecrop/atable' + +import { type StonecropReturn, useStonecrop } from './composable' import DoctypeMeta from './doctype' import Registry from './registry' import Stonecrop from './plugins' export type { ImmutableDoctype, MutableDoctype, Schema, InstallOptions } from './types' -export { DoctypeMeta, Registry, Stonecrop, useStonecrop } +export { DoctypeMeta, Registry, Stonecrop, StonecropReturn, useStonecrop } diff --git a/stonecrop/src/plugins/index.ts b/stonecrop/src/plugins/index.ts index 2d4e1eac..6a41e716 100644 --- a/stonecrop/src/plugins/index.ts +++ b/stonecrop/src/plugins/index.ts @@ -5,6 +5,34 @@ import router from '../router' import { pinia } from '../stores' import type { InstallOptions } from '../types' +/** + * Stonecrop Vue plugin + * @param app - The Vue app instance + * @param options - The plugin options + * @example + * ```ts + * + * import { createApp } from 'vue' + * import Stonecrop from 'stonecrop' + * + * import App from './App.vue' + * + * const app = createApp(App) + * app.use(Stonecrop, { + * router, + * components: { + * // register custom components + * }, + * getMeta: async (doctype: string) => { + * // fetch doctype meta from API + * }, + * }) + * + * app.mount('#app') + * ``` + * + * @public + */ const plugin: Plugin = { install: (app: App, options?: InstallOptions) => { const appRouter = options?.router || router diff --git a/stonecrop/src/registry.ts b/stonecrop/src/registry.ts index 2f215e9b..3b78e958 100644 --- a/stonecrop/src/registry.ts +++ b/stonecrop/src/registry.ts @@ -2,11 +2,39 @@ import { Router } from 'vue-router' import DoctypeMeta from './doctype' +/** + * Stonecrop Registry class + * @public + */ export default class Registry { + /** + * The root Registry instance + */ static _root: Registry + + /** + * The name of the Registry instance + * + * @defaultValue 'Registry' + */ name: string + + /** + * The Vue router instance + * @see {@link https://router.vuejs.org/} + */ router: Router + + /** + * The registry property contains a collection of doctypes + * @see {@link DoctypeMeta} + */ registry: Record + + /** + * The getMeta function fetches doctype metadata from an API + * @see {@link DoctypeMeta} + */ getMeta?: (doctype: string) => DoctypeMeta | Promise constructor(router: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise) { @@ -20,6 +48,12 @@ export default class Registry { this.getMeta = getMeta } + /** + * Get doctype metadata + * @param doctype - The doctype to fetch metadata for + * @returns The doctype metadata + * @see {@link DoctypeMeta} + */ addDoctype(doctype: DoctypeMeta) { if (!(doctype.doctype in Object.keys(this.registry))) { this.registry[doctype.slug] = doctype diff --git a/stonecrop/src/stonecrop.ts b/stonecrop/src/stonecrop.ts index e8b7d674..577c21f8 100644 --- a/stonecrop/src/stonecrop.ts +++ b/stonecrop/src/stonecrop.ts @@ -4,25 +4,28 @@ import Registry from './registry' import { useDataStore } from './stores/data' import type { ImmutableDoctype, Schema } from './types' +/** + * Stonecrop class + * @public + */ export class Stonecrop { /** - * @property {Stonecrop} _root - * @description The root Stonecrop instance + * The root Stonecrop instance */ static _root: Stonecrop /** - * @property {string} name - * @description The name of the Stonecrop instance - * @example - * 'Stonecrop' + * The name of the Stonecrop instance + * @readonly + * + * @defaultValue 'Stonecrop' */ readonly name = 'Stonecrop' /** - * @property {Registry} registry - * @description The registry is an immutable collection of doctypes + * The registry is an immutable collection of doctypes * @example + * ```ts * { * 'task': { * doctype: 'Task', @@ -34,15 +37,16 @@ export class Stonecrop { * }, * ... * } + * ``` * @see {@link Registry} * @see {@link DoctypeMeta} */ readonly registry: Registry /** - * @property {Schema} schema - The Stonecrop schema - * @description The schema is a subset of the registry + * schema - The Stonecrop schema; the schema is a subset of the registry * @example + * ```ts * { * doctype: 'Task', * schema: { @@ -51,6 +55,7 @@ export class Stonecrop { * ... * } * } + * ``` * @see {@link Registry} * @see {@link DoctypeMeta} * @see {@link DoctypeMeta.schema} @@ -58,36 +63,33 @@ export class Stonecrop { schema: Schema /** - * @property {ImmutableDoctype['workflow']} workflow - * @description The workflow is a subset of the registry + * The workflow is a subset of the registry */ workflow: ImmutableDoctype['workflow'] /** - * @property {ImmutableDoctype['actions']} actions - * @description The actions are a subset of the registry + * The actions are a subset of the registry */ actions: ImmutableDoctype['actions'] /** - * @property {ReturnType} store - * @description The Pinia store that manages the mutable records + * The Pinia store that manages the mutable records */ store: ReturnType /** - * @constructor - * @param {Registry} registry - The immutable registry - * @param {ReturnType} store - The mutable Pinia store - * @param {Schema} [schema] - (optional) The Stonecrop schema - * @param {ImmutableDoctype['workflow']} [workflow] - (optional) The Stonecrop workflow - * @param {ImmutableDoctype['actions']} [actions] - (optional) The Stonecrop actions - * @returns {Stonecrop} The Stonecrop instance - * @description The Stonecrop constructor initializes a new Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one. + * @param registry - The immutable registry + * @param store - The mutable Pinia store + * @param schema - The Stonecrop schema + * @param workflow - The Stonecrop workflow + * @param actions - The Stonecrop actions + * @returns The Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one. * @example + * ```ts * const registry = new Registry() * const store = useDataStore() - * const stonecrop = new Stonecrop(registry, store, schema, workflow, actions) + * const stonecrop = new Stonecrop(registry, store) + * ``` */ constructor( registry: Registry, @@ -108,13 +110,13 @@ export class Stonecrop { } /** - * @method setup - * @param {DoctypeMeta} doctype - The doctype to setup - * @returns {void} - * @description Sets up the Stonecrop instance with the given doctype + * Sets up the Stonecrop instance with the given doctype + * @param doctype - The doctype to setup * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.setup(doctype) + * ``` */ setup(doctype: DoctypeMeta): void { void this.getMeta(doctype) @@ -123,28 +125,29 @@ export class Stonecrop { } /** - * @method getMeta - * @param {DoctypeMeta} doctype - The doctype to get meta for - * @returns {DoctypeMeta} - * @see {@link DoctypeMeta} + * Gets the meta for the given doctype + * @param doctype - The doctype to get meta for + * @returns The meta for the given doctype * @throws NotImplementedError - * @description Gets the meta for the given doctype * @example + * ```ts * const doctype = await registry.getMeta('Task') * const meta = stonecrop.getMeta(doctype) + * ``` + * @see {@link DoctypeMeta} */ getMeta(doctype: DoctypeMeta): DoctypeMeta | Promise | never { return this.registry.getMeta ? this.registry.getMeta(doctype.doctype) : new NotImplementedError(doctype.doctype) } /** - * @method getWorkflow - * @param {DoctypeMeta} doctype - The doctype to get workflow for - * @returns {void} - * @description Gets the workflow for the given doctype + * Gets the workflow for the given doctype + * @param doctype - The doctype to get workflow for * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.getWorkflow(doctype) + * ``` */ getWorkflow(doctype: DoctypeMeta): void { const doctypeRegistry = this.registry.registry[doctype.slug] @@ -152,13 +155,13 @@ export class Stonecrop { } /** - * @method getActions - * @param {DoctypeMeta} doctype - The doctype to get actions for - * @returns {void} - * @description Gets the actions for the given doctype + * Gets the actions for the given doctype + * @param doctype - The doctype to get actions for * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.getActions(doctype) + * ``` */ getActions(doctype: DoctypeMeta): void { const doctypeRegistry = this.registry.registry[doctype.slug] @@ -166,18 +169,20 @@ export class Stonecrop { } /** - * @method getRecords - * @param {DoctypeMeta} doctype - The doctype to get records for - * @param {RequestInit} [filters] - The filters to apply to the records - * @returns {Promise} - * @description Gets the records for the given doctype + * Gets the records for the given doctype + * @param doctype - The doctype to get records for + * @param filters - The filters to apply to the records * @example + * ```ts * const doctype = await registry.getMeta('Task') * await stonecrop.getRecords(doctype) + * ``` * @example + * ```ts * const doctype = await registry.getMeta('Task') * const filters = JSON.stringify({ status: 'Open' }) * await stonecrop.getRecords(doctype, { body: filters }) + * ``` */ async getRecords(doctype: DoctypeMeta, filters?: RequestInit): Promise { this.store.$patch({ records: [] }) @@ -187,14 +192,14 @@ export class Stonecrop { } /** - * @method getRecord - * @param {DoctypeMeta} doctype - The doctype to get record for - * @param {string} id - The id of the record to get - * @returns {Promise} - * @description Gets the record for the given doctype and id + * Gets the record for the given doctype and id + * @param doctype - The doctype to get record for + * @param id - The id of the record to get * @example + * ```ts * const doctype = await registry.getMeta('Task') * await stonecrop.getRecord(doctype, 'TASK-00001') + * ``` */ async getRecord(doctype: DoctypeMeta, id: string): Promise { this.store.$patch({ record: {} }) @@ -204,24 +209,30 @@ export class Stonecrop { } /** - * @method runAction - * @param {DoctypeMeta} doctype - The doctype to run action for - * @param {string} action - The action to run - * @param {string[]} [id] - The id(s) of the record(s) to run action on - * @returns {void} - * @description Runs the action for the given doctype and id + * Runs the action for the given doctype and id + * @param doctype - The doctype to run action for + * @param action - The action to run + * @param id - The id(s) of the record(s) to run action on * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.runAction(doctype, 'CREATE') + * ``` * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.runAction(doctype, 'UPDATE', ['TASK-00001']) + * ``` * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.runAction(doctype, 'DELETE', ['TASK-00001']) + * ``` * @example + * ```ts * const doctype = await registry.getMeta('Task') * stonecrop.runAction(doctype, 'TRANSITION', ['TASK-00001', 'TASK-00002']) + * ``` */ runAction(doctype: DoctypeMeta, action: string, id?: string[]): void { const doctypeRegistry = this.registry.registry[doctype.slug] diff --git a/stonecrop/src/types/index.ts b/stonecrop/src/types/index.ts index 1aedd627..591e125f 100644 --- a/stonecrop/src/types/index.ts +++ b/stonecrop/src/types/index.ts @@ -6,6 +6,10 @@ import { MachineConfig, StateMachine } from 'xstate' import DoctypeMeta from '../doctype' +/** + * Immutable Doctype type for Stonecrop instances + * @public + */ export type ImmutableDoctype = { // TODO: allow schema to be a function readonly schema?: List @@ -13,6 +17,10 @@ export type ImmutableDoctype = { readonly actions?: Map } +/** + * Mutable Doctype type for Stonecrop instances + * @public + */ export type MutableDoctype = { // TODO: allow schema to be a function schema?: SchemaTypes[] @@ -20,11 +28,19 @@ export type MutableDoctype = { actions?: Record } +/** + * Schema type for Stonecrop instances + * @public + */ export type Schema = { doctype: string schema: List } +/** + * Install options for Stonecrop Vue plugin + * @public + */ export type InstallOptions = { router?: Router components?: Record From a64d1bac05931c942026c4be14b207626fa3b534 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Fri, 27 Dec 2024 14:49:25 +0530 Subject: [PATCH 2/2] fix: add changelogs --- .../stonecrop/fix-stonecrop-docs_2024-12-27-09-19.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@stonecrop/stonecrop/fix-stonecrop-docs_2024-12-27-09-19.json diff --git a/common/changes/@stonecrop/stonecrop/fix-stonecrop-docs_2024-12-27-09-19.json b/common/changes/@stonecrop/stonecrop/fix-stonecrop-docs_2024-12-27-09-19.json new file mode 100644 index 00000000..e056db34 --- /dev/null +++ b/common/changes/@stonecrop/stonecrop/fix-stonecrop-docs_2024-12-27-09-19.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@stonecrop/stonecrop", + "comment": "fix stonecrop documentation generation", + "type": "patch" + } + ], + "packageName": "@stonecrop/stonecrop" +} \ No newline at end of file