Skip to content

Commit

Permalink
feat: add types to type imports (#5021)
Browse files Browse the repository at this point in the history
* feat: add types to type imports

* changeset
  • Loading branch information
marikaner authored Sep 24, 2024
1 parent 282b45b commit 252c338
Show file tree
Hide file tree
Showing 446 changed files with 1,481 additions and 1,480 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-islands-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-cloud-sdk/eslint-config': minor
---

[New Functionality] Add `@typescript-eslint/consistent-type-imports` to the ruleset.
2 changes: 1 addition & 1 deletion packages/connectivity/src/http-agent/agent-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as http from 'http';
import type * as http from 'http';

/**
* Interface for the `http-agent` within the Axios request config.
Expand Down
4 changes: 2 additions & 2 deletions packages/connectivity/src/http-agent/http-agent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { X509Certificate } from 'node:crypto';
import mock from 'mock-fs';
import { createLogger } from '@sap-cloud-sdk/util';
import { DestinationCertificate } from '../scp-cf';
import { HttpDestination } from '../scp-cf/destination';
import type { DestinationCertificate } from '../scp-cf';
import type { HttpDestination } from '../scp-cf/destination';
import { registerDestinationCache } from '../scp-cf/destination/register-destination-cache';
import { certAsString } from '../../../../test-resources/test/test-util/test-certificate';
import { getAgentConfigAsync } from './http-agent';
Expand Down
10 changes: 5 additions & 5 deletions packages/connectivity/src/http-agent/http-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { readFile } from 'fs/promises';
import http from 'http';
import https from 'https';
import { createLogger, last } from '@sap-cloud-sdk/util';
import {
import type {
BasicProxyConfiguration,
Destination,
DestinationCertificate,
getProtocolOrDefault
DestinationCertificate
} from '../scp-cf';
import { getProtocolOrDefault } from '../scp-cf';
/* Careful the proxy imports cause circular dependencies if imported from scp directly */
import type { HttpDestination } from '../scp-cf/destination';
import {
addProxyConfigurationInternet,
getProxyConfig,
HttpDestination,
proxyStrategy
} from '../scp-cf/destination';
import { registerDestinationCache } from '../scp-cf/destination/register-destination-cache';
import { HttpAgentConfig, HttpsAgentConfig } from './agent-config';
import type { HttpAgentConfig, HttpsAgentConfig } from './agent-config';

const logger = createLogger({
package: 'connectivity',
Expand Down
3 changes: 2 additions & 1 deletion packages/connectivity/src/scp-cf/async-cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cache, CacheEntry } from './cache';
import type { CacheEntry } from './cache';
import { Cache } from './cache';

/**
* Generic async cache interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../../../../test-resources/test/test-util/request-mocker';
import { buildAuthorizationHeaders } from './authorization-header';
import * as destinationImport from './destination/destination';
import { Destination } from './destination';
import type { Destination } from './destination';

const principalPropagationDestination = {
url: '',
Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/src/scp-cf/authorization-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
encodeBase64,
pickValueIgnoreCase
} from '@sap-cloud-sdk/util';
import {
import type {
AuthenticationType,
Destination,
DestinationAuthToken
Expand Down
9 changes: 3 additions & 6 deletions packages/connectivity/src/scp-cf/cache.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Cache } from './cache';
import { clientCredentialsTokenCache } from './client-credentials-token-cache';
import {
AuthenticationType,
Destination,
destinationCache
} from './destination';
import { ClientCredentialsResponse } from './xsuaa-service-types';
import type { AuthenticationType, Destination } from './destination';
import { destinationCache } from './destination';
import type { ClientCredentialsResponse } from './xsuaa-service-types';

const destinationOne: Destination = {
url: 'https://destination1.example',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createLogger } from '@sap-cloud-sdk/util';
import { Cache } from './cache';
import { ClientCredentialsResponse } from './xsuaa-service-types';
import type { ClientCredentialsResponse } from './xsuaa-service-types';

const logger = createLogger({
package: 'connectivity',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Protocol } from './protocol';
import type { Protocol } from './protocol';

/**
* Proxy settings for connecting to an on-premise destination via connectivity proxy or web proxies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
addProxyConfigurationOnPrem,
httpProxyHostAndPort
} from './connectivity-service';
import { Destination, getRequiredSubscriberToken } from './destination';
import type { Destination } from './destination';
import { getRequiredSubscriberToken } from './destination';
import { getJwtPair } from './jwt';

describe('connectivity-service', () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/connectivity/src/scp-cf/connectivity-service.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { createLogger, ErrorWithCause } from '@sap-cloud-sdk/util';
import { JwtPayload } from './jsonwebtoken-type';
import { Protocol } from './protocol';
import {
import type { JwtPayload } from './jsonwebtoken-type';
import type { Protocol } from './protocol';
import type {
ProxyConfiguration,
ProxyConfigurationHeaders
} from './connectivity-service-types';
import {
import type {
AuthenticationType,
Destination
} from './destination/destination-service-types';
import { getServiceBindings } from './environment-accessor';
import { Service } from './environment-accessor/environment-accessor-types';
import type { Service } from './environment-accessor/environment-accessor-types';
import { serviceToken } from './token-accessor';
import { SubscriberToken } from './destination';
import type { SubscriberToken } from './destination';

const logger = createLogger({
package: 'connectivity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
oauthMultipleResponse,
providerServiceToken
} from '../../../../../test-resources/test/test-util';
import { DestinationFetchOptions } from './destination-accessor-types';
import type { DestinationFetchOptions } from './destination-accessor-types';
import { alwaysProvider } from './destination-selection-strategies';
import { getDestination } from './destination-accessor';
import { DestinationConfiguration } from './destination';
import type { DestinationConfiguration } from './destination';

describe('custom JWTs', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {
MockServiceBindings,
mockServiceBindings
} from '../../../../../test-resources/test/test-util';
import type { MockServiceBindings } from '../../../../../test-resources/test/test-util';
import { mockServiceBindings } from '../../../../../test-resources/test/test-util';
import { getDestination, useOrFetchDestination } from './destination-accessor';
import {
DestinationWithName,
registerDestination
} from './destination-from-registration';
import type { DestinationWithName } from './destination-from-registration';
import { registerDestination } from './destination-from-registration';
import { registerDestinationCache } from './register-destination-cache';

function mockEnvDestinations() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createLogger, ErrorWithCause } from '@sap-cloud-sdk/util';
import { AxiosError } from 'axios';
import type { ErrorWithCause } from '@sap-cloud-sdk/util';
import { createLogger } from '@sap-cloud-sdk/util';
import type { AxiosError } from 'axios';
import nock from 'nock';
import {
mockFetchDestinationCalls,
Expand Down Expand Up @@ -27,23 +28,24 @@ import {
} from '../../../../../test-resources/test/test-util/mocked-access-tokens';
import { mockServiceToken } from '../../../../../test-resources/test/test-util/token-accessor-mocks';
import * as identityService from '../identity-service';
import { DestinationConfiguration, parseDestination } from './destination';
import type { DestinationConfiguration } from './destination';
import { parseDestination } from './destination';
import {
getAllDestinationsFromDestinationService,
getDestination
} from './destination-accessor';
import {
import type {
DestinationFetchOptions,
DestinationWithoutToken
} from './destination-accessor-types';
import { getDestinationFromDestinationService } from './destination-from-service';
import type { DestinationSelectionStrategy } from './destination-selection-strategies';
import {
alwaysProvider,
alwaysSubscriber,
DestinationSelectionStrategy,
subscriberFirst
} from './destination-selection-strategies';
import { Destination } from './destination-service-types';
import type { Destination } from './destination-service-types';

const destName = 'DESTINATION';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { getDestination } from './destination-accessor';
import * as ProxyUtil from './http-proxy-util';
import { alwaysProvider } from './destination-selection-strategies';
import { Destination } from './destination-service-types';
import type { Destination } from './destination-service-types';
import { destinationCache } from './destination-cache';
import { destinationServiceCache } from './destination-service-cache';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VerifyJwtOptions } from '../jwt';
import type { VerifyJwtOptions } from '../jwt';
import type {
Destination,
DestinationRetrievalOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ import { createLogger, ErrorWithCause } from '@sap-cloud-sdk/util';
import { exchangeToken, shouldExchangeToken } from '../identity-service';
import { getDestinationServiceCredentials } from '../environment-accessor';
import { getSubdomain } from '../jwt';
import {
DestinationOrFetchOptions,
sanitizeDestination,
toDestinationNameUrl
} from './destination';
import { Destination } from './destination-service-types';
import type { DestinationOrFetchOptions } from './destination';
import { sanitizeDestination, toDestinationNameUrl } from './destination';
import type { Destination } from './destination-service-types';
import { searchEnvVariablesForDestination } from './destination-from-env';
import {
DestinationForServiceBindingOptions,
searchServiceBindingForDestination
} from './destination-from-vcap';
import type { DestinationForServiceBindingOptions } from './destination-from-vcap';
import { searchServiceBindingForDestination } from './destination-from-vcap';
import { getDestinationFromDestinationService } from './destination-from-service';
import {
import type {
DestinationFetchOptions,
isDestinationFetchOptions,
AllDestinationOptions,
DestinationWithoutToken
} from './destination-accessor-types';
import { isDestinationFetchOptions } from './destination-accessor-types';
import { searchRegisteredDestination } from './destination-from-registration';
import { getSubscriberToken } from './get-subscriber-token';
import { getProviderServiceToken } from './get-provider-token';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
mockJwtBearerToken,
mockServiceToken
} from '../../../../../test-resources/test/test-util/token-accessor-mocks';
import {
import type {
AuthenticationType,
Destination,
DestinationAuthToken
Expand All @@ -43,10 +43,10 @@ import {
subscriberFirst
} from './destination-selection-strategies';
import { getDestinationFromDestinationService } from './destination-from-service';
import type { IsolationStrategy } from './destination-cache';
import {
destinationCache,
getDestinationCacheKey,
IsolationStrategy,
setDestinationCache
} from './destination-cache';
import { getDestination } from './destination-accessor';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { createLogger, first } from '@sap-cloud-sdk/util';
import { getTenantId, userId } from '../jwt';
import { JwtPayload } from '../jsonwebtoken-type';
import { AsyncCache, AsyncCacheInterface } from '../async-cache';
import { Destination } from './destination-service-types';
import { DestinationsByType } from './destination-accessor-types';
import { SubscriberToken } from './get-subscriber-token';
import type { JwtPayload } from '../jsonwebtoken-type';
import type { AsyncCacheInterface } from '../async-cache';
import { AsyncCache } from '../async-cache';
import type { Destination } from './destination-service-types';
import type { DestinationsByType } from './destination-accessor-types';
import type { SubscriberToken } from './get-subscriber-token';

const logger = createLogger({
package: 'connectivity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
unmockDestinationsEnv
} from '../../../../../test-resources/test/test-util/request-mocker';
import { signedJwt } from '../../../../../test-resources/test/test-util';
import { Destination } from './destination-service-types';
import type { Destination } from './destination-service-types';
import {
getDestinationFromEnvByName,
getDestinationsFromEnv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
isDestinationConfiguration,
parseDestination
} from './destination';
import { DestinationFetchOptions } from './destination-accessor-types';
import type { DestinationFetchOptions } from './destination-accessor-types';
import type { Destination } from './destination-service-types';
import {
addProxyConfigurationInternet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
xsuaaBindingMock
} from '../../../../../test-resources/test/test-util';
import { certAsString } from '../../../../../test-resources/test/test-util/test-certificate';
import type { DestinationWithName } from './destination-from-registration';
import {
DestinationWithName,
registerDestination,
searchRegisteredDestination
} from './destination-from-registration';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {
defaultTenantId,
getTenantId
} from '../jwt';
import { DestinationFetchOptions } from './destination-accessor-types';
import {
IsolationStrategy,
getDefaultIsolationStrategy
} from './destination-cache';
import { Destination, isHttpDestination } from './destination-service-types';
import type { DestinationFetchOptions } from './destination-accessor-types';
import type { IsolationStrategy } from './destination-cache';
import { getDefaultIsolationStrategy } from './destination-cache';
import type { Destination } from './destination-service-types';
import { isHttpDestination } from './destination-service-types';
import {
addProxyConfigurationInternet,
proxyStrategy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { createLogger } from '@sap-cloud-sdk/util';
import { addProxyConfigurationOnPrem } from '../connectivity-service';
import type { Service } from '../environment-accessor';
import {
Service,
getDestinationServiceCredentials,
getServiceBinding
} from '../environment-accessor';
import { exchangeToken, shouldExchangeToken } from '../identity-service';
import { JwtPair, getSubdomain, isXsuaaToken } from '../jwt';
import type { JwtPair } from '../jwt';
import { getSubdomain, isXsuaaToken } from '../jwt';
import { isIdenticalTenant } from '../tenant';
import { jwtBearerToken } from '../token-accessor';
import {
import type {
DestinationFetchOptions,
DestinationsByType
} from './destination-accessor-types';
Expand All @@ -22,22 +23,20 @@ import {
alwaysSubscriber,
subscriberFirst
} from './destination-selection-strategies';
import type { AuthAndExchangeTokens } from './destination-service';
import {
AuthAndExchangeTokens,
fetchCertificate,
fetchDestinationWithTokenRetrieval,
fetchDestinationWithoutTokenRetrieval
} from './destination-service';
import {
assertHttpDestination,
Destination
} from './destination-service-types';
import type { Destination } from './destination-service-types';
import { assertHttpDestination } from './destination-service-types';
import { getProviderServiceToken } from './get-provider-token';
import type { SubscriberToken } from './get-subscriber-token';
import {
getRequiredSubscriberToken,
getSubscriberToken,
hasTokens,
SubscriberToken
hasTokens
} from './get-subscriber-token';
import {
addProxyConfigurationInternet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
testTenants
} from '../../../../../test-resources/test/test-util';
import * as tokenAccessor from '../token-accessor';
import { Service } from '../environment-accessor/environment-accessor-types';
import type { Service } from '../environment-accessor/environment-accessor-types';
import { decodeJwt } from '../jwt';
import { getDestination } from './destination-accessor';
import { getDestinationFromServiceBinding } from './destination-from-vcap';
Expand Down
Loading

0 comments on commit 252c338

Please sign in to comment.