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
+105-8Lines changed: 105 additions & 8 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,11 @@ 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))
48
-
5.**Deduplicates** shared object definitions into `objects.json`
49
-
6. Writes the optimized, pretty-printed JSON files
49
+
4.**Strips** unused fields like `type`, `in`, `isRequired` (see [Stripped Fields](#stripped-fields))
50
+
5.**Compacts** params into a space-efficient array format (see [Compact Format](#compact-format))
51
+
6.**Deduplicates** shared object definitions into `objects.json`
52
+
7.**Interns** duplicate property names into `strings.json` (see [String Interning](#string-interning))
53
+
8. Writes the optimized, pretty-printed JSON files
50
54
51
55
### Handling New Webhook Events
52
56
@@ -101,13 +105,15 @@ The code imports the minified versions:
101
105
102
106
```ts
103
107
importwebhooksfrom"./events/webhooks.min.json"
108
+
importobjectsfrom"./events/objects.min.json"
109
+
importstringsfrom"./events/strings.min.json"
104
110
```
105
111
106
112
## CI Verification
107
113
108
114
CI verifies that generated source files are up-to-date:
109
115
110
-
1. Runs `npm run update-webhooks` to regenerate webhooks.jsonand objects.json
116
+
1. Runs `npm run update-webhooks` to regenerate webhooks.json, objects.json, and strings.json
111
117
2. Checks for uncommitted changes with `git diff --exit-code`
112
118
113
119
The `.min.json` files are generated at build time and are not committed to the repository.
@@ -147,4 +153,95 @@ Only `name`, `description`, and `childParamsGroups` are kept — these are used
147
153
148
154
To compare all fields vs stripped, run `npm run update-webhooks -- --all` and diff the `.all.json` files against the regular ones.
149
155
150
-
See `EVENT_ACTION_FIELDS` and `BODY_PARAM_FIELDS` in `script/webhooks/index.ts` to modify what gets stripped.
156
+
See `EVENT_ACTION_FIELDS` and `BODY_PARAM_FIELDS` in `script/webhooks/update-webhooks.ts` to modify what gets stripped.
157
+
158
+
## Compact Format
159
+
160
+
After stripping, params are further compacted from objects into arrays using type-based dispatch:
161
+
162
+
| Format | Meaning |
163
+
|--------|---------|
164
+
|`"name"`| Name only (no description, no children) |
165
+
|`[name, desc]`| Name + description (arr[1] is a string) |
166
+
|`[name, children]`| Name + children (arr[1] is an array) |
167
+
|`[name, desc, children]`| Name + description + children |
168
+
169
+
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.
170
+
171
+
**Example:**
172
+
173
+
```json
174
+
// Before (object format)
175
+
{
176
+
"name": "issue",
177
+
"description": "The issue itself.",
178
+
"childParamsGroups": [
179
+
{ "name": "id" },
180
+
{ "name": "title", "description": "Issue title" }
181
+
]
182
+
}
183
+
184
+
// After (compact format)
185
+
["issue", "The issue itself.", [
186
+
"id",
187
+
["title", "Issue title"]
188
+
]]
189
+
```
190
+
191
+
## String Interning
192
+
193
+
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