@morehao/trendradar-contract 0.0.0-stage → 0.2.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 +23 -0
- package/README.md +90 -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/gen/ts/index.d.ts +126 -0
- package/gen/ts/index.js +1096 -0
- package/package.json +46 -4
- package/schema/api.v2.yaml +76 -0
- package/schema/digest.v2.json +25 -0
- package/schema/errors.v2.json +341 -0
- package/schema/ipc.v2.json +109 -0
- package/schema/model.v2.json +40 -0
- package/schema/version-info.v2.json +17 -0
- package/version-map.json +8 -0
package/gen/ts/index.js
ADDED
|
@@ -0,0 +1,1096 @@
|
|
|
1
|
+
// Code generated by scripts/generate.mjs; DO NOT EDIT.
|
|
2
|
+
import Ajv from 'ajv/dist/2020.js'
|
|
3
|
+
import addFormats from 'ajv-formats'
|
|
4
|
+
|
|
5
|
+
export const contractVersion = "0.2.0"
|
|
6
|
+
|
|
7
|
+
export const errorCatalog = {
|
|
8
|
+
"INTERNAL": {
|
|
9
|
+
"retriable": true,
|
|
10
|
+
"description": "Unexpected internal error (transient panic/IO); retry may succeed."
|
|
11
|
+
},
|
|
12
|
+
"CONFIG_INVALID": {
|
|
13
|
+
"retriable": false,
|
|
14
|
+
"description": "Configuration is invalid or unreadable."
|
|
15
|
+
},
|
|
16
|
+
"PAYLOAD_TOO_LARGE": {
|
|
17
|
+
"retriable": false,
|
|
18
|
+
"description": "Input payload exceeds the allowed size."
|
|
19
|
+
},
|
|
20
|
+
"FETCH_FAILED": {
|
|
21
|
+
"retriable": false,
|
|
22
|
+
"description": "Fetching trending data failed terminally (retries exhausted)."
|
|
23
|
+
},
|
|
24
|
+
"FETCH_RATE_LIMITED": {
|
|
25
|
+
"retriable": true,
|
|
26
|
+
"description": "Fetching was rate limited; retry later."
|
|
27
|
+
},
|
|
28
|
+
"PARSE_FAILED": {
|
|
29
|
+
"retriable": false,
|
|
30
|
+
"description": "Parsing fetched HTML/JSON failed."
|
|
31
|
+
},
|
|
32
|
+
"MODEL_UNAUTHORIZED": {
|
|
33
|
+
"retriable": false,
|
|
34
|
+
"description": "Model provider rejected the credentials."
|
|
35
|
+
},
|
|
36
|
+
"MODEL_RATE_LIMITED": {
|
|
37
|
+
"retriable": true,
|
|
38
|
+
"description": "Model provider rate limited the request."
|
|
39
|
+
},
|
|
40
|
+
"MODEL_TIMEOUT": {
|
|
41
|
+
"retriable": true,
|
|
42
|
+
"description": "Model request timed out."
|
|
43
|
+
},
|
|
44
|
+
"MODEL_FAILED": {
|
|
45
|
+
"retriable": true,
|
|
46
|
+
"description": "Model request failed."
|
|
47
|
+
},
|
|
48
|
+
"MODEL_BAD_OUTPUT": {
|
|
49
|
+
"retriable": false,
|
|
50
|
+
"description": "Model returned output that violates the expected shape."
|
|
51
|
+
},
|
|
52
|
+
"GIT_NOT_INSTALLED": {
|
|
53
|
+
"retriable": false,
|
|
54
|
+
"description": "git executable was not found."
|
|
55
|
+
},
|
|
56
|
+
"REPO_NOT_GIT": {
|
|
57
|
+
"retriable": false,
|
|
58
|
+
"description": "Target directory is not a git repository."
|
|
59
|
+
},
|
|
60
|
+
"REPO_DIRTY": {
|
|
61
|
+
"retriable": false,
|
|
62
|
+
"description": "Git working tree has uncommitted changes."
|
|
63
|
+
},
|
|
64
|
+
"GIT_OPERATION_FAILED": {
|
|
65
|
+
"retriable": true,
|
|
66
|
+
"description": "A git operation (commit/push) failed."
|
|
67
|
+
},
|
|
68
|
+
"PR_FAILED": {
|
|
69
|
+
"retriable": true,
|
|
70
|
+
"description": "Opening or updating the pull request failed."
|
|
71
|
+
},
|
|
72
|
+
"NOT_MERGEABLE": {
|
|
73
|
+
"retriable": false,
|
|
74
|
+
"description": "Pull request is not mergeable."
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const fixtures = {
|
|
79
|
+
"normal": {
|
|
80
|
+
"schema": 2,
|
|
81
|
+
"date": "2026-10-30",
|
|
82
|
+
"period": "daily",
|
|
83
|
+
"languages": [
|
|
84
|
+
"all",
|
|
85
|
+
"go",
|
|
86
|
+
"python",
|
|
87
|
+
"rust"
|
|
88
|
+
],
|
|
89
|
+
"count": 6,
|
|
90
|
+
"degraded": false,
|
|
91
|
+
"contentHash": "sha256:a4769ff29cd41f2f85703c20faf9104a7f8b34500295d991f0b87786719544b2",
|
|
92
|
+
"contentHashAlgo": "jcs-sha256-v1",
|
|
93
|
+
"coreVersion": "0.1.0",
|
|
94
|
+
"generatedAt": "2026-10-30T00:05:00Z",
|
|
95
|
+
"repos": [
|
|
96
|
+
{
|
|
97
|
+
"fullName": "golang/go",
|
|
98
|
+
"url": "https://github.com/golang/go",
|
|
99
|
+
"description": "The Go programming language",
|
|
100
|
+
"language": "go",
|
|
101
|
+
"stars": 126000,
|
|
102
|
+
"starsInPeriod": 320,
|
|
103
|
+
"forks": 17800,
|
|
104
|
+
"rank": 1,
|
|
105
|
+
"source": "trending-html",
|
|
106
|
+
"summaryZh": "Go 官方仓库,今日新增 star 位居榜单前列。",
|
|
107
|
+
"summarySource": "model"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"fullName": "gin-gonic/gin",
|
|
111
|
+
"url": "https://github.com/gin-gonic/gin",
|
|
112
|
+
"description": "HTTP web framework written in Go",
|
|
113
|
+
"language": "go",
|
|
114
|
+
"stars": 80200,
|
|
115
|
+
"starsInPeriod": 210,
|
|
116
|
+
"forks": 8100,
|
|
117
|
+
"rank": 2,
|
|
118
|
+
"source": "trending-html",
|
|
119
|
+
"summaryZh": "流行的 Go Web 框架,热度持续。",
|
|
120
|
+
"summarySource": "model"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"fullName": "python/cpython",
|
|
124
|
+
"url": "https://github.com/python/cpython",
|
|
125
|
+
"description": "The Python programming language",
|
|
126
|
+
"language": "python",
|
|
127
|
+
"stars": 64500,
|
|
128
|
+
"starsInPeriod": 180,
|
|
129
|
+
"forks": 30500,
|
|
130
|
+
"rank": 3,
|
|
131
|
+
"source": "trending-html",
|
|
132
|
+
"summaryZh": "CPython 官方实现,今日关注度上升。",
|
|
133
|
+
"summarySource": "model"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"fullName": "psf/requests",
|
|
137
|
+
"url": "https://github.com/psf/requests",
|
|
138
|
+
"description": "A simple, yet elegant HTTP library",
|
|
139
|
+
"language": "python",
|
|
140
|
+
"stars": 52500,
|
|
141
|
+
"starsInPeriod": 95,
|
|
142
|
+
"forks": 9400,
|
|
143
|
+
"rank": 4,
|
|
144
|
+
"source": "trending-html",
|
|
145
|
+
"summaryZh": "经典 Python HTTP 库,稳居热榜。",
|
|
146
|
+
"summarySource": "model"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"fullName": "rust-lang/rust",
|
|
150
|
+
"url": "https://github.com/rust-lang/rust",
|
|
151
|
+
"description": "Empowering everyone to build reliable and efficient software",
|
|
152
|
+
"language": "rust",
|
|
153
|
+
"stars": 102000,
|
|
154
|
+
"starsInPeriod": 260,
|
|
155
|
+
"forks": 13200,
|
|
156
|
+
"rank": 5,
|
|
157
|
+
"source": "trending-html",
|
|
158
|
+
"summaryZh": "Rust 语言主仓库,社区活跃。",
|
|
159
|
+
"summarySource": "model"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"fullName": "tokio-rs/tokio",
|
|
163
|
+
"url": "https://github.com/tokio-rs/tokio",
|
|
164
|
+
"description": "A runtime for writing reliable asynchronous applications with Rust",
|
|
165
|
+
"language": "rust",
|
|
166
|
+
"stars": 28600,
|
|
167
|
+
"starsInPeriod": 120,
|
|
168
|
+
"forks": 2650,
|
|
169
|
+
"rank": 6,
|
|
170
|
+
"source": "trending-html",
|
|
171
|
+
"summaryZh": "Rust 异步运行时,性能方向关注度高。",
|
|
172
|
+
"summarySource": "model"
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"degraded": {
|
|
177
|
+
"schema": 2,
|
|
178
|
+
"date": "2026-10-30",
|
|
179
|
+
"period": "daily",
|
|
180
|
+
"languages": [
|
|
181
|
+
"all",
|
|
182
|
+
"go"
|
|
183
|
+
],
|
|
184
|
+
"count": 2,
|
|
185
|
+
"degraded": true,
|
|
186
|
+
"contentHash": "sha256:a21dfa56cbd2fe611c9e7b9844d672b3608922156bf8e998f49f4293ab5ce3e3",
|
|
187
|
+
"contentHashAlgo": "jcs-sha256-v1",
|
|
188
|
+
"coreVersion": "0.1.0",
|
|
189
|
+
"generatedAt": "2026-10-30T00:05:00Z",
|
|
190
|
+
"repos": [
|
|
191
|
+
{
|
|
192
|
+
"fullName": "golang/go",
|
|
193
|
+
"url": "https://github.com/golang/go",
|
|
194
|
+
"description": "The Go programming language",
|
|
195
|
+
"language": "go",
|
|
196
|
+
"stars": 126000,
|
|
197
|
+
"starsInPeriod": 0,
|
|
198
|
+
"forks": 17800,
|
|
199
|
+
"rank": 1,
|
|
200
|
+
"source": "search-api",
|
|
201
|
+
"summaryZh": "[原文] The Go programming language",
|
|
202
|
+
"summarySource": "original"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"fullName": "gin-gonic/gin",
|
|
206
|
+
"url": "https://github.com/gin-gonic/gin",
|
|
207
|
+
"description": "HTTP web framework written in Go",
|
|
208
|
+
"language": "go",
|
|
209
|
+
"stars": 80200,
|
|
210
|
+
"starsInPeriod": 0,
|
|
211
|
+
"forks": 8100,
|
|
212
|
+
"rank": 2,
|
|
213
|
+
"source": "search-api",
|
|
214
|
+
"summaryZh": "[原文] HTTP web framework written in Go",
|
|
215
|
+
"summarySource": "original"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"emptyLang": {
|
|
220
|
+
"schema": 2,
|
|
221
|
+
"date": "2026-10-30",
|
|
222
|
+
"period": "daily",
|
|
223
|
+
"languages": [
|
|
224
|
+
"all",
|
|
225
|
+
"unknown"
|
|
226
|
+
],
|
|
227
|
+
"count": 2,
|
|
228
|
+
"degraded": false,
|
|
229
|
+
"contentHash": "sha256:84a5ef479995ae104544dfc0869227442f3d8968c0d27b5f76410040d4c8b2e4",
|
|
230
|
+
"contentHashAlgo": "jcs-sha256-v1",
|
|
231
|
+
"coreVersion": "0.1.0",
|
|
232
|
+
"generatedAt": "2026-10-30T00:05:00Z",
|
|
233
|
+
"repos": [
|
|
234
|
+
{
|
|
235
|
+
"fullName": "someorg/no-language",
|
|
236
|
+
"url": "https://github.com/someorg/no-language",
|
|
237
|
+
"description": "A repo whose primary language could not be detected",
|
|
238
|
+
"language": "unknown",
|
|
239
|
+
"stars": 1200,
|
|
240
|
+
"starsInPeriod": 40,
|
|
241
|
+
"forks": 30,
|
|
242
|
+
"rank": 1,
|
|
243
|
+
"source": "trending-html",
|
|
244
|
+
"summaryZh": "语言未知的仓库,热度进入榜单。",
|
|
245
|
+
"summarySource": "model"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"fullName": "someorg/aggregate-only",
|
|
249
|
+
"url": "https://github.com/someorg/aggregate-only",
|
|
250
|
+
"description": "Repo surfaced only in the all-languages list",
|
|
251
|
+
"language": "unknown",
|
|
252
|
+
"stars": 980,
|
|
253
|
+
"starsInPeriod": 33,
|
|
254
|
+
"forks": 12,
|
|
255
|
+
"rank": 2,
|
|
256
|
+
"source": "trending-html",
|
|
257
|
+
"summaryZh": "仅在全局榜单出现的仓库。",
|
|
258
|
+
"summarySource": "model"
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
"missingOptional": {
|
|
263
|
+
"schema": 2,
|
|
264
|
+
"date": "2026-10-30",
|
|
265
|
+
"period": "daily",
|
|
266
|
+
"languages": [
|
|
267
|
+
"all",
|
|
268
|
+
"go",
|
|
269
|
+
"python",
|
|
270
|
+
"rust"
|
|
271
|
+
],
|
|
272
|
+
"count": 2,
|
|
273
|
+
"degraded": false,
|
|
274
|
+
"contentHash": "sha256:38c38188602424014a7fdd8a3bfd0408690ce8a5db21be9c8559ac3ca85b2b4c",
|
|
275
|
+
"contentHashAlgo": "jcs-sha256-v1",
|
|
276
|
+
"coreVersion": "0.1.0",
|
|
277
|
+
"generatedAt": "2026-10-30T00:05:00Z",
|
|
278
|
+
"repos": [
|
|
279
|
+
{
|
|
280
|
+
"fullName": "golang/go",
|
|
281
|
+
"url": "https://github.com/golang/go",
|
|
282
|
+
"language": "go",
|
|
283
|
+
"stars": 126000,
|
|
284
|
+
"starsInPeriod": 320,
|
|
285
|
+
"rank": 1,
|
|
286
|
+
"source": "trending-html",
|
|
287
|
+
"summaryZh": "Go 官方仓库,今日新增 star 位居榜单前列。",
|
|
288
|
+
"summarySource": "model"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"fullName": "gin-gonic/gin",
|
|
292
|
+
"url": "https://github.com/gin-gonic/gin",
|
|
293
|
+
"language": "go",
|
|
294
|
+
"stars": 80200,
|
|
295
|
+
"starsInPeriod": 210,
|
|
296
|
+
"rank": 2,
|
|
297
|
+
"source": "trending-html",
|
|
298
|
+
"summaryZh": "流行的 Go Web 框架,热度持续。",
|
|
299
|
+
"summarySource": "model"
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const model = {
|
|
306
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
307
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/model.v2.json",
|
|
308
|
+
"title": "trendradar model v2",
|
|
309
|
+
"description": "Domain model: a scraped repository snapshot (RepoSnapshot) and its digested form (RepoDigest). RepoDigest composes RepoSnapshot via allOf instead of flattening.",
|
|
310
|
+
"$ref": "#/$defs/RepoDigest",
|
|
311
|
+
"$defs": {
|
|
312
|
+
"RepoSnapshot": {
|
|
313
|
+
"type": "object",
|
|
314
|
+
"additionalProperties": true,
|
|
315
|
+
"required": [
|
|
316
|
+
"fullName",
|
|
317
|
+
"url",
|
|
318
|
+
"language",
|
|
319
|
+
"stars",
|
|
320
|
+
"starsInPeriod",
|
|
321
|
+
"rank",
|
|
322
|
+
"source"
|
|
323
|
+
],
|
|
324
|
+
"properties": {
|
|
325
|
+
"fullName": {
|
|
326
|
+
"type": "string",
|
|
327
|
+
"pattern": "^[^/]+/[^/]+$"
|
|
328
|
+
},
|
|
329
|
+
"url": {
|
|
330
|
+
"type": "string",
|
|
331
|
+
"format": "uri"
|
|
332
|
+
},
|
|
333
|
+
"description": {
|
|
334
|
+
"type": "string"
|
|
335
|
+
},
|
|
336
|
+
"language": {
|
|
337
|
+
"type": "string"
|
|
338
|
+
},
|
|
339
|
+
"stars": {
|
|
340
|
+
"type": "integer",
|
|
341
|
+
"minimum": 0
|
|
342
|
+
},
|
|
343
|
+
"starsInPeriod": {
|
|
344
|
+
"type": "integer",
|
|
345
|
+
"minimum": 0
|
|
346
|
+
},
|
|
347
|
+
"forks": {
|
|
348
|
+
"type": "integer",
|
|
349
|
+
"minimum": 0
|
|
350
|
+
},
|
|
351
|
+
"rank": {
|
|
352
|
+
"type": "integer",
|
|
353
|
+
"minimum": 1
|
|
354
|
+
},
|
|
355
|
+
"source": {
|
|
356
|
+
"type": "string",
|
|
357
|
+
"enum": [
|
|
358
|
+
"trending-html",
|
|
359
|
+
"search-api"
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
"RepoDigest": {
|
|
365
|
+
"description": "RepoSnapshot plus the digest-only summary fields; the two sub-schemas are merged with allOf.",
|
|
366
|
+
"allOf": [
|
|
367
|
+
{
|
|
368
|
+
"$ref": "#/$defs/RepoSnapshot"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"type": "object",
|
|
372
|
+
"additionalProperties": true,
|
|
373
|
+
"required": [
|
|
374
|
+
"summaryZh",
|
|
375
|
+
"summarySource"
|
|
376
|
+
],
|
|
377
|
+
"properties": {
|
|
378
|
+
"summaryZh": {
|
|
379
|
+
"type": "string"
|
|
380
|
+
},
|
|
381
|
+
"summarySource": {
|
|
382
|
+
"type": "string",
|
|
383
|
+
"enum": [
|
|
384
|
+
"model",
|
|
385
|
+
"original"
|
|
386
|
+
]
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const ipc = {
|
|
395
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
396
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/ipc.v2.json",
|
|
397
|
+
"title": "trendradar ipc v2",
|
|
398
|
+
"description": "Envelope exchanged between the trendradar core binary and the DSH plugin. Only RunRequest forbids extra fields. ipcSchema is const 2.",
|
|
399
|
+
"oneOf": [
|
|
400
|
+
{
|
|
401
|
+
"$ref": "#/$defs/RunRequest"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"$ref": "#/$defs/RunResult"
|
|
405
|
+
}
|
|
406
|
+
],
|
|
407
|
+
"$defs": {
|
|
408
|
+
"ErrorCode": {
|
|
409
|
+
"type": "string",
|
|
410
|
+
"enum": [
|
|
411
|
+
"INTERNAL",
|
|
412
|
+
"CONFIG_INVALID",
|
|
413
|
+
"PAYLOAD_TOO_LARGE",
|
|
414
|
+
"FETCH_FAILED",
|
|
415
|
+
"FETCH_RATE_LIMITED",
|
|
416
|
+
"PARSE_FAILED",
|
|
417
|
+
"MODEL_UNAUTHORIZED",
|
|
418
|
+
"MODEL_RATE_LIMITED",
|
|
419
|
+
"MODEL_TIMEOUT",
|
|
420
|
+
"MODEL_FAILED",
|
|
421
|
+
"MODEL_BAD_OUTPUT",
|
|
422
|
+
"GIT_NOT_INSTALLED",
|
|
423
|
+
"REPO_NOT_GIT",
|
|
424
|
+
"REPO_DIRTY",
|
|
425
|
+
"GIT_OPERATION_FAILED",
|
|
426
|
+
"PR_FAILED",
|
|
427
|
+
"NOT_MERGEABLE"
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
"ErrorInfo": {
|
|
431
|
+
"type": "object",
|
|
432
|
+
"additionalProperties": true,
|
|
433
|
+
"required": [
|
|
434
|
+
"code",
|
|
435
|
+
"message",
|
|
436
|
+
"retriable"
|
|
437
|
+
],
|
|
438
|
+
"properties": {
|
|
439
|
+
"code": {
|
|
440
|
+
"$ref": "#/$defs/ErrorCode"
|
|
441
|
+
},
|
|
442
|
+
"message": {
|
|
443
|
+
"type": "string"
|
|
444
|
+
},
|
|
445
|
+
"retriable": {
|
|
446
|
+
"type": "boolean"
|
|
447
|
+
},
|
|
448
|
+
"details": {
|
|
449
|
+
"type": "object",
|
|
450
|
+
"additionalProperties": true
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
"FileArtifact": {
|
|
455
|
+
"type": "object",
|
|
456
|
+
"additionalProperties": true,
|
|
457
|
+
"required": [
|
|
458
|
+
"path",
|
|
459
|
+
"bytes",
|
|
460
|
+
"sha256"
|
|
461
|
+
],
|
|
462
|
+
"properties": {
|
|
463
|
+
"path": {
|
|
464
|
+
"type": "string"
|
|
465
|
+
},
|
|
466
|
+
"bytes": {
|
|
467
|
+
"type": "integer",
|
|
468
|
+
"minimum": 0
|
|
469
|
+
},
|
|
470
|
+
"sha256": {
|
|
471
|
+
"type": "string"
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
"RunRequest": {
|
|
476
|
+
"type": "object",
|
|
477
|
+
"additionalProperties": false,
|
|
478
|
+
"required": [
|
|
479
|
+
"ipcSchema",
|
|
480
|
+
"command"
|
|
481
|
+
],
|
|
482
|
+
"properties": {
|
|
483
|
+
"ipcSchema": {
|
|
484
|
+
"const": 2
|
|
485
|
+
},
|
|
486
|
+
"command": {
|
|
487
|
+
"type": "string",
|
|
488
|
+
"enum": [
|
|
489
|
+
"run",
|
|
490
|
+
"serve",
|
|
491
|
+
"config",
|
|
492
|
+
"version"
|
|
493
|
+
]
|
|
494
|
+
},
|
|
495
|
+
"configPath": {
|
|
496
|
+
"type": "string"
|
|
497
|
+
},
|
|
498
|
+
"date": {
|
|
499
|
+
"type": "string",
|
|
500
|
+
"format": "date"
|
|
501
|
+
},
|
|
502
|
+
"dryRun": {
|
|
503
|
+
"type": "boolean"
|
|
504
|
+
},
|
|
505
|
+
"outputDir": {
|
|
506
|
+
"type": "string"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
"RunResult": {
|
|
511
|
+
"type": "object",
|
|
512
|
+
"additionalProperties": true,
|
|
513
|
+
"required": [
|
|
514
|
+
"ipcSchema",
|
|
515
|
+
"ok",
|
|
516
|
+
"command",
|
|
517
|
+
"startedAt",
|
|
518
|
+
"finishedAt",
|
|
519
|
+
"skipped",
|
|
520
|
+
"files"
|
|
521
|
+
],
|
|
522
|
+
"properties": {
|
|
523
|
+
"ipcSchema": {
|
|
524
|
+
"const": 2
|
|
525
|
+
},
|
|
526
|
+
"ok": {
|
|
527
|
+
"type": "boolean"
|
|
528
|
+
},
|
|
529
|
+
"command": {
|
|
530
|
+
"type": "string",
|
|
531
|
+
"enum": [
|
|
532
|
+
"run",
|
|
533
|
+
"serve",
|
|
534
|
+
"config",
|
|
535
|
+
"version"
|
|
536
|
+
]
|
|
537
|
+
},
|
|
538
|
+
"startedAt": {
|
|
539
|
+
"type": "string",
|
|
540
|
+
"format": "date-time"
|
|
541
|
+
},
|
|
542
|
+
"finishedAt": {
|
|
543
|
+
"type": "string",
|
|
544
|
+
"format": "date-time"
|
|
545
|
+
},
|
|
546
|
+
"skipped": {
|
|
547
|
+
"type": "boolean"
|
|
548
|
+
},
|
|
549
|
+
"files": {
|
|
550
|
+
"type": "array",
|
|
551
|
+
"items": {
|
|
552
|
+
"$ref": "#/$defs/FileArtifact"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
"branch": {
|
|
556
|
+
"type": "string"
|
|
557
|
+
},
|
|
558
|
+
"commit": {
|
|
559
|
+
"type": "string"
|
|
560
|
+
},
|
|
561
|
+
"prUrl": {
|
|
562
|
+
"type": "string",
|
|
563
|
+
"format": "uri"
|
|
564
|
+
},
|
|
565
|
+
"contentHash": {
|
|
566
|
+
"type": "string",
|
|
567
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
568
|
+
},
|
|
569
|
+
"error": {
|
|
570
|
+
"$ref": "#/$defs/ErrorInfo"
|
|
571
|
+
},
|
|
572
|
+
"warnings": {
|
|
573
|
+
"type": "array",
|
|
574
|
+
"items": {
|
|
575
|
+
"type": "string"
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
"StateRun": {
|
|
581
|
+
"type": "object",
|
|
582
|
+
"additionalProperties": true,
|
|
583
|
+
"required": [
|
|
584
|
+
"date",
|
|
585
|
+
"contentHash",
|
|
586
|
+
"runAt"
|
|
587
|
+
],
|
|
588
|
+
"properties": {
|
|
589
|
+
"date": {
|
|
590
|
+
"type": "string",
|
|
591
|
+
"format": "date"
|
|
592
|
+
},
|
|
593
|
+
"contentHash": {
|
|
594
|
+
"type": "string"
|
|
595
|
+
},
|
|
596
|
+
"outputDir": {
|
|
597
|
+
"type": "string"
|
|
598
|
+
},
|
|
599
|
+
"runAt": {
|
|
600
|
+
"type": "string",
|
|
601
|
+
"format": "date-time"
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"State": {
|
|
606
|
+
"type": "object",
|
|
607
|
+
"additionalProperties": true,
|
|
608
|
+
"required": [
|
|
609
|
+
"ipcSchema",
|
|
610
|
+
"stateSchema"
|
|
611
|
+
],
|
|
612
|
+
"properties": {
|
|
613
|
+
"ipcSchema": {
|
|
614
|
+
"const": 2
|
|
615
|
+
},
|
|
616
|
+
"stateSchema": {
|
|
617
|
+
"const": 2
|
|
618
|
+
},
|
|
619
|
+
"lastRun": {
|
|
620
|
+
"$ref": "#/$defs/StateRun"
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
const digest = {
|
|
627
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
628
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/digest.v2.json",
|
|
629
|
+
"title": "trendradar digest v2",
|
|
630
|
+
"description": "One day's rendered digest document. contentHash is stable across runs (generatedAt/coreVersion excluded); contentHashAlgo records which algorithm produced it.",
|
|
631
|
+
"type": "object",
|
|
632
|
+
"additionalProperties": true,
|
|
633
|
+
"required": [
|
|
634
|
+
"schema",
|
|
635
|
+
"date",
|
|
636
|
+
"period",
|
|
637
|
+
"languages",
|
|
638
|
+
"count",
|
|
639
|
+
"degraded",
|
|
640
|
+
"contentHash",
|
|
641
|
+
"contentHashAlgo",
|
|
642
|
+
"repos"
|
|
643
|
+
],
|
|
644
|
+
"properties": {
|
|
645
|
+
"schema": {
|
|
646
|
+
"const": 2
|
|
647
|
+
},
|
|
648
|
+
"date": {
|
|
649
|
+
"type": "string",
|
|
650
|
+
"format": "date"
|
|
651
|
+
},
|
|
652
|
+
"period": {
|
|
653
|
+
"type": "string",
|
|
654
|
+
"enum": [
|
|
655
|
+
"daily",
|
|
656
|
+
"weekly",
|
|
657
|
+
"monthly"
|
|
658
|
+
]
|
|
659
|
+
},
|
|
660
|
+
"languages": {
|
|
661
|
+
"type": "array",
|
|
662
|
+
"minItems": 1,
|
|
663
|
+
"items": {
|
|
664
|
+
"type": "string"
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
"count": {
|
|
668
|
+
"type": "integer",
|
|
669
|
+
"minimum": 0
|
|
670
|
+
},
|
|
671
|
+
"degraded": {
|
|
672
|
+
"type": "boolean"
|
|
673
|
+
},
|
|
674
|
+
"contentHash": {
|
|
675
|
+
"type": "string",
|
|
676
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
677
|
+
},
|
|
678
|
+
"contentHashAlgo": {
|
|
679
|
+
"type": "string",
|
|
680
|
+
"enum": [
|
|
681
|
+
"jcs-sha256-v1",
|
|
682
|
+
"legacy-struct-marshal-v1"
|
|
683
|
+
]
|
|
684
|
+
},
|
|
685
|
+
"coreVersion": {
|
|
686
|
+
"type": "string"
|
|
687
|
+
},
|
|
688
|
+
"generatedAt": {
|
|
689
|
+
"type": "string",
|
|
690
|
+
"format": "date-time"
|
|
691
|
+
},
|
|
692
|
+
"repos": {
|
|
693
|
+
"type": "array",
|
|
694
|
+
"items": {
|
|
695
|
+
"$ref": "https://github.com/morehao/trendradar/contract/schema/model.v2.json#/$defs/RepoDigest"
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const versionInfo = {
|
|
701
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
702
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/version-info.v2.json",
|
|
703
|
+
"title": "trendradar version info v2",
|
|
704
|
+
"description": "Handshake payload returned by `trendradar version --json`. The plugin requires ipcSchema===2 && digestSchema===2 && contractVersion major===2.",
|
|
705
|
+
"type": "object",
|
|
706
|
+
"additionalProperties": true,
|
|
707
|
+
"required": [
|
|
708
|
+
"version",
|
|
709
|
+
"commit",
|
|
710
|
+
"ipcSchema",
|
|
711
|
+
"digestSchema",
|
|
712
|
+
"contractVersion",
|
|
713
|
+
"supportedProviders"
|
|
714
|
+
],
|
|
715
|
+
"properties": {
|
|
716
|
+
"version": {
|
|
717
|
+
"type": "string"
|
|
718
|
+
},
|
|
719
|
+
"commit": {
|
|
720
|
+
"type": "string"
|
|
721
|
+
},
|
|
722
|
+
"ipcSchema": {
|
|
723
|
+
"const": 2
|
|
724
|
+
},
|
|
725
|
+
"digestSchema": {
|
|
726
|
+
"const": 2
|
|
727
|
+
},
|
|
728
|
+
"contractVersion": {
|
|
729
|
+
"type": "string"
|
|
730
|
+
},
|
|
731
|
+
"supportedProviders": {
|
|
732
|
+
"type": "array",
|
|
733
|
+
"items": {
|
|
734
|
+
"type": "string"
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const errors = {
|
|
740
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
741
|
+
"$id": "https://github.com/morehao/trendradar/contract/schema/errors.v2.json",
|
|
742
|
+
"title": "trendradar errors v2",
|
|
743
|
+
"description": "Canonical error-code catalog. Each property is one error code whose retriable/description are consts, so this file is the single source of truth for retriability. ipc.v2.json ErrorCode enum must match these keys exactly.",
|
|
744
|
+
"type": "object",
|
|
745
|
+
"additionalProperties": false,
|
|
746
|
+
"required": [
|
|
747
|
+
"INTERNAL",
|
|
748
|
+
"CONFIG_INVALID",
|
|
749
|
+
"PAYLOAD_TOO_LARGE",
|
|
750
|
+
"FETCH_FAILED",
|
|
751
|
+
"FETCH_RATE_LIMITED",
|
|
752
|
+
"PARSE_FAILED",
|
|
753
|
+
"MODEL_UNAUTHORIZED",
|
|
754
|
+
"MODEL_RATE_LIMITED",
|
|
755
|
+
"MODEL_TIMEOUT",
|
|
756
|
+
"MODEL_FAILED",
|
|
757
|
+
"MODEL_BAD_OUTPUT",
|
|
758
|
+
"GIT_NOT_INSTALLED",
|
|
759
|
+
"REPO_NOT_GIT",
|
|
760
|
+
"REPO_DIRTY",
|
|
761
|
+
"GIT_OPERATION_FAILED",
|
|
762
|
+
"PR_FAILED",
|
|
763
|
+
"NOT_MERGEABLE"
|
|
764
|
+
],
|
|
765
|
+
"properties": {
|
|
766
|
+
"INTERNAL": {
|
|
767
|
+
"type": "object",
|
|
768
|
+
"additionalProperties": false,
|
|
769
|
+
"required": [
|
|
770
|
+
"retriable",
|
|
771
|
+
"description"
|
|
772
|
+
],
|
|
773
|
+
"properties": {
|
|
774
|
+
"retriable": {
|
|
775
|
+
"const": true
|
|
776
|
+
},
|
|
777
|
+
"description": {
|
|
778
|
+
"const": "Unexpected internal error (transient panic/IO); retry may succeed."
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
"CONFIG_INVALID": {
|
|
783
|
+
"type": "object",
|
|
784
|
+
"additionalProperties": false,
|
|
785
|
+
"required": [
|
|
786
|
+
"retriable",
|
|
787
|
+
"description"
|
|
788
|
+
],
|
|
789
|
+
"properties": {
|
|
790
|
+
"retriable": {
|
|
791
|
+
"const": false
|
|
792
|
+
},
|
|
793
|
+
"description": {
|
|
794
|
+
"const": "Configuration is invalid or unreadable."
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
"PAYLOAD_TOO_LARGE": {
|
|
799
|
+
"type": "object",
|
|
800
|
+
"additionalProperties": false,
|
|
801
|
+
"required": [
|
|
802
|
+
"retriable",
|
|
803
|
+
"description"
|
|
804
|
+
],
|
|
805
|
+
"properties": {
|
|
806
|
+
"retriable": {
|
|
807
|
+
"const": false
|
|
808
|
+
},
|
|
809
|
+
"description": {
|
|
810
|
+
"const": "Input payload exceeds the allowed size."
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
"FETCH_FAILED": {
|
|
815
|
+
"type": "object",
|
|
816
|
+
"additionalProperties": false,
|
|
817
|
+
"required": [
|
|
818
|
+
"retriable",
|
|
819
|
+
"description"
|
|
820
|
+
],
|
|
821
|
+
"properties": {
|
|
822
|
+
"retriable": {
|
|
823
|
+
"const": false
|
|
824
|
+
},
|
|
825
|
+
"description": {
|
|
826
|
+
"const": "Fetching trending data failed terminally (retries exhausted)."
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
"FETCH_RATE_LIMITED": {
|
|
831
|
+
"type": "object",
|
|
832
|
+
"additionalProperties": false,
|
|
833
|
+
"required": [
|
|
834
|
+
"retriable",
|
|
835
|
+
"description"
|
|
836
|
+
],
|
|
837
|
+
"properties": {
|
|
838
|
+
"retriable": {
|
|
839
|
+
"const": true
|
|
840
|
+
},
|
|
841
|
+
"description": {
|
|
842
|
+
"const": "Fetching was rate limited; retry later."
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
"PARSE_FAILED": {
|
|
847
|
+
"type": "object",
|
|
848
|
+
"additionalProperties": false,
|
|
849
|
+
"required": [
|
|
850
|
+
"retriable",
|
|
851
|
+
"description"
|
|
852
|
+
],
|
|
853
|
+
"properties": {
|
|
854
|
+
"retriable": {
|
|
855
|
+
"const": false
|
|
856
|
+
},
|
|
857
|
+
"description": {
|
|
858
|
+
"const": "Parsing fetched HTML/JSON failed."
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
"MODEL_UNAUTHORIZED": {
|
|
863
|
+
"type": "object",
|
|
864
|
+
"additionalProperties": false,
|
|
865
|
+
"required": [
|
|
866
|
+
"retriable",
|
|
867
|
+
"description"
|
|
868
|
+
],
|
|
869
|
+
"properties": {
|
|
870
|
+
"retriable": {
|
|
871
|
+
"const": false
|
|
872
|
+
},
|
|
873
|
+
"description": {
|
|
874
|
+
"const": "Model provider rejected the credentials."
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
"MODEL_RATE_LIMITED": {
|
|
879
|
+
"type": "object",
|
|
880
|
+
"additionalProperties": false,
|
|
881
|
+
"required": [
|
|
882
|
+
"retriable",
|
|
883
|
+
"description"
|
|
884
|
+
],
|
|
885
|
+
"properties": {
|
|
886
|
+
"retriable": {
|
|
887
|
+
"const": true
|
|
888
|
+
},
|
|
889
|
+
"description": {
|
|
890
|
+
"const": "Model provider rate limited the request."
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
"MODEL_TIMEOUT": {
|
|
895
|
+
"type": "object",
|
|
896
|
+
"additionalProperties": false,
|
|
897
|
+
"required": [
|
|
898
|
+
"retriable",
|
|
899
|
+
"description"
|
|
900
|
+
],
|
|
901
|
+
"properties": {
|
|
902
|
+
"retriable": {
|
|
903
|
+
"const": true
|
|
904
|
+
},
|
|
905
|
+
"description": {
|
|
906
|
+
"const": "Model request timed out."
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
"MODEL_FAILED": {
|
|
911
|
+
"type": "object",
|
|
912
|
+
"additionalProperties": false,
|
|
913
|
+
"required": [
|
|
914
|
+
"retriable",
|
|
915
|
+
"description"
|
|
916
|
+
],
|
|
917
|
+
"properties": {
|
|
918
|
+
"retriable": {
|
|
919
|
+
"const": true
|
|
920
|
+
},
|
|
921
|
+
"description": {
|
|
922
|
+
"const": "Model request failed."
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
"MODEL_BAD_OUTPUT": {
|
|
927
|
+
"type": "object",
|
|
928
|
+
"additionalProperties": false,
|
|
929
|
+
"required": [
|
|
930
|
+
"retriable",
|
|
931
|
+
"description"
|
|
932
|
+
],
|
|
933
|
+
"properties": {
|
|
934
|
+
"retriable": {
|
|
935
|
+
"const": false
|
|
936
|
+
},
|
|
937
|
+
"description": {
|
|
938
|
+
"const": "Model returned output that violates the expected shape."
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
"GIT_NOT_INSTALLED": {
|
|
943
|
+
"type": "object",
|
|
944
|
+
"additionalProperties": false,
|
|
945
|
+
"required": [
|
|
946
|
+
"retriable",
|
|
947
|
+
"description"
|
|
948
|
+
],
|
|
949
|
+
"properties": {
|
|
950
|
+
"retriable": {
|
|
951
|
+
"const": false
|
|
952
|
+
},
|
|
953
|
+
"description": {
|
|
954
|
+
"const": "git executable was not found."
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
},
|
|
958
|
+
"REPO_NOT_GIT": {
|
|
959
|
+
"type": "object",
|
|
960
|
+
"additionalProperties": false,
|
|
961
|
+
"required": [
|
|
962
|
+
"retriable",
|
|
963
|
+
"description"
|
|
964
|
+
],
|
|
965
|
+
"properties": {
|
|
966
|
+
"retriable": {
|
|
967
|
+
"const": false
|
|
968
|
+
},
|
|
969
|
+
"description": {
|
|
970
|
+
"const": "Target directory is not a git repository."
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
"REPO_DIRTY": {
|
|
975
|
+
"type": "object",
|
|
976
|
+
"additionalProperties": false,
|
|
977
|
+
"required": [
|
|
978
|
+
"retriable",
|
|
979
|
+
"description"
|
|
980
|
+
],
|
|
981
|
+
"properties": {
|
|
982
|
+
"retriable": {
|
|
983
|
+
"const": false
|
|
984
|
+
},
|
|
985
|
+
"description": {
|
|
986
|
+
"const": "Git working tree has uncommitted changes."
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
"GIT_OPERATION_FAILED": {
|
|
991
|
+
"type": "object",
|
|
992
|
+
"additionalProperties": false,
|
|
993
|
+
"required": [
|
|
994
|
+
"retriable",
|
|
995
|
+
"description"
|
|
996
|
+
],
|
|
997
|
+
"properties": {
|
|
998
|
+
"retriable": {
|
|
999
|
+
"const": true
|
|
1000
|
+
},
|
|
1001
|
+
"description": {
|
|
1002
|
+
"const": "A git operation (commit/push) failed."
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
},
|
|
1006
|
+
"PR_FAILED": {
|
|
1007
|
+
"type": "object",
|
|
1008
|
+
"additionalProperties": false,
|
|
1009
|
+
"required": [
|
|
1010
|
+
"retriable",
|
|
1011
|
+
"description"
|
|
1012
|
+
],
|
|
1013
|
+
"properties": {
|
|
1014
|
+
"retriable": {
|
|
1015
|
+
"const": true
|
|
1016
|
+
},
|
|
1017
|
+
"description": {
|
|
1018
|
+
"const": "Opening or updating the pull request failed."
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
},
|
|
1022
|
+
"NOT_MERGEABLE": {
|
|
1023
|
+
"type": "object",
|
|
1024
|
+
"additionalProperties": false,
|
|
1025
|
+
"required": [
|
|
1026
|
+
"retriable",
|
|
1027
|
+
"description"
|
|
1028
|
+
],
|
|
1029
|
+
"properties": {
|
|
1030
|
+
"retriable": {
|
|
1031
|
+
"const": false
|
|
1032
|
+
},
|
|
1033
|
+
"description": {
|
|
1034
|
+
"const": "Pull request is not mergeable."
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
"$defs": {
|
|
1040
|
+
"ErrorCode": {
|
|
1041
|
+
"type": "string",
|
|
1042
|
+
"enum": [
|
|
1043
|
+
"INTERNAL",
|
|
1044
|
+
"CONFIG_INVALID",
|
|
1045
|
+
"PAYLOAD_TOO_LARGE",
|
|
1046
|
+
"FETCH_FAILED",
|
|
1047
|
+
"FETCH_RATE_LIMITED",
|
|
1048
|
+
"PARSE_FAILED",
|
|
1049
|
+
"MODEL_UNAUTHORIZED",
|
|
1050
|
+
"MODEL_RATE_LIMITED",
|
|
1051
|
+
"MODEL_TIMEOUT",
|
|
1052
|
+
"MODEL_FAILED",
|
|
1053
|
+
"MODEL_BAD_OUTPUT",
|
|
1054
|
+
"GIT_NOT_INSTALLED",
|
|
1055
|
+
"REPO_NOT_GIT",
|
|
1056
|
+
"REPO_DIRTY",
|
|
1057
|
+
"GIT_OPERATION_FAILED",
|
|
1058
|
+
"PR_FAILED",
|
|
1059
|
+
"NOT_MERGEABLE"
|
|
1060
|
+
]
|
|
1061
|
+
},
|
|
1062
|
+
"ErrorMeta": {
|
|
1063
|
+
"type": "object",
|
|
1064
|
+
"additionalProperties": false,
|
|
1065
|
+
"required": [
|
|
1066
|
+
"retriable",
|
|
1067
|
+
"description"
|
|
1068
|
+
],
|
|
1069
|
+
"properties": {
|
|
1070
|
+
"retriable": {
|
|
1071
|
+
"type": "boolean"
|
|
1072
|
+
},
|
|
1073
|
+
"description": {
|
|
1074
|
+
"type": "string"
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
const api = "openapi: 3.1.0\ninfo:\n title: trendradar serve API\n version: 0.2.0\n description: |\n Read-only HTTP surface exposed by `trendradar serve`. All payloads reuse the\n digest.v2 schema, so the plugin can consume the same shape whether data comes\n from the filesystem or over HTTP. Historical v1 digests read from disk are\n normalized to this v2 shape with contentHashAlgo=legacy-struct-marshal-v1.\nservers:\n - url: http://127.0.0.1:8787\npaths:\n /api/v2/digests/{date}:\n get:\n operationId: getDigest\n summary: Fetch one day's digest\n parameters:\n - name: date\n in: path\n required: true\n schema:\n type: string\n format: date\n responses:\n \"200\":\n description: The digest document\n content:\n application/json:\n schema:\n $ref: \"./digest.v2.json\"\n \"404\":\n description: No digest for that date\n /api/v2/manifest:\n get:\n operationId: getManifest\n summary: List available dates and their content identity\n responses:\n \"200\":\n description: Manifest of available digests\n content:\n application/json:\n schema:\n type: object\n required: [entries]\n properties:\n coreVersion:\n type: string\n entries:\n type: array\n items:\n type: object\n required: [date, contentHash, schema, contentHashAlgo]\n properties:\n date:\n type: string\n format: date\n contentHash:\n type: string\n schema:\n type: integer\n contentHashAlgo:\n type: string\n enum: [jcs-sha256-v1, legacy-struct-marshal-v1]\n degraded:\n type: boolean\n /feed.xml:\n get:\n operationId: getFeed\n summary: RSS feed of the most recent digests\n responses:\n \"200\":\n description: RSS 2.0 feed\n content:\n application/rss+xml:\n schema:\n type: string\n"
|
|
1081
|
+
|
|
1082
|
+
export const rawSchema = { model, ipc, digest, errors, versionInfo, api }
|
|
1083
|
+
|
|
1084
|
+
const ajv = new Ajv({ allErrors: true, strict: false })
|
|
1085
|
+
addFormats(ajv)
|
|
1086
|
+
ajv.addSchema(model)
|
|
1087
|
+
ajv.addSchema(ipc)
|
|
1088
|
+
ajv.addSchema(digest)
|
|
1089
|
+
ajv.addSchema(versionInfo)
|
|
1090
|
+
|
|
1091
|
+
export const validators = {
|
|
1092
|
+
runRequest: ajv.compile({ $ref: ipc.$id + '#/$defs/RunRequest' }),
|
|
1093
|
+
runResult: ajv.compile({ $ref: ipc.$id + '#/$defs/RunResult' }),
|
|
1094
|
+
digest: ajv.getSchema(digest.$id),
|
|
1095
|
+
versionInfo: ajv.getSchema(versionInfo.$id),
|
|
1096
|
+
}
|