From f8d0463e3450e304b0c5961d7ec4a87521926419 Mon Sep 17 00:00:00 2001 From: Christian Klotz Date: Wed, 30 Jun 2021 16:59:01 +0300 Subject: [PATCH] Add API documentation (#197) * Add documentation * Add changeset --- .changeset/mighty-mails-count.md | 5 +++++ packages/utils/src/assistant-config-schema/index.ts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/mighty-mails-count.md diff --git a/.changeset/mighty-mails-count.md b/.changeset/mighty-mails-count.md new file mode 100644 index 0000000..ab53622 --- /dev/null +++ b/.changeset/mighty-mails-count.md @@ -0,0 +1,5 @@ +--- +'@sketch-hq/sketch-assistant-utils': patch +--- + +Add documentation for buildAssistantConfigSchema diff --git a/packages/utils/src/assistant-config-schema/index.ts b/packages/utils/src/assistant-config-schema/index.ts index e815323..cd755a3 100644 --- a/packages/utils/src/assistant-config-schema/index.ts +++ b/packages/utils/src/assistant-config-schema/index.ts @@ -26,6 +26,15 @@ const applyRuleConfig = (ops: JSONSchemaProps, config: RuleConfig): JSONSchemaPr }, {}) } +/** + * Builds the JSON Schema for the configuration accepted by the given + * assistant. The schema is augmented with assistant's configuration, + * meaning the options set in the configuration are used as default values + * for the corresponding properties. + * + * @param assistant Assistant to generate the configuration schema from + * @returns JSON Schema describing the assistant's configuration shape + */ const buildAssistantConfigSchema: AssistantConfigSchemaCreator = (assistant) => { return { type: 'object',