@morehao/trendradar-contract 0.0.0-stage → 0.3.0
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/CHANGELOG.md +59 -0
- package/README.md +96 -2
- package/fixtures/digest-degraded.json +43 -0
- package/fixtures/digest-empty-lang.json +43 -0
- package/fixtures/digest-missing-optional.json +41 -0
- package/fixtures/digest-normal.json +97 -0
- package/fixtures/release-degraded.json +30 -0
- package/fixtures/release-empty.json +10 -0
- package/fixtures/release-normal.json +53 -0
- package/gen/ts/index.d.ts +216 -0
- package/gen/ts/index.js +1644 -0
- package/package.json +45 -4
- package/schema/api.v2.yaml +145 -0
- package/schema/digest.v2.json +25 -0
- package/schema/errors.v2.json +341 -0
- package/schema/ipc.v2.json +406 -0
- package/schema/model.v2.json +40 -0
- package/schema/releases.v2.json +278 -0
- package/schema/version-info.v2.json +17 -0
- package/version-map.json +57 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/ipc.v2.json",
|
|
4
|
+
"title": "trendradar ipc v2",
|
|
5
|
+
"description": "Envelope exchanged between the trendradar core binary and the DSH plugin. Only RunRequest forbids extra fields. ipcSchema is const 2.",
|
|
6
|
+
"oneOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "#/$defs/RunRequest"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"$ref": "#/$defs/RunResult"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"$defs": {
|
|
15
|
+
"ErrorCode": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"enum": [
|
|
18
|
+
"INTERNAL",
|
|
19
|
+
"CONFIG_INVALID",
|
|
20
|
+
"PAYLOAD_TOO_LARGE",
|
|
21
|
+
"FETCH_FAILED",
|
|
22
|
+
"FETCH_RATE_LIMITED",
|
|
23
|
+
"PARSE_FAILED",
|
|
24
|
+
"MODEL_UNAUTHORIZED",
|
|
25
|
+
"MODEL_RATE_LIMITED",
|
|
26
|
+
"MODEL_TIMEOUT",
|
|
27
|
+
"MODEL_FAILED",
|
|
28
|
+
"MODEL_BAD_OUTPUT",
|
|
29
|
+
"GIT_NOT_INSTALLED",
|
|
30
|
+
"REPO_NOT_GIT",
|
|
31
|
+
"REPO_DIRTY",
|
|
32
|
+
"GIT_OPERATION_FAILED",
|
|
33
|
+
"PR_FAILED",
|
|
34
|
+
"NOT_MERGEABLE"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"ErrorInfo": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"additionalProperties": true,
|
|
40
|
+
"required": [
|
|
41
|
+
"code",
|
|
42
|
+
"message",
|
|
43
|
+
"retriable"
|
|
44
|
+
],
|
|
45
|
+
"properties": {
|
|
46
|
+
"code": {
|
|
47
|
+
"$ref": "#/$defs/ErrorCode"
|
|
48
|
+
},
|
|
49
|
+
"message": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"retriable": {
|
|
53
|
+
"type": "boolean"
|
|
54
|
+
},
|
|
55
|
+
"details": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"additionalProperties": true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"FileArtifact": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": true,
|
|
64
|
+
"required": [
|
|
65
|
+
"path",
|
|
66
|
+
"bytes",
|
|
67
|
+
"sha256"
|
|
68
|
+
],
|
|
69
|
+
"properties": {
|
|
70
|
+
"path": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"bytes": {
|
|
74
|
+
"type": "integer",
|
|
75
|
+
"minimum": 0
|
|
76
|
+
},
|
|
77
|
+
"sha256": {
|
|
78
|
+
"type": "string"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"RunRequest": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"additionalProperties": false,
|
|
85
|
+
"required": [
|
|
86
|
+
"ipcSchema",
|
|
87
|
+
"command"
|
|
88
|
+
],
|
|
89
|
+
"properties": {
|
|
90
|
+
"ipcSchema": {
|
|
91
|
+
"const": 2
|
|
92
|
+
},
|
|
93
|
+
"command": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"enum": [
|
|
96
|
+
"run",
|
|
97
|
+
"serve",
|
|
98
|
+
"config",
|
|
99
|
+
"version",
|
|
100
|
+
"subscribe"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"configPath": {
|
|
104
|
+
"type": "string"
|
|
105
|
+
},
|
|
106
|
+
"date": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"format": "date"
|
|
109
|
+
},
|
|
110
|
+
"dryRun": {
|
|
111
|
+
"type": "boolean"
|
|
112
|
+
},
|
|
113
|
+
"outputDir": {
|
|
114
|
+
"type": "string"
|
|
115
|
+
},
|
|
116
|
+
"action": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"enum": [
|
|
119
|
+
"list",
|
|
120
|
+
"add",
|
|
121
|
+
"remove"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"repo": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"description": "Strict request envelope. command=subscribe manages the repo subscription list: action=list needs no repo; action=add/remove require exactly one repo.",
|
|
130
|
+
"allOf": [
|
|
131
|
+
{
|
|
132
|
+
"if": {
|
|
133
|
+
"properties": {
|
|
134
|
+
"command": {
|
|
135
|
+
"const": "subscribe"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"required": [
|
|
139
|
+
"command"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"then": {
|
|
143
|
+
"required": [
|
|
144
|
+
"action"
|
|
145
|
+
],
|
|
146
|
+
"properties": {
|
|
147
|
+
"action": {
|
|
148
|
+
"enum": [
|
|
149
|
+
"list",
|
|
150
|
+
"add",
|
|
151
|
+
"remove"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"allOf": [
|
|
156
|
+
{
|
|
157
|
+
"if": {
|
|
158
|
+
"properties": {
|
|
159
|
+
"action": {
|
|
160
|
+
"const": "list"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"required": [
|
|
164
|
+
"action"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
"then": {
|
|
168
|
+
"not": {
|
|
169
|
+
"required": [
|
|
170
|
+
"repo"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"if": {
|
|
177
|
+
"properties": {
|
|
178
|
+
"action": {
|
|
179
|
+
"enum": [
|
|
180
|
+
"add",
|
|
181
|
+
"remove"
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"required": [
|
|
186
|
+
"action"
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
"then": {
|
|
190
|
+
"required": [
|
|
191
|
+
"repo"
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"if": {
|
|
200
|
+
"properties": {
|
|
201
|
+
"command": {
|
|
202
|
+
"enum": [
|
|
203
|
+
"run",
|
|
204
|
+
"serve",
|
|
205
|
+
"config",
|
|
206
|
+
"version"
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"required": [
|
|
211
|
+
"command"
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
"then": {
|
|
215
|
+
"not": {
|
|
216
|
+
"anyOf": [
|
|
217
|
+
{
|
|
218
|
+
"required": [
|
|
219
|
+
"action"
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"required": [
|
|
224
|
+
"repo"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
"RunResult": {
|
|
234
|
+
"type": "object",
|
|
235
|
+
"additionalProperties": true,
|
|
236
|
+
"required": [
|
|
237
|
+
"ipcSchema",
|
|
238
|
+
"ok",
|
|
239
|
+
"command",
|
|
240
|
+
"startedAt",
|
|
241
|
+
"finishedAt",
|
|
242
|
+
"skipped",
|
|
243
|
+
"files"
|
|
244
|
+
],
|
|
245
|
+
"properties": {
|
|
246
|
+
"ipcSchema": {
|
|
247
|
+
"const": 2
|
|
248
|
+
},
|
|
249
|
+
"ok": {
|
|
250
|
+
"type": "boolean"
|
|
251
|
+
},
|
|
252
|
+
"command": {
|
|
253
|
+
"type": "string",
|
|
254
|
+
"enum": [
|
|
255
|
+
"run",
|
|
256
|
+
"serve",
|
|
257
|
+
"config",
|
|
258
|
+
"version"
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
"startedAt": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"format": "date-time"
|
|
264
|
+
},
|
|
265
|
+
"finishedAt": {
|
|
266
|
+
"type": "string",
|
|
267
|
+
"format": "date-time"
|
|
268
|
+
},
|
|
269
|
+
"skipped": {
|
|
270
|
+
"type": "boolean"
|
|
271
|
+
},
|
|
272
|
+
"files": {
|
|
273
|
+
"type": "array",
|
|
274
|
+
"items": {
|
|
275
|
+
"$ref": "#/$defs/FileArtifact"
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"branch": {
|
|
279
|
+
"type": "string"
|
|
280
|
+
},
|
|
281
|
+
"commit": {
|
|
282
|
+
"type": "string"
|
|
283
|
+
},
|
|
284
|
+
"prUrl": {
|
|
285
|
+
"type": "string",
|
|
286
|
+
"format": "uri"
|
|
287
|
+
},
|
|
288
|
+
"contentHash": {
|
|
289
|
+
"type": "string",
|
|
290
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
291
|
+
},
|
|
292
|
+
"error": {
|
|
293
|
+
"$ref": "#/$defs/ErrorInfo"
|
|
294
|
+
},
|
|
295
|
+
"warnings": {
|
|
296
|
+
"type": "array",
|
|
297
|
+
"items": {
|
|
298
|
+
"type": "string"
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
"usage": {
|
|
302
|
+
"$ref": "#/$defs/Usage"
|
|
303
|
+
},
|
|
304
|
+
"releases": {
|
|
305
|
+
"$ref": "releases.v2.json#/$defs/ReleasesReport"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
"Usage": {
|
|
310
|
+
"type": "object",
|
|
311
|
+
"additionalProperties": true,
|
|
312
|
+
"required": [
|
|
313
|
+
"promptTokens",
|
|
314
|
+
"completionTokens",
|
|
315
|
+
"totalTokens",
|
|
316
|
+
"cachedTokens",
|
|
317
|
+
"usageKnown",
|
|
318
|
+
"calls",
|
|
319
|
+
"retries",
|
|
320
|
+
"batches",
|
|
321
|
+
"cacheHits"
|
|
322
|
+
],
|
|
323
|
+
"properties": {
|
|
324
|
+
"promptTokens": {
|
|
325
|
+
"type": "integer",
|
|
326
|
+
"minimum": 0
|
|
327
|
+
},
|
|
328
|
+
"completionTokens": {
|
|
329
|
+
"type": "integer",
|
|
330
|
+
"minimum": 0
|
|
331
|
+
},
|
|
332
|
+
"totalTokens": {
|
|
333
|
+
"type": "integer",
|
|
334
|
+
"minimum": 0
|
|
335
|
+
},
|
|
336
|
+
"cachedTokens": {
|
|
337
|
+
"type": "integer",
|
|
338
|
+
"minimum": 0
|
|
339
|
+
},
|
|
340
|
+
"usageKnown": {
|
|
341
|
+
"type": "boolean"
|
|
342
|
+
},
|
|
343
|
+
"calls": {
|
|
344
|
+
"type": "integer",
|
|
345
|
+
"minimum": 0
|
|
346
|
+
},
|
|
347
|
+
"retries": {
|
|
348
|
+
"type": "integer",
|
|
349
|
+
"minimum": 0
|
|
350
|
+
},
|
|
351
|
+
"batches": {
|
|
352
|
+
"type": "integer",
|
|
353
|
+
"minimum": 0
|
|
354
|
+
},
|
|
355
|
+
"cacheHits": {
|
|
356
|
+
"type": "integer",
|
|
357
|
+
"minimum": 0
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
"StateRun": {
|
|
362
|
+
"type": "object",
|
|
363
|
+
"additionalProperties": true,
|
|
364
|
+
"required": [
|
|
365
|
+
"date",
|
|
366
|
+
"contentHash",
|
|
367
|
+
"runAt"
|
|
368
|
+
],
|
|
369
|
+
"properties": {
|
|
370
|
+
"date": {
|
|
371
|
+
"type": "string",
|
|
372
|
+
"format": "date"
|
|
373
|
+
},
|
|
374
|
+
"contentHash": {
|
|
375
|
+
"type": "string"
|
|
376
|
+
},
|
|
377
|
+
"outputDir": {
|
|
378
|
+
"type": "string"
|
|
379
|
+
},
|
|
380
|
+
"runAt": {
|
|
381
|
+
"type": "string",
|
|
382
|
+
"format": "date-time"
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
"State": {
|
|
387
|
+
"type": "object",
|
|
388
|
+
"additionalProperties": true,
|
|
389
|
+
"required": [
|
|
390
|
+
"ipcSchema",
|
|
391
|
+
"stateSchema"
|
|
392
|
+
],
|
|
393
|
+
"properties": {
|
|
394
|
+
"ipcSchema": {
|
|
395
|
+
"const": 2
|
|
396
|
+
},
|
|
397
|
+
"stateSchema": {
|
|
398
|
+
"const": 2
|
|
399
|
+
},
|
|
400
|
+
"lastRun": {
|
|
401
|
+
"$ref": "#/$defs/StateRun"
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/model.v2.json",
|
|
4
|
+
"title": "trendradar model v2",
|
|
5
|
+
"description": "Domain model: a scraped repository snapshot (RepoSnapshot) and its digested form (RepoDigest). RepoDigest composes RepoSnapshot via allOf instead of flattening.",
|
|
6
|
+
"$ref": "#/$defs/RepoDigest",
|
|
7
|
+
"$defs": {
|
|
8
|
+
"RepoSnapshot": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"additionalProperties": true,
|
|
11
|
+
"required": ["fullName", "url", "language", "stars", "starsInPeriod", "rank", "source"],
|
|
12
|
+
"properties": {
|
|
13
|
+
"fullName": { "type": "string", "pattern": "^[^/]+/[^/]+$" },
|
|
14
|
+
"url": { "type": "string", "format": "uri" },
|
|
15
|
+
"description": { "type": "string" },
|
|
16
|
+
"language": { "type": "string" },
|
|
17
|
+
"stars": { "type": "integer", "minimum": 0 },
|
|
18
|
+
"starsInPeriod": { "type": "integer", "minimum": 0 },
|
|
19
|
+
"forks": { "type": "integer", "minimum": 0 },
|
|
20
|
+
"rank": { "type": "integer", "minimum": 1 },
|
|
21
|
+
"source": { "type": "string", "enum": ["trending-html", "search-api"] }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"RepoDigest": {
|
|
25
|
+
"description": "RepoSnapshot plus the digest-only summary fields; the two sub-schemas are merged with allOf.",
|
|
26
|
+
"allOf": [
|
|
27
|
+
{ "$ref": "#/$defs/RepoSnapshot" },
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": true,
|
|
31
|
+
"required": ["summaryZh", "summarySource"],
|
|
32
|
+
"properties": {
|
|
33
|
+
"summaryZh": { "type": "string" },
|
|
34
|
+
"summarySource": { "type": "string", "enum": ["model", "original"] }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|