From 2699b71f2311d1670e29ccf41848bb283c52121d Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Mon, 16 Oct 2023 15:04:16 +0200 Subject: [PATCH] fix: rename "whole document" to "document root" and "whole item" to "item root" to prevent confusion --- src/lib/components/modals/JSONEditorModal.svelte | 2 +- src/lib/components/modals/SortModal.svelte | 2 +- src/lib/components/modals/TransformModal.svelte | 2 +- src/lib/logic/selection.ts | 2 +- src/lib/plugins/query/javascriptQueryLanguage.ts | 2 +- src/lib/plugins/query/jmespathQueryLanguage.ts | 2 +- src/lib/plugins/query/lodashQueryLanguage.ts | 2 +- src/lib/utils/pathUtils.test.ts | 2 +- src/lib/utils/pathUtils.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/components/modals/JSONEditorModal.svelte b/src/lib/components/modals/JSONEditorModal.svelte index 24a3612c..edc0b7da 100644 --- a/src/lib/components/modals/JSONEditorModal.svelte +++ b/src/lib/components/modals/JSONEditorModal.svelte @@ -82,7 +82,7 @@ $: currentState = last(stack) || rootState $: absolutePath = stack.flatMap((state) => state.relativePath) - $: pathDescription = !isEmpty(absolutePath) ? stringifyJSONPath(absolutePath) : '(whole document)' + $: pathDescription = !isEmpty(absolutePath) ? stringifyJSONPath(absolutePath) : '(document root)' // not relevant in this Modal setting, but well $: parseMemoizeOne = memoizeOne(parser.parse) diff --git a/src/lib/components/modals/SortModal.svelte b/src/lib/components/modals/SortModal.svelte index 6830ffc2..d748586d 100644 --- a/src/lib/components/modals/SortModal.svelte +++ b/src/lib/components/modals/SortModal.svelte @@ -103,7 +103,7 @@ type="text" readonly title="Selected path" - value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(whole document)'} + value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(document root)'} /> diff --git a/src/lib/components/modals/TransformModal.svelte b/src/lib/components/modals/TransformModal.svelte index 214a7afc..229c4775 100644 --- a/src/lib/components/modals/TransformModal.svelte +++ b/src/lib/components/modals/TransformModal.svelte @@ -214,7 +214,7 @@ type="text" readonly title="Selected path" - value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(whole document)'} + value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(document root)'} />
diff --git a/src/lib/logic/selection.ts b/src/lib/logic/selection.ts index e54cef62..9c3d0fe6 100644 --- a/src/lib/logic/selection.ts +++ b/src/lib/logic/selection.ts @@ -718,7 +718,7 @@ export function updateSelectionInDocumentState( } /** - * Create a selection which selects the whole document + * Create a selection which selects the root of the document */ // TODO: write unit tests export function selectAll(): JSONSelection { diff --git a/src/lib/plugins/query/javascriptQueryLanguage.ts b/src/lib/plugins/query/javascriptQueryLanguage.ts index 6ec47223..a2b57b78 100644 --- a/src/lib/plugins/query/javascriptQueryLanguage.ts +++ b/src/lib/plugins/query/javascriptQueryLanguage.ts @@ -68,7 +68,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin // and use that when building the query to make it more readable. if (projection.paths.length > 1) { const paths = projection.paths.map((path) => { - const name = path[path.length - 1] || 'item' // 'item' in case of having selected the whole item + const name = path[path.length - 1] || 'item' // 'item' in case of having selected the item root const item = `item${createPropertySelector(path)}` return ` ${JSON.stringify(name)}: ${item}` }) diff --git a/src/lib/plugins/query/jmespathQueryLanguage.ts b/src/lib/plugins/query/jmespathQueryLanguage.ts index 08d447ca..6c857a08 100644 --- a/src/lib/plugins/query/jmespathQueryLanguage.ts +++ b/src/lib/plugins/query/jmespathQueryLanguage.ts @@ -74,7 +74,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin query += path.length === 0 - ? '' // edge case, selecting projection of "whole item" + ? '' // edge case, selecting projection of the item root : '.' + stringifyPathForJmespath(path) } else if (projection.paths.length > 1) { query += diff --git a/src/lib/plugins/query/lodashQueryLanguage.ts b/src/lib/plugins/query/lodashQueryLanguage.ts index ec70d2dd..3de07124 100644 --- a/src/lib/plugins/query/lodashQueryLanguage.ts +++ b/src/lib/plugins/query/lodashQueryLanguage.ts @@ -56,7 +56,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin if (projection.paths.length > 1) { // Note that we do not use _.pick() here because this function doesn't flatten the results const paths = projection.paths.map((path) => { - const name = last(path) || 'item' // 'item' in case of having selected the whole item + const name = last(path) || 'item' // 'item' in case of having selected the item root return ` ${JSON.stringify(name)}: item${createPropertySelector(path)}` }) queryParts.push(` .map(item => ({\n${paths.join(',\n')}\n }))\n`) diff --git a/src/lib/utils/pathUtils.test.ts b/src/lib/utils/pathUtils.test.ts index 2f2f0abd..ae4f6b67 100644 --- a/src/lib/utils/pathUtils.test.ts +++ b/src/lib/utils/pathUtils.test.ts @@ -74,7 +74,7 @@ describe('pathUtils', () => { }) test('pathToOption', () => { - deepStrictEqual(pathToOption([]), { value: [], label: '(whole item)' }) + deepStrictEqual(pathToOption([]), { value: [], label: '(item root)' }) deepStrictEqual(pathToOption(['users', '2', 'first name']), { value: ['users', '2', 'first name'], label: 'users[2].first name' diff --git a/src/lib/utils/pathUtils.ts b/src/lib/utils/pathUtils.ts index 471ca3ce..62a863d5 100644 --- a/src/lib/utils/pathUtils.ts +++ b/src/lib/utils/pathUtils.ts @@ -85,7 +85,7 @@ export function parseJSONPath(pathStr: string): JSONPath { export function pathToOption(path: JSONPath): { value: JSONPath; label: string } { return { value: path, - label: isEmpty(path) ? '(whole item)' : stringifyJSONPath(path) + label: isEmpty(path) ? '(item root)' : stringifyJSONPath(path) } }