Skip to content

Commit c90d625

Browse files
committed
remove service utils chagne
1 parent 80b1fec commit c90d625

File tree

1 file changed

+26
-5
lines changed
  • packages/service-utils/src/core

1 file changed

+26
-5
lines changed

packages/service-utils/src/core/api.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,30 @@ type TeamCapabilities = {
8080
customAuth: boolean;
8181
customBranding: boolean;
8282
};
83+
engineCloud: {
84+
enabled: boolean;
85+
mainnetEnabled: boolean;
86+
rateLimit: number;
87+
};
8388
};
8489

90+
type TeamPlan =
91+
| "free"
92+
| "starter"
93+
| "starter_legacy"
94+
| "growth_legacy"
95+
| "growth"
96+
| "accelerate"
97+
| "scale"
98+
| "pro";
99+
85100
export type TeamResponse = {
86101
id: string;
87102
name: string;
88103
slug: string;
89104
image: string | null;
90-
billingPlan: "free" | "starter" | "growth" | "pro";
91-
supportPlan: "free" | "starter" | "growth" | "pro";
105+
billingPlan: TeamPlan;
106+
supportPlan: TeamPlan;
92107
billingPlanVersion: number;
93108
createdAt: string;
94109
updatedAt: string | null;
@@ -108,7 +123,7 @@ export type TeamResponse = {
108123
enabledScopes: ServiceName[];
109124
isOnboarded: boolean;
110125
capabilities: TeamCapabilities;
111-
unthreadCustomerId: string | null;
126+
planCancellationDate: string | null;
112127
};
113128

114129
export type ProjectSecretKey = {
@@ -219,7 +234,7 @@ export async function fetchTeamAndProject(
219234
config: CoreServiceConfig,
220235
): Promise<ApiResponse> {
221236
const { apiUrl, serviceApiKey } = config;
222-
const { teamId, clientId } = authData;
237+
const { teamId, clientId, incomingServiceApiKey } = authData;
223238

224239
const url = new URL("/v2/keys/use", apiUrl);
225240
if (clientId) {
@@ -238,11 +253,17 @@ export async function fetchTeamAndProject(
238253
headers: {
239254
...(authData.secretKey ? { "x-secret-key": authData.secretKey } : {}),
240255
...(authData.jwt ? { Authorization: `Bearer ${authData.jwt}` } : {}),
241-
"x-service-api-key": serviceApiKey,
256+
// use the incoming service api key if it exists, otherwise use the service api key
257+
// this is done to ensure that the incoming service API key is VALID in the first place
258+
"x-service-api-key": incomingServiceApiKey
259+
? incomingServiceApiKey
260+
: serviceApiKey,
242261
"content-type": "application/json",
243262
},
244263
});
245264

265+
// TODO: if the response is a well understood status code (401, 402, etc), we should skip retry logic
266+
246267
let text = "";
247268
try {
248269
text = await response.text();

0 commit comments

Comments
 (0)