@data-fair/catalog-data-fair 0.2.1 → 0.2.3
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/index.ts +1 -1
- package/lib/download.ts +3 -1
- package/lib/imports.ts +4 -5
- package/package.json +2 -2
- package/types/datafairSchemas/.type/index.d.ts +9 -0
- package/types/datafairSchemas/schema.json +16 -0
package/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ const plugin: CatalogPlugin<DataFairConfig, DataFairCapabilities> = {
|
|
|
12
12
|
return prepare(context)
|
|
13
13
|
},
|
|
14
14
|
|
|
15
|
-
async
|
|
15
|
+
async list (context) {
|
|
16
16
|
const { listResources } = await import('./lib/imports.ts')
|
|
17
17
|
return listResources(context)
|
|
18
18
|
},
|
package/lib/download.ts
CHANGED
|
@@ -71,6 +71,8 @@ const getMetaData = async ({ catalogConfig, resourceId, log, secrets }: GetResou
|
|
|
71
71
|
frequency: dataset.frequency,
|
|
72
72
|
image: dataset.image,
|
|
73
73
|
keywords: dataset.keywords,
|
|
74
|
+
analysis: dataset.analysis,
|
|
75
|
+
projection: dataset.projection,
|
|
74
76
|
size,
|
|
75
77
|
schema: dataset.schema,
|
|
76
78
|
filePath: '',
|
|
@@ -181,7 +183,7 @@ const downloadResourceFile = async (filePath: string, { catalogConfig, resourceI
|
|
|
181
183
|
* @throws If there is an error writing the file or fetching the dataset.
|
|
182
184
|
*/
|
|
183
185
|
const downloadResourceLines = async (destFile: string, { catalogConfig, resourceId, importConfig, secrets, log }: GetResourceContext<DataFairConfig> & { importConfig: ImportConfig }): Promise<void> => {
|
|
184
|
-
let url: string | null = `${catalogConfig.url}/data-fair/api/v1/datasets/${resourceId}/lines?format=csv&size=
|
|
186
|
+
let url: string | null = `${catalogConfig.url}/data-fair/api/v1/datasets/${resourceId}/lines?format=csv&size=10000`
|
|
185
187
|
|
|
186
188
|
if (importConfig.fields) {
|
|
187
189
|
url += '&select=' + importConfig.fields.map(field => field.key).join(',')
|
package/lib/imports.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { DataFairCatalog, DataFairDataset, DataFairConfig } from '#types'
|
|
2
2
|
import axios from '@data-fair/lib-node/axios.js'
|
|
3
|
-
import type { CatalogPlugin,
|
|
3
|
+
import type { CatalogPlugin, ListContext } from '@data-fair/types-catalogs'
|
|
4
4
|
import type { DataFairCapabilities } from './capabilities.ts'
|
|
5
5
|
|
|
6
|
-
type ResourceList = Awaited<ReturnType<CatalogPlugin['
|
|
6
|
+
type ResourceList = Awaited<ReturnType<CatalogPlugin['list']>>['results']
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Transform an ODS catalog into a Data Fair catalog
|
|
10
9
|
* @param dataFairDataset the dataset to transform
|
|
11
10
|
* @returns an object containing the count of resources, the transformed resources, and an empty path array
|
|
12
11
|
*/
|
|
@@ -36,8 +35,8 @@ const prepareCatalog = (dataFairDatasets: DataFairDataset[]): ResourceList => {
|
|
|
36
35
|
* @param config the Data Fair configuration
|
|
37
36
|
* @returns the list of Resources available on this catalog
|
|
38
37
|
*/
|
|
39
|
-
export const listResources = async (config:
|
|
40
|
-
const dataFairParams: Record<string, any> = {}
|
|
38
|
+
export const listResources = async (config: ListContext<DataFairConfig, DataFairCapabilities>): ReturnType<CatalogPlugin<DataFairConfig>['list']> => {
|
|
39
|
+
const dataFairParams: Record<string, any> = { sort: 'title' }
|
|
41
40
|
if (config.params?.q) dataFairParams.q = config.params.q
|
|
42
41
|
if (config.params?.size) dataFairParams.size = config.params.size
|
|
43
42
|
if (config.params?.page) dataFairParams.page = config.params.page
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-fair/catalog-data-fair",
|
|
3
3
|
"description": "A simple Data Fair plugin for the Data Fair catalogs service.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@commitlint/cli": "^19.8.0",
|
|
39
39
|
"@commitlint/config-conventional": "^19.8.0",
|
|
40
40
|
"@data-fair/lib-types-builder": "^1.8.0",
|
|
41
|
-
"@data-fair/types-catalogs": "^0.
|
|
41
|
+
"@data-fair/types-catalogs": "^0.5.1",
|
|
42
42
|
"@types/nock": "^10.0.3",
|
|
43
43
|
"chalk": "^5.4.1",
|
|
44
44
|
"dayjs": "^1.11.13",
|
|
@@ -101,6 +101,15 @@ export type DataFairDataset = {
|
|
|
101
101
|
| "daily"
|
|
102
102
|
| "continuous"
|
|
103
103
|
| "irregular";
|
|
104
|
+
analysis?: {
|
|
105
|
+
escapeKeyAlgorithm?: "compat-ods";
|
|
106
|
+
[k: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
projection?: {
|
|
109
|
+
code?: string;
|
|
110
|
+
title?: string;
|
|
111
|
+
[k: string]: unknown;
|
|
112
|
+
};
|
|
104
113
|
file?: {
|
|
105
114
|
/**
|
|
106
115
|
* Size of the file on disk
|
|
@@ -81,6 +81,22 @@
|
|
|
81
81
|
"irregular"
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
|
+
"analysis": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": {
|
|
87
|
+
"escapeKeyAlgorithm": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"enum": ["compat-ods"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"projection": {
|
|
94
|
+
"type": "object",
|
|
95
|
+
"properties": {
|
|
96
|
+
"code": { "type": "string" },
|
|
97
|
+
"title": { "type": "string" }
|
|
98
|
+
}
|
|
99
|
+
},
|
|
84
100
|
"file": {
|
|
85
101
|
"type": "object",
|
|
86
102
|
"required": [
|