Skip to content

Commit

Permalink
address comments: better naming and tsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskibear committed Nov 3, 2023
1 parent 2c8a821 commit 59cccd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/AzureAppConfigurationImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AzureAppConfigurationImpl extends Map<string, unknown> implements A
const keyValues: [key: string, value: unknown][] = [];

// validate selectors
const selectors = validatedSelectors(this.options?.selectors);
const selectors = getValidSelectors(this.options?.selectors);

for (const selector of selectors) {
const listOptions: ListConfigurationSettingsOptions = {
Expand Down Expand Up @@ -109,15 +109,15 @@ export class AzureAppConfigurationImpl extends Map<string, unknown> implements A
}
}

function validatedSelectors(selectors?: { keyFilter: string, labelFilter?: string }[]) {
function getValidSelectors(selectors?: { keyFilter: string, labelFilter?: string }[]) {
if (!selectors || selectors.length === 0) {
// Default selector: key: *, label: \0
return [{ keyFilter: KeyFilter.Any, labelFilter: LabelFilter.Null }];
}
return selectors.map(selectorCandidate => {
const selector = { ...selectorCandidate };
if (!selector.keyFilter) {
throw new Error("Key filters cannot be empty.");
throw new Error("Key filter cannot be null or empty.");
}
if (!selector.labelFilter) {
selector.labelFilter = LabelFilter.Null;
Expand Down
19 changes: 16 additions & 3 deletions src/AzureAppConfigurationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ export const MaxRetryDelayInMs = 60000;

export interface AzureAppConfigurationOptions {
/**
* Selectors used to control what key-values are retrieved from Azure App Configuration.
* Specify what key-values to include in the configuration provider. include multiple sets of key-values
*
* @property keyFilter: A filter that determines the set of keys that are included in the configuration provider, cannot be omitted.
* @property labelFilter: A filter that determines what label to use when selecting key-values for the the configuration provider, omitted for no label.
* @property keyFilter:
* The key filter to apply when querying Azure App Configuration for key-values.
* An asterisk `*` can be added to the end to return all key-values whose key begins with the key filter.
* e.g. key filter `abc*` returns all key-values whose key starts with `abc`.
* A comma `,` can be used to select multiple key-values. Comma separated filters must exactly match a key to select it.
* Using asterisk to select key-values that begin with a key filter while simultaneously using comma separated key filters is not supported.
* E.g. the key filter `abc*,def` is not supported. The key filters `abc*` and `abc,def` are supported.
* For all other cases the characters: asterisk `*`, comma `,`, and backslash `\` are reserved. Reserved characters must be escaped using a backslash (\).
* e.g. the key filter `a\\b\,\*c*` returns all key-values whose key starts with `a\b,*c`.
*
* @property labelFilter:
* The label filter to apply when querying Azure App Configuration for key-values.
* By default, the "null label" will be used, matching key-values without a label.
* The characters asterisk `*` and comma `,` are not supported.
* Backslash `\` character is reserved and must be escaped using another backslash `\`.
*/
selectors?: { keyFilter: string, labelFilter?: string }[];
trimKeyPrefixes?: string[];
Expand Down

0 comments on commit 59cccd1

Please sign in to comment.