@data-fair/catalog-sftp 0.1.0 → 0.2.0
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/lib/imports.ts +6 -5
- package/package.json +2 -2
package/lib/imports.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SFTPConfig } from '#types'
|
|
2
|
-
import type { SFTPWrapper } from 'ssh2'
|
|
2
|
+
import type { FileEntryWithStats, SFTPWrapper } from 'ssh2'
|
|
3
3
|
import type capabilities from './capabilities.ts'
|
|
4
4
|
import type { ListContext, Folder, Resource, GetResourceContext } from '@data-fair/lib-common-types/catalog/index.js'
|
|
5
5
|
import { type Config, NodeSSH } from 'node-ssh'
|
|
@@ -28,15 +28,16 @@ let clientSFTP: SFTPWrapper
|
|
|
28
28
|
* @param path - The current directory path.
|
|
29
29
|
* @returns An array of `Folder` or `Resource` objects representing the files and folders.
|
|
30
30
|
*/
|
|
31
|
-
const prepareFiles = (list:
|
|
32
|
-
return list.map((file) => {
|
|
31
|
+
const prepareFiles = (list: FileEntryWithStats[], path: string): (Folder | Resource)[] => {
|
|
32
|
+
return list.map((file : FileEntryWithStats) => {
|
|
33
33
|
const pointPos = file.filename.lastIndexOf('.')
|
|
34
34
|
return {
|
|
35
35
|
id: path + '/' + file.filename,
|
|
36
36
|
title: file.filename,
|
|
37
37
|
type: (file.longname.charAt(0) === 'd') ? 'folder' : 'resource',
|
|
38
38
|
url: path + '/' + file.filename,
|
|
39
|
-
format: (pointPos === -1) ? '' : (file.filename.substring(pointPos + 1))
|
|
39
|
+
format: (pointPos === -1) ? '' : (file.filename.substring(pointPos + 1)),
|
|
40
|
+
size: file.attrs.size
|
|
40
41
|
}
|
|
41
42
|
})
|
|
42
43
|
}
|
|
@@ -77,7 +78,7 @@ export const list = async ({ catalogConfig, secrets, params }: ListContext<SFTPC
|
|
|
77
78
|
clientSFTP = await ssh.requestSFTP()
|
|
78
79
|
}
|
|
79
80
|
const path = params.currentFolderId ?? '.'
|
|
80
|
-
const files:
|
|
81
|
+
const files: FileEntryWithStats[] = await new Promise((resolve, reject) => {
|
|
81
82
|
if (!clientSFTP) {
|
|
82
83
|
throw new Error('Configuration invalide')
|
|
83
84
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-fair/catalog-sftp",
|
|
3
3
|
"description": "SFTP plugin for the Data Fair catalogs service.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@data-fair/lib-utils": "^1.6.0",
|
|
34
34
|
"debug": "^4.4.1",
|
|
35
35
|
"fs-extra": "^11.3.0",
|
|
36
|
+
"node-ssh": "^13.2.1",
|
|
36
37
|
"prom-client": "^15.1.3"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
@@ -47,7 +48,6 @@
|
|
|
47
48
|
"eslint": "^9.25.1",
|
|
48
49
|
"husky": "^9.1.7",
|
|
49
50
|
"neostandard": "^0.12.1",
|
|
50
|
-
"node-ssh": "^13.2.1",
|
|
51
51
|
"typescript": "^5.8.3"
|
|
52
52
|
},
|
|
53
53
|
"relativeDependencies": {
|