mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-05 03:30:05 +00:00
feat: listFolder and improvements
This commit is contained in:
File diff suppressed because one or more lines are too long
231
docs/classes/reflection-817.reflection-220.fileuploader.html
Normal file
231
docs/classes/reflection-817.reflection-220.fileuploader.html
Normal file
File diff suppressed because one or more lines are too long
312
docs/classes/reflection-817.reflection-220.sas9apiclient.html
Normal file
312
docs/classes/reflection-817.reflection-220.sas9apiclient.html
Normal file
File diff suppressed because one or more lines are too long
1715
docs/classes/reflection-817.reflection-220.sasjs.html
Normal file
1715
docs/classes/reflection-817.reflection-220.sasjs.html
Normal file
File diff suppressed because one or more lines are too long
1516
docs/classes/reflection-817.reflection-220.sasviyaapiclient.html
Normal file
1516
docs/classes/reflection-817.reflection-220.sasviyaapiclient.html
Normal file
File diff suppressed because one or more lines are too long
323
docs/classes/reflection-817.reflection-220.sessionmanager.html
Normal file
323
docs/classes/reflection-817.reflection-220.sessionmanager.html
Normal file
File diff suppressed because one or more lines are too long
@@ -76,7 +76,7 @@
|
||||
<section class="tsd-index-section ">
|
||||
<h3>Modules</h3>
|
||||
<ul class="tsd-index-list">
|
||||
<li class="tsd-kind-module tsd-is-not-exported"><a href="modules/reflection-804.html" class="tsd-kind-icon"><em>Module</em></a></li>
|
||||
<li class="tsd-kind-module tsd-is-not-exported"><a href="modules/reflection-817.html" class="tsd-kind-icon"><em>Module</em></a></li>
|
||||
<li class="tsd-kind-module"><a href="modules/types.html" class="tsd-kind-icon">types</a></li>
|
||||
<li class="tsd-kind-module"><a href="modules/utils.html" class="tsd-kind-icon">utils</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<ul class="tsd-index-list">
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.folder.html#id" class="tsd-kind-icon">id</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.folder.html#links" class="tsd-kind-icon">links</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.folder.html#membercount" class="tsd-kind-icon">memberCount</a></li>
|
||||
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="types.folder.html#uri" class="tsd-kind-icon">uri</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
@@ -128,6 +129,20 @@
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="membercount" class="tsd-anchor"></a>
|
||||
<h3>member<wbr>Count</h3>
|
||||
<div class="tsd-signature tsd-kind-icon">member<wbr>Count<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in
|
||||
<a href="https://github.com/sasjs/adapter/blob/master/src/types/Folder.ts#L7">
|
||||
types/Folder.ts:7
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
|
||||
<a name="uri" class="tsd-anchor"></a>
|
||||
<h3>uri</h3>
|
||||
@@ -180,6 +195,9 @@
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.folder.html#links" class="tsd-kind-icon">links</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.folder.html#membercount" class="tsd-kind-icon">member<wbr>Count</a>
|
||||
</li>
|
||||
<li class=" tsd-kind-property tsd-parent-kind-interface">
|
||||
<a href="types.folder.html#uri" class="tsd-kind-icon">uri</a>
|
||||
</li>
|
||||
|
||||
106
docs/modules/reflection-817.html
Normal file
106
docs/modules/reflection-817.html
Normal file
File diff suppressed because one or more lines are too long
128
docs/modules/reflection-817.reflection-220.html
Normal file
128
docs/modules/reflection-817.reflection-220.html
Normal file
File diff suppressed because one or more lines are too long
@@ -1359,8 +1359,13 @@ export class SASViyaApiClient {
|
||||
return uploadedFiles
|
||||
}
|
||||
|
||||
private async getFolderUri(folderPath: string, accessToken?: string) {
|
||||
const url = '/folders/folders/@item?path=' + folderPath
|
||||
private async getFolderDetails(
|
||||
folderPath: string,
|
||||
accessToken?: string
|
||||
): Promise<Folder | undefined> {
|
||||
const url = isUri(folderPath)
|
||||
? folderPath
|
||||
: `/folders/folders/@item?path=${folderPath}`
|
||||
const requestInfo: any = {
|
||||
method: 'GET'
|
||||
}
|
||||
@@ -1375,7 +1380,15 @@ export class SASViyaApiClient {
|
||||
})
|
||||
|
||||
if (!folder) return undefined
|
||||
return `/folders/folders/${folder.id}`
|
||||
return folder
|
||||
}
|
||||
|
||||
private async getFolderUri(folderPath: string, accessToken?: string) {
|
||||
const folderDetails = await this.getFolderDetails(folderPath, accessToken)
|
||||
|
||||
if (!folderDetails) return undefined
|
||||
|
||||
return `/folders/folders/${folderDetails.id}`
|
||||
}
|
||||
|
||||
private async getRecycleBinUri(accessToken: string) {
|
||||
@@ -1459,6 +1472,47 @@ export class SASViyaApiClient {
|
||||
return context
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists a children folders for given Viya folder.
|
||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
||||
* @param accessToken - an access token for authorizing the request.
|
||||
*/
|
||||
public async listFolder(sourceFolder: string, accessToken?: string) {
|
||||
// checks if 'sourceFolder' is already a URI
|
||||
const sourceFolderUri = isUri(sourceFolder)
|
||||
? sourceFolder
|
||||
: await this.getFolderUri(sourceFolder, accessToken)
|
||||
|
||||
const requestInfo = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer ' + accessToken
|
||||
}
|
||||
}
|
||||
|
||||
const url = sourceFolderUri
|
||||
|
||||
const { result: members } = await this.request<{ items: any[] }>(
|
||||
`${this.serverUrl}${url}/members`,
|
||||
requestInfo
|
||||
).catch((err) => {
|
||||
if (err.code && err.code === 'ENOTFOUND') {
|
||||
const notFoundError = {
|
||||
body: JSON.stringify({
|
||||
message: `Folder '${sourceFolder.split('/').pop()}' was not found.`
|
||||
})
|
||||
}
|
||||
|
||||
throw notFoundError
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
|
||||
return members.items.map((item: any) => item.name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a Viya folder to a new location. The folder may be renamed at the same time.
|
||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
|
||||
|
||||
11
src/SASjs.ts
11
src/SASjs.ts
@@ -277,6 +277,17 @@ export default class SASjs {
|
||||
return await this.sasViyaApiClient?.deleteFolder(folderPath, accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists a children folders for given Viya folder.
|
||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
|
||||
* @param accessToken - an access token for authorizing the request.
|
||||
*/
|
||||
public async listFolder(sourceFolder: string, accessToken?: string) {
|
||||
this.isMethodSupported('listFolder', ServerType.SASViya)
|
||||
|
||||
return await this.sasViyaApiClient?.listFolder(sourceFolder, accessToken)
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves folder to a new location. The folder may be renamed at the same time.
|
||||
* @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
|
||||
|
||||
Reference in New Issue
Block a user