UnifiedLogs.constants.tsx364 lines · main
| 1 | import { |
| 2 | createParser, |
| 3 | parseAsArrayOf, |
| 4 | parseAsBoolean, |
| 5 | parseAsInteger, |
| 6 | parseAsString, |
| 7 | parseAsStringLiteral, |
| 8 | parseAsTimestamp, |
| 9 | } from 'nuqs' |
| 10 | |
| 11 | import { |
| 12 | ARRAY_DELIMITER, |
| 13 | LEVELS, |
| 14 | RANGE_DELIMITER, |
| 15 | SLIDER_DELIMITER, |
| 16 | SORT_DELIMITER, |
| 17 | } from '@/components/ui/DataTable/DataTable.constants' |
| 18 | |
| 19 | export const REGIONS = ['ams', 'fra', 'gru', 'hkg', 'iad', 'syd'] as const |
| 20 | export const METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'] as const |
| 21 | export const LOG_TYPES = ['postgres', 'postgrest', 'auth', 'storage', 'edge function'] as const |
| 22 | export const DEFAULT_LOG_TYPES = ['postgres', 'postgrest'] as const |
| 23 | |
| 24 | const parseAsSort = createParser({ |
| 25 | parse(queryValue: string) { |
| 26 | const [id, desc] = queryValue.split(SORT_DELIMITER) |
| 27 | if (!id && !desc) return null |
| 28 | return { id, desc: desc === 'desc' } |
| 29 | }, |
| 30 | serialize(value: { id: string; desc: boolean }) { |
| 31 | return `${value.id}.${value.desc ? 'desc' : 'asc'}` |
| 32 | }, |
| 33 | }) |
| 34 | |
| 35 | export const SEARCH_PARAMS_PARSER = { |
| 36 | // CUSTOM FILTERS |
| 37 | level: parseAsArrayOf(parseAsStringLiteral(LEVELS), ARRAY_DELIMITER), |
| 38 | log_type: parseAsArrayOf(parseAsString, ARRAY_DELIMITER), |
| 39 | latency: parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 40 | 'timing.dns': parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 41 | 'timing.connection': parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 42 | 'timing.tls': parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 43 | 'timing.ttfb': parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 44 | 'timing.transfer': parseAsArrayOf(parseAsInteger, SLIDER_DELIMITER), |
| 45 | status: parseAsArrayOf(parseAsString, ARRAY_DELIMITER), |
| 46 | regions: parseAsArrayOf(parseAsStringLiteral(REGIONS), ARRAY_DELIMITER), |
| 47 | method: parseAsArrayOf(parseAsStringLiteral(METHODS), ARRAY_DELIMITER), |
| 48 | host: parseAsString, |
| 49 | pathname: parseAsString, |
| 50 | date: parseAsArrayOf(parseAsTimestamp, RANGE_DELIMITER), |
| 51 | |
| 52 | // REQUIRED FOR SORTING & PAGINATION |
| 53 | sort: parseAsSort, |
| 54 | size: parseAsInteger.withDefault(40), |
| 55 | start: parseAsInteger.withDefault(0), |
| 56 | |
| 57 | // REQUIRED FOR INFINITE SCROLLING (Live Mode and Load More) |
| 58 | direction: parseAsStringLiteral(['prev', 'next']).withDefault('next'), |
| 59 | cursor: parseAsTimestamp.withDefault(new Date()), |
| 60 | live: parseAsBoolean.withDefault(false), |
| 61 | |
| 62 | uuid: parseAsString, |
| 63 | id: parseAsString, |
| 64 | } |
| 65 | |
| 66 | const POSTGRES_STATUS_CODE_LABELS = { |
| 67 | '00000': 'Successful Completion', |
| 68 | '01000': 'Warning', |
| 69 | '0100C': 'Dynamic Result Sets Returned', |
| 70 | '01008': 'Implicit Zero Bit Padding', |
| 71 | '01003': 'Null Value Eliminated In Set Function', |
| 72 | '01007': 'Privilege Not Granted', |
| 73 | '01006': 'Privilege Not Revoked', |
| 74 | '01004': 'String Data Right Truncation', |
| 75 | '01P01': 'Deprecated Feature', |
| 76 | '02000': 'No Data', |
| 77 | '02001': 'No Additional Dynamic Result Sets Returned', |
| 78 | '03000': 'SQL Statement Not Yet Complete', |
| 79 | '08000': 'Connection Exception', |
| 80 | '08003': 'Connection Does Not Exist', |
| 81 | '08006': 'Connection Failure', |
| 82 | '08001': 'SQL Client Unable To Establish SQL Connection', |
| 83 | '08004': 'SQL Server Rejected Establishment Of SQL Connection', |
| 84 | '08007': 'Transaction Resolution Unknown', |
| 85 | '08P01': 'Protocol Violation', |
| 86 | '09000': 'Triggered Action Exception', |
| 87 | '0A000': 'Feature Not Supported', |
| 88 | '0B000': 'Invalid Transaction Initiation', |
| 89 | '0F000': 'Locator Exception', |
| 90 | '0F001': 'Invalid Locator Specification', |
| 91 | '0L000': 'Invalid Grantor', |
| 92 | '0LP01': 'Invalid Grant Operation', |
| 93 | '0P000': 'Invalid Role Specification', |
| 94 | '0Z000': 'Diagnostics Exception', |
| 95 | '0Z002': 'Stacked Diagnostics Accessed Without Active Handler', |
| 96 | '20000': 'Case Not Found', |
| 97 | '21000': 'Cardinality Violation', |
| 98 | '22000': 'Data Exception', |
| 99 | '2202E': 'Array Subscript Error', |
| 100 | '22021': 'Character Not In Repertoire', |
| 101 | '22008': 'Datetime Field Overflow', |
| 102 | '22012': 'Division By Zero', |
| 103 | '22005': 'Error In Assignment', |
| 104 | '2200B': 'Escape Character Conflict', |
| 105 | '22022': 'Indicator Overflow', |
| 106 | '22015': 'Interval Field Overflow', |
| 107 | '2201E': 'Invalid Argument For Logarithm', |
| 108 | '22014': 'Invalid Argument For Ntile Function', |
| 109 | '22016': 'Invalid Argument For Nth Value Function', |
| 110 | '2201F': 'Invalid Argument For Power Function', |
| 111 | '2201G': 'Invalid Argument For Width Bucket Function', |
| 112 | '22018': 'Invalid Character Value For Cast', |
| 113 | '22007': 'Invalid Datetime Format', |
| 114 | '22019': 'Invalid Escape Character', |
| 115 | '2200D': 'Invalid Escape Octet', |
| 116 | '22025': 'Invalid Escape Sequence', |
| 117 | '22P06': 'Nonstandard Use Of Escape Character', |
| 118 | '22010': 'Invalid Indicator Parameter Value', |
| 119 | '22023': 'Invalid Parameter Value', |
| 120 | '2201B': 'Invalid Regular Expression', |
| 121 | '2201W': 'Invalid Row Count In Limit Clause', |
| 122 | '2201X': 'Invalid Row Count In Result Offset Clause', |
| 123 | '22009': 'Invalid Time Zone Displacement Value', |
| 124 | '2200C': 'Invalid Use Of Escape Character', |
| 125 | '2200G': 'Most Specific Type Mismatch', |
| 126 | '22004': 'Null Value Not Allowed', |
| 127 | '22002': 'Null Value No Indicator Parameter', |
| 128 | '22003': 'Numeric Value Out Of Range', |
| 129 | '22026': 'String Data Length Mismatch', |
| 130 | '22001': 'String Data Right Truncation', |
| 131 | '22011': 'Substring Error', |
| 132 | '22027': 'Trim Error', |
| 133 | '22024': 'Unterminated C String', |
| 134 | '2200F': 'Zero Length Character String', |
| 135 | '22P01': 'Floating Point Exception', |
| 136 | '22P02': 'Invalid Text Representation', |
| 137 | '22P03': 'Invalid Binary Representation', |
| 138 | '22P04': 'Bad Copy File Format', |
| 139 | '22P05': 'Untranslatable Character', |
| 140 | '2200L': 'Not An XML Document', |
| 141 | '2200M': 'Invalid XML Document', |
| 142 | '2200N': 'Invalid XML Content', |
| 143 | '2200S': 'Invalid XML Comment', |
| 144 | '2200T': 'Invalid XML Processing Instruction', |
| 145 | '23000': 'Integrity Constraint Violation', |
| 146 | '23001': 'Restrict Violation', |
| 147 | '23502': 'Not Null Violation', |
| 148 | '23503': 'Foreign Key Violation', |
| 149 | '23505': 'Unique Violation', |
| 150 | '23514': 'Check Violation', |
| 151 | '23P01': 'Exclusion Violation', |
| 152 | '24000': 'Invalid Cursor State', |
| 153 | '25000': 'Invalid Transaction State', |
| 154 | '25001': 'Active SQL Transaction', |
| 155 | '25002': 'Branch Transaction Already Active', |
| 156 | '25008': 'Held Cursor Requires Same Isolation Level', |
| 157 | '25003': 'Inappropriate Access Mode For Branch Transaction', |
| 158 | '25004': 'Inappropriate Isolation Level For Branch Transaction', |
| 159 | '25005': 'No Active SQL Transaction For Branch Transaction', |
| 160 | '25006': 'Read Only SQL Transaction', |
| 161 | '25007': 'Schema And Data Statement Mixing Not Supported', |
| 162 | '25P01': 'No Active SQL Transaction', |
| 163 | '25P02': 'In Failed SQL Transaction', |
| 164 | '25P03': 'Idle In Transaction Session Timeout', |
| 165 | '26000': 'Invalid SQL Statement Name', |
| 166 | '27000': 'Triggered Data Change Violation', |
| 167 | '28000': 'Invalid Authorization Specification', |
| 168 | '28P01': 'Invalid Password', |
| 169 | '2B000': 'Dependent Privilege Descriptors Still Exist', |
| 170 | '2BP01': 'Dependent Objects Still Exist', |
| 171 | '2D000': 'Invalid Transaction Termination', |
| 172 | '2F000': 'SQL Routine Exception', |
| 173 | '2F005': 'Function Executed No Return Statement', |
| 174 | '2F002': 'Modifying SQL Data Not Permitted', |
| 175 | '2F003': 'Prohibited SQL Statement Attempted', |
| 176 | '2F004': 'Reading SQL Data Not Permitted', |
| 177 | '34000': 'Invalid Cursor Name', |
| 178 | '38000': 'External Routine Exception', |
| 179 | '38001': 'Containing SQL Not Permitted', |
| 180 | '38002': 'Modifying SQL Data Not Permitted', |
| 181 | '38003': 'Prohibited SQL Statement Attempted', |
| 182 | '38004': 'Reading SQL Data Not Permitted', |
| 183 | '39000': 'External Routine Invocation Exception', |
| 184 | '39001': 'Invalid SQLSTATE Returned', |
| 185 | '39004': 'Null Value Not Allowed', |
| 186 | '39P01': 'Trigger Protocol Violated', |
| 187 | '39P02': 'SRF Protocol Violated', |
| 188 | '39P03': 'Event Trigger Protocol Violated', |
| 189 | '3B000': 'Savepoint Exception', |
| 190 | '3B001': 'Invalid Savepoint Specification', |
| 191 | '3D000': 'Invalid Catalog Name', |
| 192 | '3F000': 'Invalid Schema Name', |
| 193 | '40000': 'Transaction Rollback', |
| 194 | '40002': 'Transaction Integrity Constraint Violation', |
| 195 | '40001': 'Serialization Failure', |
| 196 | '40003': 'Statement Completion Unknown', |
| 197 | '40P01': 'Deadlock Detected', |
| 198 | '42000': 'Syntax Error Or Access Rule Violation', |
| 199 | '42601': 'Syntax Error', |
| 200 | '42501': 'Insufficient Privilege', |
| 201 | '42846': 'Cannot Coerce', |
| 202 | '42803': 'Grouping Error', |
| 203 | '42P20': 'Windowing Error', |
| 204 | '42P19': 'Invalid Recursion', |
| 205 | '42830': 'Invalid Foreign Key', |
| 206 | '42602': 'Invalid Name', |
| 207 | '42622': 'Name Too Long', |
| 208 | '42939': 'Reserved Name', |
| 209 | '42804': 'Datatype Mismatch', |
| 210 | '42P18': 'Indeterminate Datatype', |
| 211 | '42809': 'Wrong Object Type', |
| 212 | '428C9': 'Generated Always', |
| 213 | '42703': 'Undefined Column', |
| 214 | '42883': 'Undefined Function', |
| 215 | '42P01': 'Undefined Table', |
| 216 | '42P02': 'Undefined Parameter', |
| 217 | '42704': 'Undefined Object', |
| 218 | '42701': 'Duplicate Column', |
| 219 | '42P03': 'Duplicate Cursor', |
| 220 | '42P04': 'Duplicate Database', |
| 221 | '42723': 'Duplicate Function', |
| 222 | '42P05': 'Duplicate Prepared Statement', |
| 223 | '42P06': 'Duplicate Schema', |
| 224 | '42P07': 'Duplicate Table', |
| 225 | '42712': 'Duplicate Alias', |
| 226 | '42710': 'Duplicate Object', |
| 227 | '42702': 'Ambiguous Column', |
| 228 | '42725': 'Ambiguous Function', |
| 229 | '42P08': 'Ambiguous Parameter', |
| 230 | '42P09': 'Ambiguous Alias', |
| 231 | '42P10': 'Invalid Column Reference', |
| 232 | '42611': 'Invalid Column Definition', |
| 233 | '42P11': 'Invalid Cursor Definition', |
| 234 | '42P12': 'Invalid Database Definition', |
| 235 | '42P13': 'Invalid Function Definition', |
| 236 | '42P14': 'Invalid Prepared Statement Definition', |
| 237 | '42P15': 'Invalid Schema Definition', |
| 238 | '42P16': 'Invalid Table Definition', |
| 239 | '42P17': 'Invalid Object Definition', |
| 240 | '44000': 'With Check Option Violation', |
| 241 | '53000': 'Insufficient Resources', |
| 242 | '53100': 'Disk Full', |
| 243 | '53200': 'Out Of Memory', |
| 244 | '53300': 'Too Many Connections', |
| 245 | '53400': 'Configuration Limit Exceeded', |
| 246 | '54000': 'Program Limit Exceeded', |
| 247 | '54001': 'Statement Too Complex', |
| 248 | '54011': 'Too Many Columns', |
| 249 | '54023': 'Too Many Arguments', |
| 250 | '55000': 'Object Not In Prerequisite State', |
| 251 | '55006': 'Object In Use', |
| 252 | '55P02': "Can't Change Runtime Param", |
| 253 | '55P03': 'Lock Not Available', |
| 254 | '55P04': 'Unsafe New Enum Value Usage', |
| 255 | '57000': 'Operator Intervention', |
| 256 | '57014': 'Query Canceled', |
| 257 | '57P01': 'Admin Shutdown', |
| 258 | '57P02': 'Crash Shutdown', |
| 259 | '57P03': 'Cannot Connect Now', |
| 260 | '57P04': 'Database Dropped', |
| 261 | '58000': 'System Error', |
| 262 | '58030': 'IO Error', |
| 263 | '58P01': 'Undefined File', |
| 264 | '58P02': 'Duplicate File', |
| 265 | F0000: 'Config File Error', |
| 266 | F0001: 'Lock File Exists', |
| 267 | HV000: 'FDW Error', |
| 268 | HV005: 'FDW Column Name Not Found', |
| 269 | HV002: 'FDW Dynamic Parameter Value Needed', |
| 270 | HV010: 'FDW Function Sequence Error', |
| 271 | HV021: 'FDW Inconsistent Data', |
| 272 | HV024: 'FDW Invalid Attribute Value', |
| 273 | HV007: 'FDW Invalid Column Name', |
| 274 | HV008: 'FDW Invalid Column Number', |
| 275 | HV004: 'FDW Invalid Data Type', |
| 276 | HV006: 'FDW Invalid Data Type Descriptors', |
| 277 | HV091: 'FDW Invalid Handle', |
| 278 | HV00B: 'FDW Invalid Option Index', |
| 279 | HV00C: 'FDW Invalid Option Name', |
| 280 | HV00D: 'FDW Invalid String Length Or Buffer Length', |
| 281 | HV090: 'FDW Invalid String Format', |
| 282 | HV00A: 'FDW Invalid Use Of Null Pointer', |
| 283 | HV009: 'FDW Too Many Handles', |
| 284 | HV014: 'FDW Out Of Memory', |
| 285 | HV001: 'FDW Unsupported Function', |
| 286 | P0000: 'PL/pgSQL Error', |
| 287 | P0001: 'Raise Exception', |
| 288 | P0002: 'No Data Found', |
| 289 | P0003: 'Too Many Rows', |
| 290 | P0004: 'Assert Failure', |
| 291 | XX000: 'Internal Error', |
| 292 | XX001: 'Data Corrupted', |
| 293 | XX002: 'Index Corrupted', |
| 294 | } |
| 295 | |
| 296 | const HTTP_STATUS_CODE_LABELS = { |
| 297 | '100': 'Continue', |
| 298 | '101': 'Switching Protocols', |
| 299 | '102': 'Processing', |
| 300 | '103': 'Early Hints', |
| 301 | '200': 'OK', |
| 302 | '201': 'Created', |
| 303 | '202': 'Accepted', |
| 304 | '203': 'Non-Authoritative Information', |
| 305 | '204': 'No Content', |
| 306 | '205': 'Reset Content', |
| 307 | '206': 'Partial Content', |
| 308 | '207': 'Multi-Status', |
| 309 | '208': 'Already Reported', |
| 310 | '226': 'IM Used', |
| 311 | '300': 'Multiple Choices', |
| 312 | '301': 'Moved Permanently', |
| 313 | '302': 'Found', |
| 314 | '303': 'See Other', |
| 315 | '304': 'Not Modified', |
| 316 | '305': 'Use Proxy', |
| 317 | '307': 'Temporary Redirect', |
| 318 | '308': 'Permanent Redirect', |
| 319 | '400': 'Bad Request', |
| 320 | '401': 'Unauthorized', |
| 321 | '402': 'Payment Required', |
| 322 | '403': 'Forbidden', |
| 323 | '404': 'Not Found', |
| 324 | '405': 'Method Not Allowed', |
| 325 | '406': 'Not Acceptable', |
| 326 | '407': 'Proxy Authentication Required', |
| 327 | '408': 'Request Timeout', |
| 328 | '409': 'Conflict', |
| 329 | '410': 'Gone', |
| 330 | '411': 'Length Required', |
| 331 | '412': 'Precondition Failed', |
| 332 | '413': 'Payload Too Large', |
| 333 | '414': 'URI Too Long', |
| 334 | '415': 'Unsupported Media Type', |
| 335 | '416': 'Range Not Satisfiable', |
| 336 | '417': 'Expectation Failed', |
| 337 | '418': "I'm a teapot", |
| 338 | '421': 'Misdirected Request', |
| 339 | '422': 'Unprocessable Entity', |
| 340 | '423': 'Locked', |
| 341 | '424': 'Failed Dependency', |
| 342 | '425': 'Too Early', |
| 343 | '426': 'Upgrade Required', |
| 344 | '428': 'Precondition Required', |
| 345 | '429': 'Too Many Requests', |
| 346 | '431': 'Request Header Fields Too Large', |
| 347 | '451': 'Unavailable For Legal Reasons', |
| 348 | '500': 'Internal Server Error', |
| 349 | '501': 'Not Implemented', |
| 350 | '502': 'Bad Gateway', |
| 351 | '503': 'Service Unavailable', |
| 352 | '504': 'Gateway Timeout', |
| 353 | '505': 'HTTP Version Not Supported', |
| 354 | '506': 'Variant Also Negotiates', |
| 355 | '507': 'Insufficient Storage', |
| 356 | '508': 'Loop Detected', |
| 357 | '510': 'Not Extended', |
| 358 | '511': 'Network Authentication Required', |
| 359 | } |
| 360 | |
| 361 | export const STATUS_CODE_LABELS = { |
| 362 | ...HTTP_STATUS_CODE_LABELS, |
| 363 | ...POSTGRES_STATUS_CODE_LABELS, |
| 364 | } |