1ls 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +279 -11
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/index.js +11 -11
- package/dist/cli/constants.d.ts +1 -1
- package/dist/{utils → cli}/stream.d.ts +1 -1
- package/dist/completions/1ls.bash +10 -18
- package/dist/completions/1ls.zsh +69 -7
- package/dist/{shared/constants.d.ts → constants.d.ts} +1 -1
- package/dist/expression/constants.d.ts +2 -0
- package/dist/expression/index.d.ts +3 -12
- package/dist/expression/utils.d.ts +14 -1
- package/dist/file/constants.d.ts +4 -0
- package/dist/file/filters.d.ts +7 -0
- package/dist/file/grep.d.ts +10 -0
- package/dist/file/index.d.ts +7 -0
- package/dist/file/info.d.ts +4 -0
- package/dist/file/io.d.ts +5 -0
- package/dist/{utils → file}/types.d.ts +0 -17
- package/dist/file/walk.d.ts +4 -0
- package/dist/formats/index.d.ts +1 -1
- package/dist/formats/types.d.ts +1 -0
- package/dist/formats/yaml/index.d.ts +2 -0
- package/dist/formats/yaml/types.d.ts +8 -0
- package/dist/formats/yaml/utils.d.ts +28 -0
- package/dist/index.js +83 -63
- package/dist/interactive/builder/constants.d.ts +14 -0
- package/dist/interactive/{builder.d.ts → builder/index.d.ts} +1 -1
- package/dist/interactive/builder/types.d.ts +4 -0
- package/dist/interactive/builder/utils.d.ts +7 -0
- package/dist/interactive/methods/constants.d.ts +10 -0
- package/dist/interactive/methods/index.d.ts +4 -0
- package/dist/interactive/methods/types.d.ts +8 -0
- package/dist/interactive/preview/constants.d.ts +4 -0
- package/dist/interactive/preview/index.d.ts +5 -0
- package/dist/interactive/preview/types.d.ts +6 -0
- package/dist/interactive/tooltip/constants.d.ts +3 -0
- package/dist/interactive/tooltip/index.d.ts +20 -0
- package/dist/interactive/tooltip/types.d.ts +13 -0
- package/dist/interactive/types.d.ts +5 -7
- package/dist/{utils/logger.d.ts → logger.d.ts} +10 -1
- package/dist/navigator/builtins/constants.d.ts +62 -0
- package/dist/navigator/builtins/index.d.ts +6 -0
- package/dist/navigator/builtins/types.d.ts +3 -0
- package/dist/navigator/builtins/utils.d.ts +12 -0
- package/dist/navigator/json/constants.d.ts +2 -0
- package/dist/navigator/json/index.d.ts +22 -0
- package/dist/navigator/json/types.d.ts +3 -0
- package/dist/navigator/json/utils.d.ts +14 -0
- package/dist/shortcuts/constants.d.ts +15 -0
- package/dist/shortcuts/index.d.ts +9 -0
- package/dist/shortcuts/types.d.ts +6 -0
- package/dist/types.d.ts +22 -2
- package/dist/version.d.ts +1 -0
- package/package.json +5 -3
- package/dist/formats/yaml.d.ts +0 -3
- package/dist/interactive/methods.d.ts +0 -12
- package/dist/navigator/json.d.ts +0 -26
- package/dist/utils/constants.d.ts +0 -12
- package/dist/utils/file.d.ts +0 -27
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/shortcuts.d.ts +0 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const ARROW_FN_PATTERNS: {
|
|
2
|
+
readonly SINGLE_PARAM: "x =>";
|
|
3
|
+
readonly SORT_PARAMS: "(a, b)";
|
|
4
|
+
readonly REDUCE_PARAMS: "(acc, x)";
|
|
5
|
+
};
|
|
6
|
+
export declare const TEMPLATE_REPLACEMENTS: {
|
|
7
|
+
readonly SINGLE_PARAM: "x => x";
|
|
8
|
+
readonly SORT_COMPARE: "(a, b) => a - b";
|
|
9
|
+
readonly REDUCE_ACC: "(acc, x) => acc";
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_PARAM_NAMES: {
|
|
12
|
+
readonly SORT: "a";
|
|
13
|
+
readonly DEFAULT: "x";
|
|
14
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { State } from "
|
|
1
|
+
import type { State } from "../types";
|
|
2
2
|
export declare const enterBuildMode: (state: State) => State;
|
|
3
3
|
export declare const exitBuildMode: (state: State) => State;
|
|
4
4
|
export declare const updateBuildQuery: (state: State, query: string) => State;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const needsArrowFn: (template: string) => boolean;
|
|
2
|
+
export declare const getParamName: (template: string) => string;
|
|
3
|
+
export declare const getParamType: (value: unknown) => string;
|
|
4
|
+
export declare const getArraySampleValue: (value: unknown) => unknown;
|
|
5
|
+
export declare const replaceLastOccurrence: (str: string, find: string, replace: string) => string;
|
|
6
|
+
export declare const replaceTemplateWithExpression: (expression: string, template: string, contextExpression: string) => string;
|
|
7
|
+
export declare const buildArrowExpression: (path: string, paramName: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Method } from "./types";
|
|
2
|
+
export declare const ARRAY_METHODS: Method[];
|
|
3
|
+
export declare const STRING_METHODS: Method[];
|
|
4
|
+
export declare const OBJECT_OPERATIONS: Method[];
|
|
5
|
+
export declare const NUMBER_METHODS: Method[];
|
|
6
|
+
export declare const ARRAY_BUILTINS: Method[];
|
|
7
|
+
export declare const OBJECT_BUILTINS: Method[];
|
|
8
|
+
export declare const STRING_BUILTINS: Method[];
|
|
9
|
+
export declare const NUMBER_BUILTINS: Method[];
|
|
10
|
+
export declare const UNIVERSAL_BUILTINS: Method[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { Method } from "./types";
|
|
2
|
+
export { ARRAY_METHODS, STRING_METHODS, OBJECT_OPERATIONS, NUMBER_METHODS, ARRAY_BUILTINS, OBJECT_BUILTINS, STRING_BUILTINS, NUMBER_BUILTINS, UNIVERSAL_BUILTINS, } from "./constants";
|
|
3
|
+
import type { Method } from "./types";
|
|
4
|
+
export declare const getMethodsForType: (type: string) => Method[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PreviewResult } from "./types";
|
|
2
|
+
export type { PreviewResult } from "./types";
|
|
3
|
+
export { MAX_PREVIEW_LINES, MAX_PREVIEW_CHARS, MAX_ARRAY_ITEMS } from "./constants";
|
|
4
|
+
export declare const evaluatePreview: (expression: string, data: unknown) => PreviewResult;
|
|
5
|
+
export declare const formatPreview: (result: PreviewResult) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Method } from "../methods/types";
|
|
2
|
+
import type { FuzzyMatch } from "../types";
|
|
3
|
+
import type { TooltipState, TooltipContext } from "./types";
|
|
4
|
+
export type { TooltipState, TooltipContext } from "./types";
|
|
5
|
+
export { MAX_TOOLTIP_HINTS, METHOD_TRIGGER_CHAR, METHOD_COMPLETE_CHARS } from "./constants";
|
|
6
|
+
export declare const createTooltipState: () => TooltipState;
|
|
7
|
+
export declare const updateTooltipFromQuery: (context: TooltipContext) => TooltipState;
|
|
8
|
+
export declare const selectNextHint: (tooltip: TooltipState) => TooltipState;
|
|
9
|
+
export declare const selectPreviousHint: (tooltip: TooltipState) => TooltipState;
|
|
10
|
+
export declare const getSelectedHint: (tooltip: TooltipState) => Method | null;
|
|
11
|
+
export declare const isMethodComplete: (query: string) => boolean;
|
|
12
|
+
export declare const getPreviewForExpression: (expression: string, data: unknown) => {
|
|
13
|
+
success: boolean;
|
|
14
|
+
preview: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const formatMethodHint: (match: FuzzyMatch<Method>) => {
|
|
17
|
+
signature: string;
|
|
18
|
+
description: string;
|
|
19
|
+
isBuiltin: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Method } from "../methods/types";
|
|
2
|
+
import type { FuzzyMatch } from "../types";
|
|
3
|
+
export interface TooltipState {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
methodHints: FuzzyMatch<Method>[];
|
|
6
|
+
partialMethod: string;
|
|
7
|
+
selectedHintIndex: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TooltipContext {
|
|
10
|
+
query: string;
|
|
11
|
+
dataType: string;
|
|
12
|
+
originalData: unknown;
|
|
13
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export type { Method } from "./methods/types";
|
|
2
|
+
export type { TooltipState } from "./tooltip/types";
|
|
3
|
+
import type { Method } from "./methods/types";
|
|
4
|
+
import type { TooltipState } from "./tooltip/types";
|
|
1
5
|
export interface JsonPath {
|
|
2
6
|
path: string;
|
|
3
7
|
value: unknown;
|
|
@@ -20,13 +24,6 @@ export interface ArrowFnContext {
|
|
|
20
24
|
paramPaths: JsonPath[];
|
|
21
25
|
expression: string;
|
|
22
26
|
}
|
|
23
|
-
export interface Method {
|
|
24
|
-
name: string;
|
|
25
|
-
signature: string;
|
|
26
|
-
description: string;
|
|
27
|
-
template?: string;
|
|
28
|
-
category?: string;
|
|
29
|
-
}
|
|
30
27
|
export interface State {
|
|
31
28
|
mode: InteractiveMode;
|
|
32
29
|
paths: JsonPath[];
|
|
@@ -37,6 +34,7 @@ export interface State {
|
|
|
37
34
|
originalData: unknown;
|
|
38
35
|
methodMatches: FuzzyMatch<Method>[];
|
|
39
36
|
propertyMatches: FuzzyMatch<JsonPath>[];
|
|
37
|
+
tooltip: TooltipState;
|
|
40
38
|
}
|
|
41
39
|
export interface FuzzyMatch<T> {
|
|
42
40
|
item: T;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
export declare const LogLevel: {
|
|
2
|
+
readonly ERROR: 0;
|
|
3
|
+
readonly WARN: 1;
|
|
4
|
+
readonly INFO: 2;
|
|
5
|
+
readonly DEBUG: 3;
|
|
6
|
+
};
|
|
7
|
+
export type LogLevelType = (typeof LogLevel)[keyof typeof LogLevel];
|
|
8
|
+
export interface LogData {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
2
11
|
export declare class Logger {
|
|
3
12
|
private level;
|
|
4
13
|
private name;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const EMPTY_SYMBOL: unique symbol;
|
|
2
|
+
export declare const BUILTIN_FUNCTIONS: {
|
|
3
|
+
readonly PIPE: "pipe";
|
|
4
|
+
readonly COMPOSE: "compose";
|
|
5
|
+
readonly HEAD: "head";
|
|
6
|
+
readonly LAST: "last";
|
|
7
|
+
readonly TAIL: "tail";
|
|
8
|
+
readonly TAKE: "take";
|
|
9
|
+
readonly DROP: "drop";
|
|
10
|
+
readonly UNIQ: "uniq";
|
|
11
|
+
readonly FLATTEN: "flatten";
|
|
12
|
+
readonly REVERSE: "rev";
|
|
13
|
+
readonly GROUPBY: "groupBy";
|
|
14
|
+
readonly SORTBY: "sortBy";
|
|
15
|
+
readonly CHUNK: "chunk";
|
|
16
|
+
readonly COMPACT: "compact";
|
|
17
|
+
readonly PICK: "pick";
|
|
18
|
+
readonly OMIT: "omit";
|
|
19
|
+
readonly KEYS: "keys";
|
|
20
|
+
readonly VALUES: "vals";
|
|
21
|
+
readonly MERGE: "merge";
|
|
22
|
+
readonly DEEPMERGE: "deepMerge";
|
|
23
|
+
readonly FROMPAIRS: "fromPairs";
|
|
24
|
+
readonly TOPAIRS: "toPairs";
|
|
25
|
+
readonly SUM: "sum";
|
|
26
|
+
readonly MEAN: "mean";
|
|
27
|
+
readonly MIN: "min";
|
|
28
|
+
readonly MAX: "max";
|
|
29
|
+
readonly LEN: "len";
|
|
30
|
+
readonly COUNT: "count";
|
|
31
|
+
readonly ISEMPTY: "isEmpty";
|
|
32
|
+
readonly ISNIL: "isNil";
|
|
33
|
+
readonly IDENTITY: "id";
|
|
34
|
+
readonly PLUCK: "pluck";
|
|
35
|
+
readonly TYPE: "type";
|
|
36
|
+
readonly RANGE: "range";
|
|
37
|
+
readonly HAS: "has";
|
|
38
|
+
readonly NTH: "nth";
|
|
39
|
+
readonly CONTAINS: "contains";
|
|
40
|
+
readonly ADD: "add";
|
|
41
|
+
readonly PATH: "path";
|
|
42
|
+
readonly GETPATH: "getpath";
|
|
43
|
+
readonly SETPATH: "setpath";
|
|
44
|
+
readonly RECURSE: "recurse";
|
|
45
|
+
readonly SPLIT: "split";
|
|
46
|
+
readonly JOIN: "join";
|
|
47
|
+
readonly STARTSWITH: "startswith";
|
|
48
|
+
readonly ENDSWITH: "endswith";
|
|
49
|
+
readonly LTRIMSTR: "ltrimstr";
|
|
50
|
+
readonly RTRIMSTR: "rtrimstr";
|
|
51
|
+
readonly TOSTRING: "tostring";
|
|
52
|
+
readonly TONUMBER: "tonumber";
|
|
53
|
+
readonly FLOOR: "floor";
|
|
54
|
+
readonly CEIL: "ceil";
|
|
55
|
+
readonly ROUND: "round";
|
|
56
|
+
readonly ABS: "abs";
|
|
57
|
+
readonly NOT: "not";
|
|
58
|
+
readonly SELECT: "select";
|
|
59
|
+
readonly EMPTY: "empty";
|
|
60
|
+
readonly ERROR: "error";
|
|
61
|
+
readonly DEBUG: "debug";
|
|
62
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BuiltinFn } from "./types";
|
|
2
|
+
export { EMPTY_SYMBOL, BUILTIN_FUNCTIONS } from "./constants";
|
|
3
|
+
export type { BuiltinFn, KeyExtractor, Predicate } from "./types";
|
|
4
|
+
export declare const BUILTINS: Record<string, BuiltinFn>;
|
|
5
|
+
export declare const isBuiltin: (name: string) => boolean;
|
|
6
|
+
export declare const executeBuiltin: (name: string, data: unknown, args: unknown[]) => unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const isArray: (x: unknown) => x is unknown[];
|
|
2
|
+
export declare const isObject: (x: unknown) => x is Record<string, unknown>;
|
|
3
|
+
export declare const isNil: (x: unknown) => x is null | undefined;
|
|
4
|
+
export declare const isString: (x: unknown) => x is string;
|
|
5
|
+
export declare const isNumber: (x: unknown) => x is number;
|
|
6
|
+
export declare const getType: (x: unknown) => string;
|
|
7
|
+
export declare const deepMerge: (target: Record<string, unknown>, source: Record<string, unknown>) => Record<string, unknown>;
|
|
8
|
+
export declare const deepContains: (container: unknown, value: unknown) => boolean;
|
|
9
|
+
export declare const getValueAtPath: (data: unknown, path: (string | number)[]) => unknown;
|
|
10
|
+
export declare const setValueAtPath: (data: unknown, path: (string | number)[], value: unknown) => unknown;
|
|
11
|
+
export declare const collectAllValues: (data: unknown) => unknown[];
|
|
12
|
+
export declare const collectPaths: (val: unknown, currentPath: (string | number)[]) => (string | number)[][];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ASTNode } from "../../types";
|
|
2
|
+
import type { NavigatorOptions } from "./types";
|
|
3
|
+
export { OPERATORS } from "./constants";
|
|
4
|
+
export type { NavigatorOptions } from "./types";
|
|
5
|
+
export { isOperatorMethod, extractOperator, executeOperator, createParameterContext, getImplicitParameter, isValidObject, getPropertyFromObject, normalizeArrayIndex, getArrayElement, sliceArray, evaluateObjectOperation, isCallableMethod, callMethod, } from "./utils";
|
|
6
|
+
export declare class JsonNavigator {
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options?: NavigatorOptions);
|
|
9
|
+
evaluate(ast: ASTNode, data: unknown): unknown;
|
|
10
|
+
private evaluatePropertyAccess;
|
|
11
|
+
private evaluateArg;
|
|
12
|
+
private evaluateMethodCall;
|
|
13
|
+
private evaluatePipe;
|
|
14
|
+
private evaluateRecursiveDescent;
|
|
15
|
+
private collectAllValues;
|
|
16
|
+
private evaluateOptionalAccess;
|
|
17
|
+
private evaluateNullCoalescing;
|
|
18
|
+
private createFunction;
|
|
19
|
+
private evaluateFunctionBody;
|
|
20
|
+
private evaluatePropertyAccessInFunction;
|
|
21
|
+
private evaluateMethodCallInFunction;
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EvaluationContext } from "../types";
|
|
2
|
+
export declare const isOperatorMethod: (method: string) => boolean;
|
|
3
|
+
export declare const extractOperator: (method: string) => string;
|
|
4
|
+
export declare const executeOperator: (left: unknown, operator: string, right: unknown) => unknown;
|
|
5
|
+
export declare const createParameterContext: (params: readonly string[], args: readonly unknown[]) => EvaluationContext;
|
|
6
|
+
export declare const getImplicitParameter: (context: EvaluationContext) => unknown;
|
|
7
|
+
export declare const isValidObject: (value: unknown) => value is Record<string, unknown>;
|
|
8
|
+
export declare const getPropertyFromObject: (obj: unknown, property: string) => unknown;
|
|
9
|
+
export declare const normalizeArrayIndex: (index: number, length: number) => number;
|
|
10
|
+
export declare const getArrayElement: (arr: unknown, index: number) => unknown;
|
|
11
|
+
export declare const sliceArray: (arr: unknown, start: number | undefined, end: number | undefined) => unknown;
|
|
12
|
+
export declare const evaluateObjectOperation: (obj: unknown, operation: "keys" | "values" | "entries" | "length") => unknown;
|
|
13
|
+
export declare const isCallableMethod: (target: unknown, method: string) => boolean;
|
|
14
|
+
export declare const callMethod: (target: unknown, method: string, args: readonly unknown[]) => unknown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ShortcutMapping } from "./types";
|
|
2
|
+
export declare const REGEX_SPECIAL_CHARS: RegExp;
|
|
3
|
+
export declare const IMPLICIT_PROP: {
|
|
4
|
+
readonly PARAM: "x";
|
|
5
|
+
readonly METHOD_WITH_ARGS: RegExp;
|
|
6
|
+
readonly PROPERTY_ACCESS: RegExp;
|
|
7
|
+
readonly PROPERTY_AT_START: RegExp;
|
|
8
|
+
readonly PROPERTY_AFTER_OPERATOR: RegExp;
|
|
9
|
+
readonly EXPAND_AT_START: RegExp;
|
|
10
|
+
readonly EXPAND_AFTER_OPERATOR: RegExp;
|
|
11
|
+
readonly ARROW_FUNC: RegExp;
|
|
12
|
+
readonly PARAM_DOT_TEMPLATE: "(?<![a-zA-Z0-9_])PARAM\\.";
|
|
13
|
+
};
|
|
14
|
+
export declare const BUILTIN_SHORTCUTS: ShortcutMapping[];
|
|
15
|
+
export declare const SHORTCUTS: ShortcutMapping[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { ShortcutMapping } from "./types";
|
|
2
|
+
export { BUILTIN_SHORTCUTS, SHORTCUTS } from "./constants";
|
|
3
|
+
export declare const escapeRegExp: (str: string) => string;
|
|
4
|
+
export declare const expandShortcuts: (expression: string) => string;
|
|
5
|
+
export declare const shortenExpression: (expression: string) => string;
|
|
6
|
+
export declare const getShortcutHelp: () => string;
|
|
7
|
+
export declare const isShortcut: (method: string) => boolean;
|
|
8
|
+
export declare const getFullMethod: (shortMethod: string) => string | undefined;
|
|
9
|
+
export declare const getShortMethod: (fullMethod: string) => string | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataFormat } from "./
|
|
1
|
+
import { DataFormat } from "./formats/types";
|
|
2
2
|
export type OutputFormat = "json" | "yaml" | "csv" | "table";
|
|
3
3
|
export interface FileOperationOptions {
|
|
4
4
|
find?: string;
|
|
@@ -30,9 +30,13 @@ export interface CliOptions extends FileOperationOptions, ShorthandOptions, Form
|
|
|
30
30
|
help?: boolean;
|
|
31
31
|
version?: boolean;
|
|
32
32
|
interactive?: boolean;
|
|
33
|
+
strict?: boolean;
|
|
34
|
+
slurp?: boolean;
|
|
35
|
+
nullInput?: boolean;
|
|
33
36
|
}
|
|
34
37
|
export declare enum TokenType {
|
|
35
38
|
DOT = "DOT",
|
|
39
|
+
DOUBLE_DOT = "DOUBLE_DOT",
|
|
36
40
|
IDENTIFIER = "IDENTIFIER",
|
|
37
41
|
LEFT_BRACKET = "LEFT_BRACKET",
|
|
38
42
|
RIGHT_BRACKET = "RIGHT_BRACKET",
|
|
@@ -46,6 +50,8 @@ export declare enum TokenType {
|
|
|
46
50
|
COMMA = "COMMA",
|
|
47
51
|
ARROW = "ARROW",
|
|
48
52
|
OPERATOR = "OPERATOR",
|
|
53
|
+
QUESTION = "QUESTION",
|
|
54
|
+
DOUBLE_QUESTION = "DOUBLE_QUESTION",
|
|
49
55
|
EOF = "EOF"
|
|
50
56
|
}
|
|
51
57
|
export interface Token {
|
|
@@ -53,7 +59,7 @@ export interface Token {
|
|
|
53
59
|
value: string;
|
|
54
60
|
position: number;
|
|
55
61
|
}
|
|
56
|
-
export type ASTNode = PropertyAccessNode | IndexAccessNode | SliceAccessNode | MethodCallNode | ObjectOperationNode | ArraySpreadNode | LiteralNode | ArrowFunctionNode | RootNode;
|
|
62
|
+
export type ASTNode = PropertyAccessNode | IndexAccessNode | SliceAccessNode | MethodCallNode | ObjectOperationNode | ArraySpreadNode | LiteralNode | ArrowFunctionNode | RootNode | RecursiveDescentNode | OptionalAccessNode | NullCoalescingNode;
|
|
57
63
|
export interface PropertyAccessNode {
|
|
58
64
|
type: "PropertyAccess";
|
|
59
65
|
property: string;
|
|
@@ -99,3 +105,17 @@ export interface RootNode {
|
|
|
99
105
|
type: "Root";
|
|
100
106
|
expression?: ASTNode;
|
|
101
107
|
}
|
|
108
|
+
export interface RecursiveDescentNode {
|
|
109
|
+
type: "RecursiveDescent";
|
|
110
|
+
object?: ASTNode;
|
|
111
|
+
}
|
|
112
|
+
export interface OptionalAccessNode {
|
|
113
|
+
type: "OptionalAccess";
|
|
114
|
+
expression: ASTNode;
|
|
115
|
+
object?: ASTNode;
|
|
116
|
+
}
|
|
117
|
+
export interface NullCoalescingNode {
|
|
118
|
+
type: "NullCoalescing";
|
|
119
|
+
left: ASTNode;
|
|
120
|
+
right: ASTNode;
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.13";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "1ls",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "turbo dev --filter=1ls-app",
|
|
31
31
|
"dev:cli": "bun run ./src/cli/index.ts",
|
|
32
|
-
"build": "rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && bun build ./src/browser/index.ts --outdir dist/browser --target browser --minify --format esm && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
|
|
33
|
-
"build:binary:all": "rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
|
|
32
|
+
"build": "bun scripts/sync-version.ts && rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && bun build ./src/browser/index.ts --outdir dist/browser --target browser --minify --format esm && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
|
|
33
|
+
"build:binary:all": "bun scripts/sync-version.ts && rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
|
|
34
34
|
"build:qjs": "bash scripts/build-qjs.sh",
|
|
35
35
|
"build:qjs:bundle": "mkdir -p dist/qjs && bun build ./src/browser/index.ts --outfile dist/qjs/core.js --target browser --minify --format esm",
|
|
36
36
|
"clean": "rm -rf dist bin",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"test": "bun test",
|
|
39
39
|
"test:coverage": "bun test --coverage --coverage-reporter=lcov",
|
|
40
40
|
"test:integration": "bun test test/integration/",
|
|
41
|
+
"test:bench": "docker build -f test/benchmarks/Dockerfile -t 1ls-bench . && docker run --rm 1ls-bench",
|
|
42
|
+
"test:bench:update": "bash test/benchmarks/update.sh",
|
|
41
43
|
"lint": "bunx oxlint src/",
|
|
42
44
|
"typecheck": "tsc --noEmit",
|
|
43
45
|
"release": "release-it",
|
package/dist/formats/yaml.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface Method {
|
|
2
|
-
name: string;
|
|
3
|
-
signature: string;
|
|
4
|
-
description: string;
|
|
5
|
-
template?: string;
|
|
6
|
-
category?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const ARRAY_METHODS: Method[];
|
|
9
|
-
export declare const STRING_METHODS: Method[];
|
|
10
|
-
export declare const OBJECT_OPERATIONS: Method[];
|
|
11
|
-
export declare const NUMBER_METHODS: Method[];
|
|
12
|
-
export declare const getMethodsForType: (type: string) => Method[];
|
package/dist/navigator/json.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ASTNode } from "../types";
|
|
2
|
-
import { EvaluationContext, OperatorFunction } from "./types";
|
|
3
|
-
export declare const OPERATORS: Readonly<Record<string, OperatorFunction>>;
|
|
4
|
-
export declare function isOperatorMethod(method: string): boolean;
|
|
5
|
-
export declare function extractOperator(method: string): string;
|
|
6
|
-
export declare function executeOperator(left: unknown, operator: string, right: unknown): unknown;
|
|
7
|
-
export declare function createParameterContext(params: readonly string[], args: readonly unknown[]): EvaluationContext;
|
|
8
|
-
export declare function getImplicitParameter(context: EvaluationContext): unknown;
|
|
9
|
-
export declare function isValidObject(value: unknown): value is Record<string, unknown>;
|
|
10
|
-
export declare function getPropertyFromObject(obj: unknown, property: string): unknown;
|
|
11
|
-
export declare function normalizeArrayIndex(index: number, length: number): number;
|
|
12
|
-
export declare function getArrayElement(arr: unknown, index: number): unknown;
|
|
13
|
-
export declare function sliceArray(arr: unknown, start: number | undefined, end: number | undefined): unknown;
|
|
14
|
-
export declare function evaluateObjectOperation(obj: unknown, operation: "keys" | "values" | "entries" | "length"): unknown;
|
|
15
|
-
export declare function isCallableMethod(target: unknown, method: string): boolean;
|
|
16
|
-
export declare function callMethod(target: unknown, method: string, args: readonly unknown[]): unknown;
|
|
17
|
-
export declare class JsonNavigator {
|
|
18
|
-
evaluate(ast: ASTNode, data: unknown): unknown;
|
|
19
|
-
private evaluatePropertyAccess;
|
|
20
|
-
private evaluateArg;
|
|
21
|
-
private evaluateMethodCall;
|
|
22
|
-
private createFunction;
|
|
23
|
-
private evaluateFunctionBody;
|
|
24
|
-
private evaluatePropertyAccessInFunction;
|
|
25
|
-
private evaluateMethodCallInFunction;
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const SUPPORTED_CODE_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx"];
|
|
2
|
-
export declare const SUPPORTED_DATA_EXTENSIONS: readonly [".json", ".yml", ".yaml"];
|
|
3
|
-
export declare const SUPPORTED_TEXT_EXTENSIONS: readonly [".md", ".txt"];
|
|
4
|
-
export declare const DEFAULT_SEARCH_EXTENSIONS: readonly [".ts", ".js", ".tsx", ".jsx", ".json", ".yml", ".yaml", ".md", ".txt"];
|
|
5
|
-
export declare const OPERATOR_METHOD_PREFIX = "__operator_";
|
|
6
|
-
export declare const OPERATOR_METHOD_SUFFIX = "__";
|
|
7
|
-
export declare const APP_VERSION = "1.0.0";
|
|
8
|
-
export declare const APP_NAME = "1ls";
|
|
9
|
-
export declare const VALID_OUTPUT_FORMATS: readonly ["json", "yaml", "csv", "table"];
|
|
10
|
-
export declare const VALID_INPUT_FORMATS: readonly ["json", "yaml", "toml", "csv", "tsv", "lines", "text"];
|
|
11
|
-
export declare const VALID_OBJECT_OPERATIONS: readonly ["keys", "values", "entries", "length"];
|
|
12
|
-
export declare const REGEX_SPECIAL_CHARS: RegExp;
|
package/dist/utils/file.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { stat } from "node:fs/promises";
|
|
2
|
-
import type { FileInfo, ListOptions, GrepOptions, GrepResult } from "./types";
|
|
3
|
-
export declare function readFile(path: string): Promise<unknown>;
|
|
4
|
-
export declare function readFile(path: string, parseJson: true): Promise<unknown>;
|
|
5
|
-
export declare function readFile(path: string, parseJson: false): Promise<string>;
|
|
6
|
-
export declare function serializeContent(content: unknown): string;
|
|
7
|
-
export declare function writeFile(path: string, content: unknown): Promise<void>;
|
|
8
|
-
export declare function createFileInfo(path: string, stats: Awaited<ReturnType<typeof stat>>): FileInfo;
|
|
9
|
-
export declare function getFileInfo(path: string): Promise<FileInfo>;
|
|
10
|
-
export declare function isHiddenFile(entry: string): boolean;
|
|
11
|
-
export declare function shouldIncludeHiddenFile(entry: string, includeHidden: boolean): boolean;
|
|
12
|
-
export declare function matchesExtensionFilter(ext: string, extensions: string[] | undefined): boolean;
|
|
13
|
-
export declare function matchesPatternFilter(name: string, pattern: RegExp | undefined): boolean;
|
|
14
|
-
export declare function shouldIncludeFile(info: FileInfo, extensions: string[] | undefined, pattern: RegExp | undefined): boolean;
|
|
15
|
-
export declare function isWithinDepthLimit(depth: number, maxDepth: number | undefined): boolean;
|
|
16
|
-
export declare function processDirectoryEntry(currentDir: string, entry: string, depth: number, options: ListOptions): Promise<FileInfo[]>;
|
|
17
|
-
export declare function walkDirectory(currentDir: string, depth: number, options: ListOptions): Promise<FileInfo[]>;
|
|
18
|
-
export declare function listFiles(dir: string, options?: ListOptions): Promise<FileInfo[]>;
|
|
19
|
-
export declare function createRegexFromPattern(pattern: string | RegExp, ignoreCase: boolean): RegExp;
|
|
20
|
-
export declare function createGrepResult(filePath: string, lineNumber: number, matchIndex: number, lineContent: string, lines: readonly string[], contextSize: number | undefined): GrepResult;
|
|
21
|
-
export declare function logVerboseError(filePath: string, error: unknown, verbose: boolean): void;
|
|
22
|
-
export declare function extractMatchesFromLine(line: string, lineIndex: number, regex: RegExp, filePath: string, allLines: readonly string[], contextSize: number | undefined): GrepResult[];
|
|
23
|
-
export declare function shouldStopSearching(currentCount: number, maxMatches: number | undefined): boolean;
|
|
24
|
-
export declare function searchFileContent(filePath: string, regex: RegExp, options: GrepOptions): Promise<GrepResult[]>;
|
|
25
|
-
export declare function searchInDirectory(path: string, regex: RegExp, options: GrepOptions): Promise<GrepResult[]>;
|
|
26
|
-
export declare function grep(pattern: string, path: string, options?: GrepOptions): Promise<GrepResult[]>;
|
|
27
|
-
export declare function grep(pattern: RegExp, path: string, options?: GrepOptions): Promise<GrepResult[]>;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ShortcutMapping } from "./types";
|
|
2
|
-
export declare const SHORTCUTS: ShortcutMapping[];
|
|
3
|
-
export declare function expandShortcuts(expression: string): string;
|
|
4
|
-
export declare function shortenExpression(expression: string): string;
|
|
5
|
-
export declare function getShortcutHelp(): string;
|
|
6
|
-
export declare function isShortcut(method: string): boolean;
|
|
7
|
-
export declare function getFullMethod(shortMethod: string): string | undefined;
|
|
8
|
-
export declare function getShortMethod(fullMethod: string): string | undefined;
|