@fedify/vocab-tools 2.5.0-dev.2822 → 2.5.0-dev.2825
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/dist/mod.cjs +47 -1
- package/dist/mod.js +47 -1
- package/package.json +2 -2
package/dist/mod.cjs
CHANGED
|
@@ -35,6 +35,7 @@ function hasSingularAccessor(property) {
|
|
|
35
35
|
return isNonFunctionalProperty(property) && property.singularAccessor === true;
|
|
36
36
|
}
|
|
37
37
|
const XSD_STRING_URI = "http://www.w3.org/2001/XMLSchema#string";
|
|
38
|
+
const FEDIFY_TYPED_STRING_URI = "fedify:typedString";
|
|
38
39
|
const XSD_DECIMAL_URI = "http://www.w3.org/2001/XMLSchema#decimal";
|
|
39
40
|
const FEDIFY_VOCAB_ENTITY_TYPE_URI = "fedify:vocabEntityType";
|
|
40
41
|
/**
|
|
@@ -52,6 +53,7 @@ function validateTypeSchemas(types) {
|
|
|
52
53
|
for (const type of Object.values(types)) for (const property of type.properties) {
|
|
53
54
|
const hasString = property.range.includes(XSD_STRING_URI);
|
|
54
55
|
const hasDecimal = property.range.includes(XSD_DECIMAL_URI);
|
|
56
|
+
if (property.range.includes(FEDIFY_TYPED_STRING_URI) && (hasString || hasDecimal)) throw new TypeError(`The property ${type.name}.${property.singularName} cannot mix fedify:typedString with xsd:string or xsd:decimal because the generated encoder cannot disambiguate them at runtime.`);
|
|
55
57
|
if (hasString && hasDecimal) throw new TypeError(`The property ${type.name}.${property.singularName} cannot have both xsd:string and xsd:decimal in its range because the generated encoder cannot disambiguate them at runtime.`);
|
|
56
58
|
if (property.range.includes(FEDIFY_VOCAB_ENTITY_TYPE_URI) && property.range.length > 1) throw new TypeError(`The property ${type.name}.${property.singularName} cannot mix fedify:vocabEntityType with other range types because the generated decoder cannot disambiguate entity type references from ordinary IRIs.`);
|
|
57
59
|
}
|
|
@@ -248,6 +250,50 @@ const scalarTypes = {
|
|
|
248
250
|
return `parseDecimal(${v}["@value"])`;
|
|
249
251
|
}
|
|
250
252
|
},
|
|
253
|
+
"fedify:typedString": {
|
|
254
|
+
name: "string",
|
|
255
|
+
typeGuard(v) {
|
|
256
|
+
return `typeof ${v} === "string"`;
|
|
257
|
+
},
|
|
258
|
+
encoder(v) {
|
|
259
|
+
return `{ "@type": "http://www.w3.org/2001/XMLSchema#string", "@value": ${v} }`;
|
|
260
|
+
},
|
|
261
|
+
compactEncoder(v) {
|
|
262
|
+
return v;
|
|
263
|
+
},
|
|
264
|
+
dataCheck(v) {
|
|
265
|
+
return `${v} != null && typeof ${v} === "object" && "@value" in ${v}
|
|
266
|
+
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})
|
|
267
|
+
&& (!("@type" in ${v}) || ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#string")`;
|
|
268
|
+
},
|
|
269
|
+
decoder(v) {
|
|
270
|
+
return `${v}["@value"]`;
|
|
271
|
+
},
|
|
272
|
+
skipUnparsable: true
|
|
273
|
+
},
|
|
274
|
+
"fedify:positiveSafeInteger": {
|
|
275
|
+
name: "number",
|
|
276
|
+
typeGuard(v) {
|
|
277
|
+
return `typeof ${v} === "number" && Number.isSafeInteger(${v}) && ${v} > 0`;
|
|
278
|
+
},
|
|
279
|
+
encoder(v) {
|
|
280
|
+
return `{ "@type": "http://www.w3.org/2001/XMLSchema#integer", "@value": ${v} }`;
|
|
281
|
+
},
|
|
282
|
+
compactEncoder(v) {
|
|
283
|
+
return v;
|
|
284
|
+
},
|
|
285
|
+
dataCheck(v) {
|
|
286
|
+
return `${v} != null && typeof ${v} === "object" && "@value" in ${v}
|
|
287
|
+
&& typeof ${v}["@value"] === "number" && Number.isSafeInteger(${v}["@value"])
|
|
288
|
+
&& ${v}["@value"] > 0
|
|
289
|
+
&& !("@language" in ${v})
|
|
290
|
+
&& (!("@type" in ${v}) || ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#integer")`;
|
|
291
|
+
},
|
|
292
|
+
decoder(v) {
|
|
293
|
+
return `${v}["@value"]`;
|
|
294
|
+
},
|
|
295
|
+
skipUnparsable: true
|
|
296
|
+
},
|
|
251
297
|
"http://www.w3.org/2001/XMLSchema#string": {
|
|
252
298
|
name: "string",
|
|
253
299
|
typeGuard(v) {
|
|
@@ -901,7 +947,7 @@ function* generatePropertyDecoder(property, types, variable, arrayVariable, modu
|
|
|
901
947
|
//#endregion
|
|
902
948
|
//#region deno.json
|
|
903
949
|
var name = "@fedify/vocab-tools";
|
|
904
|
-
var version = "2.5.0-dev.
|
|
950
|
+
var version = "2.5.0-dev.2825+f3f41ba3";
|
|
905
951
|
//#endregion
|
|
906
952
|
//#region src/field.ts
|
|
907
953
|
async function getFieldName(propertyUri, prefix = "#") {
|
package/dist/mod.js
CHANGED
|
@@ -34,6 +34,7 @@ function hasSingularAccessor(property) {
|
|
|
34
34
|
return isNonFunctionalProperty(property) && property.singularAccessor === true;
|
|
35
35
|
}
|
|
36
36
|
const XSD_STRING_URI = "http://www.w3.org/2001/XMLSchema#string";
|
|
37
|
+
const FEDIFY_TYPED_STRING_URI = "fedify:typedString";
|
|
37
38
|
const XSD_DECIMAL_URI = "http://www.w3.org/2001/XMLSchema#decimal";
|
|
38
39
|
const FEDIFY_VOCAB_ENTITY_TYPE_URI = "fedify:vocabEntityType";
|
|
39
40
|
/**
|
|
@@ -51,6 +52,7 @@ function validateTypeSchemas(types) {
|
|
|
51
52
|
for (const type of Object.values(types)) for (const property of type.properties) {
|
|
52
53
|
const hasString = property.range.includes(XSD_STRING_URI);
|
|
53
54
|
const hasDecimal = property.range.includes(XSD_DECIMAL_URI);
|
|
55
|
+
if (property.range.includes(FEDIFY_TYPED_STRING_URI) && (hasString || hasDecimal)) throw new TypeError(`The property ${type.name}.${property.singularName} cannot mix fedify:typedString with xsd:string or xsd:decimal because the generated encoder cannot disambiguate them at runtime.`);
|
|
54
56
|
if (hasString && hasDecimal) throw new TypeError(`The property ${type.name}.${property.singularName} cannot have both xsd:string and xsd:decimal in its range because the generated encoder cannot disambiguate them at runtime.`);
|
|
55
57
|
if (property.range.includes(FEDIFY_VOCAB_ENTITY_TYPE_URI) && property.range.length > 1) throw new TypeError(`The property ${type.name}.${property.singularName} cannot mix fedify:vocabEntityType with other range types because the generated decoder cannot disambiguate entity type references from ordinary IRIs.`);
|
|
56
58
|
}
|
|
@@ -247,6 +249,50 @@ const scalarTypes = {
|
|
|
247
249
|
return `parseDecimal(${v}["@value"])`;
|
|
248
250
|
}
|
|
249
251
|
},
|
|
252
|
+
"fedify:typedString": {
|
|
253
|
+
name: "string",
|
|
254
|
+
typeGuard(v) {
|
|
255
|
+
return `typeof ${v} === "string"`;
|
|
256
|
+
},
|
|
257
|
+
encoder(v) {
|
|
258
|
+
return `{ "@type": "http://www.w3.org/2001/XMLSchema#string", "@value": ${v} }`;
|
|
259
|
+
},
|
|
260
|
+
compactEncoder(v) {
|
|
261
|
+
return v;
|
|
262
|
+
},
|
|
263
|
+
dataCheck(v) {
|
|
264
|
+
return `${v} != null && typeof ${v} === "object" && "@value" in ${v}
|
|
265
|
+
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})
|
|
266
|
+
&& (!("@type" in ${v}) || ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#string")`;
|
|
267
|
+
},
|
|
268
|
+
decoder(v) {
|
|
269
|
+
return `${v}["@value"]`;
|
|
270
|
+
},
|
|
271
|
+
skipUnparsable: true
|
|
272
|
+
},
|
|
273
|
+
"fedify:positiveSafeInteger": {
|
|
274
|
+
name: "number",
|
|
275
|
+
typeGuard(v) {
|
|
276
|
+
return `typeof ${v} === "number" && Number.isSafeInteger(${v}) && ${v} > 0`;
|
|
277
|
+
},
|
|
278
|
+
encoder(v) {
|
|
279
|
+
return `{ "@type": "http://www.w3.org/2001/XMLSchema#integer", "@value": ${v} }`;
|
|
280
|
+
},
|
|
281
|
+
compactEncoder(v) {
|
|
282
|
+
return v;
|
|
283
|
+
},
|
|
284
|
+
dataCheck(v) {
|
|
285
|
+
return `${v} != null && typeof ${v} === "object" && "@value" in ${v}
|
|
286
|
+
&& typeof ${v}["@value"] === "number" && Number.isSafeInteger(${v}["@value"])
|
|
287
|
+
&& ${v}["@value"] > 0
|
|
288
|
+
&& !("@language" in ${v})
|
|
289
|
+
&& (!("@type" in ${v}) || ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#integer")`;
|
|
290
|
+
},
|
|
291
|
+
decoder(v) {
|
|
292
|
+
return `${v}["@value"]`;
|
|
293
|
+
},
|
|
294
|
+
skipUnparsable: true
|
|
295
|
+
},
|
|
250
296
|
"http://www.w3.org/2001/XMLSchema#string": {
|
|
251
297
|
name: "string",
|
|
252
298
|
typeGuard(v) {
|
|
@@ -900,7 +946,7 @@ function* generatePropertyDecoder(property, types, variable, arrayVariable, modu
|
|
|
900
946
|
//#endregion
|
|
901
947
|
//#region deno.json
|
|
902
948
|
var name = "@fedify/vocab-tools";
|
|
903
|
-
var version = "2.5.0-dev.
|
|
949
|
+
var version = "2.5.0-dev.2825+f3f41ba3";
|
|
904
950
|
//#endregion
|
|
905
951
|
//#region src/field.ts
|
|
906
952
|
async function getFieldName(propertyUri, prefix = "#") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-tools",
|
|
3
|
-
"version": "2.5.0-dev.
|
|
3
|
+
"version": "2.5.0-dev.2825+f3f41ba3",
|
|
4
4
|
"description": "Code generator for Activity Vocabulary APIs",
|
|
5
5
|
"homepage": "https://fedify.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@types/node": "^24.12.2",
|
|
69
69
|
"tsdown": "^0.22.0",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
|
-
"@fedify/vocab-runtime": "^2.5.0-dev.
|
|
71
|
+
"@fedify/vocab-runtime": "^2.5.0-dev.2825+f3f41ba3"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@cfworker/json-schema": "^4.1.1",
|