Skip to main content

Type Definitions (Types)

All TypeScript type definitions from the src/shared/types.ts file.

Main Configuration

GrayToolConfig

The main interface encompassing the entire extension configuration.

interface GrayToolConfig {
version: 2;
urlPatterns: UrlPattern[];
buttons: ButtonConfig[];
globalFieldConfig: GlobalFieldConfig;
settings: AppSettings;
}
FieldTypeDescription
version2 (literal)Configuration format version
urlPatternsUrlPattern[]Active URL pattern list
buttonsButtonConfig[]Defined buttons list
globalFieldConfigGlobalFieldConfigField discovery and JSON parse settings
settingsAppSettingsFeature toggle settings

URL Pattern

UrlPattern

interface UrlPattern {
id: string;
pattern: string;
label: string;
enabled: boolean;
}
FieldTypeDescription
idstringUnique identifier (auto-generated)
patternstringGlob pattern (* wildcard)
labelstringDisplay name
enabledbooleanActive/inactive state

Button Configuration

ButtonConfig

interface ButtonConfig {
id: string;
label: string;
url: string;
fieldBindings: FieldBinding[];
conditions: ButtonCondition[];
openInNewTab: boolean;
enabled: boolean;
color: ButtonColor;
icon?: string;
urlPatternIds?: string[];
}
FieldTypeDescription
idstringUnique identifier
labelstringText displayed on the button
urlstringURL template with {placeholder}
fieldBindingsFieldBinding[]Field bindings
conditionsButtonCondition[]Visibility conditions
openInNewTabbooleanOpen in new tab
enabledbooleanActive/inactive
colorButtonColorButton color
iconstring?Optional SVG icon string
urlPatternIdsstring[]?Show on specific patterns (empty = all)

ButtonColor

type ButtonColor = "primary" | "default" | "danger" | "warning" | "success";

FieldBinding

interface FieldBinding {
placeholder: string;
fieldPath: string;
fallbackPaths?: string[];
}
FieldTypeDescription
placeholderstring{name} in the URL
fieldPathstringPrimary field path
fallbackPathsstring[]?Alternative field paths

ButtonCondition

interface ButtonCondition {
field: string;
operator: ButtonConditionOperator;
value?: string;
}

ButtonConditionOperator

type ButtonConditionOperator =
| "exists"
| "equals"
| "contains"
| "startsWith"
| "notEquals";

Field Configuration

GlobalFieldConfig

interface GlobalFieldConfig {
defaultMessageField?: string | null;
rowFieldPrefixes: string[];
searchPrefixes?: string[];
parseJsonStrings?: boolean;
jsonParseMaxDepth?: number;
}
FieldTypeDefaultDescription
defaultMessageFieldstring | null?nullJSON viewer default field
rowFieldPrefixesstring[]["msg.", "context.", ""]Prefixes to search
searchPrefixesstring[]?UI alias
parseJsonStringsboolean?trueParse JSON strings
jsonParseMaxDepthnumber?5Max parse depth

Application Settings

AppSettings

interface AppSettings {
enabled: boolean;
showMessageDetailButton: boolean;
jsonViewerEnabled: boolean;
keyboardShortcutsEnabled: boolean;
searchHistoryEnabled: boolean;
}
FieldTypeDefaultDescription
enabledbooleantrueMaster on/off
showMessageDetailButtonbooleantrueMessage detail button
jsonViewerEnabledbooleantrueJSON viewer
keyboardShortcutsEnabledbooleantrueKeyboard shortcuts
searchHistoryEnabledbooleantrueSearch history

Field Discovery

DiscoveredField

interface DiscoveredField {
name: string;
value: string;
source: FieldSource;
element?: Element;
}

FieldSource

type FieldSource = "data-field" | "json-parse" | "text-pattern" | "dom-attribute";
SourcePriorityDescription
data-field4 (highest)HTML data attribute
dom-attribute3DOM structural element
json-parse2JSON parse result
text-pattern1 (lowest)Text pattern

Search History

SearchHistoryEntry

interface SearchHistoryEntry {
query: string;
timestamp: number;
}

Message Types

GrayToolMessage

type GrayToolMessage =
| ActivateMessage
| DeactivateMessage
| ConfigUpdatedMessage
| CheckUrlMessage
| GetConfigMessage
| PingMessage
| RequestPermissionMessage
| HasPermissionMessage
| GetConfiguredOriginsMessage;

ActivateMessage

interface ActivateMessage {
type: "ACTIVATE";
matchedPatternId?: string;
}

DeactivateMessage

interface DeactivateMessage {
type: "DEACTIVATE";
}

ConfigUpdatedMessage

interface ConfigUpdatedMessage {
type: "CONFIG_UPDATED";
}

Request Messages

interface CheckUrlMessage { type: "CHECK_URL"; }
interface GetConfigMessage { type: "GET_CONFIG"; }
interface PingMessage { type: "PING"; }

interface RequestPermissionMessage {
type: "REQUEST_PERMISSION";
pattern: string;
}

interface HasPermissionMessage {
type: "HAS_PERMISSION";
url: string;
}

interface GetConfiguredOriginsMessage {
type: "GET_CONFIGURED_ORIGINS";
}