/* eslint-disable indent */ /* eslint-disable @typescript-eslint/no-namespace */ declare namespace RGX { const MARKER: { readonly BULLET: RegExp; readonly KEY_PRFX: RegExp; readonly COL: RegExp; readonly MLINE_STR: RegExp; }; // for whitespace handling... const MARKER_WS: { readonly KEY_PRFX: RegExp; readonly COL: RegExp; }; const VALID_CHARS: { readonly KEY: RegExp; readonly VAL: RegExp; readonly VAL_LINE: RegExp; }; const CAP_GRP: { readonly KEY: RegExp; readonly VAL: RegExp; readonly VAL_LINE: RegExp; readonly VAL_MSTR: RegExp; }; const LINE: { readonly KEY: RegExp; readonly LIST_ITEM: RegExp; }; // <------------------------------------------------------------------------> // multi-line string patterns (compositional approach) // <------------------------------------------------------------------------> const MLINE: { readonly SINGLE: RegExp; readonly IN_COMMA: RegExp; readonly IN_MKDN_LIST: RegExp; }; const CAML: RegExp; } // data interface CamlValData { type: string; string: string; value: null | boolean | number | bigint | Date | string; // | NaN; } // func // dump() interface CamlDumpOpts { format?: "pretty" | "pad" | "none"; listFormat?: "comma" | "mkdn"; prefix?: boolean; multiLine?: "none" | "literal" | "folded"; chomp?: "clip" | "strip" | "keep"; indent?: number; } // load() interface CamlLoadPayload { data: any; content: string; } // scan() interface CamlScanOpts { skipEsc?: boolean; // whether to skip escaped CAML instances (default: true) } interface ScanTxt { text: string; start: number; } interface CamlScanResVal { type: string; val: ScanTxt; } interface CamlScanResult { key: ScanTxt; vals: CamlScanResVal[]; } /****************************************************************************** from: https://github.com/eemeli/yaml licensing permission: Copyright Eemeli Aro Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************************/ // 'val' as in, "i want to extract the value" and likely used in conjunction // with other regexes to interact with caml attributes declare const VAL: { readonly NULL: RegExp; readonly BOOL: RegExp; readonly INT: RegExp; readonly INT_HEX: RegExp; readonly INT_OCT: RegExp; readonly FLOAT: RegExp; readonly FLOAT_EXP: RegExp; readonly FLOAT_NAN: RegExp; readonly TIME_INT: RegExp; readonly TIME_FLOAT: RegExp; readonly TIMESTAMP: RegExp; readonly STRING: RegExp; }; // 'type' as in, "i want to determine the type of the value" and likely used in isolation // to narrowly determine the type of a given value, perhaps to 'rgx.test(str)' for example. declare const TYPE: { readonly NULL: RegExp; readonly BOOL: RegExp; readonly INT: RegExp; readonly INT_HEX: RegExp; readonly INT_OCT: RegExp; readonly FLOAT: RegExp; readonly FLOAT_EXP: RegExp; readonly FLOAT_NAN: RegExp; readonly TIME_INT: RegExp; readonly TIME_FLOAT: RegExp; readonly TIMESTAMP: RegExp; readonly STRING: RegExp; }; // from: https://github.com/eemeli/yaml/blob/27bd4faa79c4ff01410c8c6fcf8baa8586769320/src/schema/yaml-1.1/timestamp.ts#L6 declare function parseSexagesimal(str: string, asBigInt?: B): B extends true ? number | bigint : number; // from js-yaml: https://github.com/nodeca/js-yaml/blob/master/lib/type/timestamp.js#L29 declare function constructYamlTimestamp(data: any): Date; declare function dump(attrs: any, opts?: CamlDumpOpts): string; declare function load(content: string, opts?: { skipEsc?: boolean; }): CamlLoadPayload; // todo: what if there's leading/trailing whitespace? (trimming beforehand, for now) declare function resolve(value: string): CamlValData; // scan -- useful for syntax highlights declare function scan(content: string, opts?: CamlScanOpts): CamlScanResult[]; interface UpdateOpts { type?: string; format?: "offsets" | "content"; skipEsc?: boolean; // if true (default), skip escaped CAML (e.g. in code blocks) } declare function update(content: string, key: string, newVal: string, opts?: UpdateOpts): [ number, number, string ] | string | undefined; export { RGX, CamlValData, CamlDumpOpts, CamlLoadPayload, CamlScanOpts, ScanTxt, CamlScanResVal, CamlScanResult, VAL, TYPE, parseSexagesimal, constructYamlTimestamp, dump, load, resolve, scan, UpdateOpts, update };