You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/json-data-files.md
+87-20Lines changed: 87 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,9 @@ This document describes the JSON data files used by the language service package
6
6
7
7
The language service uses several JSON files containing schema definitions, webhook payloads, and other metadata. To reduce bundle size, these files are:
8
8
9
-
1.**Optimized at generation time** — unused events are dropped, unused fields are stripped
10
-
2.**Minified at build time** — whitespace is removed to produce `.min.json` files
9
+
1.**Optimized at generation time** — unused events are dropped, unused fields are stripped, shared objects are deduplicated, property names are interned
10
+
2.**Compacted using a space-efficient format** — params use type-based dispatch arrays instead of objects
11
+
3.**Minified at build time** — whitespace is removed to produce `.min.json` files
11
12
12
13
The source `.json` files are human-readable and checked into the repository. The `.min.json` files are generated during build and gitignored.
13
14
@@ -19,6 +20,7 @@ The source `.json` files are human-readable and checked into the repository. The
19
20
|------|-------------|
20
21
|`src/context-providers/events/webhooks.json`| Webhook event payload schemas for autocompletion |
21
22
|`src/context-providers/events/objects.json`| Deduplicated shared object definitions referenced by webhooks |
23
+
|`src/context-providers/events/strings.json`| Interned property names shared by webhooks and objects |
22
24
|`src/context-providers/events/schedule.json`| Schedule event context data |
23
25
|`src/context-providers/events/workflow_call.json`| Reusable workflow call context data |
24
26
|`src/context-providers/descriptions.json`| Context variable descriptions for hover |
@@ -33,7 +35,7 @@ The source `.json` files are human-readable and checked into the repository. The
33
35
34
36
### Webhooks and Objects
35
37
36
-
The `webhooks.json`and `objects.json` files are generated from the [GitHub REST API description](https://github.com/github/rest-api-description):
38
+
The `webhooks.json`, `objects.json`, and `strings.json` files are generated from the [GitHub REST API description](https://github.com/github/rest-api-description):
37
39
38
40
```bash
39
41
cd languageservice
@@ -44,9 +46,10 @@ This script:
44
46
1. Fetches webhook schemas from the GitHub API description
45
47
2.**Validates** all events are categorized (fails if new events are found)
46
48
3.**Drops** events that aren't valid workflow triggers (see [Dropped Events](#dropped-events))
47
-
4.**Strips**unused fields like `description` and `summary` (see [Stripped Fields](#stripped-fields))
49
+
4.**Compacts**params into a space-efficient array format, keeping only `name`, `description`, and `childParamsGroups` (see [Compact Format](#compact-format))
48
50
5.**Deduplicates** shared object definitions into `objects.json`
49
-
6. Writes the optimized, pretty-printed JSON files
51
+
6.**Interns** duplicate property names into `strings.json` (see [String Interning](#string-interning))
52
+
7. Writes the optimized, pretty-printed JSON files
50
53
51
54
### Handling New Webhook Events
52
55
@@ -101,13 +104,15 @@ The code imports the minified versions:
101
104
102
105
```ts
103
106
importwebhooksfrom"./events/webhooks.min.json"
107
+
importobjectsfrom"./events/objects.min.json"
108
+
importstringsfrom"./events/strings.min.json"
104
109
```
105
110
106
111
## CI Verification
107
112
108
113
CI verifies that generated source files are up-to-date:
109
114
110
-
1. Runs `npm run update-webhooks` to regenerate webhooks.jsonand objects.json
115
+
1. Runs `npm run update-webhooks` to regenerate webhooks.json, objects.json, and strings.json
111
116
2. Checks for uncommitted changes with `git diff --exit-code`
112
117
113
118
The `.min.json` files are generated at build time and are not committed to the repository.
@@ -120,31 +125,93 @@ Webhook events that aren't valid workflow `on:` triggers are dropped (e.g., `ins
120
125
121
126
See `DROPPED_EVENTS` in `script/webhooks/index.ts` for the full list.
122
127
123
-
## Stripped Fields
128
+
## Compact Format
124
129
125
-
Unused fields are stripped to reduce bundle size. For example:
130
+
Params are converted from verbose objects into compact arrays, keeping only the fields needed for autocompletion and hover docs (`name`, `description`, `childParamsGroups`). Unused fields like `type`, `in`, `isRequired`, `enum`, and `default` are discarded.
131
+
132
+
| Format | Meaning |
133
+
|--------|---------|
134
+
|`"name"`| Name only (no description, no children) |
135
+
|`[name, desc]`| Name + description (arr[1] is a string) |
136
+
|`[name, children]`| Name + children (arr[1] is an array) |
137
+
|`[name, desc, children]`| Name + description + children |
138
+
139
+
The reader uses `typeof arr[1]` to determine the format: if it's a string, it's a description; if it's an array, it's children.
140
+
141
+
**Example:**
126
142
127
143
```json
128
-
// Before (from webhooks.all.json)
144
+
// Before (object format)
129
145
{
130
-
"type": "object",
131
146
"name": "issue",
132
-
"in": "body",
133
147
"description": "The issue itself.",
134
-
"isRequired": true,
135
-
"childParamsGroups": [...]
148
+
"childParamsGroups": [
149
+
{ "name": "id" },
150
+
{ "name": "title", "description": "Issue title" }
151
+
]
136
152
}
137
153
138
-
// After (webhooks.json)
154
+
// After (compact format)
155
+
["issue", "The issue itself.", [
156
+
"id",
157
+
["title", "Issue title"]
158
+
]]
159
+
```
160
+
161
+
## String Interning
162
+
163
+
Property names that appear 2+ times are "interned" into a shared string table (`strings.json`). In the compact arrays, these names are replaced with numeric indices:
0 commit comments