fql-toolkit
Version:
80 lines • 2.67 kB
TypeScript
export type FQLLiteral = string | number | boolean | null;
export type FQLConditionOperator = '=' | '!=' | '<>' | '<' | '>' | '<=' | '>=';
/**
* Internal condition representation.
* Kept as a loose recursive type to avoid deeply-nested tuple complexity.
* Shape: [operator, operand1, operand2] | ['and'|'or', ...conditions] | ['symb', ...parts]
*/
export type FQLConditionArray = unknown[];
/** A single segment in a reference path: a field name or a compound tuple of names. */
export type RefPathSegment = string | string[];
/** A reference path: either a dot-notation string or an array of segments. */
export type RefPath = string | RefPathSegment[];
export interface DataDefinition {
name: string;
/** FQL type name. Accepts JS aliases (string→text, int→number, bool→boolean). */
type: string;
notNull?: boolean;
unique?: boolean;
}
export interface DataReference {
name: string;
/** [min, max] cardinality. Use 'many' as the max for unlimited. Default: [0, 1]. */
cardinality?: [number, number | string];
path: RefPath;
totally?: boolean;
unique?: boolean;
}
/** Internal fully-resolved spec used by FQLQueryBuilder. */
export type ResolvedSpec = (DataDefinition & {
type: string;
cardinality?: never;
path?: never;
totally?: never;
}) | (DataReference & {
type: 'reference';
});
export interface FormData {
name: string;
specs: ResolvedSpec[];
}
export interface CreateFormInput {
name: string;
dataSpecs?: DataDefinition[];
dataRefs?: DataReference[];
}
export interface ModifyFormInput {
add?: (DataDefinition | DataReference)[];
remove?: string[];
}
export type FQLRecord = Record<string, FQLLiteral | FQLLiteral[]>;
/** Normalized fql_token returned by `get case` — required for `modify case`. */
export interface FQLToken {
/** Opaque record identity string. */
token: Array<Record<string, FQLLiteral>>;
/** Name of the form the token belongs to. */
formName: string;
}
/** Raw backend shape of fql_token (before normalization). */
export interface FQLTokenRaw {
TOKEN: Array<Record<string, FQLLiteral>>;
'FORM-NAME': string;
}
/** Raw JSON shape returned by POST /api/run_code. */
export interface FQLResponseRaw {
msg?: string;
message?: string;
output?: unknown;
fql_token?: FQLTokenRaw | null;
error?: boolean;
success?: boolean;
}
/** Normalized response returned by all public fql-toolkit methods. */
export interface FQLResult<T = unknown[]> {
ok: boolean;
data: T | null;
error: string | null;
fqlToken: FQLToken | null;
message: string;
}
//# sourceMappingURL=types.d.ts.map