@arpproject/recrate 0.1.45-test → 0.1.46
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UnverifiedEntityDefinition, NormalisedEntityDefinition } from '../types.js';
|
|
2
2
|
export declare const urlProtocols: string[];
|
|
3
|
+
export declare function shouldGenerateEntityName(value: unknown): boolean;
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
* @param {string} value - string to check as a URL: checks 'http','https','ftp', 'arcp'
|
package/dist/recrate.es.js
CHANGED
|
@@ -73946,6 +73946,14 @@ function validateId({ id: id2, type: type4 }) {
|
|
|
73946
73946
|
};
|
|
73947
73947
|
}
|
|
73948
73948
|
const urlProtocols = ["http", "https", "ftp", "ftps"];
|
|
73949
|
+
function shouldGenerateEntityName(value) {
|
|
73950
|
+
if (!value) return true;
|
|
73951
|
+
if (isString(value)) return value.trim().length === 0;
|
|
73952
|
+
if (isArray(value)) {
|
|
73953
|
+
return value.map((entry) => String(entry ?? "")).join(" ").trim().length === 0;
|
|
73954
|
+
}
|
|
73955
|
+
return false;
|
|
73956
|
+
}
|
|
73949
73957
|
function isURL(value) {
|
|
73950
73958
|
if (!value) return false;
|
|
73951
73959
|
if (isNumber(value)) return false;
|
|
@@ -73987,7 +73995,7 @@ function normalise(entity, i) {
|
|
|
73987
73995
|
if (!isValid && message === "The identifier is not valid according to the RO Crate spec nor is it a valid IRI.") {
|
|
73988
73996
|
normalisedEntity["@id"] = `#${normalisedEntity["@id"]}`;
|
|
73989
73997
|
}
|
|
73990
|
-
normalisedEntity.name = entity.name ?
|
|
73998
|
+
normalisedEntity.name = shouldGenerateEntityName(entity.name) ? normalisedEntity["@id"].replace(/^#/, "") : entity.name;
|
|
73991
73999
|
if (isArray(normalisedEntity.name)) normalisedEntity.name = normalisedEntity.name.join(" ");
|
|
73992
74000
|
for (let property of Object.keys(entity)) {
|
|
73993
74001
|
if (["@id", "@type", "name", "@reverse"].includes(property)) continue;
|
|
@@ -126785,6 +126793,12 @@ class CrateManager {
|
|
|
126785
126793
|
crate["@graph"][i],
|
|
126786
126794
|
i
|
|
126787
126795
|
);
|
|
126796
|
+
if (shouldGenerateEntityName(crate["@graph"][i].name)) {
|
|
126797
|
+
this.__setWarning(
|
|
126798
|
+
"init",
|
|
126799
|
+
`Entity '${normalisedEntity["@id"]}' did not have a name. Recrate generated '${normalisedEntity.name}' from its identifier.`
|
|
126800
|
+
);
|
|
126801
|
+
}
|
|
126788
126802
|
idMap[crate["@graph"][i]["@id"]] = normalisedEntity["@id"];
|
|
126789
126803
|
if (normalisedEntity["@id"].match(/^_:/)) {
|
|
126790
126804
|
this.blankNodes.push(normalisedEntity["@id"]);
|
|
@@ -135177,7 +135191,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
135177
135191
|
}) : null
|
|
135178
135192
|
);
|
|
135179
135193
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
135180
|
-
const version = "0.1.
|
|
135194
|
+
const version = "0.1.46";
|
|
135181
135195
|
const pkg = {
|
|
135182
135196
|
version
|
|
135183
135197
|
};
|