Skip to content

Commit 49f84e3

Browse files
authored
Merge pull request #442 from abraham/copilot/fix-687218e6-a2f6-4522-8542-08c02d239390
Fix missing enum values in NotificationGroup type by respecting blocked files in EntityParser
2 parents cd8980f + 71f55ee commit 49f84e3

File tree

4 files changed

+57
-20
lines changed

4 files changed

+57
-20
lines changed

dist/schema.json

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38092,7 +38092,7 @@
3809238092
}
3809338093
},
3809438094
"status_id": {
38095-
"description": "ID of the [Status]({{< relref \"entities/Status\" >}}) that was the object of the notification. Attached when `type` of the notification is `favourite`, `reblog`, `status`, `mention`, `poll`, or `update`.",
38095+
"description": "ID of the [Status]({{< relref \"entities/Status\" >}}) that was the object of the notification. Attached when `type` of the notification is `favourite`, `reblog`, `status`, `mention`, `poll`, `update`, `quote` or `quoted_update`. In the case of `quoted_update`, your quote of the edited status is attached, not the status that was edited.",
3809638096
"type": [
3809738097
"string",
3809838098
"null"
@@ -38104,7 +38104,7 @@
3810438104
"string",
3810538105
"null"
3810638106
],
38107-
"$ref": "#/components/schemas/NotificationGroupTypeEnum"
38107+
"$ref": "#/components/schemas/NotificationTypeEnum"
3810838108
}
3810938109
},
3811038110
"externalDocs": {
@@ -38709,23 +38709,6 @@
3870938709
"account_suspension"
3871038710
]
3871138711
},
38712-
"NotificationGroupTypeEnum": {
38713-
"type": "string",
38714-
"enum": [
38715-
"mention",
38716-
"status",
38717-
"reblog",
38718-
"follow",
38719-
"follow_request",
38720-
"favourite",
38721-
"poll",
38722-
"update",
38723-
"admin.sign_up",
38724-
"admin.report",
38725-
"severed_relationships",
38726-
"moderation_warning"
38727-
]
38728-
},
3872938712
"GetApiV1NotificationsParamTypesEnum": {
3873038713
"type": "string",
3873138714
"enum": [

src/__tests__/parsers/EntityParser.draft.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ describe('EntityParser - Draft File Handling', () => {
4040
// This test validates that only explicit draft: true is filtered
4141
// This is implicitly tested by checking that we still get a reasonable number of entities
4242
const entities = parser.parseAllEntities();
43-
expect(entities.length).toBe(93); // Exact count after removing EncryptedMessage (increased due to extracted nested entities + Admin::DimensionData + DiscoverOauthServerConfigurationResponse + OEmbedResponse)
43+
expect(entities.length).toBe(90); // Exact count after removing EncryptedMessage and entities from blocked files (increased due to extracted nested entities + Admin::DimensionData + DiscoverOauthServerConfigurationResponse + OEmbedResponse)
4444
});
4545
});

src/__tests__/parsers/EntityParser.methodEntities.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,42 @@ describe('EntityParser - Method Entity Extraction', () => {
5555
expect(notificationGroup.attributes.some((a) => a.name === 'type')).toBe(
5656
true
5757
);
58+
59+
// Check that type attribute has enum values including quote and quoted_update
60+
const typeAttribute = notificationGroup.attributes.find(
61+
(a) => a.name === 'type'
62+
);
63+
expect(typeAttribute).toBeDefined();
64+
if (typeAttribute) {
65+
expect(typeAttribute.enumValues).toBeDefined();
66+
expect(typeAttribute.enumValues).toContain('quote');
67+
expect(typeAttribute.enumValues).toContain('quoted_update');
68+
expect(typeAttribute.enumValues).toContain('mention');
69+
expect(typeAttribute.enumValues).toContain('favourite');
70+
// Should have all 14 values
71+
expect(typeAttribute.enumValues?.length).toBe(14);
72+
}
5873
}
5974
});
75+
76+
test('should skip blocked method files for entity parsing', () => {
77+
const entities = parser.parseAllEntities();
78+
79+
// Find all NotificationGroup entities
80+
const notificationGroups = entities.filter(
81+
(e) => e.name === 'NotificationGroup'
82+
);
83+
84+
// Should only have one NotificationGroup entity (from grouped_notifications.md, not notifications_alpha.md)
85+
expect(notificationGroups).toHaveLength(1);
86+
87+
// The single NotificationGroup should have complete enum values
88+
const notificationGroup = notificationGroups[0];
89+
const typeAttribute = notificationGroup.attributes.find(
90+
(a) => a.name === 'type'
91+
);
92+
expect(typeAttribute?.enumValues).toContain('quote');
93+
expect(typeAttribute?.enumValues).toContain('quoted_update');
94+
expect(typeAttribute?.enumValues?.length).toBe(14);
95+
});
6096
});

src/parsers/EntityParser.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,29 @@ class EntityParser {
4646

4747
// Parse entities from method files
4848
if (fs.existsSync(this.methodsPath)) {
49+
// Load blocked files from config
50+
let blockedFiles: string[] = [];
51+
try {
52+
const config = JSON.parse(fs.readFileSync('config.json', 'utf8'));
53+
blockedFiles = config.blockedFiles || [];
54+
} catch (error) {
55+
console.warn('Could not load blockedFiles from config.json:', error);
56+
}
57+
4958
const methodFiles = fs
5059
.readdirSync(this.methodsPath)
5160
.filter((file) => file.endsWith('.md'));
5261

5362
for (const file of methodFiles) {
63+
// Check if file is blocked
64+
const relativePath = `methods/${file}`;
65+
if (blockedFiles.includes(relativePath)) {
66+
console.log(
67+
`Skipping blocked file for entity parsing: ${relativePath}`
68+
);
69+
continue;
70+
}
71+
5472
try {
5573
const methodEntities = MethodEntityParser.parseEntitiesFromMethodFile(
5674
path.join(this.methodsPath, file)

0 commit comments

Comments
 (0)