IF Commons GitHub

sql/cli/discover

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0047-arcactl-init FR-011, 0047-arcactl-init FR-012

Finding the instances a person can reach (commons data 0047-arcactl-init FR-011, FR-012): from the connection the environment names, libpq's own variables, the services of pg_service.conf, the hosts .pgpass has passwords for, what arcactl already knows, and (where asked) PostgreSQL on this machine; and the arca.config.ts files in an Ergonex workspace. Then looking at each one and saying, without changing anything, whether it is reached, as whom, what that role could do to it (read, migrate, migrate and guard) and what arca it has. A password goes only to the host it is written for, never to a wildcard, and no password is printed.

Source: commons/data/sql/cli/discover.ts

6 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Candidateinterface
interface Candidate

A place a person might connect to, and where we heard of it.

MemberTypeWhat it is
namestring
sourcesreadonly string[]
host?string
port?number
database?string
user?string
sslmode?string
userService?booleanWhere the person defined a service of this name themselves, outside arcactl's block.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

discoverfunction
function discover(i: DiscoverInput): { readonly candidates: readonly Candidate[]; readonly configs: readonly string[]; }

The instances a person might reach, and the configurations their workspace has.

ParameterWhat it is
iwhat to look in

Returns: the candidates, each with where it was heard of, and the arca.config.ts files

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

passwordForfunction
function passwordFor(paths: Paths, c: Pick<Candidate, "database" | "host" | "port" | "user">): string | undefined

The password .pgpass has for a place, as libpq reads it (the first line that matches, each field exact or *); none where there is none.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Probeinterfaceno test imports it
interface Probe

What looking at one instance found.

MemberTypeWhat it is
reachableboolean
error?string
version?string
user?string
superuser?boolean
levelLevel
arca{ readonly schema: string; readonly exists: boolean; readonly tables: number; readonly models: readonly ("arcaParty" | "arcaTenancy" | "contract" | "flow" | "identity" | "identityAbac" | "identityAccess" | "identityAgent" | "identityDelegation" | "identityDevice" | "identityMachine" | "identityPki" | "identityRebac" | "issues" | "meaning" | "operations" | "proof")[]; }
probefunction
function probe(connect: (o: ConnectOptions) => Promise<Connection>, c: Candidate, password: string | undefined, schema?: string): Promise<Probe>

Looks at an instance: reads and changes nothing.

ParameterWhat it is
connecthow a connection is made
cthe instance
passwordthe password .pgpass has for it, where there is one
schemathe schema arca is looked for in

Returns: what was found

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

tablesOfModelfunctionno test imports it
function tablesOfModel(m: "arcaParty" | "arcaTenancy" | "contract" | "flow" | "identity" | "identityAbac" | "identityAccess" | "identityAgent" | "identityDelegation" | "identityDevice" | "identityMachine" | "identityPki" | "identityRebac" | "issues" | "meaning" | "operations" | "proof"): ReadonlySet<string>

The tables of a model with what it requires, as they are named in the database.

urlOffunction
function urlOf(c: Candidate, password?: string | undefined): string

A connection URL for a candidate, with a password where there is one; the password is encoded, and the URL is for the program and never for the screen.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

workspaceConfigsfunction
function workspaceConfigs(root: string, depth?: number): readonly string[]

The arca.config.ts files under a workspace root, a few levels deep, leaving out what is not source.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.