From c60c033fd0ec3492ffb72a27441e383701dee76d Mon Sep 17 00:00:00 2001 From: Hugo <95517615+HugoHSun@users.noreply.github.com> Date: Thu, 17 Sep 2026 18:00:10 +1000 Subject: [PATCH 1/3] feat(glossary): add upload and export commands --- README.md | 1 + documentation/commands/glossary.md | 103 +++++++++++++++++++ package.json | 3 + src/commands/glossary/export.ts | 61 +++++++++++ src/commands/glossary/upload.ts | 90 +++++++++++++++++ src/index.ts | 5 + src/lib/glossary.ts | 67 ++++++++++++ test/commands/glossary/glossary.test.ts | 129 ++++++++++++++++++++++++ 8 files changed, 459 insertions(+) create mode 100644 documentation/commands/glossary.md create mode 100644 src/commands/glossary/export.ts create mode 100644 src/commands/glossary/upload.ts create mode 100644 src/lib/glossary.ts create mode 100644 test/commands/glossary/glossary.test.ts diff --git a/README.md b/README.md index c2c3da43c..489e5915f 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ npm run build && npm run build:docs * [`rdme changelog`](documentation/commands/changelog.md) - Upload Markdown files to the Changelog section of your ReadMe project. * [`rdme custompages`](documentation/commands/custompages.md) - Upload Markdown or HTML files to the Custom Pages section of your ReadMe project. * [`rdme docs`](documentation/commands/docs.md) - Upload or export Guides in your ReadMe project. +* [`rdme glossary`](documentation/commands/glossary.md) - Upload or export glossary terms in your ReadMe project. * [`rdme help`](documentation/commands/help.md) - Display help for rdme. * [`rdme login`](documentation/commands/login.md) - Login to a ReadMe project. * [`rdme logout`](documentation/commands/logout.md) - Logs the currently authenticated user out of ReadMe. diff --git a/documentation/commands/glossary.md b/documentation/commands/glossary.md new file mode 100644 index 000000000..5981c3566 --- /dev/null +++ b/documentation/commands/glossary.md @@ -0,0 +1,103 @@ +`rdme glossary` +=============== + +Upload or export glossary terms in your ReadMe project. + +* [`rdme glossary export FILE`](#rdme-glossary-export-file) +* [`rdme glossary upload FILE`](#rdme-glossary-upload-file) + +## `rdme glossary export FILE` + +Export glossary terms from your ReadMe project to a JSON file. + +``` +USAGE + $ rdme glossary export FILE --key [--include-group] + +ARGUMENTS + FILE JSON file to write the exported glossary to. + +FLAGS + --key= (required) ReadMe project API key + --include-group Include terms inherited from the project’s Enterprise group in a separate `group_terms` list. Only + applicable to projects within an Enterprise group. + +DESCRIPTION + Export glossary terms from your ReadMe project to a JSON file. + + Exports project terms by default and writes them to a `terms` list, ready for `rdme glossary upload`. The destination + file is overwritten if it already exists. + + Use `--include-group` to also export terms inherited from an Enterprise group in a separate `group_terms` list. Only + applicable to projects within an Enterprise group. + + `group_terms` is omitted when group terms are not requested or the project has no Enterprise group. + + Within each list, the first occurrence of a name is retained, ignoring case and surrounding whitespace. Matching names + in the two lists are preserved. + +EXAMPLES + Export project terms to a JSON file: + + $ rdme glossary export glossary.json + + Also export terms inherited from your Enterprise group: + + $ rdme glossary export glossary.json --include-group + +FLAG DESCRIPTIONS + --key= ReadMe project API key + + An API key for your ReadMe project. Note that API authentication is required despite being omitted from the example + usage. See our docs for more information: https://github.com/readmeio/rdme/tree/v10#authentication +``` + +## `rdme glossary upload FILE` + +Upload glossary terms to your ReadMe project from a JSON file. + +``` +USAGE + $ rdme glossary upload FILE --key [--dry-run] [--replace] + +ARGUMENTS + FILE JSON file containing glossary terms to upload. + +FLAGS + --key= (required) ReadMe project API key + --dry-run Preview the resulting project terms without saving changes. + --replace Replace all project terms instead of merging. + +DESCRIPTION + Upload glossary terms to your ReadMe project from a JSON file. + + The JSON file must contain a `terms` array of objects with non-empty `term` and `definition` strings. For example: `{ + "terms": [{ "term": "API", "definition": "Application programming interface" }] }`. + + By default, matching project terms are updated in place, omitted terms are retained, and new terms are added at the + top in file order. Names are matched ignoring case and surrounding whitespace; the first occurrence in the file wins. + + Use `--replace` to replace all project terms, or `{ "terms": [] }` with `--replace` to clear them. Use `--dry-run` to + preview the resulting project terms without saving changes. + + `group_terms` from an export is ignored; only project terms are uploaded. + +EXAMPLES + Merge terms from a JSON file into your project glossary: + + $ rdme glossary upload glossary.json + + Preview the resulting project terms without saving changes: + + $ rdme glossary upload glossary.json --dry-run + + Replace all project terms with the terms in the file: + + $ rdme glossary upload glossary.json --replace + +FLAG DESCRIPTIONS + --key= ReadMe project API key + + An API key for your ReadMe project. Note that API authentication is required despite being omitted from the example + usage. See our docs for more information: https://github.com/readmeio/rdme/tree/v10#authentication +``` diff --git a/package.json b/package.json index 4fc59d28b..621288250 100644 --- a/package.json +++ b/package.json @@ -179,6 +179,9 @@ "docs": { "description": "Upload or export Guides in your ReadMe project." }, + "glossary": { + "description": "Upload or export glossary terms in your ReadMe project." + }, "openapi": { "description": "Manage your API definition (e.g., syncing, validation, analysis, conversion, etc.). Supports OpenAPI, Swagger, and Postman collections, in either JSON or YAML formats." }, diff --git a/src/commands/glossary/export.ts b/src/commands/glossary/export.ts new file mode 100644 index 000000000..6c32179ed --- /dev/null +++ b/src/commands/glossary/export.ts @@ -0,0 +1,61 @@ +import type { Glossary } from '../../lib/glossary.js'; + +import fs from 'node:fs/promises'; +import path from 'node:path'; + +import { Args, Flags } from '@oclif/core'; + +import BaseCommand from '../../lib/baseCommand.js'; +import { keyFlag } from '../../lib/flags.js'; + +export default class GlossaryExportCommand extends BaseCommand { + id = 'glossary export' as const; + + static summary = 'Export glossary terms from your ReadMe project to a JSON file.'; + + static description = [ + 'Exports project terms by default and writes them to a `terms` list, ready for `<%= config.bin %> glossary upload`. The destination file is overwritten if it already exists.', + 'Use `--include-group` to also export terms inherited from an Enterprise group in a separate `group_terms` list. Only applicable to projects within an Enterprise group.', + '`group_terms` is omitted when group terms are not requested or the project has no Enterprise group.', + 'Within each list, the first occurrence of a name is retained, ignoring case and surrounding whitespace. Matching names in the two lists are preserved.', + ].join('\n\n'); + + static args = { + file: Args.string({ description: 'JSON file to write the exported glossary to.', required: true }), + }; + + static flags = { + key: keyFlag, + 'include-group': Flags.boolean({ + description: + 'Include terms inherited from the project’s Enterprise group in a separate `group_terms` list. Only applicable to projects within an Enterprise group.', + }), + }; + + static examples = [ + { + description: 'Export project terms to a JSON file:', + command: '<%= config.bin %> <%= command.id %> glossary.json', + }, + { + description: 'Also export terms inherited from your Enterprise group:', + command: '<%= config.bin %> <%= command.id %> glossary.json --include-group', + }, + ]; + + async run() { + const query = this.flags['include-group'] ? '?include_group=true' : ''; + const response = await this.readmeAPIFetch(`/projects/me/glossary${query}`, { + headers: { authorization: `Bearer ${this.flags.key}` }, + }); + const { data } = await this.handleAPIRes<{ data: Glossary }>(response); + const glossary = { terms: data.terms, ...(data.group_terms !== null ? { group_terms: data.group_terms } : {}) }; + + await fs.mkdir(path.dirname(this.args.file), { recursive: true }); + await fs.writeFile(this.args.file, `${JSON.stringify(glossary, null, 2)}\n`, 'utf8'); + this.info( + `Exported ${data.terms.length} project terms${data.group_terms ? ` and ${data.group_terms.length} group terms` : ''} to ${this.args.file}.`, + ); + return glossary; + } +} diff --git a/src/commands/glossary/upload.ts b/src/commands/glossary/upload.ts new file mode 100644 index 000000000..90a1aa06b --- /dev/null +++ b/src/commands/glossary/upload.ts @@ -0,0 +1,90 @@ +import type { Glossary, GlossaryUploadResponse } from '../../lib/glossary.js'; + +import fs from 'node:fs/promises'; + +import { Args, Flags } from '@oclif/core'; + +import BaseCommand from '../../lib/baseCommand.js'; +import { keyFlag } from '../../lib/flags.js'; +import { parseGlossary, previewGlossary } from '../../lib/glossary.js'; +import { isRecord } from '../../utils.js'; + +export default class GlossaryUploadCommand extends BaseCommand { + id = 'glossary upload' as const; + + static summary = 'Upload glossary terms to your ReadMe project from a JSON file.'; + + static description = [ + 'The JSON file must contain a `terms` array of objects with non-empty `term` and `definition` strings. For example: `{ "terms": [{ "term": "API", "definition": "Application programming interface" }] }`.', + 'By default, matching project terms are updated in place, omitted terms are retained, and new terms are added at the top in file order. Names are matched ignoring case and surrounding whitespace; the first occurrence in the file wins.', + 'Use `--replace` to replace all project terms, or `{ "terms": [] }` with `--replace` to clear them. Use `--dry-run` to preview the resulting project terms without saving changes.', + '`group_terms` from an export is ignored; only project terms are uploaded.', + ].join('\n\n'); + + static args = { + file: Args.string({ description: 'JSON file containing glossary terms to upload.', required: true }), + }; + + static flags = { + key: keyFlag, + 'dry-run': Flags.boolean({ description: 'Preview the resulting project terms without saving changes.' }), + replace: Flags.boolean({ description: 'Replace all project terms instead of merging.' }), + }; + + static examples = [ + { + description: 'Merge terms from a JSON file into your project glossary:', + command: '<%= config.bin %> <%= command.id %> glossary.json', + }, + { + description: 'Preview the resulting project terms without saving changes:', + command: '<%= config.bin %> <%= command.id %> glossary.json --dry-run', + }, + { + description: 'Replace all project terms with the terms in the file:', + command: '<%= config.bin %> <%= command.id %> glossary.json --replace', + }, + ]; + + async run() { + const source = await fs.readFile(this.args.file, 'utf8'); + let input: unknown; + try { + input = JSON.parse(source); + } catch { + throw new Error(`Unable to parse ${this.args.file}: expected a valid JSON glossary file.`); + } + + const glossary = parseGlossary(input); + if (isRecord(input) && input.group_terms != null) { + this.warn('Ignoring group_terms. Only project terms are uploaded.'); + } + const headers = { authorization: `Bearer ${this.flags.key}`, 'Content-Type': 'application/json' }; + const replace = this.flags.replace ?? false; + + if (this.flags['dry-run']) { + const response = await this.readmeAPIFetch('/projects/me/glossary', { headers }); + const { data } = await this.handleAPIRes<{ data: Glossary }>(response); + const terms = previewGlossary(data.terms, glossary.terms, replace); + this.info(`Dry run: would ${replace ? 'replace' : 'merge'} project glossary terms. No changes saved.`); + this.log(JSON.stringify({ terms }, null, 2)); + return { data: { terms }, dry_run: true }; + } + + const response = await this.readmeAPIFetch( + '/projects/me/glossary', + { + method: replace ? 'PUT' : 'PATCH', + headers, + body: JSON.stringify({ terms: glossary.terms }), + }, + { file: { path: this.args.file, type: 'path' } }, + ); + const result = await this.handleAPIRes(response); + const { added, updated, removed, duplicates_ignored: duplicates } = result.changes; + this.info( + `Glossary uploaded: ${added} added, ${updated} updated, ${removed} removed, ${duplicates} duplicate entries ignored.`, + ); + return result; + } +} diff --git a/src/index.ts b/src/index.ts index 525e1d16e..531867524 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,8 @@ import CustomPagesUploadCommand from './commands/custompages/upload.js'; import DocsExportCommand from './commands/docs/export.js'; import DocsMigrateCommand from './commands/docs/migrate.js'; import DocsUploadCommand from './commands/docs/upload.js'; +import GlossaryExportCommand from './commands/glossary/export.js'; +import GlossaryUploadCommand from './commands/glossary/upload.js'; import LoginCommand from './commands/login.js'; import LogoutCommand from './commands/logout.js'; import OpenAPIConvertCommand from './commands/openapi/convert.js'; @@ -44,6 +46,9 @@ export const COMMANDS = { 'docs:migrate': DocsMigrateCommand, 'docs:upload': DocsUploadCommand, + 'glossary:export': GlossaryExportCommand, + 'glossary:upload': GlossaryUploadCommand, + login: LoginCommand, logout: LogoutCommand, diff --git a/src/lib/glossary.ts b/src/lib/glossary.ts new file mode 100644 index 000000000..4f102fb91 --- /dev/null +++ b/src/lib/glossary.ts @@ -0,0 +1,67 @@ +import { isRecord } from '../utils.js'; + +export interface GlossaryTerm { + definition: string; + term: string; +} + +export interface Glossary { + group_terms: GlossaryTerm[] | null; + terms: GlossaryTerm[]; +} + +export interface GlossaryUploadResponse { + changes: { added: number; updated: number; removed: number; duplicates_ignored: number }; + data: Pick; +} + +const parseTerms = (terms: unknown): GlossaryTerm[] => { + if (!Array.isArray(terms)) throw new Error('Glossary terms must be an array.'); + return terms.map((entry: unknown, index) => { + if ( + !isRecord(entry) || + typeof entry.term !== 'string' || + !entry.term.trim() || + typeof entry.definition !== 'string' || + !entry.definition.trim() || + Object.keys(entry).some(key => !['term', 'definition'].includes(key)) + ) { + throw new Error(`Glossary entry ${index + 1} must contain only a non-empty "term" and "definition".`); + } + return { term: entry.term.trim(), definition: entry.definition.trim() }; + }); +}; + +/** Validate the upload before making requests, including during a dry run. */ +export function parseGlossary(input: unknown): Pick { + if (!isRecord(input) || !Array.isArray(input.terms)) { + throw new Error( + 'Glossary files must contain a "terms" array. Use { "terms": [] } to clear project terms with --replace.', + ); + } + if (Object.keys(input).some(key => !['terms', 'group_terms'].includes(key))) { + throw new Error('Glossary files only support "terms" and optional "group_terms" lists.'); + } + + return { + terms: parseTerms(input.terms), + }; +} + +const normalize = (term: string) => term.trim().toLowerCase(); + +/** Preview the exported result; hidden stored duplicates are managed by the API. */ +export function previewGlossary(existing: GlossaryTerm[], uploaded: GlossaryTerm[], replace: boolean): GlossaryTerm[] { + const incoming = new Map(); + uploaded.forEach(term => { + const key = normalize(term.term); + if (!incoming.has(key)) incoming.set(key, term); + }); + if (replace) return [...incoming.values()]; + + const names = new Set(existing.map(({ term }) => normalize(term))); + return [ + ...[...incoming].filter(([key]) => !names.has(key)).map(([, term]) => term), + ...existing.map(term => incoming.get(normalize(term.term)) ?? term), + ]; +} diff --git a/test/commands/glossary/glossary.test.ts b/test/commands/glossary/glossary.test.ts new file mode 100644 index 000000000..11bb6e87a --- /dev/null +++ b/test/commands/glossary/glossary.test.ts @@ -0,0 +1,129 @@ +import fs from 'node:fs/promises'; +import os from 'node:os'; +import path from 'node:path'; + +import nock from 'nock'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; + +import ExportCommand from '../../../src/commands/glossary/export.js'; +import UploadCommand from '../../../src/commands/glossary/upload.js'; +import { getAPIv2Mock } from '../../helpers/get-api-mock.js'; +import { runCommand } from '../../helpers/oclif.js'; + +const key = 'rdme_123'; +const headers = { authorization: `Bearer ${key}` }; +const endpoint = '/projects/me/glossary'; +const a = { term: 'A', definition: 'First' }; +const b = { term: 'B', definition: 'Second' }; +const changes = { added: 1, updated: 0, removed: 0, duplicates_ignored: 0 }; + +let directory: string; +let file: string; + +beforeEach(async () => { + directory = await fs.mkdtemp(path.join(os.tmpdir(), 'rdme-glossary-')); + file = path.join(directory, 'glossary.json'); + nock.disableNetConnect(); +}); + +afterEach(async () => { + nock.cleanAll(); + await fs.rm(directory, { recursive: true, force: true }); +}); + +describe('glossary upload', () => { + const run = runCommand(UploadCommand); + + it('merges by default, trims project terms and strips group terms from the request', async () => { + await fs.writeFile( + file, + JSON.stringify({ + terms: [{ term: ' A ', definition: ' First ' }], + group_terms: [b], + }), + ); + + const result = { data: { terms: [a] }, changes }; + const mock = getAPIv2Mock(headers) + .patch(endpoint, { terms: [a] }) + .reply(200, result); + const output = await run([file, '--key', key]); + expect(output.error).toBeUndefined(); + expect(output.result).toStrictEqual(result); + expect(output.stderr).toContain('Ignoring group_terms'); + mock.done(); + }); + + it('uses PUT for --replace and allows an empty project glossary with null group terms', async () => { + await fs.writeFile(file, JSON.stringify({ terms: [], group_terms: null })); + + const mock = getAPIv2Mock(headers) + .put(endpoint, { terms: [] }) + .reply(200, { + data: { terms: [] }, + changes: { ...changes, added: 0 }, + }); + const output = await run([file, '--key', key, '--replace']); + expect(output.error).toBeUndefined(); + expect(output.stderr).not.toContain('Ignoring group_terms'); + mock.done(); + }); + + it.each([ + { input: { group_terms: [a] }, message: 'must contain a "terms" array' }, + { input: { terms: null }, message: 'must contain a "terms" array' }, + { input: { terms: [{ term: ' ', definition: 'Definition' }] }, message: 'Glossary entry 1' }, + { input: { terms: [{ term: 'Term', definition: ' ' }] }, message: 'Glossary entry 1' }, + { input: { terms: [{ term: 123, definition: 'Definition' }] }, message: 'Glossary entry 1' }, + { input: { terms: [{ ...a, inherited: true }] }, message: 'Glossary entry 1' }, + { input: { terms: [a], typo: true }, message: 'only support "terms" and optional "group_terms"' }, + ])('rejects invalid upload input before making requests: $input', async ({ input, message }) => { + await fs.writeFile(file, JSON.stringify(input)); + const output = await run([file, '--key', key]); + expect(output.error?.message).toContain(message); + }); + + it('reports malformed JSON before making requests', async () => { + await fs.writeFile(file, '{'); + const output = await run([file, '--key', key]); + expect(output.error?.message).toContain('expected a valid JSON glossary file'); + }); + + it('previews an upload without sending a write request', async () => { + await fs.writeFile(file, JSON.stringify({ terms: [b] })); + + const mock = getAPIv2Mock(headers) + .get(endpoint) + .reply(200, { data: { terms: [a], group_terms: null } }); + const output = await run([file, '--key', key, '--dry-run']); + expect(output.error).toBeUndefined(); + expect(output.result).toStrictEqual({ data: { terms: [b, a] }, dry_run: true }); + mock.done(); + }); +}); + +describe('glossary export', () => { + const run = runCommand(ExportCommand); + + it.each([ + { includeGroup: false, groupTerms: null }, + { includeGroup: true, groupTerms: [{ ...a, definition: 'Group definition' }] }, + { includeGroup: true, groupTerms: null }, + { includeGroup: true, groupTerms: [] }, + ])('exports the API data with the requested group scope: %j', async ({ includeGroup, groupTerms }) => { + const data = { terms: [a, b], group_terms: groupTerms }; + + const mock = getAPIv2Mock(headers) + .get(endpoint) + .query(includeGroup ? { include_group: 'true' } : {}) + .reply(200, { data }); + const destination = path.join(directory, 'nested', 'glossary.json'); + const output = await run([destination, '--key', key, ...(includeGroup ? ['--include-group'] : [])]); + expect(output.error).toBeUndefined(); + + const expected = groupTerms === null ? { terms: [a, b] } : data; + expect(JSON.parse(await fs.readFile(destination, 'utf8'))).toStrictEqual(expected); + expect(output.result).toStrictEqual(expected); + mock.done(); + }); +}); From f7fadcf017d3737a5eeed0e9c048403aa2d251ee Mon Sep 17 00:00:00 2001 From: Hugo <95517615+HugoHSun@users.noreply.github.com> Date: Thu, 17 Sep 2026 19:13:39 +1000 Subject: [PATCH 2/3] chore: refresh github workflow schema --- test/helpers/github-workflow-schema.json | 881 ++++++++++++++--------- 1 file changed, 526 insertions(+), 355 deletions(-) diff --git a/test/helpers/github-workflow-schema.json b/test/helpers/github-workflow-schema.json index 45988a9ca..212220c6c 100644 --- a/test/helpers/github-workflow-schema.json +++ b/test/helpers/github-workflow-schema.json @@ -10,6 +10,12 @@ "$ref": "#/definitions/globs", "description": "When using the push and pull_request events, you can configure a workflow to run on specific branches or tags. If you only define only tags or only branches, the workflow won't run for events affecting the undefined Git ref.\nThe branches, branches-ignore, tags, and tags-ignore keywords accept glob patterns that use the * and ** wildcard characters to match more than one branch or tag name. For more information, see https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet.\nThe patterns defined in branches and tags are evaluated against the Git ref's name. For example, defining the pattern mona/octocat in branches will match the refs/heads/mona/octocat Git ref. The pattern releases/** will match the refs/heads/releases/10 Git ref.\nYou can use two types of filters to prevent a workflow from running on pushes and pull requests to tags and branches:\n- branches or branches-ignore - You cannot use both the branches and branches-ignore filters for the same event in a workflow. Use the branches filter when you need to filter branches for positive matches and exclude branches. Use the branches-ignore filter when you only need to exclude branch names.\n- tags or tags-ignore - You cannot use both the tags and tags-ignore filters for the same event in a workflow. Use the tags filter when you need to filter tags for positive matches and exclude tags. Use the tags-ignore filter when you only need to exclude tag names.\nYou can exclude tags and branches using the ! character. The order that you define patterns matters.\n- A matching negative pattern (prefixed with !) after a positive match will exclude the Git ref.\n- A matching positive pattern after a negative match will include the Git ref again." }, + "cacheMode": { + "$comment": "https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#cache-mode", + "description": "Controls the level of GitHub Actions cache access granted to a workflow or job.", + "type": "string", + "enum": ["read", "write", "write-only", "none"] + }, "concurrency": { "type": "object", "properties": { @@ -170,7 +176,7 @@ "contents": { "$ref": "#/definitions/permissions-level" }, "deployments": { "$ref": "#/definitions/permissions-level" }, "discussions": { "$ref": "#/definitions/permissions-level" }, - "id-token": { "$ref": "#/definitions/permissions-level" }, + "id-token": { "type": "string", "enum": ["write", "none"] }, "issues": { "$ref": "#/definitions/permissions-level" }, "models": { "type": "string", "enum": ["read", "none"] }, "packages": { "$ref": "#/definitions/permissions-level" }, @@ -178,7 +184,9 @@ "pull-requests": { "$ref": "#/definitions/permissions-level" }, "repository-projects": { "$ref": "#/definitions/permissions-level" }, "security-events": { "$ref": "#/definitions/permissions-level" }, - "statuses": { "$ref": "#/definitions/permissions-level" } + "statuses": { "$ref": "#/definitions/permissions-level" }, + "vulnerability-alerts": { "type": "string", "enum": ["read", "none"] }, + "copilot-requests": { "type": "string", "enum": ["write"] } } }, "permissions-level": { "type": "string", "enum": ["read", "write", "none"] }, @@ -258,7 +266,7 @@ "repository_dispatch" ] }, - "eventObject": { "oneOf": [{ "type": "object" }, { "type": "null" }], "additionalProperties": true }, + "eventObject": { "oneOf": [{ "type": "object", "additionalProperties": true }, { "type": "null" }] }, "expressionSyntax": { "$comment": "escape `{` and `}` in pattern to be unicode compatible (#1360)", "type": "string", @@ -320,12 +328,12 @@ "additionalProperties": false, "dependencies": { "working-directory": ["run"], "shell": ["run"] }, "oneOf": [ - { "required": ["uses"] }, - { "required": ["run"] }, - { "required": ["wait"] }, - { "required": ["wait-all"] }, - { "required": ["cancel"] }, - { "required": ["parallel"] } + { "type": "object", "properties": { "uses": true }, "required": ["uses"] }, + { "type": "object", "properties": { "run": true }, "required": ["run"] }, + { "type": "object", "properties": { "wait": true }, "required": ["wait"] }, + { "type": "object", "properties": { "wait-all": true }, "required": ["wait-all"] }, + { "type": "object", "properties": { "cancel": true }, "required": ["cancel"] }, + { "type": "object", "properties": { "parallel": true }, "required": ["parallel"] } ], "properties": { "id": { @@ -336,7 +344,7 @@ "if": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsif", "description": "You can use the if conditional to prevent a step from running unless a condition is met. You can use any supported context and expression to create a conditional.\nExpressions in an if conditional do not require the ${{ }} syntax. For more information, see https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions.", - "type": ["boolean", "number", "string"] + "anyOf": [{ "type": "boolean" }, { "type": "number" }, { "type": "string" }] }, "name": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsname", @@ -359,16 +367,22 @@ "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith", "$ref": "#/definitions/env", "description": "A map of the input parameters defined by the action. Each input parameter is a key/value pair. Input parameters are set as environment variables. The variable is prefixed with INPUT_ and converted to upper case.", - "properties": { - "args": { - "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs", - "type": "string" - }, - "entrypoint": { - "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithentrypoint", - "type": "string" + "anyOf": [ + { "$ref": "#/definitions/env" }, + { + "type": "object", + "properties": { + "args": { + "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs", + "type": "string" + }, + "entrypoint": { + "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithentrypoint", + "type": "string" + } + } } - } + ] }, "env": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsenv", @@ -399,7 +413,7 @@ "wait-all": { "$comment": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswait-all", "description": "Pauses the job until all active background steps complete. The wait-all keyword takes no arguments.", - "type": ["boolean", "null"] + "anyOf": [{ "type": "boolean" }, { "type": "null" }] }, "cancel": { "$comment": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscancel", @@ -475,10 +489,11 @@ }, "needs": { "$ref": "#/definitions/jobNeeds" }, "permissions": { "$ref": "#/definitions/permissions" }, + "cache-mode": { "$ref": "#/definitions/cacheMode" }, "if": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idif", "description": "You can use the if conditional to prevent a job from running unless a condition is met. You can use any supported context and expression to create a conditional.\nExpressions in an if conditional do not require the ${{ }} syntax. For more information, see https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions.", - "type": ["boolean", "number", "string"] + "anyOf": [{ "type": "boolean" }, { "type": "number" }, { "type": "string" }] }, "uses": { "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses", @@ -505,13 +520,13 @@ "fail-fast": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast", "description": "When set to true, GitHub cancels all in-progress jobs if any matrix job fails. Default: true", - "type": ["boolean", "string"], + "anyOf": [{ "type": "boolean" }, { "type": "string" }], "default": true }, "max-parallel": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel", "description": "The maximum number of jobs that can run simultaneously when using a matrix job strategy. By default, GitHub will maximize the number of jobs run in parallel depending on the available runners on GitHub-hosted virtual machines.", - "type": ["number", "string"] + "anyOf": [{ "type": "number" }, { "type": "string" }] } }, "required": ["matrix"], @@ -539,6 +554,7 @@ "needs": { "$ref": "#/definitions/jobNeeds" }, "snapshot": { "$ref": "#/definitions/snapshot" }, "permissions": { "$ref": "#/definitions/permissions" }, + "cache-mode": { "$ref": "#/definitions/cacheMode" }, "runs-on": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on", "description": "The type of machine to run the job on. The machine can be either a GitHub-hosted runner, or a self-hosted runner.", @@ -550,7 +566,7 @@ { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#self-hosted-runners", "type": "array", - "anyOf": [{ "items": [{ "type": "string" }], "minItems": 1, "additionalItems": { "type": "string" } }] + "anyOf": [{ "items": { "type": "string" }, "minItems": 1 }] }, { "$comment": "https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-runners-in-a-group", @@ -589,7 +605,7 @@ "if": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idif", "description": "You can use the if conditional to prevent a job from running unless a condition is met. You can use any supported context and expression to create a conditional.\nExpressions in an if conditional do not require the ${{ }} syntax. For more information, see https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions.", - "type": ["boolean", "number", "string"] + "anyOf": [{ "type": "boolean" }, { "type": "number" }, { "type": "string" }] }, "steps": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps", @@ -613,13 +629,13 @@ "fail-fast": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast", "description": "When set to true, GitHub cancels all in-progress jobs if any matrix job fails. Default: true", - "type": ["boolean", "string"], + "anyOf": [{ "type": "boolean" }, { "type": "string" }], "default": true }, "max-parallel": { "$comment": "https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel", "description": "The maximum number of jobs that can run simultaneously when using a matrix job strategy. By default, GitHub will maximize the number of jobs run in parallel depending on the available runners on GitHub-hosted virtual machines.", - "type": ["number", "string"] + "anyOf": [{ "type": "number" }, { "type": "string" }] } }, "required": ["matrix"], @@ -687,26 +703,34 @@ "minItems": 1 } }, - "allOf": [ + "oneOf": [ { - "if": { "properties": { "type": { "const": "string" } }, "required": ["type"] }, - "then": { "properties": { "default": { "type": "string" } } } + "type": "object", + "properties": { "type": { "const": "string" }, "default": { "type": "string" } }, + "required": ["type"] }, { - "if": { "properties": { "type": { "const": "boolean" } }, "required": ["type"] }, - "then": { "properties": { "default": { "type": "boolean" } } } + "type": "object", + "properties": { "type": { "const": "boolean" }, "default": { "type": "boolean" } }, + "required": ["type"] }, { - "if": { "properties": { "type": { "const": "number" } }, "required": ["type"] }, - "then": { "properties": { "default": { "type": "number" } } } + "type": "object", + "properties": { "type": { "const": "number" }, "default": { "type": "number" } }, + "required": ["type"] }, { - "if": { "properties": { "type": { "const": "environment" } }, "required": ["type"] }, - "then": { "properties": { "default": { "type": "string" } } } + "type": "object", + "properties": { "type": { "const": "environment" }, "default": { "type": "string" } }, + "required": ["type"] }, { - "if": { "properties": { "type": { "const": "choice" } }, "required": ["type"] }, - "then": { "required": ["options"] } + "type": "object", + "properties": { + "type": { "const": "choice" }, + "options": { "$ref": "#/definitions/workflowDispatchInput/properties/options" } + }, + "required": ["type", "options"] } ], "additionalProperties": false @@ -729,277 +753,371 @@ "properties": { "branch_protection_rule": { "$comment": "https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#branch_protection_rule", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the branch_protection_rule event occurs. More than one activity type triggers this event.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, - "default": ["created", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, + "default": ["created", "edited", "deleted"] + } + } } - } + ] }, "check_run": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#check-run-event-check_run", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the check_run event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/checks/runs.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "rerequested", "completed", "requested_action"] }, - "default": ["created", "rerequested", "completed", "requested_action"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { + "type": "string", + "enum": ["created", "rerequested", "completed", "requested_action"] + }, + "default": ["created", "rerequested", "completed", "requested_action"] + } + } } - } + ] }, "check_suite": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#check-suite-event-check_suite", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the check_suite event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/checks/suites/.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["completed", "requested", "rerequested"] }, - "default": ["completed", "requested", "rerequested"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["completed", "requested", "rerequested"] }, + "default": ["completed", "requested", "rerequested"] + } + } } - } + ] }, "create": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#create-event-create", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime someone creates a branch or tag, which triggers the create event. For information about the REST API, see https://developer.github.com/v3/git/refs/#create-a-reference." }, "delete": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#delete-event-delete", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime someone deletes a branch or tag, which triggers the delete event. For information about the REST API, see https://developer.github.com/v3/git/refs/#delete-a-reference." }, "deployment": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#deployment-event-deployment", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime someone creates a deployment, which triggers the deployment event. Deployments created with a commit SHA may not have a Git ref. For information about the REST API, see https://developer.github.com/v3/repos/deployments/." }, "deployment_status": { "$comment": "https://docs.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime a third party provides a deployment status, which triggers the deployment_status event. Deployments created with a commit SHA may not have a Git ref. For information about the REST API, see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status." }, "discussion": { "$comment": "https://docs.github.com/en/actions/reference/events-that-trigger-workflows#discussion", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the discussion event occurs. More than one activity type triggers this event. For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { - "type": "string", - "enum": [ - "created", - "edited", - "deleted", - "transferred", - "pinned", - "unpinned", - "labeled", - "unlabeled", - "locked", - "unlocked", - "category_changed", - "answered", - "unanswered" - ] - }, - "default": [ - "created", - "edited", - "deleted", - "transferred", - "pinned", - "unpinned", - "labeled", - "unlabeled", - "locked", - "unlocked", - "category_changed", - "answered", - "unanswered" - ] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { + "type": "string", + "enum": [ + "created", + "edited", + "deleted", + "transferred", + "pinned", + "unpinned", + "labeled", + "unlabeled", + "locked", + "unlocked", + "category_changed", + "answered", + "unanswered" + ] + }, + "default": [ + "created", + "edited", + "deleted", + "transferred", + "pinned", + "unpinned", + "labeled", + "unlabeled", + "locked", + "unlocked", + "category_changed", + "answered", + "unanswered" + ] + } + } } - } + ] }, "discussion_comment": { "$comment": "https://docs.github.com/en/actions/reference/events-that-trigger-workflows#discussion_comment", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the discussion_comment event occurs. More than one activity type triggers this event. For information about the GraphQL API, see https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, - "default": ["created", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, + "default": ["created", "edited", "deleted"] + } + } } - } + ] }, "fork": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#fork-event-fork", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime when someone forks a repository, which triggers the fork event. For information about the REST API, see https://developer.github.com/v3/repos/forks/#create-a-fork." }, "gollum": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#gollum-event-gollum", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow when someone creates or updates a Wiki page, which triggers the gollum event." }, "issue_comment": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#issue-comment-event-issue_comment", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the issue_comment event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/issues/comments/.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, - "default": ["created", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, + "default": ["created", "edited", "deleted"] + } + } } - } + ] }, "issues": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#issues-event-issues", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the issues event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/issues.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { - "type": "string", - "enum": [ - "opened", - "edited", - "deleted", - "transferred", - "pinned", - "unpinned", - "closed", - "reopened", - "assigned", - "unassigned", - "labeled", - "unlabeled", - "locked", - "unlocked", - "milestoned", - "demilestoned", - "typed", - "untyped", - "field_added", - "field_removed" - ] - }, - "default": [ - "opened", - "edited", - "deleted", - "transferred", - "pinned", - "unpinned", - "closed", - "reopened", - "assigned", - "unassigned", - "labeled", - "unlabeled", - "locked", - "unlocked", - "milestoned", - "demilestoned", - "typed", - "untyped", - "field_added", - "field_removed" - ] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { + "type": "string", + "enum": [ + "opened", + "edited", + "deleted", + "transferred", + "pinned", + "unpinned", + "closed", + "reopened", + "assigned", + "unassigned", + "labeled", + "unlabeled", + "locked", + "unlocked", + "milestoned", + "demilestoned", + "typed", + "untyped", + "field_added", + "field_removed" + ] + }, + "default": [ + "opened", + "edited", + "deleted", + "transferred", + "pinned", + "unpinned", + "closed", + "reopened", + "assigned", + "unassigned", + "labeled", + "unlabeled", + "locked", + "unlocked", + "milestoned", + "demilestoned", + "typed", + "untyped", + "field_added", + "field_removed" + ] + } + } } - } + ] }, "label": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#label-event-label", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the label event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/issues/labels/.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, - "default": ["created", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, + "default": ["created", "edited", "deleted"] + } + } } - } + ] }, "merge_group": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#merge_group", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow when a pull request is added to a merge queue, which adds the pull request to a merge group. For information about the merge queue, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/merging-a-pull-request-with-a-merge-queue .", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["checks_requested"] }, - "default": ["checks_requested"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["checks_requested"] }, + "default": ["checks_requested"] + } + } } - } + ] }, "milestone": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#milestone-event-milestone", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the milestone event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/issues/milestones/.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "closed", "opened", "edited", "deleted"] }, - "default": ["created", "closed", "opened", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "closed", "opened", "edited", "deleted"] }, + "default": ["created", "closed", "opened", "edited", "deleted"] + } + } } - } + ] }, "page_build": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#page-build-event-page_build", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime someone pushes to a GitHub Pages-enabled branch, which triggers the page_build event. For information about the REST API, see https://developer.github.com/v3/repos/pages/." }, "project": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#project-event-project", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the project event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/projects/.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { - "type": "string", - "enum": ["created", "updated", "closed", "reopened", "edited", "deleted"] - }, - "default": ["created", "updated", "closed", "reopened", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { + "type": "string", + "enum": ["created", "updated", "closed", "reopened", "edited", "deleted"] + }, + "default": ["created", "updated", "closed", "reopened", "edited", "deleted"] + } + } } - } + ] }, "project_card": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#project-card-event-project_card", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the project_card event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/projects/cards.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "moved", "converted", "edited", "deleted"] }, - "default": ["created", "moved", "converted", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "moved", "converted", "edited", "deleted"] }, + "default": ["created", "moved", "converted", "edited", "deleted"] + } + } } - } + ] }, "project_column": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#project-column-event-project_column", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the project_column event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/projects/columns.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "updated", "moved", "deleted"] }, - "default": ["created", "updated", "moved", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "updated", "moved", "deleted"] }, + "default": ["created", "updated", "moved", "deleted"] + } + } } - } + ] }, "public": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#public-event-public", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime someone makes a private repository public, which triggers the public event. For information about the REST API, see https://developer.github.com/v3/repos/#edit." }, "pull_request": { @@ -1013,7 +1131,8 @@ "type": "object", "properties": { "types": { - "allOf": [{ "$ref": "#/definitions/types" }], + "$ref": "#/definitions/types", + "type": "array", "items": { "type": "string", "enum": [ @@ -1051,36 +1170,50 @@ }, "additionalProperties": false }, - { "not": { "required": ["branches", "branches-ignore"] } }, - { "not": { "required": ["tags", "tags-ignore"] } }, - { "not": { "required": ["paths", "paths-ignore"] } } + { "not": { "type": "object", "required": ["branches", "branches-ignore"] } }, + { "not": { "type": "object", "required": ["tags", "tags-ignore"] } }, + { "not": { "type": "object", "required": ["paths", "paths-ignore"] } } ] } ] }, "pull_request_review": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-review-event-pull_request_review", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the pull_request_review event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/pulls/reviews.\nNote: Workflows do not run on private base repositories when you open a pull request from a forked repository.\nWhen you create a pull request from a forked repository to the base repository, GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository.\nWorkflows don't run on forked repositories by default. You must enable GitHub Actions in the Actions tab of the forked repository.\nThe permissions for the GITHUB_TOKEN in forked repositories is read-only. For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["submitted", "edited", "dismissed"] }, - "default": ["submitted", "edited", "dismissed"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["submitted", "edited", "dismissed"] }, + "default": ["submitted", "edited", "dismissed"] + } + } } - } + ] }, "pull_request_review_comment": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#pull-request-review-comment-event-pull_request_review_comment", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime a comment on a pull request's unified diff is modified, which triggers the pull_request_review_comment event. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/pulls/comments.\nNote: Workflows do not run on private base repositories when you open a pull request from a forked repository.\nWhen you create a pull request from a forked repository to the base repository, GitHub sends the pull_request event to the base repository and no pull request events occur on the forked repository.\nWorkflows don't run on forked repositories by default. You must enable GitHub Actions in the Actions tab of the forked repository.\nThe permissions for the GITHUB_TOKEN in forked repositories is read-only. For more information about the GITHUB_TOKEN, see https://help.github.com/en/articles/virtual-environments-for-github-actions.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, - "default": ["created", "edited", "deleted"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["created", "edited", "deleted"] }, + "default": ["created", "edited", "deleted"] + } + } } - } + ] }, "pull_request_target": { "$comment": "https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target", @@ -1093,7 +1226,8 @@ "type": "object", "properties": { "types": { - "allOf": [{ "$ref": "#/definitions/types" }], + "$ref": "#/definitions/types", + "type": "array", "items": { "type": "string", "enum": [ @@ -1127,9 +1261,9 @@ }, "additionalProperties": false }, - { "not": { "required": ["branches", "branches-ignore"] } }, - { "not": { "required": ["tags", "tags-ignore"] } }, - { "not": { "required": ["paths", "paths-ignore"] } } + { "not": { "type": "object", "required": ["branches", "branches-ignore"] } }, + { "not": { "type": "object", "required": ["tags", "tags-ignore"] } }, + { "not": { "type": "object", "required": ["paths", "paths-ignore"] } } ] } ] @@ -1153,177 +1287,213 @@ }, "additionalProperties": false }, - { "not": { "required": ["branches", "branches-ignore"] } }, - { "not": { "required": ["tags", "tags-ignore"] } }, - { "not": { "required": ["paths", "paths-ignore"] } } + { "not": { "type": "object", "required": ["branches", "branches-ignore"] } }, + { "not": { "type": "object", "required": ["tags", "tags-ignore"] } }, + { "not": { "type": "object", "required": ["paths", "paths-ignore"] } } ] } ] }, "registry_package": { "$comment": "https://help.github.com/en/actions/reference/events-that-trigger-workflows#registry-package-event-registry_package", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime a package is published or updated. For more information, see https://help.github.com/en/github/managing-packages-with-github-packages.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["published", "updated"] }, - "default": ["published", "updated"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["published", "updated"] }, + "default": ["published", "updated"] + } + } } - } + ] }, "release": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#release-event-release", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the release event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/repos/releases/ in the GitHub Developer documentation.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { - "type": "string", - "enum": ["published", "unpublished", "created", "edited", "deleted", "prereleased", "released"] - }, - "default": ["published", "unpublished", "created", "edited", "deleted", "prereleased", "released"] + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { + "type": "string", + "enum": ["published", "unpublished", "created", "edited", "deleted", "prereleased", "released"] + }, + "default": ["published", "unpublished", "created", "edited", "deleted", "prereleased", "released"] + } + } } - } + ] }, "status": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#status-event-status", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the status of a Git commit changes, which triggers the status event. For information about the REST API, see https://developer.github.com/v3/repos/statuses/." }, "watch": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#watch-event-watch", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "Runs your workflow anytime the watch event occurs. More than one activity type triggers this event. For information about the REST API, see https://developer.github.com/v3/activity/starring/." }, "workflow_call": { "$comment": "https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_call", "description": "Allows workflows to be reused by other workflows.", - "properties": { - "inputs": { - "$comment": "https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onworkflow_callinputs", - "description": "When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow.", + "oneOf": [ + { "type": "null" }, + { "type": "object", - "patternProperties": { - "^[_a-zA-Z][a-zA-Z0-9_-]*$": { - "$comment": "https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_id", - "description": "A string identifier to associate with the input. The value of is a map of the input's metadata. The must be a unique identifier within the inputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _.", + "properties": { + "inputs": { + "$comment": "https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onworkflow_callinputs", + "description": "When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow.", "type": "object", - "properties": { - "description": { - "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_iddescription", - "description": "A string description of the input parameter.", - "type": "string" - }, - "required": { - "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_idrequired", - "description": "A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required.", - "type": "boolean" - }, - "type": { - "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype", - "description": "Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string.", - "type": "string", - "enum": ["boolean", "number", "string"] - }, - "default": { - "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_iddefault", - "description": "The default value is used when an input parameter isn't specified in a workflow file.", - "type": ["boolean", "number", "string"] + "patternProperties": { + "^[_a-zA-Z][a-zA-Z0-9_-]*$": { + "$comment": "https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_id", + "description": "A string identifier to associate with the input. The value of is a map of the input's metadata. The must be a unique identifier within the inputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _.", + "type": "object", + "properties": { + "description": { + "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_iddescription", + "description": "A string description of the input parameter.", + "type": "string" + }, + "required": { + "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_idrequired", + "description": "A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required.", + "type": "boolean" + }, + "type": { + "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype", + "description": "Required if input is defined for the on.workflow_call keyword. The value of this parameter is a string specifying the data type of the input. This must be one of: boolean, number, or string.", + "type": "string", + "enum": ["boolean", "number", "string"] + }, + "default": { + "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputsinput_iddefault", + "description": "The default value is used when an input parameter isn't specified in a workflow file.", + "anyOf": [{ "type": "boolean" }, { "type": "number" }, { "type": "string" }] + } + }, + "required": ["type"], + "additionalProperties": false } }, - "required": ["type"], "additionalProperties": false - } - }, - "additionalProperties": false - }, - "outputs": { - "$comment": "https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onworkflow_calloutputs", - "description": "When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow.", - "type": "object", - "patternProperties": { - "^[_a-zA-Z][a-zA-Z0-9_-]*$": { - "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id", - "description": "A string identifier to associate with the output. The value of is a map of the output's metadata. The must be a unique identifier within the outputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _.", + }, + "outputs": { + "$comment": "https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onworkflow_calloutputs", + "description": "When using the workflow_call keyword, you can optionally specify inputs that are passed to the called workflow from the caller workflow.", "type": "object", - "properties": { - "description": { - "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_iddescription", - "description": "A string description of the output parameter.", - "type": "string" - }, - "value": { - "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_idvalue", - "description": "The value that the output parameter will be mapped to. You can set this to a string or an expression with context. For example, you can use the steps context to set the value of an output to the output value of a step.", - "type": "string" + "patternProperties": { + "^[_a-zA-Z][a-zA-Z0-9_-]*$": { + "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id", + "description": "A string identifier to associate with the output. The value of is a map of the output's metadata. The must be a unique identifier within the outputs object. The must start with a letter or _ and contain only alphanumeric characters, -, or _.", + "type": "object", + "properties": { + "description": { + "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_iddescription", + "description": "A string description of the output parameter.", + "type": "string" + }, + "value": { + "$comment": "https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputsoutput_idvalue", + "description": "The value that the output parameter will be mapped to. You can set this to a string or an expression with context. For example, you can use the steps context to set the value of an output to the output value of a step.", + "type": "string" + } + }, + "required": ["value"], + "additionalProperties": false } }, - "required": ["value"], "additionalProperties": false - } - }, - "additionalProperties": false - }, - "secrets": { - "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets", - "description": "A map of the secrets that can be used in the called workflow. Within the called workflow, you can use the secrets context to refer to a secret.", - "patternProperties": { - "^[_a-zA-Z][a-zA-Z0-9_-]*$": { - "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_id", - "description": "A string identifier to associate with the secret.", - "properties": { - "description": { - "description": "A string description of the secret parameter.", - "type": "string" - }, - "required": { - "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_idrequired", - "description": "A boolean specifying whether the secret must be supplied.", - "type": "boolean" + }, + "secrets": { + "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets", + "type": "object", + "description": "A map of the secrets that can be used in the called workflow. Within the called workflow, you can use the secrets context to refer to a secret.", + "patternProperties": { + "^[_a-zA-Z][a-zA-Z0-9_-]*$": { + "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_id", + "type": "object", + "description": "A string identifier to associate with the secret.", + "properties": { + "description": { + "description": "A string description of the secret parameter.", + "type": "string" + }, + "required": { + "$comment": "https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_idrequired", + "description": "A boolean specifying whether the secret must be supplied.", + "type": "boolean" + } + }, + "additionalProperties": false } }, "additionalProperties": false } - }, - "additionalProperties": false + } } - } + ] }, "workflow_dispatch": { "$comment": "https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/", + "$ref": "#/definitions/eventObject", "description": "You can now create workflows that are manually triggered with the new workflow_dispatch event. You will then see a 'Run workflow' button on the Actions tab, enabling you to easily trigger a run.", - "properties": { - "inputs": { - "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputs", - "description": "Input parameters allow you to specify data that the action expects to use during runtime. GitHub stores input parameters as environment variables. Input ids with uppercase letters are converted to lowercase during runtime. We recommended using lowercase input ids.", + "oneOf": [ + { "type": "null" }, + { "type": "object", - "patternProperties": { - "^[_a-zA-Z][a-zA-Z0-9_-]*$": { "$ref": "#/definitions/workflowDispatchInput" } + "properties": { + "inputs": { + "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions#inputs", + "description": "Input parameters allow you to specify data that the action expects to use during runtime. GitHub stores input parameters as environment variables. Input ids with uppercase letters are converted to lowercase during runtime. We recommended using lowercase input ids.", + "type": "object", + "patternProperties": { + "^[_a-zA-Z][a-zA-Z0-9_-]*$": { "$ref": "#/definitions/workflowDispatchInput" } + }, + "additionalProperties": false + } }, "additionalProperties": false } - }, - "additionalProperties": false + ] }, "workflow_run": { "$comment": "https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow. For example, if your pull_request workflow generates build artifacts, you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request.", - "properties": { - "types": { - "allOf": [{ "$ref": "#/definitions/types" }], - "items": { "type": "string", "enum": ["requested", "completed", "in_progress"] }, - "default": ["requested", "completed"] - }, - "workflows": { "type": "array", "items": { "type": "string" }, "minItems": 1 } - }, - "patternProperties": { "^branches(-ignore)?$": {} } + "oneOf": [ + { "type": "null" }, + { + "type": "object", + "properties": { + "types": { + "$ref": "#/definitions/types", + "type": "array", + "items": { "type": "string", "enum": ["requested", "completed", "in_progress"] }, + "default": ["requested", "completed"] + }, + "workflows": { "type": "array", "items": { "type": "string" }, "minItems": 1 } + }, + "patternProperties": { "^branches(-ignore)?$": {} } + } + ] }, "repository_dispatch": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows#external-events-repository_dispatch", - "allOf": [{ "$ref": "#/definitions/eventObject" }], + "$ref": "#/definitions/eventObject", "description": "You can use the GitHub API to trigger a webhook event called repository_dispatch when you want to trigger a workflow for activity that happens outside of GitHub. For more information, see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event.\nTo trigger the custom repository_dispatch webhook event, you must send a POST request to a GitHub API endpoint and provide an event_type name to describe the activity type. To trigger a workflow run, you must also configure your workflow to use the repository_dispatch event." }, "schedule": { @@ -1367,6 +1537,7 @@ "description": "Concurrency ensures that only a single job or workflow using the same concurrency group will run at a time. A concurrency group can be any string or expression. The expression can use any context except for the secrets context. \nYou can also specify concurrency at the workflow level. \nWhen a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be pending. By default any previously pending job or workflow in the concurrency group will be canceled; this behavior can be changed with `queue`. To also cancel any currently running job or workflow in the same concurrency group, specify cancel-in-progress: true.", "oneOf": [{ "type": "string" }, { "$ref": "#/definitions/concurrency" }] }, + "cache-mode": { "$ref": "#/definitions/cacheMode" }, "jobs": { "$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobs", "description": "A workflow run is made up of one or more jobs. Jobs run in parallel by default. To run jobs sequentially, you can define dependencies on other jobs using the jobs..needs keyword.\nEach job runs in a fresh instance of the virtual environment specified by runs-on.\nYou can run an unlimited number of jobs as long as you are within the workflow usage limits. For more information, see https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#usage-limits.", From 2da3047787d0d8798f8f05d90faaacca17eed70b Mon Sep 17 00:00:00 2001 From: Hugo <95517615+HugoHSun@users.noreply.github.com> Date: Wed, 23 Sep 2026 10:04:52 +1000 Subject: [PATCH 3/3] fix(glossary): read change counts from response data --- src/commands/glossary/upload.ts | 2 +- src/lib/glossary.ts | 6 ++++-- test/commands/glossary/glossary.test.ts | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/commands/glossary/upload.ts b/src/commands/glossary/upload.ts index 90a1aa06b..2323f4a7b 100644 --- a/src/commands/glossary/upload.ts +++ b/src/commands/glossary/upload.ts @@ -81,7 +81,7 @@ export default class GlossaryUploadCommand extends BaseCommand(response); - const { added, updated, removed, duplicates_ignored: duplicates } = result.changes; + const { added, updated, removed, duplicates_ignored: duplicates } = result.data.changes; this.info( `Glossary uploaded: ${added} added, ${updated} updated, ${removed} removed, ${duplicates} duplicate entries ignored.`, ); diff --git a/src/lib/glossary.ts b/src/lib/glossary.ts index 4f102fb91..66dbb3276 100644 --- a/src/lib/glossary.ts +++ b/src/lib/glossary.ts @@ -11,8 +11,10 @@ export interface Glossary { } export interface GlossaryUploadResponse { - changes: { added: number; updated: number; removed: number; duplicates_ignored: number }; - data: Pick; + data: { + changes: { added: number; updated: number; removed: number; duplicates_ignored: number }; + terms: GlossaryTerm[]; + }; } const parseTerms = (terms: unknown): GlossaryTerm[] => { diff --git a/test/commands/glossary/glossary.test.ts b/test/commands/glossary/glossary.test.ts index 11bb6e87a..15514a3aa 100644 --- a/test/commands/glossary/glossary.test.ts +++ b/test/commands/glossary/glossary.test.ts @@ -43,7 +43,7 @@ describe('glossary upload', () => { }), ); - const result = { data: { terms: [a] }, changes }; + const result = { data: { terms: [a], changes } }; const mock = getAPIv2Mock(headers) .patch(endpoint, { terms: [a] }) .reply(200, result); @@ -60,8 +60,7 @@ describe('glossary upload', () => { const mock = getAPIv2Mock(headers) .put(endpoint, { terms: [] }) .reply(200, { - data: { terms: [] }, - changes: { ...changes, added: 0 }, + data: { terms: [], changes: { ...changes, added: 0 } }, }); const output = await run([file, '--key', key, '--replace']); expect(output.error).toBeUndefined();