tftsr-devops_investigation/node_modules/micromark-util-combine-extensions/index.js

144 lines
3.2 KiB
JavaScript
Raw Normal View History

feat: initial implementation of TFTSR IT Triage & RCA application Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
/**
* @import {
* Extension,
* Handles,
* HtmlExtension,
* NormalizedExtension
* } from 'micromark-util-types'
*/
import {splice} from 'micromark-util-chunked'
const hasOwnProperty = {}.hasOwnProperty
/**
* Combine multiple syntax extensions into one.
*
* @param {ReadonlyArray<Extension>} extensions
* List of syntax extensions.
* @returns {NormalizedExtension}
* A single combined extension.
*/
export function combineExtensions(extensions) {
/** @type {NormalizedExtension} */
const all = {}
let index = -1
while (++index < extensions.length) {
syntaxExtension(all, extensions[index])
}
return all
}
/**
* Merge `extension` into `all`.
*
* @param {NormalizedExtension} all
* Extension to merge into.
* @param {Extension} extension
* Extension to merge.
* @returns {undefined}
* Nothing.
*/
function syntaxExtension(all, extension) {
/** @type {keyof Extension} */
let hook
for (hook in extension) {
const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined
/** @type {Record<string, unknown>} */
const left = maybe || (all[hook] = {})
/** @type {Record<string, unknown> | undefined} */
const right = extension[hook]
/** @type {string} */
let code
if (right) {
for (code in right) {
if (!hasOwnProperty.call(left, code)) left[code] = []
const value = right[code]
constructs(
// @ts-expect-error Looks like a list.
left[code],
Array.isArray(value) ? value : value ? [value] : []
)
}
}
}
}
/**
* Merge `list` into `existing` (both lists of constructs).
* Mutates `existing`.
*
* @param {Array<unknown>} existing
* List of constructs to merge into.
* @param {Array<unknown>} list
* List of constructs to merge.
* @returns {undefined}
* Nothing.
*/
function constructs(existing, list) {
let index = -1
/** @type {Array<unknown>} */
const before = []
while (++index < list.length) {
// @ts-expect-error Looks like an object.
;(list[index].add === 'after' ? existing : before).push(list[index])
}
splice(existing, 0, 0, before)
}
/**
* Combine multiple HTML extensions into one.
*
* @param {ReadonlyArray<HtmlExtension>} htmlExtensions
* List of HTML extensions.
* @returns {HtmlExtension}
* Single combined HTML extension.
*/
export function combineHtmlExtensions(htmlExtensions) {
/** @type {HtmlExtension} */
const handlers = {}
let index = -1
while (++index < htmlExtensions.length) {
htmlExtension(handlers, htmlExtensions[index])
}
return handlers
}
/**
* Merge `extension` into `all`.
*
* @param {HtmlExtension} all
* Extension to merge into.
* @param {HtmlExtension} extension
* Extension to merge.
* @returns {undefined}
* Nothing.
*/
function htmlExtension(all, extension) {
/** @type {keyof HtmlExtension} */
let hook
for (hook in extension) {
const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined
const left = maybe || (all[hook] = {})
const right = extension[hook]
/** @type {keyof Handles} */
let type
if (right) {
for (type in right) {
// @ts-expect-error assume document vs regular handler are managed correctly.
left[type] = right[type]
}
}
}
}