Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust @configu/ts - ConfiguConfigStore for the Revision Tag feature #349

Merged
merged 6 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
62 changes: 44 additions & 18 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ts/packages/cli/package.json
RichardAkman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
],
"dependencies": {
"@configu/lib": "^0.7.0",
"@configu/node": "^0.20.1",
"@configu/ts": "^0.20.1",
"@configu/node": "^0.20.2-next.6",
"@configu/ts": "^0.20.2-next.6",
"@oclif/core": "^3.14.1",
"@oclif/plugin-autocomplete": "^3.0.3",
"@oclif/plugin-not-found": "^3.0.5",
Expand Down
1 change: 1 addition & 0 deletions ts/packages/cli/src/base.ts
RichardAkman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
token: process.env.CONFIGU_TOKEN,
},
endpoint: process.env.CONFIGU_ENDPOINT,
tag: process.env.CONFIGU_TAG,
},
storeConfiguration, // from .configu file
{ source: 'cli' },
Expand Down
23 changes: 23 additions & 0 deletions ts/packages/ts/src/stores/Configu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,28 @@ describe(`ConfiguConfigStore`, () => {
expect(typeof headers.common.Token).toBe('string');
expect(typeof headers.common.Authorization).toBe('undefined');
});
it(`sets the tag property if provided`, () => {
const store = new ConfiguConfigStore({
credentials: {
org: 'test',
token: 'test-token',
},
source: 'test',
tag: 'test-tag',
});

expect(store['tag']).toBe('test-tag');
});
it(`does not set the tag property if not provided`, () => {
const store = new ConfiguConfigStore({
credentials: {
org: 'test',
token: 'test-token',
},
source: 'test',
});

expect(store['tag']).toBeUndefined();
});
});
});
13 changes: 11 additions & 2 deletions ts/packages/ts/src/stores/Configu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ export type ConfiguConfigStoreConfiguration = {
credentials: { org: string; token: string };
endpoint?: string;
source?: string;
tag?: string;
};

export class ConfiguConfigStore extends ConfigStore {
private client: Axios;
constructor({ credentials, endpoint = `https://api.configu.com`, source = 'sdk' }: ConfiguConfigStoreConfiguration) {
private tag?: string;
RichardAkman marked this conversation as resolved.
Show resolved Hide resolved
constructor({
credentials,
endpoint = `https://api.configu.com`,
source = 'sdk',
tag,
}: ConfiguConfigStoreConfiguration) {
super('configu');

this.client = axios.create({
Expand All @@ -28,10 +35,12 @@ export class ConfiguConfigStore extends ConfigStore {
} else {
this.client.defaults.headers.common.Token = credentials.token;
}

this.tag = tag;
}

async get(queries: ConfigStoreQuery[]): Promise<Config[]> {
const { data } = await this.client.post('/config', { queries });
const { data } = await this.client.post(`/config${this.tag ? `?tag=${this.tag}` : ''}`, { queries });
return data;
}

Expand Down
Loading