tftsr-devops_investigation/node_modules/bare-url/lib/url-search-params.js
Shaun Arman 8839075805 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-14 22:36:25 -05:00

175 lines
3.8 KiB
JavaScript

module.exports = class URLSearchParams {
static _urls = new WeakMap()
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
constructor(init, url = null) {
this._params = new Map()
if (url) URLSearchParams._urls.set(this, url)
if (typeof init === 'string') {
this._parse(init)
} else if (init) {
for (const [name, value] of typeof init[Symbol.iterator] === 'function'
? init
: Object.entries(init)) {
this.append(name, value)
}
}
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
get size() {
return this._params.length
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
append(name, value = null) {
if (value === null) return
let list = this._params.get(name)
if (list === undefined) {
list = []
this._params.set(name, list)
}
list.push(value)
this._update()
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
delete(name, value = null) {
if (value === null) this._params.delete(name)
else {
let list = this._params.get(name)
if (list === undefined) return
list = list.filter((found) => found !== value)
if (list.length === 0) this._params.delete(name)
else this._params.set(name, list)
}
this._update()
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
get(name) {
const list = this._params.get(name)
if (list === undefined) return null
return list[0]
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall
getAll(name) {
const list = this._params.get(name)
if (list === undefined) return []
return Array.from(list)
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
has(name, value = null) {
const list = this._params.get(name)
if (list === undefined) return false
if (value === null) return true
return list.includes(value)
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
set(name, value = null) {
if (value === null) this._params.delete(name)
else this._params.set(name, [value])
this._update()
}
toString() {
return this._serialize()
}
toJSON() {
return [...this]
}
*[Symbol.iterator]() {
for (const [name, values] of this._params) {
for (const value of values) yield [name, value]
}
}
[Symbol.for('bare.inspect')]() {
const object = {
__proto__: { constructor: URLSearchParams }
}
for (const [name, values] of this._params) {
if (values.length === 1) object[name] = values[0]
else object[name] = values
}
return object
}
// https://url.spec.whatwg.org/#concept-urlsearchparams-update
_update() {
const url = URLSearchParams._urls.get(this)
if (url === undefined) return
url.search = this._serialize()
}
// https://url.spec.whatwg.org/#concept-urlencoded-parser
_parse(input) {
if (input[0] === '?') input = input.substring(1)
this._params = new Map()
for (const sequence of input.split('&')) {
if (sequence.length === 0) continue
let i = sequence.indexOf('=')
if (i === -1) i = sequence.length
const name = decodeURIComponent(sequence.substring(0, i))
const value = decodeURIComponent(sequence.substring(i + 1, sequence.length))
let list = this._params.get(name)
if (list === undefined) {
list = []
this._params.set(name, list)
}
list.push(value)
}
}
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
_serialize() {
let output = ''
for (let [name, values] of this._params) {
name = encodeURIComponent(name)
for (const value of values) {
if (output) output += '&'
output += name + '=' + encodeURIComponent(value)
}
}
return output
}
}