Skip to content

Commit 3ce60f3

Browse files
committed
feat: Add FirefoxAddon.slug, FirefoxAddon.guid, and
`EdgeAddon.productId` to model schema
1 parent c07c5ea commit 3ce60f3

File tree

3 files changed

+130
-4
lines changed

3 files changed

+130
-4
lines changed

src/assets/schema.gql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ type FirefoxAddon implements Extension {
9292

9393
# Additional fields
9494

95+
slug: String!
96+
guid: String!
9597
dailyActiveUsers: Int!
9698
}
9799

@@ -116,6 +118,7 @@ type EdgeAddon implements Extension {
116118

117119
"Number of users shown on `microsoftedge.microsoft.com`"
118120
activeInstallCount: Int!
121+
productId: String!
119122
}
120123

121124
type Screenshot {

src/services/edge-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function createEdgeApi(): EdgeApi {
1010
res: GetProductDetailsByCrxId200Response,
1111
): Gql.EdgeAddon => ({
1212
id: res.crxId,
13+
productId: res.storeProductId,
1314
iconUrl: `https:${res.logoUrl}`, // URL without the schema (ex: "//store-images.s-microsoft.com/image/...")
1415
lastUpdated: new Date(res.lastUpdateDate * 1000).toISOString(),
1516
longDescription: res.description,

src/services/firefox-api.ts

Lines changed: 126 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ export interface FirefoxApi {
77
}
88

99
export function createFirefoxApi(): FirefoxApi {
10-
const toGqlFirefoxAddon = (res: any): Gql.FirefoxAddon => ({
11-
id: res.id,
10+
const toGqlFirefoxAddon = (res: GetAddon200Response): Gql.FirefoxAddon => ({
11+
id: String(res.id),
12+
slug: res.slug,
13+
guid: res.guid,
1214
iconUrl: res.icon_url,
1315
lastUpdated: res.last_updated,
1416
longDescription: Object.values<string>(res.description)[0]!,
@@ -25,7 +27,7 @@ export function createFirefoxApi(): FirefoxApi {
2527
rawUrl: preview.image_url,
2628
indexUrl: buildScreenshotUrl(
2729
ExtensionStoreName.FirefoxAddonStore,
28-
res.id,
30+
String(res.id),
2931
i,
3032
),
3133
})),
@@ -44,11 +46,131 @@ export function createFirefoxApi(): FirefoxApi {
4446
`${url.href} failed with status: ${res.status} ${res.statusText}`,
4547
);
4648

47-
const json = await res.json();
49+
const json = (await res.json()) as GetAddon200Response;
4850
return toGqlFirefoxAddon(json);
4951
};
5052

5153
return {
5254
getAddon,
5355
};
5456
}
57+
58+
type GetAddon200Response = {
59+
id: number;
60+
authors: Array<{
61+
id: number;
62+
name: string;
63+
url: string;
64+
username: string;
65+
picture_url: string;
66+
}>;
67+
average_daily_users: number;
68+
categories: string[];
69+
contributions_url: {
70+
url: string;
71+
outgoing: string;
72+
};
73+
created: string;
74+
current_version: {
75+
id: number;
76+
compatibility: {
77+
firefox: unknown;
78+
};
79+
edit_url: string;
80+
file: {
81+
id: number;
82+
created: string;
83+
hash: string;
84+
is_mozilla_signed_extension: boolean;
85+
size: number;
86+
status: string;
87+
url: string;
88+
permissions: string[];
89+
optional_permissions: string[];
90+
host_permissions: string[];
91+
data_collection_permissions: string[];
92+
optional_data_collection_permissions: string[];
93+
};
94+
is_strict_compatibility_enabled: boolean;
95+
license: {
96+
id: number;
97+
is_custom: boolean;
98+
name: unknown;
99+
slug: string;
100+
url: string;
101+
};
102+
release_notes: {
103+
[locale: string]: string;
104+
};
105+
reviewed: string;
106+
version: string;
107+
};
108+
default_locale: string;
109+
description: {
110+
[locale: string]: string;
111+
};
112+
developer_comments: string | null;
113+
edit_url: string;
114+
guid: string;
115+
has_eula: boolean;
116+
has_privacy_policy: boolean;
117+
homepage: {
118+
url: {
119+
[locale: string]: string;
120+
};
121+
outgoing: {
122+
[locale: string]: string;
123+
};
124+
};
125+
icon_url: string;
126+
icons: {
127+
[size: string]: string;
128+
};
129+
is_disabled: boolean;
130+
is_experimental: boolean;
131+
is_noindexed: boolean;
132+
last_updated: string;
133+
name: {
134+
[locale: string]: string;
135+
};
136+
previews: Array<{
137+
id: number;
138+
caption: unknown;
139+
image_size: [number, number];
140+
image_url: string;
141+
position: number;
142+
thumbnail_size: [number, number];
143+
thumbnail_url: string;
144+
}>;
145+
promoted: unknown[];
146+
ratings: {
147+
average: number;
148+
bayesian_average: number;
149+
count: number;
150+
text_count: number;
151+
};
152+
ratings_url: string;
153+
requires_payment: boolean;
154+
review_url: string;
155+
slug: string;
156+
status: string;
157+
summary: {
158+
[locale: string]: string;
159+
};
160+
support_email: {
161+
[locale: string]: string;
162+
};
163+
support_url: {
164+
url: {
165+
[locale: string]: string;
166+
};
167+
outgoing: {
168+
[locale: string]: string;
169+
};
170+
};
171+
tags: string[];
172+
type: string;
173+
url: string;
174+
versions_url: string;
175+
weekly_downloads: number;
176+
};

0 commit comments

Comments
 (0)