Public
Script
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { fetch } from "https://esm.town/v/std/fetch";
export async function getMktpTotals() {
const body = {
"filters": [{
"pageNumber": 1,
"pageSize": 1,
"criteria": [{ "filterType": 7, "value": "stateful.runme" }],
}],
"assetTypes": [],
"flags": 2309,
};
const hdrs = {
"Accept": "application/json;api-version=3.0-preview.1",
"Content-Type": "application/json",
};
const response = await fetch(
"https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery",
{
body: JSON.stringify(body),
headers: { ...hdrs },
method: "POST",
},
);
const upstream = await response.json() as {
results?: [
{
extensions: [
{
publisher: {
displayName: string;
};
statistics: [
{
statisticName: string;
value: number;
},
];
extensionName: string;
},
];
},
];
};
const extensions: {
extension: string;
statistics: {
[k: string]: number;
};
}[] = upstream
.results?.[0].extensions.map((extension) => {
return {
extension:
`${extension.publisher.displayName}.${extension.extensionName}`,
statistics: Object.fromEntries(
extension.statistics.map((s) => [s.statisticName, s.value]),
),
};
}) ?? [];
return extensions;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023