|
| 1 | +type collection |
| 2 | +type cursor |
| 3 | +type savedDoc = {_key: string} |
| 4 | + |
| 5 | +@send external collSave: (collection, 'a) => promise<savedDoc> = "save" |
| 6 | +@send external collUpdate: (collection, string, 'a) => promise<unit> = "update" |
| 7 | +@send external collDocument: (collection, string) => promise<'a> = "document" |
| 8 | +@send external collByExample: (collection, 'a) => promise<cursor> = "byExample" |
| 9 | +@send external collCount: collection => promise<{"count": int}> = "count" |
| 10 | + |
| 11 | +@send external cursorAll: cursor => promise<array<'a>> = "all" |
| 12 | +@get external cursorCount: cursor => option<int> = "count" |
| 13 | + |
| 14 | +type wcagLevel = [#A | #"AA" | #"AAA"] |
| 15 | +type siteStatus = [#active | #inactive | #failed] |
| 16 | + |
| 17 | +type site = { |
| 18 | + _key: string, |
| 19 | + url: string, |
| 20 | + domain: string, |
| 21 | + firstScanned: Date.t, |
| 22 | + lastScanned: Date.t, |
| 23 | + scanCount: int, |
| 24 | + currentScore: int, |
| 25 | + previousScore?: int, |
| 26 | + status: siteStatus, |
| 27 | +} |
| 28 | + |
| 29 | +type scan = { |
| 30 | + _key: string, |
| 31 | + siteKey: string, |
| 32 | + timestamp: string, |
| 33 | + score: int, |
| 34 | + violations: int, |
| 35 | + passes: int, |
| 36 | + incomplete: int, |
| 37 | + url: string, |
| 38 | + wcagLevel: wcagLevel, |
| 39 | + duration: int, |
| 40 | + userAgent?: string, |
| 41 | +} |
| 42 | + |
| 43 | +type violation = { |
| 44 | + _key: string, |
| 45 | + scanKey: string, |
| 46 | + siteKey: string, |
| 47 | + wcagCriterion: string, |
| 48 | + wcagLevel: wcagLevel, |
| 49 | + impact: string, |
| 50 | + description: string, |
| 51 | + helpUrl: string, |
| 52 | + selector: string, |
| 53 | + html: string, |
| 54 | + timestamp: Date.t, |
| 55 | + fixed: bool, |
| 56 | +} |
| 57 | + |
| 58 | +type organization = { |
| 59 | + _key: string, |
| 60 | + name: string, |
| 61 | + tier: string, |
| 62 | +} |
| 63 | + |
| 64 | +type criterionCount = {criterion: string, count: int} |
| 65 | +type trendPoint = {timestamp: Date.t, violations: int, score: int} |
| 66 | + |
| 67 | +type service = { |
| 68 | + sites: collection, |
| 69 | + scans: collection, |
| 70 | + violations: collection, |
| 71 | + wcagCriteria: collection, |
| 72 | + organizations: collection, |
| 73 | + siteScans: collection, |
| 74 | + scanViolations: collection, |
| 75 | + violationCriteria: collection, |
| 76 | + orgSites: collection, |
| 77 | +} |
| 78 | + |
| 79 | +@module("@accessibility-everywhere/core") |
| 80 | +external createArangoDBService: unit => service = "createArangoDBService" |
| 81 | +@module("@accessibility-everywhere/core") external initialize: service => promise<unit> = "initialize" |
| 82 | +@module("@accessibility-everywhere/core") external getSiteByUrl: (service, string) => promise<option<site>> = "getSiteByUrl" |
| 83 | +@module("@accessibility-everywhere/core") |
| 84 | +external getRecentScansForSite: (service, string, ~limit: int=?) => promise<array<scan>> = "getRecentScansForSite" |
| 85 | +@module("@accessibility-everywhere/core") |
| 86 | +external getViolationsForScan: (service, string) => promise<array<violation>> = "getViolationsForScan" |
| 87 | +@module("@accessibility-everywhere/core") |
| 88 | +external getTopSites: (service, ~limit: int=?) => promise<array<site>> = "getTopSites" |
| 89 | +@module("@accessibility-everywhere/core") |
| 90 | +external getCommonViolations: (service, ~limit: int=?) => promise<array<criterionCount>> = "getCommonViolations" |
| 91 | +@module("@accessibility-everywhere/core") |
| 92 | +external getSiteViolationTrend: (service, string, ~days: int=?) => promise<array<trendPoint>> = "getSiteViolationTrend" |
| 93 | +@module("@accessibility-everywhere/core") |
| 94 | +external getOrganizationSites: (service, string) => promise<array<site>> = "getOrganizationSites" |
| 95 | + |
| 96 | +type scanner |
| 97 | + |
| 98 | +type scanOptions = { |
| 99 | + url: string, |
| 100 | + wcagLevel: wcagLevel, |
| 101 | + screenshot?: bool, |
| 102 | +} |
| 103 | + |
| 104 | +type scanNodeDetail = {target: array<string>, html: string} |
| 105 | +type scanViolationDetail = { |
| 106 | + impact: string, |
| 107 | + description: string, |
| 108 | + helpUrl: string, |
| 109 | + wcag: array<string>, |
| 110 | + nodes: array<scanNodeDetail>, |
| 111 | +} |
| 112 | +type scanPassDetail = {description: string} |
| 113 | +type scanIncompleteDetail = {description: string} |
| 114 | +type scanMetadata = {userAgent: string} |
| 115 | +type scanResult = { |
| 116 | + url: string, |
| 117 | + timestamp: string, |
| 118 | + score: int, |
| 119 | + duration: int, |
| 120 | + violations: array<scanViolationDetail>, |
| 121 | + passes: array<scanPassDetail>, |
| 122 | + incomplete: array<scanIncompleteDetail>, |
| 123 | + metadata: scanMetadata, |
| 124 | +} |
| 125 | + |
| 126 | +@module("@accessibility-everywhere/scanner") external createScanner: unit => scanner = "createScanner" |
| 127 | +@send external runScan: (scanner, scanOptions) => promise<scanResult> = "scan" |
0 commit comments