@piveau/sdk-vue 0.0.0-alpha-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/README.md +66 -0
- package/dist/__tests__/defineResourceGetters.test.d.ts +1 -0
- package/dist/__tests__/defineResourceGetters.test.js +119 -0
- package/dist/__tests__/testUtils.d.ts +10 -0
- package/dist/__tests__/testUtils.js +10 -0
- package/dist/__tests__/useResourceFactory.test.d.ts +1 -0
- package/dist/__tests__/useResourceFactory.test.js +125 -0
- package/dist/__tests__/useSearchFactory.test.d.ts +1 -0
- package/dist/__tests__/useSearchFactory.test.js +102 -0
- package/dist/__tests__/useSearchQueryParams.test.d.ts +1 -0
- package/dist/__tests__/useSearchQueryParams.test.js +89 -0
- package/dist/composables/locale.d.ts +27 -0
- package/dist/composables/locale.js +8 -0
- package/dist/composables/usePropertyTable.d.ts +1 -0
- package/dist/composables/usePropertyTable.js +2 -0
- package/dist/defineHubSearch.d.ts +37 -0
- package/dist/defineHubSearch.js +91 -0
- package/dist/getters.d.ts +26 -0
- package/dist/getters.js +28 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +29 -0
- package/dist/integrations/__tests__/dcatAp.test.d.ts +1 -0
- package/dist/integrations/__tests__/dcatAp.test.js +36 -0
- package/dist/integrations/__tests__/https-data-paysdelaloire-fr-explore-dataset-agenda-culture-de-la-region-des-pays-de-la-loire-.json +647 -0
- package/dist/integrations/dcatAp/dcatAp.d.ts +1107 -0
- package/dist/integrations/dcatAp/dcatAp.js +185 -0
- package/dist/integrations/dcatAp/index.d.ts +2 -0
- package/dist/integrations/dcatAp/index.js +2 -0
- package/dist/integrations/dcatAp/properties.d.ts +9 -0
- package/dist/integrations/dcatAp/properties.js +142 -0
- package/dist/integrations/index.d.ts +1 -0
- package/dist/integrations/index.js +1 -0
- package/dist/locale/__tests__/index.test.d.ts +1 -0
- package/dist/locale/__tests__/index.test.js +12 -0
- package/dist/locale/adapters/default.d.ts +6 -0
- package/dist/locale/adapters/default.js +60 -0
- package/dist/locale/de.d.ts +2096 -0
- package/dist/locale/de.js +2096 -0
- package/dist/locale/en.d.ts +2101 -0
- package/dist/locale/en.js +2101 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/index.js +2 -0
- package/dist/mock/db.json +10862 -0
- package/dist/mock/mockedHubSearch.d.ts +4 -0
- package/dist/mock/mockedHubSearch.js +40 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +0 -0
- package/dist/useGettersFactory.d.ts +7 -0
- package/dist/useGettersFactory.js +10 -0
- package/dist/useMetrics.d.ts +14 -0
- package/dist/useMetrics.js +22 -0
- package/dist/useResourceFactory.d.ts +41 -0
- package/dist/useResourceFactory.js +89 -0
- package/dist/useSearchFactory.d.ts +91 -0
- package/dist/useSearchFactory.js +161 -0
- package/dist/useSearchQueryParams.d.ts +223 -0
- package/dist/useSearchQueryParams.js +91 -0
- package/dist/utils/__tests__/propertyTable.test.d.ts +1 -0
- package/dist/utils/__tests__/propertyTable.test.js +372 -0
- package/dist/utils/helpers.d.ts +92 -0
- package/dist/utils/helpers.js +46 -0
- package/dist/utils/propertyTable.d.ts +82 -0
- package/dist/utils/propertyTable.js +113 -0
- package/dist/utils/vHelpers.d.ts +58 -0
- package/dist/utils/vHelpers.js +50 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.js +37 -0
- package/package.json +54 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { computed, toRef, toValue } from "vue-demi";
|
|
2
|
+
import { SchemaDataset } from "@piveau/sdk-core";
|
|
3
|
+
import { defineHubSearchIntegration } from "../../index.js";
|
|
4
|
+
import { useLocale } from "../../composables/locale.js";
|
|
5
|
+
import { getTranslationFor, nonNullable } from "../../utils/helpers.js";
|
|
6
|
+
import { usePropertyTableDataset, usePropertyTableDistribution } from "./properties.js";
|
|
7
|
+
export function dcatApDataset() {
|
|
8
|
+
return defineHubSearchIntegration(SchemaDataset, (dataset) => {
|
|
9
|
+
const {
|
|
10
|
+
t,
|
|
11
|
+
d,
|
|
12
|
+
currentLocale: origCurrentLocale,
|
|
13
|
+
fallbackLocale: origFallLocale
|
|
14
|
+
} = useLocale();
|
|
15
|
+
const ds = toRef(dataset);
|
|
16
|
+
const currentLocale = toRef(origCurrentLocale);
|
|
17
|
+
const fallbackLocale = toRef(origFallLocale);
|
|
18
|
+
const getId = computed(() => ds.value?.id);
|
|
19
|
+
const getTitle = computed(() => getTranslationFor(ds.value?.title, [currentLocale.value, fallbackLocale.value]));
|
|
20
|
+
const getDescription = computed(() => getTranslationFor(ds.value?.description, [currentLocale.value, fallbackLocale.value]));
|
|
21
|
+
const getCategories = computed(() => ds.value?.categories || []);
|
|
22
|
+
const getPublisher = computed(() => ds.value?.publisher);
|
|
23
|
+
const getPropertyTable = computed(() => {
|
|
24
|
+
if (!ds.value)
|
|
25
|
+
return [];
|
|
26
|
+
const dataset2 = toValue(ds);
|
|
27
|
+
const licenses = dataset2.distributions?.flatMap((d2) => d2.license?.id || d2.license?.label || d2.license?.resource).filter(nonNullable) || [];
|
|
28
|
+
const licenseSet = new Set(licenses);
|
|
29
|
+
const table = [
|
|
30
|
+
{
|
|
31
|
+
type: "node",
|
|
32
|
+
id: "formats",
|
|
33
|
+
label: t("__pv.metadata.format"),
|
|
34
|
+
data: [
|
|
35
|
+
{
|
|
36
|
+
type: "value",
|
|
37
|
+
id: "formatVal",
|
|
38
|
+
// get unique formats
|
|
39
|
+
data: [...new Set(dataset2.distributions?.map((distribution) => distribution.format?.label || distribution.format?.id || distribution.format?.resource || "").filter(Boolean) || [])]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "node",
|
|
45
|
+
id: "author",
|
|
46
|
+
label: t("__pv.metadata.creator"),
|
|
47
|
+
data: [
|
|
48
|
+
{
|
|
49
|
+
type: "value",
|
|
50
|
+
id: "authorVal",
|
|
51
|
+
data: dataset2.creator?.name || dataset2?.publisher?.name || ""
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "node",
|
|
57
|
+
id: "createdAt",
|
|
58
|
+
label: t("__pv.metadata.created"),
|
|
59
|
+
data: [
|
|
60
|
+
{
|
|
61
|
+
type: "value",
|
|
62
|
+
id: "createdAtVal",
|
|
63
|
+
// dataset.issued (iso) to dd.mm.yyyy
|
|
64
|
+
data: dataset2.issued ? d(dataset2.issued) : "-"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: "node",
|
|
70
|
+
id: "updatedAt",
|
|
71
|
+
label: t("__pv.metadata.modificationDate"),
|
|
72
|
+
data: [
|
|
73
|
+
{
|
|
74
|
+
type: "value",
|
|
75
|
+
id: "updatedAtVal",
|
|
76
|
+
data: dataset2.modified ? d(dataset2.modified) : "-"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "node",
|
|
82
|
+
id: "categories",
|
|
83
|
+
label: t("__pv.metadata.categories"),
|
|
84
|
+
data: [
|
|
85
|
+
{
|
|
86
|
+
type: "value",
|
|
87
|
+
id: "categoriesVal",
|
|
88
|
+
data: dataset2.categories?.map((category) => {
|
|
89
|
+
return getTranslationFor(category.label, [currentLocale.value, fallbackLocale.value]) ?? "-";
|
|
90
|
+
}) || []
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "node",
|
|
96
|
+
id: "license",
|
|
97
|
+
label: t("__pv.metadata.license"),
|
|
98
|
+
data: [{
|
|
99
|
+
type: "value",
|
|
100
|
+
id: "licenseVal",
|
|
101
|
+
data: licenseSet.size > 0 ? [...licenseSet] : "-"
|
|
102
|
+
}]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: "node",
|
|
106
|
+
id: "languages",
|
|
107
|
+
label: t("__pv.metadata.languages"),
|
|
108
|
+
data: [
|
|
109
|
+
{
|
|
110
|
+
type: "value",
|
|
111
|
+
id: "languagesVal",
|
|
112
|
+
data: ds.value?.language?.map((language) => language?.label).filter(nonNullable) || []
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
// {
|
|
117
|
+
// type: 'node',
|
|
118
|
+
// id: 'contactPoints',
|
|
119
|
+
// label: t('__pv.metadata.contactPoints'),
|
|
120
|
+
// data: [
|
|
121
|
+
// {
|
|
122
|
+
// type: 'value',
|
|
123
|
+
// id: 'contactPointsVal',
|
|
124
|
+
// data: ds.value?.contact_point?.map(contactPoint => contactPoint.name) || [],
|
|
125
|
+
// },
|
|
126
|
+
// ],
|
|
127
|
+
// },
|
|
128
|
+
];
|
|
129
|
+
return table;
|
|
130
|
+
});
|
|
131
|
+
const { getPropertyTable: getPropertyTable2 } = usePropertyTableDataset(ds);
|
|
132
|
+
const getDistributions = computed(() => {
|
|
133
|
+
if (!ds.value)
|
|
134
|
+
return [];
|
|
135
|
+
const dataset2 = toValue(ds);
|
|
136
|
+
return dataset2.distributions?.map((dist) => {
|
|
137
|
+
const { getPropertyTable: propertyTable } = usePropertyTableDistribution(dist);
|
|
138
|
+
return {
|
|
139
|
+
/**
|
|
140
|
+
* The ID of the distribution
|
|
141
|
+
*/
|
|
142
|
+
id: dist.id,
|
|
143
|
+
/** The localized title of the distribution */
|
|
144
|
+
title: dist.title ? getTranslationFor(dist.title, [currentLocale.value, fallbackLocale.value]) : "",
|
|
145
|
+
/**
|
|
146
|
+
* The localized description of the distribution
|
|
147
|
+
*/
|
|
148
|
+
description: dist.description ? getTranslationFor(dist.description, [currentLocale.value, fallbackLocale.value]) : "",
|
|
149
|
+
/**
|
|
150
|
+
* The format of the distribution
|
|
151
|
+
* Fallback order: label, id, resource
|
|
152
|
+
*/
|
|
153
|
+
format: dist.format?.label || dist.format?.id || dist.format?.resource || "",
|
|
154
|
+
/**
|
|
155
|
+
* The modified date of the distribution
|
|
156
|
+
*/
|
|
157
|
+
modified: dist.modified ? d(dist.modified) : void 0,
|
|
158
|
+
/**
|
|
159
|
+
* The license of the distribution
|
|
160
|
+
*/
|
|
161
|
+
license: dist.license || void 0,
|
|
162
|
+
created: dist.issued ? d(dist.issued) : void 0,
|
|
163
|
+
issued: dist.issued ? d(dist.issued) : void 0,
|
|
164
|
+
languages: dist.language?.map((language) => language?.label).filter(nonNullable) || [],
|
|
165
|
+
accessUrls: dist.access_url || [],
|
|
166
|
+
downloadUrls: dist.download_url || [],
|
|
167
|
+
/**
|
|
168
|
+
* Opinionated recursive property table
|
|
169
|
+
*/
|
|
170
|
+
properties: propertyTable.value
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
getId,
|
|
176
|
+
getTitle,
|
|
177
|
+
getDescription,
|
|
178
|
+
getCategories,
|
|
179
|
+
getPublisher,
|
|
180
|
+
getDistributions,
|
|
181
|
+
getPropertyTable,
|
|
182
|
+
getPropertyTable2
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Dataset, Distribution } from '@piveau/sdk-core';
|
|
2
|
+
import { type MaybeRefOrGetter } from 'vue-demi';
|
|
3
|
+
import type { PropertyTableEntryNode } from '../../utils/propertyTable.js';
|
|
4
|
+
export declare function usePropertyTableDataset(dataset?: MaybeRefOrGetter<Dataset | undefined>): {
|
|
5
|
+
getPropertyTable: import("vue-demi").ComputedRef<PropertyTableEntryNode[]>;
|
|
6
|
+
};
|
|
7
|
+
export declare function usePropertyTableDistribution(distribution?: MaybeRefOrGetter<Distribution | undefined>): {
|
|
8
|
+
getPropertyTable: import("vue-demi").ComputedRef<PropertyTableEntryNode[]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { computed, toRef, toValue } from "vue-demi";
|
|
2
|
+
import { useLocale } from "../../composables/locale.js";
|
|
3
|
+
import { parseResource, parseResourceList, parseUrl, definePropertyNodeCompact as pn } from "../../utils/propertyTable.js";
|
|
4
|
+
import { getTranslationFor } from "../../utils/helpers.js";
|
|
5
|
+
export function usePropertyTableDataset(dataset) {
|
|
6
|
+
const {
|
|
7
|
+
t,
|
|
8
|
+
d,
|
|
9
|
+
currentLocale: _currentLocale,
|
|
10
|
+
fallbackLocale: _fallbackLocale
|
|
11
|
+
} = useLocale();
|
|
12
|
+
const ds = toRef(dataset);
|
|
13
|
+
const currentLocale = toRef(_currentLocale);
|
|
14
|
+
const fallbackLocale = toRef(_fallbackLocale);
|
|
15
|
+
const getPropertyTable = computed(() => {
|
|
16
|
+
if (!ds.value)
|
|
17
|
+
return [];
|
|
18
|
+
const dataset2 = toValue(ds);
|
|
19
|
+
const created = pn({ id: "created", label: t("__pv.metadata.created"), help: t("__pv.tooltip.datasetDetails.created"), data: dataset2.issued ? d(dataset2.issued ?? "", "medium") : void 0 });
|
|
20
|
+
const modified = pn({ id: "modified", label: t("__pv.metadata.modificationDate"), help: t("__pv.tooltip.datasetDetails.modified"), data: dataset2.modified ? d(dataset2.modified ?? "", "medium") : void 0 });
|
|
21
|
+
const landingPage = pn({ id: "landingPage", label: t("__pv.metadata.landingPage"), help: t("__pv.tooltip.datasetDetails.landingPage"), data: parseResourceList(dataset2.landing_page, "landingPageVal") });
|
|
22
|
+
const sources = pn({ id: "sources", label: t("__pv.metadata.sources"), help: t("__pv.tooltip.datasetDetails.sources"), data: dataset2.source });
|
|
23
|
+
const languages = pn({ id: "languages", label: t("__pv.metadata.languages"), help: t("__pv.tooltip.datasetDetails.languages"), data: parseResourceList(dataset2.language) });
|
|
24
|
+
const publisher = pn({ id: "publisher", label: t("__pv.metadata.publisher"), help: t("__pv.tooltip.datasetDetails.publisher"), data: [
|
|
25
|
+
pn({ id: "publisherName", label: t("__pv.metadata.name"), help: t("__pv.tooltip.datasetDetails.publisherName"), data: dataset2.publisher?.name }),
|
|
26
|
+
pn({ id: "publisherHomepage", label: t("__pv.metadata.homepage"), help: t("__pv.tooltip.datasetDetails.publisherHomepage"), data: parseUrl(dataset2.publisher?.homepage) }),
|
|
27
|
+
pn({ id: "publisherEmail", label: t("__pv.metadata.email"), help: t("__pv.tooltip.datasetDetails.publisherEmail"), data: dataset2.publisher?.email })
|
|
28
|
+
] });
|
|
29
|
+
const contactPointItems = dataset2.contact_point ? dataset2.contact_point.map((contactPoint2) => {
|
|
30
|
+
return pn({ id: "contactPoint", label: contactPoint2.name || contactPoint2.organisation_name || "", data: [
|
|
31
|
+
pn({ id: "contactPointName", label: t("__pv.metadata.name"), help: t("__pv.tooltip.datasetDetails.contactPointName"), data: contactPoint2.name }),
|
|
32
|
+
pn({ id: "contactPointOrganization", label: t("__pv.metadata.organizationName"), help: t("__pv.tooltip.datasetDetails.contactPointOrganisationName"), data: contactPoint2.organisation_name }),
|
|
33
|
+
pn({ id: "contactPointEmail", label: t("__pv.metadata.email"), help: t("__pv.tooltip.datasetDetails.contactPointEmail"), data: contactPoint2.email }),
|
|
34
|
+
pn({ id: "contactPointTelephone", label: t("__pv.metadata.telephone"), help: t("__pv.tooltip.datasetDetails.contactPointTelephone"), data: contactPoint2.telephone }),
|
|
35
|
+
pn({ id: "contactPointAddressCity", label: t("__pv.metadata.address"), help: t("__pv.tooltip.datasetDetails.contactPointAdressCity"), data: contactPoint2.address }),
|
|
36
|
+
pn({ id: "contactPointUrl", label: t("__pv.metadata.url"), help: t("__pv.tooltip.datasetDetails.contactPointUrl"), data: contactPoint2.url })
|
|
37
|
+
] });
|
|
38
|
+
}) : [];
|
|
39
|
+
const contactPoint = pn({ id: "contactPoint", label: t("__pv.metadata.contactPoints"), help: t("__pv.tooltip.datasetDetails.contactPoints"), data: contactPointItems });
|
|
40
|
+
const catalogRecord = pn({ id: "catalogRecord", label: t("__pv.metadata.catalogRecord"), help: t("__pv.tooltip.datasetDetails.catalogRecord"), data: [
|
|
41
|
+
`${t("__pv.metadata.created")} ${d(dataset2.catalog_record?.issued ?? "", "medium")}`,
|
|
42
|
+
`${t("__pv.metadata.modificationDate")} ${d(dataset2.catalog_record?.modified ?? "", "medium")}`
|
|
43
|
+
] });
|
|
44
|
+
const conformsTo = pn({ id: "conformsTo", label: t("__pv.metadata.conformsTo"), help: t("__pv.tooltip.datasetDetails.conformsTo"), data: parseResourceList(dataset2.conforms_to) });
|
|
45
|
+
const provenance = pn({ id: "provenance", label: t("__pv.metadata.provenances"), help: t("__pv.tooltip.datasetDetails.provenance"), data: parseResourceList(dataset2.provenance) });
|
|
46
|
+
const identifiers = pn({ id: "identifiers", label: t("__pv.metadata.identifiers"), help: t("__pv.tooltip.datasetDetails.identifiers"), data: dataset2.identifier });
|
|
47
|
+
const admsIdentifierItems = dataset2.adms_identifier ? dataset2.adms_identifier.map((adms) => {
|
|
48
|
+
return pn({ id: "admsIdentifier", label: "", data: [
|
|
49
|
+
`${t("__pv.metadata.identifier")} ${adms.identifier}`,
|
|
50
|
+
`${t("__pv.metadata.scheme")} ${adms.scheme}`
|
|
51
|
+
] });
|
|
52
|
+
}) : [];
|
|
53
|
+
const admsIdentifiers = pn({ id: "admsIdentifiers", label: t("__pv.metadata.otherIdentifiers"), help: t("__pv.tooltip.datasetDetails.otherIdentifiers"), data: admsIdentifierItems });
|
|
54
|
+
const resource = pn({ id: "resource", label: t("__pv.metadata.resource"), help: t("__pv.tooltip.datasetDetails.resources"), data: dataset2.resource });
|
|
55
|
+
const accessRight = pn({ id: "accessRight", label: t("__pv.metadata.accessRights"), help: t("__pv.tooltip.datasetDetails.accessRights"), data: parseResource(dataset2.access_right) });
|
|
56
|
+
const accrualPeriodicity = pn({ id: "accrualPeriodicity", label: t("__pv.metadata.accrualPeriodicity"), help: t("__pv.tooltip.datasetDetails.accrualPeriodicity"), data: parseResource(dataset2.accrual_periodicity) });
|
|
57
|
+
const hasVersion = pn({ id: "hasVersion", label: t("__pv.metadata.hasVersion"), help: t("__pv.tooltip.datasetDetails.hasVersion"), data: dataset2.has_version });
|
|
58
|
+
const isVersionOf = pn({ id: "isVersionOf", label: t("__pv.metadata.isVersionOf"), help: t("__pv.tooltip.datasetDetails.isVersionOf"), data: dataset2.is_version_of });
|
|
59
|
+
const temporal = pn({ id: "temporal", label: t("__pv.metadata.temporal"), help: t("__pv.tooltip.datasetDetails.temporalCoverage"), data: dataset2.temporal && dataset2.temporal.map(
|
|
60
|
+
(t2) => `${d(t2.gte, "medium")} - ${d(t2.lte, "medium")}`
|
|
61
|
+
) });
|
|
62
|
+
const versionInfo = pn({ id: "version", label: t("__pv.metadata.versionInfo"), help: t("__pv.tooltip.datasetDetails.versionInfo"), data: dataset2.version_info });
|
|
63
|
+
const versionNotes = pn({ id: "versionNotes", label: t("__pv.metadata.versionNotes"), help: t("__pv.tooltip.datasetDetails.versionNotes"), data: getTranslationFor(dataset2.version_notes, [currentLocale.value, fallbackLocale.value]) });
|
|
64
|
+
const isReferencedBy = pn({ id: "isReferencedBy", label: t("__pv.metadata.isReferencedBy"), help: t("__pv.tooltip.datasetDetails.isReferencedBy"), data: dataset2.is_referenced_by });
|
|
65
|
+
const qualifiedRelationItems = dataset2.qualified_relation ? dataset2.qualified_relation.map((relation) => {
|
|
66
|
+
return pn({ id: "qualifiedRelation", label: "", data: [
|
|
67
|
+
`${t("__pv.metadata.relation")} ${relation.relation}`,
|
|
68
|
+
`${t("__pv.metadata.role")} ${relation.had_role}`
|
|
69
|
+
] });
|
|
70
|
+
}) : [];
|
|
71
|
+
const qualifiedRelation = pn({ id: "qualifiedRelation", label: t("__pv.metadata.qualifiedRelation"), help: t("__pv.tooltip.datasetDetails.qualifiedRelation"), data: qualifiedRelationItems });
|
|
72
|
+
const sample = pn({ id: "sample", label: t("__pv.metadata.sample"), help: t("__pv.tooltip.datasetDetails.sample"), data: dataset2.sample });
|
|
73
|
+
const type = pn({ id: "type", label: t("__pv.metadata.type"), help: t("__pv.tooltip.datasetDetails.type"), data: parseResource(dataset2.type) });
|
|
74
|
+
const temporalResolution = pn({ id: "temporalResolution", label: t("__pv.metadata.temporalResolution"), help: t("__pv.tooltip.datasetDetails.temporalResolution"), data: dataset2.temporal_resolution });
|
|
75
|
+
const table = [
|
|
76
|
+
created,
|
|
77
|
+
modified,
|
|
78
|
+
landingPage,
|
|
79
|
+
sources,
|
|
80
|
+
languages,
|
|
81
|
+
publisher,
|
|
82
|
+
contactPoint,
|
|
83
|
+
catalogRecord,
|
|
84
|
+
conformsTo,
|
|
85
|
+
provenance,
|
|
86
|
+
identifiers,
|
|
87
|
+
admsIdentifiers,
|
|
88
|
+
resource,
|
|
89
|
+
accessRight,
|
|
90
|
+
accrualPeriodicity,
|
|
91
|
+
hasVersion,
|
|
92
|
+
isVersionOf,
|
|
93
|
+
temporal,
|
|
94
|
+
versionInfo,
|
|
95
|
+
versionNotes,
|
|
96
|
+
isReferencedBy,
|
|
97
|
+
qualifiedRelation,
|
|
98
|
+
sample,
|
|
99
|
+
type,
|
|
100
|
+
temporalResolution
|
|
101
|
+
];
|
|
102
|
+
return table;
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
getPropertyTable
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function usePropertyTableDistribution(distribution) {
|
|
109
|
+
const {
|
|
110
|
+
t,
|
|
111
|
+
d,
|
|
112
|
+
n,
|
|
113
|
+
currentLocale: _currentLocale,
|
|
114
|
+
fallbackLocale: _fallbackLocale
|
|
115
|
+
} = useLocale();
|
|
116
|
+
const dist = toRef(distribution);
|
|
117
|
+
const getPropertyTable = computed(() => {
|
|
118
|
+
if (!dist.value)
|
|
119
|
+
return [];
|
|
120
|
+
const di = toValue(dist);
|
|
121
|
+
const propertyTable = [
|
|
122
|
+
pn({ id: "license", label: t("__pv.metadata.license"), help: t("__pv.tooltip.datasetDetails.distribution.licence"), data: [
|
|
123
|
+
{ type: "href", id: "licenseVal", data: { href: di.license?.resource || "", label: di.license?.label || di.license?.description || di.license?.id || "" } }
|
|
124
|
+
] }),
|
|
125
|
+
pn({ id: "modified", label: t("__pv.metadata.modificationDate"), help: t("__pv.tooltip.datasetDetails.distribution.modified"), data: d(di.modified || "", "medium") }),
|
|
126
|
+
pn({ id: "created", label: t("__pv.metadata.created"), help: t("__pv.tooltip.datasetDetails.distribution.created"), data: d(di.issued || "", "medium") }),
|
|
127
|
+
pn({ id: "languages", label: t("__pv.metadata.languages"), help: t("__pv.tooltip.datasetDetails.distribution.languages"), data: parseResourceList(di.language || []) }),
|
|
128
|
+
pn({ id: "status", label: t("__pv.metadata.status"), help: t("__pv.tooltip.datasetDetails.distribution.status"), data: parseResource(di.status) }),
|
|
129
|
+
pn({ id: "rights", label: t("__pv.metadata.rights"), help: t("__pv.tooltip.datasetDetails.distribution.rights"), data: parseResource(di.rights) }),
|
|
130
|
+
pn({ id: "mediaType", label: t("__pv.metadata.mediaType"), help: t("__pv.tooltip.datasetDetails.distribution.mediaType"), data: di.media_type }),
|
|
131
|
+
pn({ id: "byteSize", label: t("__pv.metadata.byteSize"), help: t("__pv.tooltip.datasetDetails.distribution.byteSize"), data: di.byte_size ? n(di.byte_size) : void 0 }),
|
|
132
|
+
pn({ id: "pages", label: t("__pv.metadata.pages"), help: t("__pv.tooltip.datasetDetails.distribution.pages"), data: di.page?.map((p) => p?.resource) }),
|
|
133
|
+
pn({ id: "compressFormat", label: t("__pv.metadata.compressFormat"), help: t("__pv.tooltip.datasetDetails.distribution.compressFormat"), data: parseResource(di.compress_format) }),
|
|
134
|
+
pn({ id: "packageFormat", label: t("__pv.metadata.packageFormat"), help: t("__pv.tooltip.datasetDetails.distribution.packageFormat"), data: parseResource(di.package_format) }),
|
|
135
|
+
pn({ id: "conformsTo", label: t("__pv.metadata.conformsTo"), help: t("__pv.tooltip.datasetDetails.distribution.conformsTo"), data: parseResourceList(di.conforms_to || []) })
|
|
136
|
+
];
|
|
137
|
+
return propertyTable;
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
getPropertyTable
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dcatAp/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dcatAp/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import * as locales from "../index.js";
|
|
5
|
+
describe("locales", () => {
|
|
6
|
+
it("should export all locales inside locales folder", () => {
|
|
7
|
+
const files = fs.readdirSync(path.join(__dirname, ".."));
|
|
8
|
+
const localeFiles = files.filter((f) => f.endsWith(".ts") && f !== "index.ts");
|
|
9
|
+
const keys = Object.keys(locales);
|
|
10
|
+
expect(localeFiles.length).toBe(keys.length);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ref } from 'vue-demi';
|
|
2
|
+
import type { DateFormatStrings, DateFormats, DateLike, LocaleInstance, LocaleMessages, LocaleOptions } from '../../composables/locale.js';
|
|
3
|
+
export declare function createTranslateFunction(current: Ref<string>, fallback: Ref<string>, messages: Ref<LocaleMessages>): (key: string, ...params: unknown[]) => string;
|
|
4
|
+
export declare function createNumberFunction(current: Ref<string>, fallback: Ref<string>): (value: number, options?: Intl.NumberFormatOptions) => string;
|
|
5
|
+
export declare function createDateFunction(current: Ref<string>, fallback: Ref<string>, dateFormatStrings: Ref<DateFormatStrings>): (value: DateLike, format?: DateFormats, locale?: Intl.LocalesArgument) => string;
|
|
6
|
+
export declare function defaultLocaleAdapter(options?: LocaleOptions): LocaleInstance;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ref, shallowRef } from "vue-demi";
|
|
2
|
+
import { formatDate, normalizeDate } from "@vueuse/core";
|
|
3
|
+
import { getObjectValueByPath, replace } from "../../utils/vHelpers.js";
|
|
4
|
+
import { de, en } from "../index.js";
|
|
5
|
+
const LANG_PREFIX = "__pv.";
|
|
6
|
+
export function createTranslateFunction(current, fallback, messages) {
|
|
7
|
+
return (key, ...params) => {
|
|
8
|
+
if (!key.startsWith(LANG_PREFIX))
|
|
9
|
+
return replace(key, params);
|
|
10
|
+
const shortKey = key.replace(LANG_PREFIX, "");
|
|
11
|
+
const currentLocale = current.value && messages.value[current.value];
|
|
12
|
+
const fallbackLocale = fallback.value && messages.value[fallback.value];
|
|
13
|
+
let str = getObjectValueByPath(currentLocale, shortKey, null);
|
|
14
|
+
if (!str) {
|
|
15
|
+
console.warn(`Translation key "${key}" not found in "${current.value}", trying fallback locale`);
|
|
16
|
+
str = getObjectValueByPath(fallbackLocale, shortKey, null);
|
|
17
|
+
}
|
|
18
|
+
if (!str) {
|
|
19
|
+
console.error(`Translation key "${key}" not found in fallback`);
|
|
20
|
+
str = key;
|
|
21
|
+
}
|
|
22
|
+
if (typeof str !== "string") {
|
|
23
|
+
console.error(`Translation key "${key}" has a non-string value`);
|
|
24
|
+
str = key;
|
|
25
|
+
}
|
|
26
|
+
return replace(str, params);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function createNumberFunction(current, fallback) {
|
|
30
|
+
return (value, options) => {
|
|
31
|
+
const numberFormat = new Intl.NumberFormat([current.value, fallback.value], options);
|
|
32
|
+
return numberFormat.format(value);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function createDateFunction(current, fallback, dateFormatStrings) {
|
|
36
|
+
return (value, format = "short", locale) => {
|
|
37
|
+
const locales = locale ? Array.isArray(locale) ? locale : [locale] : [current.value, fallback.value];
|
|
38
|
+
return formatDate(normalizeDate(value), dateFormatStrings.value?.[format] || "", { locales });
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function defaultLocaleAdapter(options) {
|
|
42
|
+
const currentLocale = shallowRef(options?.locale ?? "en");
|
|
43
|
+
const fallbackLocale = shallowRef(options?.fallback ?? "en");
|
|
44
|
+
const messages = ref({ en, de, ...options?.messages });
|
|
45
|
+
const dateFormatStrings = shallowRef({
|
|
46
|
+
short: "YYYY-MM-DD",
|
|
47
|
+
medium: "YYYY-MM-DD HH:mm",
|
|
48
|
+
long: "YYYY-MM-DD HH:mm:ss",
|
|
49
|
+
...options?.dateFormatStrings
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
name: "__default",
|
|
53
|
+
currentLocale,
|
|
54
|
+
fallbackLocale,
|
|
55
|
+
messages,
|
|
56
|
+
t: createTranslateFunction(currentLocale, fallbackLocale, messages),
|
|
57
|
+
n: createNumberFunction(currentLocale, fallbackLocale),
|
|
58
|
+
d: createDateFunction(currentLocale, fallbackLocale, dateFormatStrings)
|
|
59
|
+
};
|
|
60
|
+
}
|