@data-fair/lib-common-types 1.11.0 → 1.12.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.
@@ -65,19 +65,68 @@ export type Resource = {
65
65
  * The unique identifier of the resource, independent of the folder it is in
66
66
  */
67
67
  id: string;
68
+ /**
69
+ * The title of the resource
70
+ */
68
71
  title: string;
69
- type: "resource";
70
72
  description?: string;
73
+ /**
74
+ * The path to the downloaded resource file.
75
+ */
76
+ filePath: string;
77
+ /**
78
+ * The format of the resource, e.g. csv, json, xml, etc. It is displayed in the UI of catalogs.
79
+ */
71
80
  format: string;
72
- url: string;
73
- fileName?: string;
74
- mimeType?: string;
75
- size?: number;
76
- keywords?: string[];
81
+ /**
82
+ * 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.
83
+ */
84
+ frequency?:
85
+ | ""
86
+ | "triennial"
87
+ | "biennial"
88
+ | "annual"
89
+ | "semiannual"
90
+ | "threeTimesAYear"
91
+ | "quarterly"
92
+ | "bimonthly"
93
+ | "monthly"
94
+ | "semimonthly"
95
+ | "biweekly"
96
+ | "threeTimesAMonth"
97
+ | "weekly"
98
+ | "semiweekly"
99
+ | "threeTimesAWeek"
100
+ | "daily"
101
+ | "continuous"
102
+ | "irregular";
103
+ /**
104
+ * The URL of the image representing the resource, if available
105
+ */
77
106
  image?: string;
78
107
  license?: string;
79
- frequency?: string;
80
- private?: boolean;
108
+ /**
109
+ * The list of keywords associated with the resource, if available
110
+ */
111
+ keywords?: string[];
112
+ /**
113
+ * The Mime type of the resource, if available
114
+ */
115
+ mimeType?: string;
116
+ /**
117
+ * The URL where the original data can be found
118
+ */
119
+ origin?: string;
120
+ /**
121
+ * The schema of the resource, if available
122
+ */
123
+ schema?: {
124
+ [k: string]: unknown;
125
+ };
126
+ /**
127
+ * The size of the resource in bytes, if available. It is displayed in the UI of catalogs.
128
+ */
129
+ size?: number;
81
130
  }
82
131
  /**
83
132
  * A small object that contains the information needed to publish or update a dataset or a resource
@@ -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 from a context
61
- * @returns The path to the downloaded resource file, or undefined if the download failed
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
- downloadResource: (context: DownloadResourceContext<TCatalogConfig>) => Promise<string | undefined>;
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 getting a resource.
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 DownloadResourceContext<TCatalogConfig> = {
144
+ export type GetResourceContext<TCatalogConfig> = {
160
145
  /** The catalog configuration */
161
146
  catalogConfig: TCatalogConfig;
162
147
  /** The deciphered secrets of the catalog */
@@ -61,45 +61,54 @@ declare const _default: {
61
61
  };
62
62
  title: {
63
63
  type: string;
64
- };
65
- type: {
66
- const: string;
64
+ description: string;
67
65
  };
68
66
  description: {
69
67
  type: string;
70
68
  };
71
- format: {
69
+ filePath: {
72
70
  type: string;
71
+ description: string;
73
72
  };
74
- url: {
73
+ format: {
75
74
  type: string;
75
+ description: string;
76
76
  };
77
- fileName: {
77
+ frequency: {
78
78
  type: string;
79
+ description: string;
80
+ enum: string[];
79
81
  };
80
- mimeType: {
82
+ image: {
81
83
  type: string;
84
+ description: string;
82
85
  };
83
- size: {
86
+ license: {
84
87
  type: string;
85
88
  };
86
89
  keywords: {
87
90
  type: string;
91
+ description: string;
88
92
  items: {
89
93
  type: string;
90
94
  };
91
95
  };
92
- image: {
96
+ mimeType: {
93
97
  type: string;
98
+ description: string;
94
99
  };
95
- license: {
100
+ origin: {
96
101
  type: string;
102
+ description: string;
97
103
  };
98
- frequency: {
104
+ schema: {
99
105
  type: string;
106
+ additionalProperties: boolean;
107
+ description: string;
100
108
  };
101
- private: {
109
+ size: {
102
110
  type: string;
111
+ description: string;
103
112
  };
104
113
  };
105
114
  };
package/catalog/schema.js CHANGED
@@ -67,7 +67,7 @@ export default {
67
67
  resource: {
68
68
  type: 'object',
69
69
  description: 'The normalized resource to import from a remote catalog to Data Fair',
70
- required: ['id', 'title', 'type', 'format', 'url'],
70
+ required: ['id', 'title', 'filePath', 'format'],
71
71
  additionalProperties: false,
72
72
  properties: {
73
73
  id: {
@@ -75,46 +75,56 @@ export default {
75
75
  description: 'The unique identifier of the resource, independent of the folder it is in'
76
76
  },
77
77
  title: {
78
- type: 'string'
79
- },
80
- type: {
81
- const: 'resource',
78
+ type: 'string',
79
+ description: 'The title of the resource'
82
80
  },
83
81
  description: {
84
82
  type: 'string',
85
83
  },
84
+ filePath: {
85
+ type: 'string',
86
+ description: 'The path to the downloaded resource file.',
87
+ },
86
88
  format: {
87
- type: 'string'
89
+ type: 'string',
90
+ description: 'The format of the resource, e.g. csv, json, xml, etc. It is displayed in the UI of catalogs.',
88
91
  },
89
- url: {
90
- type: 'string'
92
+ // https://www.w3.org/TR/vocab-dcat-2/#Property:dataset_frequency and https://www.dublincore.org/specifications/dublin-core/collection-description/frequency/
93
+ frequency: {
94
+ type: 'string',
95
+ 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.',
96
+ enum: ['', 'triennial', 'biennial', 'annual', 'semiannual', 'threeTimesAYear', 'quarterly', 'bimonthly', 'monthly', 'semimonthly', 'biweekly', 'threeTimesAMonth', 'weekly', 'semiweekly', 'threeTimesAWeek', 'daily', 'continuous', 'irregular']
91
97
  },
92
- fileName: {
93
- type: 'string'
98
+ image: {
99
+ type: 'string',
100
+ description: 'The URL of the image representing the resource, if available'
94
101
  },
95
- mimeType: {
102
+ license: {
96
103
  type: 'string'
97
104
  },
98
- size: {
99
- type: 'number'
100
- },
101
105
  keywords: {
102
106
  type: 'array',
107
+ description: 'The list of keywords associated with the resource, if available',
103
108
  items: {
104
109
  type: 'string'
105
110
  }
106
111
  },
107
- image: {
108
- type: 'string'
112
+ mimeType: {
113
+ type: 'string',
114
+ description: 'The Mime type of the resource, if available'
109
115
  },
110
- license: {
111
- type: 'string'
116
+ origin: {
117
+ type: 'string',
118
+ description: 'The URL where the original data can be found'
112
119
  },
113
- frequency: {
114
- type: 'string'
120
+ schema: {
121
+ type: 'object',
122
+ additionalProperties: true,
123
+ description: 'The schema of the resource, if available'
115
124
  },
116
- private: {
117
- type: 'boolean'
125
+ size: {
126
+ type: 'number',
127
+ description: 'The size of the resource in bytes, if available. It is displayed in the UI of catalogs.'
118
128
  }
119
129
  }
120
130
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-common-types",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Shared schemas and built type definitions in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "scripts": {