Where the data can come from
The SDK can query two broad families of external sources, and both feed the same decision and proof flow.
Live networked sources are queried over the network at check time. One group is relational databases, covering PostgreSQL, MySQL, MariaDB, SQLite, MSSQL, Oracle, DB2, and legacy systems reached through ODBC connections such as PAS and mainframe estates. For these, the host application supplies driver executors that know how to talk to the database, and the SDK uses those executors to run the lookup. The other group is any HTTP service that returns JSON. For these, you configure a profile with a base address, a path template that names where the record lives, optional authentication material taken from an environment variable, and a JSON path that says where the record sits inside the response. The SDK then fetches from that service and extracts the record for checking.
import { AffixSDK, SqlStore, createPgExecutor } from "affixio";
import pg from "pg";
const pool = new pg.Pool({ connectionString: process.env.AFFIX_SQL_PRIMARY_URL });
const executor = createPgExecutor(pool, { readOnly: true, timeoutMs: 10_000, role: "primary" });
const store = SqlStore.fromExecutor(executor, {
table: "records",
dialect: "postgres",
lookupSql: "SELECT id, status, site FROM records WHERE id = :id LIMIT 1",
readOnly: true,
timeoutMs: 10_000,
});
const sdk = new AffixSDK({ apiKey: process.env.AFFIX_API_KEY });
const proved = await sdk.checkAndProve(store, {
id: "REC-1001",
claimField: "status",
required: "active",
}, { mode: "offline" });
import { createHttpDataStore, testHttpProfile } from "affixio";
const profile = {
baseUrl: "https://records.example.com",
pathTemplate: "/v1/records/{id}",
authEnv: "AFFIX_RECORDS_API_TOKEN",
recordsPath: "data.record",
timeoutMs: 10_000,
};
const check = await testHttpProfile(profile);
if (!check.ok) throw new Error("HTTP profile unreachable: " + check.error);
const store = createHttpDataStore(profile, "records-api");
File-based and exported sources are for offline or air-gapped contexts. These are loaded from files rather than reached over a live network call, which makes them suitable where connectivity is restricted, where you work from scheduled exports, or where you want a fixed snapshot to check against. The supported file shapes include plain JSON documents, simple key-value files, comma-separated and tab-separated tables, pipe-delimited and semicolon-delimited tables, fixed-width tables, dBASE and FoxPro database files, LDAP export files in LDIF form, INI-style sectioned files, MongoDB-style document exports, and Redis export dumps. Even though the record comes from a file on disk, it still flows through the same yes or no decision and proof steps as a live lookup.
import { openDataStore } from "affixio";
const json = openDataStore({ kind: "json", path: "./extract.json" });
const csv = openDataStore({ kind: "csv", path: "./extract.csv" });
const tsv = openDataStore({ kind: "tsv", path: "./extract.tsv" });
const pipe = openDataStore({ kind: "pipe", path: "./extract.pipe" });
const scsv = openDataStore({ kind: "semicolon", path: "./extract.scsv" });
const fw = openDataStore({ kind: "fixed_width", path: "./extract.fw", fixedFields: [
{ name: "id", start: 0, length: 10 },
{ name: "status", start: 10, length: 12 },
]});
const dbf = openDataStore({ kind: "dbf", path: "./legacy.dbf" });
const ldif = openDataStore({ kind: "ldif", path: "./export.ldif" });
const ini = openDataStore({ kind: "ini", path: "./wards.ini" });
const mongo = openDataStore({ kind: "mongo", path: "./mongo-export.json" });
const redis = openDataStore({ kind: "redis_export", path: "./redis-export.txt" });
const kv = openDataStore({ kind: "key_value", path: "./lookup.kv" });