ANSI_FUNCTIONSconstno test imports itconst ANSI_FUNCTIONS: readonly FunctionSpec[]The functions of the common ground.
The registry of dialects (commons lang-sql 0007-sql-emit FR-006 to FR-008): a library outside this one registers a dialect it made with defineDialect and the catalog of the functions the dialect has, and another library finds both by name. A registry starts with the base dialect ansi and its catalog; a dialect's functions are its own and those of the dialects it extends, its own replacing a parent's of the same name. Nothing here throws: a name taken, a parent that is not registered and a function that cannot be is an error value.
const registry = createRegistry();
registry.register(mine); // mine extends ansi
registry.registerFunctions("mine", [{ name: "path_of", minArgs: 1, maxArgs: 1, aggregate: false }]);
registry.lookupFunction("mine", "PATH_OF"); // the function; "count" is found in ansiSpec: 0007-sql-emit FR-006, FR-007, FR-008
ANSI_FUNCTIONSconstno test imports itconst ANSI_FUNCTIONS: readonly FunctionSpec[]The functions of the common ground.
createRegistryfunctionfunction createRegistry(): RegistryA registry with the base dialect ansi and its functions.
describeRegistryErrorfunctionfunction describeRegistryError(e: RegistryError): stringOne sentence for a registry error.
FunctionSpecinterfaceinterface FunctionSpecA function of a dialect: its name, how many arguments it takes, and whether it aggregates.
| Member | Type | What it is |
|---|---|---|
name | string | |
minArgs | number | |
maxArgs | number | undefined | The most arguments it takes; undefined where there is no most. |
aggregate | boolean | |
returns? | string | The type of what it gives, as the dialect writes a type. |
summary? | string |
Registryinterfaceno test imports itinterface RegistryA registry of dialects with the catalog of functions of each.
| Member | Type | What it is |
|---|---|---|
register | (dialect: Dialect) => Result<Dialect, RegistryError> | Adds a dialect; the same dialect value again changes nothing. |
get | (name: string) => Dialect | undefined | The dialect of a name, without regard to case. |
names | () => readonly string[] | The names, in the order of registration. |
registerFunctions | (dialect: string, functions: readonly FunctionSpec[]) => Result<number, RegistryError> | Adds functions to the catalog of a registered dialect; the number added. |
lookupFunction | (dialect: string, name: string) => FunctionSpec | undefined | A function of a dialect, found in its catalog and then in those of the dialects it extends. |
functionsOf | (dialect: string) => readonly FunctionSpec[] | Every function the dialect finds, each name once, its own replacing its parent's. |
RegistryErrortypeno test imports ittype RegistryError =
| { readonly kind: "name-taken"; readonly name: string }
| { readonly kind: "unknown-parent"; readonly name: string; readonly parent: string }
| { readonly kind: "unknown-dialect"; readonly name: string }
| { readonly kind: "bad-function"; readonly name: string; readonly why: string };Why something was not registered.