IF Commons GitHub

aide/profile/mod

Profiles (commons lang-sql 0010-aide FR-002): a subset of the language, as data. A little language made of SQL says which statements, nodes, functions and tables it has and how large a statement may be, and conform gives every violation of a parse with the span of its node and one sentence, so that a language of one table and no joins is a value and not a grammar.

const files = defineProfile({ name: "files", statements: ["select"], forbidNodes: ["join", "subquery"], tables: ["files"], functions: ["lower"], maxDepth: 40 });
conform(parse("SELECT name FROM files", ansi), files); // ok

Spec: 0010-aide FR-001, FR-002

Source: commons/lang-sql/src/aide/profile/mod.ts

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

Profileinterfaceno test imports it
interface Profile

A subset of the language.

MemberTypeWhat it is
namestring
statementsreadonly ("alter-table" | "command" | "create-index" | "create-routine" | "create-table" | "create-view" | "delete" | "drop" | "insert" | "select" | "set-op" | "unparsed" | "update" | "values" | "with")[]The kinds of statement that are allowed.
forbidNodesreadonly ("add-column" | "add-constraint" | "alias" | "alter-table" | "array" | "assignment" | "between" | "binary" | "boolean" | "call" | "case" | "cast" | "check" | "collate" | "column-def" | "column-option" | "command" | "create-index" | "create-routine" | "create-table" | "create-view" | "cte" | "data-type" | "default" | "delete" | "drop" | "drop-column" | "drop-constraint" | "exists" | "extract" | "field" | "foreign-key" | "frame" | "frame-bound" | "ident" | "in" | "in-query" | "insert" | "interval" | "is" | "join" | "keyword-arg" | "lambda" | "like" | "name" | "named-arg" | "not-null" | "null" | "number" | "on-conflict" | "operator" | "order-item" | "param" | "primary-key" | "reference" | "rename-column" | "rename-table" | "routine-body" | "routine-param" | "scalar-query" | "script" | "select" | "select-item" | "set-op" | "star" | "star-modifier" | "string" | "struct" | "struct-entry" | "subquery" | "subscript" | "table" | "table-fn" | "table-like" | "table-op" | "tuple" | "type-field" | "typed-string" | "unary" | "unique" | "unparsed" | "update" | "values" | "when" | "window-def" | "window-spec" | "with")[]The kinds of node that are not.
functionsreadonly string[] | undefinedThe functions that may be called, without regard to case; any where not given.
tablesreadonly string[] | undefinedThe tables that may be read, without regard to case; any where not given.
maxDepthnumber | undefined
maxNodesnumber | undefined
maxTablesnumber | undefined
deniedFunctionsreadonly string[]The functions that may not be called, without regard to case or to a schema before the name.
maxStatementsnumber | undefinedThe most statements a text may hold; any where not given.
ProfileSpecinterfaceno test imports it
interface ProfileSpec

What a profile is made from.

MemberTypeWhat it is
namestring
statementsreadonly ("alter-table" | "command" | "create-index" | "create-routine" | "create-table" | "create-view" | "delete" | "drop" | "insert" | "select" | "set-op" | "unparsed" | "update" | "values" | "with")[]
forbidNodes?readonly ("add-column" | "add-constraint" | "alias" | "alter-table" | "array" | "assignment" | "between" | "binary" | "boolean" | "call" | "case" | "cast" | "check" | "collate" | "column-def" | "column-option" | "command" | "create-index" | "create-routine" | "create-table" | "create-view" | "cte" | "data-type" | "default" | "delete" | "drop" | "drop-column" | "drop-constraint" | "exists" | "extract" | "field" | "foreign-key" | "frame" | "frame-bound" | "ident" | "in" | "in-query" | "insert" | "interval" | "is" | "join" | "keyword-arg" | "lambda" | "like" | "name" | "named-arg" | "not-null" | "null" | "number" | "on-conflict" | "operator" | "order-item" | "param" | "primary-key" | "reference" | "rename-column" | "rename-table" | "routine-body" | "routine-param" | "scalar-query" | "script" | "select" | "select-item" | "set-op" | "star" | "star-modifier" | "string" | "struct" | "struct-entry" | "subquery" | "subscript" | "table" | "table-fn" | "table-like" | "table-op" | "tuple" | "type-field" | "typed-string" | "unary" | "unique" | "unparsed" | "update" | "values" | "when" | "window-def" | "window-spec" | "with")[]
functions?readonly string[]
tables?readonly string[]
maxDepth?number
maxNodes?number
maxTables?number
deniedFunctions?readonly string[]
maxStatements?number
Violationinterfaceno test imports it
interface Violation

What a parse does that its profile does not allow.

MemberTypeWhat it is
startnumber
endnumber
messagestring
defineProfilefunction
function defineProfile(spec: ProfileSpec): Profile

A profile from its parts.

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

conformfunction
function conform(parsed: Parsed, profile: Profile): Result<Parsed, readonly Violation[]>

The parse where it is inside the profile; every violation, with its span, where it is not.

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

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