History

Remove redundant OpenAPI credential casts

Rhys Sullivan committed 6 months ago

Commit 85c78ab1 parent b039b6e2 files · +7 −7Browse files

Unified · Split

2 files
  1. packages/plugins/openapi/src/sdk/credential-status.test.ts +4 −4
  2. packages/plugins/openapi/src/sdk/credential-status.ts +3 −3
packages/plugins/openapi/src/sdk/credential-status.test.ts+4−4
@@ -11,8 +11,8 @@ import { · 10 unmodified lines
1111 const userScope = ScopeId.make("user");
1212 const orgScope = ScopeId.make("org");
1313 const scopeRanks = new Map([
14− [userScope as string, 0],
15− [orgScope as string, 1],
14+ [userScope, 0],
15+ [orgScope, 1],
1616 ]);
1717
1818 const source: SourceForCredentialStatus = {
@@ -41,11 +41,11 @@ const bindings = ( · 22 unmodified lines
4141 slot === "oauth2:oauth2:connection"
4242 ? {
4343 kind: "connection",
44− connectionId: ConnectionId.make(`${scopeId as string}-connection`),
44+ connectionId: ConnectionId.make(`${scopeId}-connection`),
4545 }
4646 : {
4747 kind: "secret",
48− secretId: SecretId.make(`${scopeId as string}-${slot}`),
48+ secretId: SecretId.make(`${scopeId}-${slot}`),
4949 },
5050 }));
5151
packages/plugins/openapi/src/sdk/credential-status.ts+3−3
@@ -23,7 +23,7 @@ export type SourceForCredentialStatus = { · 22 unmodified lines
2323 };
2424
2525 const scopeRank = (ranks: ReadonlyMap<string, number>, scopeId: ScopeId): number =>
26− ranks.get(scopeId as string) ?? Number.MAX_SAFE_INTEGER;
26+ ranks.get(scopeId) ?? Number.MAX_SAFE_INTEGER;
2727
2828 export const effectiveBindingForScope = (
2929 rows: readonly BindingRowForCredentialStatus[],
@@ -60,7 +60,7 @@ const hasConnectionBinding = ( · 30 unmodified lines
6060 const binding = effectiveBindingForScope(rows, slot, targetScope, ranks);
6161 if (binding?.value.kind !== "connection") return false;
6262 return liveConnectionIds
63− ? liveConnectionIds.has(binding.value.connectionId as string)
63+ ? liveConnectionIds.has(binding.value.connectionId)
6464 : true;
6565 };
6666
@@ -83,7 +83,7 @@ export function missingCredentialLabels( · 16 unmodified lines
8383 const liveConnectionIds = rawLiveConnectionIds
8484 ? rawLiveConnectionIds instanceof Set
8585 ? rawLiveConnectionIds
86− : new Set([...rawLiveConnectionIds].map((id) => id as string))
86+ : new Set(rawLiveConnectionIds)
8787 : undefined;
8888
8989 for (const [headerName, value] of Object.entries(source.config.headers ?? {})) {