Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/appConfigurationImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
#sentinels: Map<WatchedSetting, SettingWatcher> = new Map();
#watchAll: boolean = false;
#kvRefreshInterval: number = DEFAULT_REFRESH_INTERVAL_IN_MS;
#kvRefreshTimer: RefreshTimer;
#kvRefreshTimer: RefreshTimer | undefined = undefined;

// Feature flags
#featureFlagEnabled: boolean = false;
#featureFlagRefreshEnabled: boolean = false;
#ffRefreshInterval: number = DEFAULT_REFRESH_INTERVAL_IN_MS;
#ffRefreshTimer: RefreshTimer;
#ffRefreshTimer: RefreshTimer | undefined = undefined;

// Key Vault references
#secretRefreshEnabled: boolean = false;
#secretReferences: ConfigurationSetting[] = []; // cached key vault references
#secretRefreshTimer: RefreshTimer;
#secretRefreshTimer: RefreshTimer | undefined = undefined;
#resolveSecretsInParallel: boolean = false;

/**
Expand All @@ -126,7 +126,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {

constructor(
clientManager: ConfigurationClientManager,
options: AzureAppConfigurationOptions | undefined,
options?: AzureAppConfigurationOptions,
) {
this.#options = options;
this.#clientManager = clientManager;
Expand Down Expand Up @@ -415,7 +415,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
postAttempts += 1;
backoffDuration = getExponentialBackoffDuration(postAttempts);
}
console.warn(`Failed to load. Error message: ${error.message}. Retrying in ${backoffDuration} ms.`);
const errorMessage = error instanceof Error ? error.message : String(error);
console.warn(`Failed to load. Error message: ${errorMessage}. Retrying in ${backoffDuration} ms.`);
await new Promise(resolve => setTimeout(resolve, backoffDuration));
}
} while (!abortSignal.aborted);
Expand Down Expand Up @@ -690,7 +691,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
*/
async #refreshFeatureFlags(): Promise<boolean> {
// if still within refresh interval/backoff, return
if (this.#ffRefreshInterval === undefined || !this.#ffRefreshTimer.canRefresh()) {
if (this.#ffRefreshInterval === undefined || !this.#ffRefreshTimer!.canRefresh()) {
return Promise.resolve(false);
}

Expand All @@ -699,7 +700,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
await this.#loadFeatureFlags();
}

this.#ffRefreshTimer.reset();
this.#ffRefreshTimer!.reset();
return Promise.resolve(needRefresh);
}

Expand Down Expand Up @@ -728,7 +729,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
* @returns true if key-value collection has changed, false otherwise.
*/
async #checkConfigurationSettingsChange(selectors: PagedSettingsWatcher[]): Promise<boolean> {
const funcToExecute = async (client) => {
const funcToExecute = async (client: AppConfigurationClient) => {
for (const selector of selectors) {
if (selector.snapshotName) { // skip snapshot selector
continue;
Expand Down Expand Up @@ -765,7 +766,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
* Gets a configuration setting by key and label.If the setting is not found, return undefine instead of throwing an error.
*/
async #getConfigurationSetting(configurationSettingId: ConfigurationSettingId, getOptions?: GetConfigurationSettingOptions): Promise<GetConfigurationSettingResponse | undefined> {
const funcToExecute = async (client) => {
const funcToExecute = async (client: AppConfigurationClient) => {
return getConfigurationSettingWithTrace(
this.#requestTraceOptions,
client,
Expand All @@ -788,7 +789,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
}

async #listConfigurationSettings(listOptions: ListConfigurationSettingsOptions): Promise<{ items: ConfigurationSetting[]; pageWatchers: SettingWatcher[] }> {
const funcToExecute = async (client) => {
const funcToExecute = async (client: AppConfigurationClient) => {
const pageWatchers: SettingWatcher[] = [];
const pageIterator = listConfigurationSettingsWithTrace(
this.#requestTraceOptions,
Expand All @@ -808,7 +809,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
}

async #getSnapshot(snapshotName: string, getOptions?: GetSnapshotOptions): Promise<GetSnapshotResponse | undefined> {
const funcToExecute = async (client) => {
const funcToExecute = async (client: AppConfigurationClient) => {
return getSnapshotWithTrace(
this.#requestTraceOptions,
client,
Expand All @@ -831,7 +832,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
}

async #listConfigurationSettingsForSnapshot(snapshotName: string, listOptions?: ListConfigurationSettingsForSnapshotOptions): Promise<ConfigurationSetting[]> {
const funcToExecute = async (client) => {
const funcToExecute = async (client: AppConfigurationClient) => {
const pageIterator = listConfigurationSettingsForSnapshotWithTrace(
this.#requestTraceOptions,
client,
Expand Down
8 changes: 4 additions & 4 deletions src/common/contentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ContentType = {
parameters: Record<string, string>;
}

export function parseContentType(contentTypeValue: string | undefined): ContentType | undefined {
export function parseContentType(contentTypeValue?: string): ContentType | undefined {
if (!contentTypeValue) {
return undefined;
}
Expand All @@ -27,7 +27,7 @@ export function parseContentType(contentTypeValue: string | undefined): ContentT

// Determine whether a content type string is a valid JSON content type.
// https://docs.microsoft.com/en-us/azure/azure-app-configuration/howto-leverage-json-content-type
export function isJsonContentType(contentType: ContentType | undefined): boolean {
export function isJsonContentType(contentType?: ContentType): boolean {
const mediaType = contentType?.mediaType;
if (!mediaType) {
return false;
Expand All @@ -45,15 +45,15 @@ export function isJsonContentType(contentType: ContentType | undefined): boolean
return typeParts[1].split("+").includes("json");
}

export function isFeatureFlagContentType(contentType: ContentType | undefined): boolean {
export function isFeatureFlagContentType(contentType?: ContentType): boolean {
const mediaType = contentType?.mediaType;
if (!mediaType) {
return false;
}
return mediaType === featureFlagContentType;
}

export function isSecretReferenceContentType(contentType: ContentType | undefined): boolean {
export function isSecretReferenceContentType(contentType?: ContentType): boolean {
const mediaType = contentType?.mediaType;
if (!mediaType) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/keyvault/keyVaultKeyValueAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AzureKeyVaultKeyValueAdapter implements IKeyValueAdapter {
#keyVaultOptions: KeyVaultOptions | undefined;
#keyVaultSecretProvider: AzureKeyVaultSecretProvider;

constructor(keyVaultOptions: KeyVaultOptions | undefined, refreshTimer?: RefreshTimer) {
constructor(keyVaultOptions?: KeyVaultOptions, refreshTimer?: RefreshTimer) {
this.#keyVaultOptions = keyVaultOptions;
this.#keyVaultSecretProvider = new AzureKeyVaultSecretProvider(keyVaultOptions, refreshTimer);
}
Expand Down
2 changes: 1 addition & 1 deletion src/keyvault/keyVaultSecretProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AzureKeyVaultSecretProvider {
#secretClients: Map<string, SecretClient>; // map key vault hostname to corresponding secret client
#cachedSecretValues: Map<string, any> = new Map<string, any>(); // map secret identifier to secret value

constructor(keyVaultOptions: KeyVaultOptions | undefined, refreshTimer?: RefreshTimer) {
constructor(keyVaultOptions?: KeyVaultOptions, refreshTimer?: RefreshTimer) {
if (keyVaultOptions?.secretRefreshIntervalInMs !== undefined) {
if (refreshTimer === undefined) {
throw new ArgumentError("Refresh timer must be specified when Key Vault secret refresh is enabled.");
Expand Down
Loading