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
11const userScope = ScopeId.make("user");11const userScope = ScopeId.make("user");
12const orgScope = ScopeId.make("org");12const orgScope = ScopeId.make("org");
13const scopeRanks = new Map([13const scopeRanks = new Map([
14 [userScope as string, 0],14 [userScope, 0],
15 [orgScope as string, 1],15 [orgScope, 1],
16]);16]);
17 17
18const source: SourceForCredentialStatus = {18const source: SourceForCredentialStatus = {
@@ -41,11 +41,11 @@ const bindings = ( · 22 unmodified lines
41 slot === "oauth2:oauth2:connection"41 slot === "oauth2:oauth2:connection"
42 ? {42 ? {
43 kind: "connection",43 kind: "connection",
44 connectionId: ConnectionId.make(`${scopeId as string}-connection`),44 connectionId: ConnectionId.make(`${scopeId}-connection`),
45 }45 }
46 : {46 : {
47 kind: "secret",47 kind: "secret",
48 secretId: SecretId.make(`${scopeId as string}-${slot}`),48 secretId: SecretId.make(`${scopeId}-${slot}`),
49 },49 },
50 }));50 }));
51 51
packages/plugins/openapi/src/sdk/credential-status.ts+3−3
@@ -23,7 +23,7 @@ export type SourceForCredentialStatus = { · 22 unmodified lines
23};23};
24 24
25const scopeRank = (ranks: ReadonlyMap<string, number>, scopeId: ScopeId): number =>25const 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;
27 27
28export const effectiveBindingForScope = (28export const effectiveBindingForScope = (
29 rows: readonly BindingRowForCredentialStatus[],29 rows: readonly BindingRowForCredentialStatus[],
@@ -60,7 +60,7 @@ const hasConnectionBinding = ( · 30 unmodified lines
60 const binding = effectiveBindingForScope(rows, slot, targetScope, ranks);60 const binding = effectiveBindingForScope(rows, slot, targetScope, ranks);
61 if (binding?.value.kind !== "connection") return false;61 if (binding?.value.kind !== "connection") return false;
62 return liveConnectionIds62 return liveConnectionIds
63 ? liveConnectionIds.has(binding.value.connectionId as string)63 ? liveConnectionIds.has(binding.value.connectionId)
64 : true;64 : true;
65};65};
66 66
@@ -83,7 +83,7 @@ export function missingCredentialLabels( · 16 unmodified lines
83 const liveConnectionIds = rawLiveConnectionIds83 const liveConnectionIds = rawLiveConnectionIds
84 ? rawLiveConnectionIds instanceof Set84 ? rawLiveConnectionIds instanceof Set
85 ? rawLiveConnectionIds85 ? rawLiveConnectionIds
86 : new Set([...rawLiveConnectionIds].map((id) => id as string))86 : new Set(rawLiveConnectionIds)
87 : undefined;87 : undefined;
88 88
89 for (const [headerName, value] of Object.entries(source.config.headers ?? {})) {89 for (const [headerName, value] of Object.entries(source.config.headers ?? {})) {