@drfed/models 0.2.0-dev.716 → 0.2.0-dev.718
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 +58 -4
- package/dist/activity-delivery.d.mts +1 -1
- package/dist/{db-CcbUSnp2.d.mts → db-Al_MT-L_.d.mts} +132 -3
- package/dist/{db-CcbUSnp2.d.mts.map → db-Al_MT-L_.d.mts.map} +1 -1
- package/dist/db.d.mts +1 -1
- package/dist/document.d.mts +14 -2
- package/dist/document.d.mts.map +1 -1
- package/dist/document.mjs +115 -26
- package/dist/document.mjs.map +1 -1
- package/dist/expansion-p4BoMDVd.d.mts +90 -0
- package/dist/expansion-p4BoMDVd.d.mts.map +1 -0
- package/dist/expansion.d.mts +2 -0
- package/dist/expansion.mjs +131 -0
- package/dist/expansion.mjs.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/instance.d.mts +1 -1
- package/dist/key.d.mts +1 -1
- package/dist/login.d.mts +1 -1
- package/dist/migrations-manifest.json +4 -0
- package/dist/relations.d.mts +1 -1
- package/dist/{resource-revision-rDmHhNCj.d.mts → resource-revision-BbXciRsu.d.mts} +117 -4
- package/dist/resource-revision-BbXciRsu.d.mts.map +1 -0
- package/dist/{resource-revision-bTQyJ7aw.mjs → resource-revision-DGsz8fnS.mjs} +338 -42
- package/dist/resource-revision-DGsz8fnS.mjs.map +1 -0
- package/dist/resource-revision.d.mts +2 -2
- package/dist/resource-revision.mjs +1 -1
- package/dist/resource.d.mts +1 -1
- package/dist/schema.d.mts +2 -2
- package/dist/schema.mjs +55 -1
- package/dist/schema.mjs.map +1 -1
- package/drizzle/20261125051505_revision_expansions/migration.sql +31 -0
- package/drizzle/20261125051505_revision_expansions/snapshot.json +4806 -0
- package/package.json +12 -7
- package/dist/resource-revision-bTQyJ7aw.mjs.map +0 -1
- package/dist/resource-revision-rDmHhNCj.d.mts.map +0 -1
package/dist/document.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MIMEType } from "node:util";
|
|
2
|
-
import { Accept, Activity, Add, Announce, Application, Arrive, Article, Block, Collection, CollectionPage, Create, Delete, Dislike, Flag, Follow, Group, Ignore, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Person, Question, Read, Reject, Remove, Service, TentativeAccept, TentativeReject, Travel, Undo, Update, View, getEntityTypeById } from "@fedify/vocab";
|
|
3
2
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
3
|
+
import { Accept, Activity, Add, Announce, Application, Arrive, Article, Block, Collection, CollectionPage, Create, Delete, Dislike, Flag, Follow, Group, Ignore, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Person, Question, Read, Reject, Remove, Service, TentativeAccept, TentativeReject, Travel, Undo, Update, View, getEntityTypeById } from "@fedify/vocab";
|
|
4
4
|
//#region src/document.ts
|
|
5
5
|
/** Stable classifications; human-readable diagnostic messages may change. */
|
|
6
6
|
const DIAGNOSTIC_REASONS = {
|
|
@@ -28,6 +28,10 @@ const DIAGNOSTIC_REASONS = {
|
|
|
28
28
|
category: "vocabulary",
|
|
29
29
|
severity: "error"
|
|
30
30
|
},
|
|
31
|
+
mutually_exclusive_properties: {
|
|
32
|
+
category: "vocabulary",
|
|
33
|
+
severity: "error"
|
|
34
|
+
},
|
|
31
35
|
property_not_applicable: {
|
|
32
36
|
category: "vocabulary",
|
|
33
37
|
severity: "error"
|
|
@@ -91,11 +95,20 @@ const DIAGNOSTIC_REASONS = {
|
|
|
91
95
|
absent_identifier: {
|
|
92
96
|
category: "compatibility",
|
|
93
97
|
severity: "warning"
|
|
98
|
+
},
|
|
99
|
+
poll_choices_not_list: {
|
|
100
|
+
category: "compatibility",
|
|
101
|
+
severity: "warning"
|
|
102
|
+
},
|
|
103
|
+
poll_choice_reference: {
|
|
104
|
+
category: "compatibility",
|
|
105
|
+
severity: "warning"
|
|
94
106
|
}
|
|
95
107
|
};
|
|
96
108
|
const ACTIVITY_STREAMS_CONTEXT = "https://www.w3.org/ns/activitystreams";
|
|
97
109
|
const MAXIMUM_DIAGNOSTICS = 100;
|
|
98
110
|
const MAXIMUM_PATH_DEPTH = 64;
|
|
111
|
+
const IRI_SCHEME_PATTERN = /^[a-z][a-z\d+.-]*:/iu;
|
|
99
112
|
const ACTOR_TYPES = [
|
|
100
113
|
Application,
|
|
101
114
|
Group,
|
|
@@ -203,6 +216,8 @@ const IDENTIFIER_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
203
216
|
...ADDRESSING_PROPERTIES,
|
|
204
217
|
"items",
|
|
205
218
|
"orderedItems",
|
|
219
|
+
"oneOf",
|
|
220
|
+
"anyOf",
|
|
206
221
|
"current",
|
|
207
222
|
"first",
|
|
208
223
|
"last",
|
|
@@ -291,20 +306,24 @@ function readDocument(document, path, report) {
|
|
|
291
306
|
function isJsonValueShape(value) {
|
|
292
307
|
return value === null || typeof value === "object" || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
293
308
|
}
|
|
294
|
-
function
|
|
309
|
+
function hasInvalidIriCharacters(value) {
|
|
310
|
+
const hasControlOrSpace = Array.from(value).some((character) => {
|
|
311
|
+
const point = character.codePointAt(0);
|
|
312
|
+
return point <= 32 || point >= 127 && point <= 159;
|
|
313
|
+
});
|
|
314
|
+
return !value.isWellFormed() || hasControlOrSpace || /[<>"{}|\\^`]/u.test(value) || /%(?![\da-f]{2})/iu.test(value);
|
|
315
|
+
}
|
|
316
|
+
function checkReference(value, path, report, context) {
|
|
295
317
|
if (value === null) return;
|
|
296
318
|
if (typeof value !== "string") {
|
|
297
319
|
if (typeof value === "object") report("unsupported_value_form", path, "Embedded values are not checked yet.");
|
|
298
320
|
else report("invalid_value_shape", path, "Expected a resource reference, embedded object, or allowed list.");
|
|
299
321
|
return;
|
|
300
322
|
}
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (!value.isWellFormed() || hasControlOrSpace || /[<>"{}|\\^`]/u.test(value) || /%(?![\da-f]{2})/iu.test(value)) report("invalid_iri", path, "Expected a syntactically valid IRI reference.");
|
|
306
|
-
else if (!/^[a-z][a-z\d+.-]*:/iu.test(value)) report("unsupported_value_form", path, "Relative references need a base-IRI policy.");
|
|
307
|
-
else if (!URL.canParse(value)) report("unsupported_value_form", path, "This IRI cannot be represented by the current URL parser.");
|
|
323
|
+
const iri = context == null ? value : expandIdentifier(value, context);
|
|
324
|
+
if (hasInvalidIriCharacters(value) || iri !== value && hasInvalidIriCharacters(iri)) report("invalid_iri", path, "Expected a syntactically valid IRI reference.");
|
|
325
|
+
else if (!IRI_SCHEME_PATTERN.test(iri)) report("unsupported_value_form", path, "Relative references need a base-IRI policy.");
|
|
326
|
+
else if (!URL.canParse(iri)) report("unsupported_value_form", path, iri === value ? "This IRI cannot be represented by the current URL parser." : "The expanded IRI cannot be represented by the current URL parser.");
|
|
308
327
|
}
|
|
309
328
|
function checkReferenceEntry(value, path, report, check) {
|
|
310
329
|
if (value === null) return;
|
|
@@ -348,7 +367,7 @@ function sameContextTerm(actual, expected) {
|
|
|
348
367
|
return actual != null && actual.iri === expected.iri && actual.type === expected.type && actual.container === expected.container && actual.prefix === expected.prefix;
|
|
349
368
|
}
|
|
350
369
|
function isSupportedContextUri(value) {
|
|
351
|
-
return
|
|
370
|
+
return IRI_SCHEME_PATTERN.test(value) && !Array.from(value).some((character) => {
|
|
352
371
|
const point = character.codePointAt(0);
|
|
353
372
|
return point <= 32 || point >= 127 && point <= 159 || "<>\"{}|\\^`".includes(character);
|
|
354
373
|
}) && URL.canParse(value);
|
|
@@ -612,8 +631,25 @@ function checkEmbeddedFedifyRange(Type, expected, path, report) {
|
|
|
612
631
|
}
|
|
613
632
|
function getEmbeddedFedifyRange(property, collectionRange) {
|
|
614
633
|
if (property === "actor" || property === "attributedTo") return ACTOR_TYPES;
|
|
634
|
+
if (isQuestionChoice(property)) return [Object$1];
|
|
615
635
|
return collectionRange?.filter((Expected) => Expected !== Link);
|
|
616
636
|
}
|
|
637
|
+
function getReferenceRange(property, collectionRange) {
|
|
638
|
+
if (isQuestionChoice(property)) return [Object$1, Link];
|
|
639
|
+
return collectionRange;
|
|
640
|
+
}
|
|
641
|
+
function isQuestionChoice(property) {
|
|
642
|
+
return property === "oneOf" || property === "anyOf";
|
|
643
|
+
}
|
|
644
|
+
function conflictingChoiceSources(Type, fields, values) {
|
|
645
|
+
if (!isTypeOrSubtype(Type, Question)) return /* @__PURE__ */ new Set();
|
|
646
|
+
const choices = {
|
|
647
|
+
oneOf: [],
|
|
648
|
+
anyOf: []
|
|
649
|
+
};
|
|
650
|
+
for (const { name, compatible, source } of fields) if (compatible && isQuestionChoice(name) && countValues(values[source]) > 0) choices[name].push(source);
|
|
651
|
+
return new Set(choices.oneOf.length > 0 && choices.anyOf.length > 0 ? [...choices.oneOf, ...choices.anyOf] : []);
|
|
652
|
+
}
|
|
617
653
|
function checkDocumentType(values, fields, path, context, report) {
|
|
618
654
|
const types = fields.filter(({ name }) => name === "type");
|
|
619
655
|
if (types.length > 1) {
|
|
@@ -646,6 +682,7 @@ function getCollectionRange(Type, property) {
|
|
|
646
682
|
}
|
|
647
683
|
function isFunctionalProperty(Type, property) {
|
|
648
684
|
if (["id", "mediaType"].includes(property)) return true;
|
|
685
|
+
if (isTypeOrSubtype(Type, Question) && property === "closed") return true;
|
|
649
686
|
if (getCollectionRange(Type, property) != null) return true;
|
|
650
687
|
if (isTypeOrSubtype(Type, Link)) return [
|
|
651
688
|
"href",
|
|
@@ -687,11 +724,17 @@ function findMultipleAliases(Type, fields, values) {
|
|
|
687
724
|
}
|
|
688
725
|
return multiple;
|
|
689
726
|
}
|
|
727
|
+
function checkFieldMultiplicity(field, path, report, conflictingChoice, multipleAliases) {
|
|
728
|
+
if (conflictingChoice) report("mutually_exclusive_properties", path, "Use either oneOf or anyOf, but not both.");
|
|
729
|
+
if (!multipleAliases.has(field.source)) return;
|
|
730
|
+
if (field.name === "closed") report("unsupported_value_form", path, "DrFed supports one closing value across all aliases.");
|
|
731
|
+
else report("invalid_multiplicity", path, "Multiple aliases supply values for one functional property.");
|
|
732
|
+
}
|
|
690
733
|
function checkNonNegativeInteger(value, path, report) {
|
|
691
734
|
if (value === null) return;
|
|
692
735
|
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) report("invalid_value_shape", path, "Expected a non-negative integer.");
|
|
693
736
|
}
|
|
694
|
-
function checkSingleValue(value, path, report, check) {
|
|
737
|
+
function checkSingleValue(value, path, report, check, multiplicityReason = "invalid_multiplicity") {
|
|
695
738
|
if (!Array.isArray(value)) {
|
|
696
739
|
check(value, path, report);
|
|
697
740
|
return;
|
|
@@ -707,7 +750,7 @@ function checkSingleValue(value, path, report, check) {
|
|
|
707
750
|
path: entryPath
|
|
708
751
|
});
|
|
709
752
|
});
|
|
710
|
-
if (entries.length > 1) report(
|
|
753
|
+
if (entries.length > 1) report(multiplicityReason, path, "Expected at most one non-null value.");
|
|
711
754
|
for (const entry of entries) checkReferenceEntry(entry.value, entry.path, report, check);
|
|
712
755
|
}
|
|
713
756
|
function checkLanguageTag(value, path, report) {
|
|
@@ -801,7 +844,13 @@ function checkDateTime(value, path, report) {
|
|
|
801
844
|
report("unsupported_value_form", path, "This date-time matches the ActivityStreams format, but cannot be parsed as an instant without rewriting; provide a timestamp such as 2024-01-01T12:34:00Z.");
|
|
802
845
|
}
|
|
803
846
|
}
|
|
847
|
+
function checkQuestionClosed(value, path, report) {
|
|
848
|
+
if (value === null || typeof value === "boolean") return;
|
|
849
|
+
if (typeof value === "object" && !Array.isArray(value) || typeof value === "string" && IRI_SCHEME_PATTERN.test(value)) report("unsupported_value_form", path, "Fedify supports boolean or date-time closing conditions, not resource values.");
|
|
850
|
+
else checkDateTime(value, path, report);
|
|
851
|
+
}
|
|
804
852
|
function getCommonPropertyKind(Type, property) {
|
|
853
|
+
if (isTypeOrSubtype(Type, Question) && property === "closed") return "closed";
|
|
805
854
|
const object = isTypeOrSubtype(Type, Object$1);
|
|
806
855
|
const actor = ACTOR_TYPES.some((Actor) => isTypeOrSubtype(Type, Actor));
|
|
807
856
|
const textProperties = object ? [
|
|
@@ -820,13 +869,14 @@ function getCommonPropertyKind(Type, property) {
|
|
|
820
869
|
].includes(property)) return "datetime";
|
|
821
870
|
if (property === "id" || property === "mediaType") return property;
|
|
822
871
|
}
|
|
823
|
-
function checkCommonProperty(kind, property, value, path, report) {
|
|
872
|
+
function checkCommonProperty(kind, property, value, path, report, identifierContext) {
|
|
824
873
|
if (kind === "text") checkReferenceValues(value, path, report, (entry, entryPath) => checkText(entry, entryPath, report, property === "name"));
|
|
825
874
|
else if (kind === "languageMap") checkLanguageMap(value, path, report, property === "nameMap");
|
|
826
875
|
else if (kind === "datetime") checkSingleValue(value, path, report, checkDateTime);
|
|
876
|
+
else if (kind === "closed") checkSingleValue(value, path, report, checkQuestionClosed, "unsupported_value_form");
|
|
827
877
|
else if (kind === "id") {
|
|
828
878
|
if (typeof value !== "string") report("invalid_value_shape", path, "Expected an IRI identifier string.");
|
|
829
|
-
else checkReference(value, path, report);
|
|
879
|
+
else checkReference(value, path, report, identifierContext);
|
|
830
880
|
} else if (kind === "mediaType") checkSingleValue(value, path, report, (entry, entryPath) => checkLinkProperty(property, entry, entryPath, report));
|
|
831
881
|
else return value === null;
|
|
832
882
|
return true;
|
|
@@ -858,7 +908,7 @@ function proposePropertyOmission(value, path, report, changes, identifier) {
|
|
|
858
908
|
function checkLinkRelation(value, path, report) {
|
|
859
909
|
if (value === null) return;
|
|
860
910
|
if (typeof value !== "string" || value.length === 0 || Array.from(value).some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127 || character === ",")) report("invalid_value_shape", path, "Expected a relation token or absolute IRI without whitespace or commas.");
|
|
861
|
-
else if (
|
|
911
|
+
else if (IRI_SCHEME_PATTERN.test(value)) checkReference(value, path, report);
|
|
862
912
|
else if (!/^[a-z][a-z\d.-]*$/iu.test(value)) report("invalid_value_shape", path, "Expected a relation token or absolute IRI.");
|
|
863
913
|
}
|
|
864
914
|
function checkLinkProperty(property, value, path, report) {
|
|
@@ -933,7 +983,24 @@ function checkExtensionKeywords(values, path, report) {
|
|
|
933
983
|
return jsonLiteral;
|
|
934
984
|
}
|
|
935
985
|
function getInapplicableProperties(Type) {
|
|
936
|
-
|
|
986
|
+
const properties = new Set(isTypeOrSubtype(Type, Link) ? OBJECT_ONLY_PROPERTIES : []);
|
|
987
|
+
if (!isTypeOrSubtype(Type, Question)) {
|
|
988
|
+
properties.add("oneOf");
|
|
989
|
+
properties.add("anyOf");
|
|
990
|
+
properties.add("closed");
|
|
991
|
+
}
|
|
992
|
+
return properties;
|
|
993
|
+
}
|
|
994
|
+
function checkInapplicableProperty(property, value, path, report) {
|
|
995
|
+
if (value === null) return;
|
|
996
|
+
if ((isQuestionChoice(property) || property === "closed") && Array.isArray(value) && value.length > 0) {
|
|
997
|
+
let hasValue = false;
|
|
998
|
+
checkReferenceValues(value, path, report, () => {
|
|
999
|
+
hasValue = true;
|
|
1000
|
+
});
|
|
1001
|
+
if (!hasValue) return;
|
|
1002
|
+
}
|
|
1003
|
+
report("property_not_applicable", path, "This property does not apply to this document's type.");
|
|
937
1004
|
}
|
|
938
1005
|
function checkPathDepth(path, report) {
|
|
939
1006
|
if (path.length <= MAXIMUM_PATH_DEPTH) return true;
|
|
@@ -976,7 +1043,7 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
976
1043
|
}
|
|
977
1044
|
for (const child of children.reverse()) pending.push(child);
|
|
978
1045
|
}
|
|
979
|
-
function checkDocument(document, path, inherited, expectedTypes, fedifyTypes) {
|
|
1046
|
+
function checkDocument(document, path, inherited, expectedTypes, fedifyTypes, embeddedAsChoice) {
|
|
980
1047
|
if (!checkPathDepth(path, report)) {
|
|
981
1048
|
onUnavailableDocument(path);
|
|
982
1049
|
return;
|
|
@@ -1023,7 +1090,11 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
1023
1090
|
"rel"
|
|
1024
1091
|
] : [];
|
|
1025
1092
|
const integerProperties = isLink ? ["height", "width"] : isOrderedPage ? ["totalItems", "startIndex"] : isCollection ? ["totalItems"] : [];
|
|
1026
|
-
const referenceProperties = [
|
|
1093
|
+
const referenceProperties = [
|
|
1094
|
+
"preview",
|
|
1095
|
+
"oneOf",
|
|
1096
|
+
"anyOf"
|
|
1097
|
+
];
|
|
1027
1098
|
if (isObject) referenceProperties.push("attributedTo", "location", ...ADDRESSING_PROPERTIES);
|
|
1028
1099
|
if (isActivity) referenceProperties.push("actor", "object", "target", "origin", "result", "instrument");
|
|
1029
1100
|
if (isCollection) referenceProperties.push("items", "orderedItems");
|
|
@@ -1034,6 +1105,8 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
1034
1105
|
]);
|
|
1035
1106
|
const multipleAliases = findMultipleAliases(Type, fields, values);
|
|
1036
1107
|
const inapplicableProperties = getInapplicableProperties(Type);
|
|
1108
|
+
const conflictingChoices = conflictingChoiceSources(Type, fields, values);
|
|
1109
|
+
const choiceWarnings = /* @__PURE__ */ new Set();
|
|
1037
1110
|
ancestors.add(sourceDocument);
|
|
1038
1111
|
pending.push(() => {
|
|
1039
1112
|
ancestors.delete(sourceDocument);
|
|
@@ -1041,6 +1114,8 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
1041
1114
|
for (const field of fields.filter(({ name }) => name !== "type").reverse()) {
|
|
1042
1115
|
const { source, name: key } = field;
|
|
1043
1116
|
const intransitiveObject = isIntransitive && key === "object";
|
|
1117
|
+
const isChoice = isQuestionChoice(key);
|
|
1118
|
+
const conflictingChoice = conflictingChoices.has(source);
|
|
1044
1119
|
pending.push(() => {
|
|
1045
1120
|
const value = values[source];
|
|
1046
1121
|
const fieldPath = [...path, source];
|
|
@@ -1058,11 +1133,10 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
1058
1133
|
return;
|
|
1059
1134
|
}
|
|
1060
1135
|
if (inapplicableProperties.has(key)) {
|
|
1061
|
-
|
|
1062
|
-
report("property_not_applicable", fieldPath, "This property applies to Object documents, not Link documents.");
|
|
1136
|
+
checkInapplicableProperty(key, value, fieldPath, report);
|
|
1063
1137
|
return;
|
|
1064
1138
|
}
|
|
1065
|
-
|
|
1139
|
+
checkFieldMultiplicity(field, fieldPath, report, conflictingChoice, multipleAliases);
|
|
1066
1140
|
const collectionRange = getCollectionRange(Type, key);
|
|
1067
1141
|
const commonKind = getCommonPropertyKind(Type, key);
|
|
1068
1142
|
if ((omittableProperties.has(key) || collectionRange != null || commonKind != null) && proposePropertyOmission(value, fieldPath, report, changes, commonKind === "id")) return;
|
|
@@ -1070,14 +1144,29 @@ function checkDocumentValue(rootDocument, rootPath, reporter, changes, onDocumen
|
|
|
1070
1144
|
else if (linkProperties.includes(key)) {
|
|
1071
1145
|
if (key === "rel") checkLinkProperty(key, value, fieldPath, report);
|
|
1072
1146
|
else checkSingleValue(value, fieldPath, report, (entry, entryPath) => checkLinkProperty(key, entry, entryPath, report));
|
|
1073
|
-
} else if (checkCommonProperty(commonKind, key, value, fieldPath, report)) {} else if (intransitiveObject) checkReferenceValues(value, fieldPath, report, (entry, entryPath) => {
|
|
1147
|
+
} else if (checkCommonProperty(commonKind, key, value, fieldPath, report, embeddedAsChoice ? context : void 0)) {} else if (intransitiveObject) checkReferenceValues(value, fieldPath, report, (entry, entryPath) => {
|
|
1074
1148
|
if (entry !== null) report("property_not_applicable", entryPath, "The object property does not apply to intransitive activities.");
|
|
1075
1149
|
});
|
|
1076
1150
|
else if (referenceProperties.includes(key) || collectionRange != null) {
|
|
1077
1151
|
const checks = [];
|
|
1078
1152
|
(collectionRange == null ? checkReferenceValues : checkSingleReference)(value, fieldPath, report, (entry, entryPath) => {
|
|
1079
|
-
if (entry !== null && typeof entry === "object" && !Array.isArray(entry))
|
|
1080
|
-
|
|
1153
|
+
if (entry !== null && typeof entry === "object" && !Array.isArray(entry)) {
|
|
1154
|
+
if (isChoice && !conflictingChoice && !choiceWarnings.has("poll_choices_not_list") && !Array.isArray(value)) {
|
|
1155
|
+
choiceWarnings.add("poll_choices_not_list");
|
|
1156
|
+
report("poll_choices_not_list", entryPath, "Mastodon expects a list of choices, even for one choice.");
|
|
1157
|
+
}
|
|
1158
|
+
checkDocument(entry, entryPath, context, getReferenceRange(key, collectionRange), getEmbeddedFedifyRange(key, collectionRange), isChoice);
|
|
1159
|
+
} else if (isChoice && typeof entry === "string") {
|
|
1160
|
+
let validReference = true;
|
|
1161
|
+
checkReference(entry, entryPath, (reason, diagnosticPath, message) => {
|
|
1162
|
+
validReference = false;
|
|
1163
|
+
report(reason, diagnosticPath, message);
|
|
1164
|
+
}, context);
|
|
1165
|
+
if (validReference && !conflictingChoice && !choiceWarnings.has("poll_choice_reference")) {
|
|
1166
|
+
choiceWarnings.add("poll_choice_reference");
|
|
1167
|
+
report("poll_choice_reference", entryPath, "Mastodon expects embedded choices and may not read this IRI reference.");
|
|
1168
|
+
}
|
|
1169
|
+
} else checkReference(entry, entryPath, report);
|
|
1081
1170
|
}, (check) => checks.push(check));
|
|
1082
1171
|
for (const check of checks.reverse()) pending.push(check);
|
|
1083
1172
|
} else report("unsupported_property", fieldPath, "This property is not checked by the initial implementation.");
|
|
@@ -1130,8 +1219,8 @@ function createPreview(document, changes) {
|
|
|
1130
1219
|
* Checks the implemented Activity Vocabulary types, including nested
|
|
1131
1220
|
* activity objects, without network access or writes. Embedded objects inherit
|
|
1132
1221
|
* the parent's context. Collections add member, count, and navigation checks.
|
|
1133
|
-
* Question
|
|
1134
|
-
*
|
|
1222
|
+
* Question adds exclusive/inclusive choices and boolean/date-time closing
|
|
1223
|
+
* conditions to shared intransitive rules.
|
|
1135
1224
|
*
|
|
1136
1225
|
* Supports allowlisted bundled contexts and simple inline aliases/prefixes,
|
|
1137
1226
|
* single types, id, string content,
|