@data-fair/lib-common-types 1.11.0 → 1.13.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/catalog/.type/index.d.ts +73 -9
- package/catalog/index.d.ts +11 -24
- package/catalog/schema.d.ts +37 -12
- package/catalog/schema.js +53 -25
- package/package.json +1 -1
- package/processings.js +1 -1
- package/ws.js +1 -1
package/catalog/.type/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export const schemaExports: string[]
|
|
|
11
11
|
* - importConfig: The plugin gives an import configuration schema
|
|
12
12
|
* - publishDataset: The plugin can publish a dataset
|
|
13
13
|
* - deletePublication: The plugin can delete a dataset or a resource published in a remote catalog
|
|
14
|
+
* - thumbnail: The plugin provides a thumbnail image
|
|
14
15
|
*
|
|
15
16
|
* This interface was referenced by `CatalogsCommonTypes`'s JSON-Schema
|
|
16
17
|
* via the `definition` "capability".
|
|
@@ -22,7 +23,8 @@ export type Capability =
|
|
|
22
23
|
| "additionalFilters"
|
|
23
24
|
| "importConfig"
|
|
24
25
|
| "publishDataset"
|
|
25
|
-
| "deletePublication"
|
|
26
|
+
| "deletePublication"
|
|
27
|
+
| "thumbnail";
|
|
26
28
|
|
|
27
29
|
export type CatalogsCommonTypes = {}
|
|
28
30
|
/**
|
|
@@ -44,6 +46,10 @@ export type Metadata = {
|
|
|
44
46
|
* The list of capabilities that a catalog can have.
|
|
45
47
|
*/
|
|
46
48
|
capabilities: Capability[];
|
|
49
|
+
/**
|
|
50
|
+
* Optional path of the thumbnail image from the root of the plugin to be displayed in the UI.
|
|
51
|
+
*/
|
|
52
|
+
thumbnailPath?: string;
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
49
55
|
* This interface was referenced by `CatalogsCommonTypes`'s JSON-Schema
|
|
@@ -65,19 +71,77 @@ export type Resource = {
|
|
|
65
71
|
* The unique identifier of the resource, independent of the folder it is in
|
|
66
72
|
*/
|
|
67
73
|
id: string;
|
|
74
|
+
/**
|
|
75
|
+
* The title of the resource
|
|
76
|
+
*/
|
|
68
77
|
title: string;
|
|
69
|
-
type: "resource";
|
|
70
78
|
description?: string;
|
|
79
|
+
/**
|
|
80
|
+
* The path to the downloaded resource file.
|
|
81
|
+
*/
|
|
82
|
+
filePath: string;
|
|
83
|
+
/**
|
|
84
|
+
* The format of the resource, e.g. csv, json, xml, etc. It is displayed in the UI of catalogs.
|
|
85
|
+
*/
|
|
71
86
|
format: string;
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The frequency of the resource updates, if available. It can be one of the following values: triennial, biennial, annual, semiannual, threeTimesAYear, quarterly, bimonthly, monthly, semimonthly, biweekly, threeTimesAMonth, weekly, semiweekly, threeTimesAWeek, daily, continuous or irregular.
|
|
89
|
+
*/
|
|
90
|
+
frequency?:
|
|
91
|
+
| ""
|
|
92
|
+
| "triennial"
|
|
93
|
+
| "biennial"
|
|
94
|
+
| "annual"
|
|
95
|
+
| "semiannual"
|
|
96
|
+
| "threeTimesAYear"
|
|
97
|
+
| "quarterly"
|
|
98
|
+
| "bimonthly"
|
|
99
|
+
| "monthly"
|
|
100
|
+
| "semimonthly"
|
|
101
|
+
| "biweekly"
|
|
102
|
+
| "threeTimesAMonth"
|
|
103
|
+
| "weekly"
|
|
104
|
+
| "semiweekly"
|
|
105
|
+
| "threeTimesAWeek"
|
|
106
|
+
| "daily"
|
|
107
|
+
| "continuous"
|
|
108
|
+
| "irregular";
|
|
109
|
+
/**
|
|
110
|
+
* The URL of the image representing the resource, if available
|
|
111
|
+
*/
|
|
112
|
+
image?: string;
|
|
113
|
+
license?: {
|
|
114
|
+
/**
|
|
115
|
+
* Short title for the license
|
|
116
|
+
*/
|
|
117
|
+
title: string;
|
|
118
|
+
/**
|
|
119
|
+
* The URL where the license can be read
|
|
120
|
+
*/
|
|
121
|
+
href: string;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The list of keywords associated with the resource, if available
|
|
125
|
+
*/
|
|
126
|
+
keywords?: string[];
|
|
127
|
+
/**
|
|
128
|
+
* The Mime type of the resource, if available
|
|
129
|
+
*/
|
|
74
130
|
mimeType?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The URL where the original data can be found
|
|
133
|
+
*/
|
|
134
|
+
origin?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The schema of the resource, if available
|
|
137
|
+
*/
|
|
138
|
+
schema?: {
|
|
139
|
+
[k: string]: unknown;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* The size of the resource in bytes, if available. It is displayed in the UI of catalogs.
|
|
143
|
+
*/
|
|
75
144
|
size?: number;
|
|
76
|
-
keywords?: string[];
|
|
77
|
-
image?: string;
|
|
78
|
-
license?: string;
|
|
79
|
-
frequency?: string;
|
|
80
|
-
private?: boolean;
|
|
81
145
|
}
|
|
82
146
|
/**
|
|
83
147
|
* A small object that contains the information needed to publish or update a dataset or a resource
|
package/catalog/index.d.ts
CHANGED
|
@@ -50,17 +50,17 @@ type WithImport<TCatalogConfig, TCapabilities extends Capability[]> = {
|
|
|
50
50
|
/** The total number of items in the current folder */
|
|
51
51
|
count: number;
|
|
52
52
|
/** The list of folders and resources in the current folder, filtered with the search and pagination parameters */
|
|
53
|
-
results: (Folder | Resource
|
|
53
|
+
results: (Folder | Pick<Resource, 'id' | 'title' | 'description' | 'format' | 'mimeType' | 'origin' | 'size'> & {
|
|
54
|
+
type: 'resource';
|
|
55
|
+
})[];
|
|
54
56
|
/** The path to the current folder, including the current folder itself, used to navigate back */
|
|
55
57
|
path: Folder[];
|
|
56
58
|
}>;
|
|
57
|
-
/** Get informations about a specific resource. */
|
|
58
|
-
getResource: (context: GetResourceContext<TCatalogConfig>) => Promise<Resource | undefined>;
|
|
59
59
|
/**
|
|
60
|
-
* Download the resource to a temporary file
|
|
61
|
-
* @returns
|
|
60
|
+
* Download the resource to a temporary file and return the metadata of the resource.
|
|
61
|
+
* @returns A promise that resolves to the metadata of the resource, including the path to the downloaded file.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
getResource: (context: GetResourceContext<TCatalogConfig>) => Promise<Resource | undefined>;
|
|
64
64
|
} & (Includes<TCapabilities, 'additionalFilters'> extends true ? {
|
|
65
65
|
listFiltersSchema: Record<string, any>;
|
|
66
66
|
} : {}) & (Includes<TCapabilities, 'importConfig'> extends true ? {
|
|
@@ -133,22 +133,7 @@ type PaginationParams = {
|
|
|
133
133
|
size?: number;
|
|
134
134
|
};
|
|
135
135
|
/**
|
|
136
|
-
* Context for
|
|
137
|
-
* @template TCatalogConfig - The type of the catalog configuration.
|
|
138
|
-
* @property catalogConfig - The catalog configuration.
|
|
139
|
-
* @property secrets - The deciphered secrets of the catalog.
|
|
140
|
-
* @property resourceId - The ID of the remote resource to get.
|
|
141
|
-
*/
|
|
142
|
-
export type GetResourceContext<TCatalogConfig> = {
|
|
143
|
-
/** The catalog configuration */
|
|
144
|
-
catalogConfig: TCatalogConfig;
|
|
145
|
-
/** The deciphered secrets of the catalog */
|
|
146
|
-
secrets: Record<string, string>;
|
|
147
|
-
/** The ID of the remote resource to get */
|
|
148
|
-
resourceId: string;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Context for downloading a resource.
|
|
136
|
+
* Context for get and downloading a resource.
|
|
152
137
|
* @template TCatalogConfig - The type of the catalog configuration.
|
|
153
138
|
* @property catalogConfig - The catalog configuration.
|
|
154
139
|
* @property secrets - The deciphered secrets of the catalog.
|
|
@@ -156,7 +141,7 @@ export type GetResourceContext<TCatalogConfig> = {
|
|
|
156
141
|
* @property resourceId - The ID of the remote resource to download.
|
|
157
142
|
* @property tmpDir - The path to the working directory where the resource will be downloaded.
|
|
158
143
|
*/
|
|
159
|
-
export type
|
|
144
|
+
export type GetResourceContext<TCatalogConfig> = {
|
|
160
145
|
/** The catalog configuration */
|
|
161
146
|
catalogConfig: TCatalogConfig;
|
|
162
147
|
/** The deciphered secrets of the catalog */
|
|
@@ -225,4 +210,6 @@ export type DeletePublicationContext<TCatalogConfig> = {
|
|
|
225
210
|
export type CatalogMetadata<TCapabilities extends Capability[]> = Metadata & {
|
|
226
211
|
/** The capabilities of the catalog plugin */
|
|
227
212
|
capabilities: TCapabilities;
|
|
228
|
-
}
|
|
213
|
+
} & (Includes<TCapabilities, 'thumbnail'> extends true ? {
|
|
214
|
+
thumbnailPath: string;
|
|
215
|
+
} : {});
|
package/catalog/schema.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ declare const _default: {
|
|
|
31
31
|
$ref: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
thumbnailPath: {
|
|
35
|
+
description: string;
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
34
38
|
};
|
|
35
39
|
};
|
|
36
40
|
folder: {
|
|
@@ -61,45 +65,66 @@ declare const _default: {
|
|
|
61
65
|
};
|
|
62
66
|
title: {
|
|
63
67
|
type: string;
|
|
64
|
-
|
|
65
|
-
type: {
|
|
66
|
-
const: string;
|
|
68
|
+
description: string;
|
|
67
69
|
};
|
|
68
70
|
description: {
|
|
69
71
|
type: string;
|
|
70
72
|
};
|
|
71
|
-
|
|
73
|
+
filePath: {
|
|
72
74
|
type: string;
|
|
75
|
+
description: string;
|
|
73
76
|
};
|
|
74
|
-
|
|
77
|
+
format: {
|
|
75
78
|
type: string;
|
|
79
|
+
description: string;
|
|
76
80
|
};
|
|
77
|
-
|
|
81
|
+
frequency: {
|
|
78
82
|
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
enum: string[];
|
|
79
85
|
};
|
|
80
|
-
|
|
86
|
+
image: {
|
|
81
87
|
type: string;
|
|
88
|
+
description: string;
|
|
82
89
|
};
|
|
83
|
-
|
|
90
|
+
license: {
|
|
84
91
|
type: string;
|
|
92
|
+
additionalProperties: boolean;
|
|
93
|
+
required: string[];
|
|
94
|
+
properties: {
|
|
95
|
+
title: {
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
href: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
85
104
|
};
|
|
86
105
|
keywords: {
|
|
87
106
|
type: string;
|
|
107
|
+
description: string;
|
|
88
108
|
items: {
|
|
89
109
|
type: string;
|
|
90
110
|
};
|
|
91
111
|
};
|
|
92
|
-
|
|
112
|
+
mimeType: {
|
|
93
113
|
type: string;
|
|
114
|
+
description: string;
|
|
94
115
|
};
|
|
95
|
-
|
|
116
|
+
origin: {
|
|
96
117
|
type: string;
|
|
118
|
+
description: string;
|
|
97
119
|
};
|
|
98
|
-
|
|
120
|
+
schema: {
|
|
99
121
|
type: string;
|
|
122
|
+
additionalProperties: boolean;
|
|
123
|
+
description: string;
|
|
100
124
|
};
|
|
101
|
-
|
|
125
|
+
size: {
|
|
102
126
|
type: string;
|
|
127
|
+
description: string;
|
|
103
128
|
};
|
|
104
129
|
};
|
|
105
130
|
};
|
package/catalog/schema.js
CHANGED
|
@@ -14,7 +14,8 @@ export default {
|
|
|
14
14
|
- additionalFilters: The plugin can use additional filters in the list method
|
|
15
15
|
- importConfig: The plugin gives an import configuration schema
|
|
16
16
|
- publishDataset: The plugin can publish a dataset
|
|
17
|
-
- deletePublication: The plugin can delete a dataset or a resource published in a remote catalog
|
|
17
|
+
- deletePublication: The plugin can delete a dataset or a resource published in a remote catalog
|
|
18
|
+
- thumbnail: The plugin provides a thumbnail image`,
|
|
18
19
|
enum: [
|
|
19
20
|
'import',
|
|
20
21
|
'search',
|
|
@@ -22,7 +23,8 @@ export default {
|
|
|
22
23
|
'additionalFilters',
|
|
23
24
|
'importConfig',
|
|
24
25
|
'publishDataset',
|
|
25
|
-
'deletePublication'
|
|
26
|
+
'deletePublication',
|
|
27
|
+
'thumbnail'
|
|
26
28
|
]
|
|
27
29
|
},
|
|
28
30
|
metadata: {
|
|
@@ -45,6 +47,10 @@ export default {
|
|
|
45
47
|
items: {
|
|
46
48
|
$ref: '#/$defs/capability'
|
|
47
49
|
}
|
|
50
|
+
},
|
|
51
|
+
thumbnailPath: {
|
|
52
|
+
description: 'Optional path of the thumbnail image from the root of the plugin to be displayed in the UI.',
|
|
53
|
+
type: 'string',
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
},
|
|
@@ -67,7 +73,7 @@ export default {
|
|
|
67
73
|
resource: {
|
|
68
74
|
type: 'object',
|
|
69
75
|
description: 'The normalized resource to import from a remote catalog to Data Fair',
|
|
70
|
-
required: ['id', 'title', '
|
|
76
|
+
required: ['id', 'title', 'filePath', 'format'],
|
|
71
77
|
additionalProperties: false,
|
|
72
78
|
properties: {
|
|
73
79
|
id: {
|
|
@@ -75,46 +81,68 @@ export default {
|
|
|
75
81
|
description: 'The unique identifier of the resource, independent of the folder it is in'
|
|
76
82
|
},
|
|
77
83
|
title: {
|
|
78
|
-
type: 'string'
|
|
79
|
-
|
|
80
|
-
type: {
|
|
81
|
-
const: 'resource',
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'The title of the resource'
|
|
82
86
|
},
|
|
83
87
|
description: {
|
|
84
88
|
type: 'string',
|
|
85
89
|
},
|
|
86
|
-
|
|
87
|
-
type: 'string'
|
|
90
|
+
filePath: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
description: 'The path to the downloaded resource file.',
|
|
88
93
|
},
|
|
89
|
-
|
|
90
|
-
type: 'string'
|
|
94
|
+
format: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
description: 'The format of the resource, e.g. csv, json, xml, etc. It is displayed in the UI of catalogs.',
|
|
91
97
|
},
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
// https://www.w3.org/TR/vocab-dcat-2/#Property:dataset_frequency and https://www.dublincore.org/specifications/dublin-core/collection-description/frequency/
|
|
99
|
+
frequency: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'The frequency of the resource updates, if available. It can be one of the following values: triennial, biennial, annual, semiannual, threeTimesAYear, quarterly, bimonthly, monthly, semimonthly, biweekly, threeTimesAMonth, weekly, semiweekly, threeTimesAWeek, daily, continuous or irregular.',
|
|
102
|
+
enum: ['', 'triennial', 'biennial', 'annual', 'semiannual', 'threeTimesAYear', 'quarterly', 'bimonthly', 'monthly', 'semimonthly', 'biweekly', 'threeTimesAMonth', 'weekly', 'semiweekly', 'threeTimesAWeek', 'daily', 'continuous', 'irregular']
|
|
94
103
|
},
|
|
95
|
-
|
|
96
|
-
type: 'string'
|
|
104
|
+
image: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: 'The URL of the image representing the resource, if available'
|
|
97
107
|
},
|
|
98
|
-
|
|
99
|
-
type: '
|
|
108
|
+
license: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
additionalProperties: false,
|
|
111
|
+
required: ['title', 'href'],
|
|
112
|
+
properties: {
|
|
113
|
+
title: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Short title for the license'
|
|
116
|
+
},
|
|
117
|
+
href: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'The URL where the license can be read'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
100
122
|
},
|
|
101
123
|
keywords: {
|
|
102
124
|
type: 'array',
|
|
125
|
+
description: 'The list of keywords associated with the resource, if available',
|
|
103
126
|
items: {
|
|
104
127
|
type: 'string'
|
|
105
128
|
}
|
|
106
129
|
},
|
|
107
|
-
|
|
108
|
-
type: 'string'
|
|
130
|
+
mimeType: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'The Mime type of the resource, if available'
|
|
109
133
|
},
|
|
110
|
-
|
|
111
|
-
type: 'string'
|
|
134
|
+
origin: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
description: 'The URL where the original data can be found'
|
|
112
137
|
},
|
|
113
|
-
|
|
114
|
-
type: '
|
|
138
|
+
schema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
additionalProperties: true,
|
|
141
|
+
description: 'The schema of the resource, if available'
|
|
115
142
|
},
|
|
116
|
-
|
|
117
|
-
type: '
|
|
143
|
+
size: {
|
|
144
|
+
type: 'number',
|
|
145
|
+
description: 'The size of the resource in bytes, if available. It is displayed in the UI of catalogs.'
|
|
118
146
|
}
|
|
119
147
|
}
|
|
120
148
|
},
|
package/package.json
CHANGED
package/processings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
package/ws.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|