tftsr-devops_investigation/node_modules/smart-buffer/build/utils.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

108 lines
4.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer");
/**
* Error strings
*/
const ERRORS = {
INVALID_ENCODING: 'Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.',
INVALID_SMARTBUFFER_SIZE: 'Invalid size provided. Size must be a valid integer greater than zero.',
INVALID_SMARTBUFFER_BUFFER: 'Invalid Buffer provided in SmartBufferOptions.',
INVALID_SMARTBUFFER_OBJECT: 'Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.',
INVALID_OFFSET: 'An invalid offset value was provided.',
INVALID_OFFSET_NON_NUMBER: 'An invalid offset value was provided. A numeric value is required.',
INVALID_LENGTH: 'An invalid length value was provided.',
INVALID_LENGTH_NON_NUMBER: 'An invalid length value was provived. A numeric value is required.',
INVALID_TARGET_OFFSET: 'Target offset is beyond the bounds of the internal SmartBuffer data.',
INVALID_TARGET_LENGTH: 'Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.',
INVALID_READ_BEYOND_BOUNDS: 'Attempted to read beyond the bounds of the managed data.',
INVALID_WRITE_BEYOND_BOUNDS: 'Attempted to write beyond the bounds of the managed data.'
};
exports.ERRORS = ERRORS;
/**
* Checks if a given encoding is a valid Buffer encoding. (Throws an exception if check fails)
*
* @param { String } encoding The encoding string to check.
*/
function checkEncoding(encoding) {
if (!buffer_1.Buffer.isEncoding(encoding)) {
throw new Error(ERRORS.INVALID_ENCODING);
}
}
exports.checkEncoding = checkEncoding;
/**
* Checks if a given number is a finite integer. (Throws an exception if check fails)
*
* @param { Number } value The number value to check.
*/
function isFiniteInteger(value) {
return typeof value === 'number' && isFinite(value) && isInteger(value);
}
exports.isFiniteInteger = isFiniteInteger;
/**
* Checks if an offset/length value is valid. (Throws an exception if check fails)
*
* @param value The value to check.
* @param offset True if checking an offset, false if checking a length.
*/
function checkOffsetOrLengthValue(value, offset) {
if (typeof value === 'number') {
// Check for non finite/non integers
if (!isFiniteInteger(value) || value < 0) {
throw new Error(offset ? ERRORS.INVALID_OFFSET : ERRORS.INVALID_LENGTH);
}
}
else {
throw new Error(offset ? ERRORS.INVALID_OFFSET_NON_NUMBER : ERRORS.INVALID_LENGTH_NON_NUMBER);
}
}
/**
* Checks if a length value is valid. (Throws an exception if check fails)
*
* @param { Number } length The value to check.
*/
function checkLengthValue(length) {
checkOffsetOrLengthValue(length, false);
}
exports.checkLengthValue = checkLengthValue;
/**
* Checks if a offset value is valid. (Throws an exception if check fails)
*
* @param { Number } offset The value to check.
*/
function checkOffsetValue(offset) {
checkOffsetOrLengthValue(offset, true);
}
exports.checkOffsetValue = checkOffsetValue;
/**
* Checks if a target offset value is out of bounds. (Throws an exception if check fails)
*
* @param { Number } offset The offset value to check.
* @param { SmartBuffer } buff The SmartBuffer instance to check against.
*/
function checkTargetOffset(offset, buff) {
if (offset < 0 || offset > buff.length) {
throw new Error(ERRORS.INVALID_TARGET_OFFSET);
}
}
exports.checkTargetOffset = checkTargetOffset;
/**
* Determines whether a given number is a integer.
* @param value The number to check.
*/
function isInteger(value) {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
/**
* Throws if Node.js version is too low to support bigint
*/
function bigIntAndBufferInt64Check(bufferMethod) {
if (typeof BigInt === 'undefined') {
throw new Error('Platform does not support JS BigInt type.');
}
if (typeof buffer_1.Buffer.prototype[bufferMethod] === 'undefined') {
throw new Error(`Platform does not support Buffer.prototype.${bufferMethod}.`);
}
}
exports.bigIntAndBufferInt64Check = bigIntAndBufferInt64Check;
//# sourceMappingURL=utils.js.map