Skip to content

Commit 17822cb

Browse files
committed
Document tree-node use cases and DataverseApiAuthMechanism re-export
- docs/useCases.md: add 'List a Folder of a Dataset Version (Tree View)' and 'Iterate a Folder of a Dataset Version (Tree View)' under Datasets read use cases, with example calls and notes on cursor / ETag / ordering. Adds matching TOC entries. - CHANGELOG.md (Unreleased): add a one-line note about re-exporting DataverseApiAuthMechanism from the public surface so the standalone reusable-component bundles can import it without a deep path.
1 parent 0df68ec commit 17822cb

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
1010

1111
- Datasets: `listDatasetTreeNode` use case and repository method backing `GET /datasets/{id}/versions/{versionId}/tree` for paginated, lazy listing of folders/files inside a dataset version. Returns `FileTreePage` with folder-first ordering, opaque keyset cursors, and per-file `downloadUrl`.
1212
- Datasets: `iterateDatasetTreeNode` async generator that walks the cursor chain so callers can consume one folder's children without driving pagination by hand.
13+
- Core: re-export `DataverseApiAuthMechanism` from the public surface so consumers of the standalone reusable bundles (e.g. `dv-tree-view`, `dv-uploader`) can import it without reaching into `core/...`.
1314

1415
### Changed
1516

docs/useCases.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ The different use cases currently available in the package are classified below,
5353
- [Get Dataset Available Dataset Types](#get-dataset-available-dataset-types)
5454
- [Get Dataset Available Dataset Type](#get-dataset-available-dataset-type)
5555
- [Get Dataset Upload Limits](#get-dataset-upload-limits)
56+
- [List a Folder of a Dataset Version (Tree View)](#list-a-folder-of-a-dataset-version-tree-view)
57+
- [Iterate a Folder of a Dataset Version (Tree View)](#iterate-a-folder-of-a-dataset-version-tree-view)
5658
- [Datasets write use cases](#datasets-write-use-cases)
5759
- [Create a Dataset](#create-a-dataset)
5860
- [Update a Dataset](#update-a-dataset)
@@ -1619,6 +1621,79 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetUploadLimits.ts) imple
16191621

16201622
If the backend does not define any quota limits for the dataset, the returned object can be empty (`{}`).
16211623

1624+
#### List a Folder of a Dataset Version (Tree View)
1625+
1626+
Returns a [FileTreePage](../src/datasets/domain/models/FileTreePage.ts) for the immediate children (folders and files) inside a folder of a dataset version, intended for lazy tree-view UIs that fetch each folder's children on demand.
1627+
1628+
Folders come first, then files. Both are name-sorted (case-insensitive); files break ties on data file id for stability. The page carries an opaque `nextCursor` token; clients echo it back to fetch the next page and never construct one themselves.
1629+
1630+
##### Example call:
1631+
1632+
```typescript
1633+
import { listDatasetTreeNode, FileTreePage } from '@iqss/dataverse-client-javascript'
1634+
1635+
/* ... */
1636+
1637+
const datasetId = 'doi:10.77777/FK2/AAAAAA'
1638+
1639+
listDatasetTreeNode
1640+
.execute({
1641+
datasetId,
1642+
datasetVersionId: '1.0',
1643+
path: 'data/raw',
1644+
limit: 100
1645+
})
1646+
.then((page: FileTreePage) => {
1647+
/* ... */
1648+
})
1649+
1650+
/* ... */
1651+
```
1652+
1653+
_See [use case](../src/datasets/domain/useCases/ListDatasetTreeNode.ts) implementation_.
1654+
1655+
`datasetId` can be a numeric id or a persistent identifier string. `datasetVersionId` is optional and defaults to `DatasetNotNumberedVersion.LATEST`.
1656+
1657+
Other optional parameters: `cursor` (opaque, from a previous response), `include` (`'all' | 'folders' | 'files'`, default `'all'`), `order` (`'NameAZ' | 'NameZA'`, default `'NameAZ'`), `includeDeaccessioned` (default `false`), and `originals` (when `true`, the per-file `downloadUrl` carries `?format=original`).
1658+
1659+
For published, non-deaccessioned versions the underlying API emits `ETag` + `Cache-Control: public, immutable` headers. Drafts and deaccessioned versions don't.
1660+
1661+
#### Iterate a Folder of a Dataset Version (Tree View)
1662+
1663+
Returns an async generator over [FileTreeNode](../src/datasets/domain/models/FileTreeNode.ts) values for one folder, walking the cursor chain so callers can consume the children without driving pagination by hand.
1664+
1665+
##### Example call:
1666+
1667+
```typescript
1668+
import {
1669+
iterateDatasetTreeNode,
1670+
FileTreeNode,
1671+
isFileTreeFileNode
1672+
} from '@iqss/dataverse-client-javascript'
1673+
1674+
/* ... */
1675+
1676+
const datasetId = 'doi:10.77777/FK2/AAAAAA'
1677+
1678+
for await (const node of iterateDatasetTreeNode.execute({
1679+
datasetId,
1680+
datasetVersionId: '1.0',
1681+
path: 'data/raw'
1682+
})) {
1683+
if (isFileTreeFileNode(node)) {
1684+
/* ... */
1685+
} else {
1686+
/* node is a folder ... */
1687+
}
1688+
}
1689+
1690+
/* ... */
1691+
```
1692+
1693+
_See [use case](../src/datasets/domain/useCases/IterateDatasetTreeNode.ts) implementation_.
1694+
1695+
The generator stops after yielding everything in the requested folder; it does **not** descend into subfolders. Pass each subfolder's `path` back through `iterateDatasetTreeNode` if you want a recursive walk.
1696+
16221697
## Files
16231698

16241699
### Files read use cases

0 commit comments

Comments
 (0)