-
Notifications
You must be signed in to change notification settings - Fork 23
Add support for the path endpoints #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0b9e1f5
Add support for the path endpoints
astrinski-smartsheet 428b17c
Update workspace constant for tests
astrinski-smartsheet 082a8d2
Fix style
astrinski-smartsheet be39803
Fix tests
astrinski-smartsheet 134e1d1
Clean up model
astrinski-smartsheet b59f546
Update the helper methods to use recursion
astrinski-smartsheet ad90427
Fix lint errors
astrinski-smartsheet 3f8b8ab
Fix build
astrinski-smartsheet b0d1352
Merge branch 'mainline' of github.com:smartsheet/smartsheet-javascrip…
astrinski-smartsheet ff7b344
Moved away from classes to interfaces
astrinski-smartsheet edb3bbc
Fixed changelog and AI review comments
astrinski-smartsheet 6b623ae
Moved helper functions into separate files and updated gocstrings
astrinski-smartsheet f397eb5
Merge branch 'mainline' into feature/add-path-endpoints
astrinski-smartsheet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { FolderPathNode } from './types'; | ||
|
|
||
| /** | ||
| * Returns the deepest {@link FolderPathNode} (the target folder). | ||
| * Use this for quick access to the leaf folder object from a path response. | ||
| * | ||
| * @param node - The root {@link FolderPathNode} returned by `getFolderPath` | ||
| * @returns The deepest (leaf) {@link FolderPathNode} | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.folders.getFolderPath({ folderId: 7116448184199044 }); | ||
| * const leaf = getLeafFolder(path); | ||
| * console.log(leaf.name); | ||
| * ``` | ||
| */ | ||
| export function getLeafFolder(node: FolderPathNode): FolderPathNode { | ||
| if (node.folders && node.folders.length > 0) { | ||
| return getLeafFolder(node.folders[0]); | ||
| } | ||
|
|
||
| return node; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a Unix-like slash-separated path string from the given node to the target folder. | ||
| * Use this for quick access to the full path string of the leaf folder from a path response. | ||
| * | ||
| * @param node - The root {@link FolderPathNode} returned by `getFolderPath` | ||
| * @returns A slash-separated path string | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.folders.getFolderPath({ folderId: 7116448184199044 }); | ||
| * const pathStr = getLeafFolderPath(path); | ||
| * console.log(pathStr); // '/Workspace/Folder/Subfolder' | ||
| * ``` | ||
| */ | ||
| export function getLeafFolderPath(node: FolderPathNode): string { | ||
| if (node.folders && node.folders.length > 0) { | ||
| return `/${node.name}${getLeafFolderPath(node.folders[0])}`; | ||
| } | ||
|
|
||
| return `/${node.name}`; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { PathLeaf } from '../types/PathLeaf'; | ||
| import type { ReportPathNode } from './types'; | ||
|
|
||
| /** | ||
| * Returns the target {@link PathLeaf} report, or undefined if not reachable. | ||
| * Use this for quick access to the leaf report object from a path response. | ||
| * | ||
| * @param node - The root {@link ReportPathNode} returned by `getReportPath` | ||
| * @returns The leaf {@link PathLeaf} report, or `undefined` if not found | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.reports.getReportPath({ reportId: 4583173393803140 }); | ||
| * const leaf = getLeafReport(path); | ||
| * console.log(leaf?.name); | ||
| * ``` | ||
| */ | ||
| export function getLeafReport(node: ReportPathNode): PathLeaf | undefined { | ||
| if (node.reports && node.reports.length > 0) { | ||
| return node.reports[0]; | ||
| } | ||
|
|
||
| if (node.folders && node.folders.length > 0) { | ||
| return getLeafReport(node.folders[0]); | ||
| } | ||
|
|
||
| return undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a Unix-like slash-separated path string from the given node to the target report. | ||
| * Use this for quick access to the full path string of the leaf report from a path response. | ||
| * | ||
| * @param node - The root {@link ReportPathNode} returned by `getReportPath` | ||
| * @returns A slash-separated path string, or `undefined` if not reachable | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.reports.getReportPath({ reportId: 4583173393803140 }); | ||
| * const pathStr = getLeafReportPath(path); | ||
| * console.log(pathStr); // '/Workspace/Folder/Report' | ||
| * ``` | ||
| */ | ||
| export function getLeafReportPath(node: ReportPathNode): string | undefined { | ||
| if (node.reports && node.reports.length > 0) { | ||
| return `/${node.reports[0].name}`; | ||
| } | ||
|
|
||
| if (node.folders && node.folders.length > 0) { | ||
| return `/${node.name}${getLeafReportPath(node.folders[0])}`; | ||
| } | ||
|
|
||
| return undefined; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { PathLeaf } from '../types/PathLeaf'; | ||
| import type { SheetPathNode } from './types'; | ||
|
|
||
| /** | ||
| * Returns the target {@link PathLeaf} sheet, or undefined if not reachable. | ||
| * Use this for quick access to the leaf sheet object from a path response. | ||
| * | ||
| * @param node - The root {@link SheetPathNode} returned by `getSheetPath` | ||
| * @returns The leaf {@link PathLeaf} sheet, or `undefined` if not found | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.sheets.getSheetPath({ sheetId: 123456789 }); | ||
| * const leaf = getLeafSheet(path); | ||
| * console.log(leaf?.name); | ||
| * ``` | ||
| */ | ||
| export function getLeafSheet(node: SheetPathNode): PathLeaf | undefined { | ||
| if (node.sheets && node.sheets.length > 0) { | ||
| return node.sheets[0]; | ||
| } | ||
|
|
||
| if (node.folders && node.folders.length > 0) { | ||
| return getLeafSheet(node.folders[0]); | ||
| } | ||
|
|
||
| return undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a Unix-like slash-separated path string from the given node to the target sheet. | ||
| * Use this for quick access to the full path string of the leaf sheet from a path response. | ||
| * | ||
| * @param node - The root {@link SheetPathNode} returned by `getSheetPath` | ||
| * @returns A slash-separated path string, or `undefined` if not reachable | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const path = await client.sheets.getSheetPath({ sheetId: 123456789 }); | ||
| * const pathStr = getLeafSheetPath(path); | ||
| * console.log(pathStr); // '/Workspace/Folder/Sheet' | ||
| * ``` | ||
| */ | ||
| export function getLeafSheetPath(node: SheetPathNode): string | undefined { | ||
| if (node.sheets && node.sheets.length > 0) { | ||
| return `/${node.sheets[0].name}`; | ||
| } | ||
|
|
||
| if (node.folders && node.folders.length > 0) { | ||
| return `/${node.name}${getLeafSheetPath(node.folders[0])}`; | ||
| } | ||
|
|
||
| return undefined; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.