Skip to content

Commit

Permalink
Merge branch '366-Implement-hidden-Property-for-Cfgu-Declaration-w-fi…
Browse files Browse the repository at this point in the history
…lter' into 0-staging-keys-casing-alias-labels-hidden-filter

# Conflicts:
#	ts/packages/ts/src/types/generated.ts
#	types/Cfgu.ts
  • Loading branch information
ShriekinNinja committed Feb 22, 2024
2 parents 2374f80 + cd407b6 commit 178be75
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
7 changes: 4 additions & 3 deletions ts/packages/ts/src/commands/ExportCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ export class ExportCommand extends Command<ExportCommandReturn> {
}

private filterPipe(pipe: EvalCommandReturn) {
if (!this.parameters.filter) {
return pipe;
const { filter } = this.parameters;
if (!filter) {
return _.pickBy(pipe, ({ context }) => !context.cfgu.hidden);
}
return _.pickBy(pipe, this.parameters.filter);
return _.pickBy(pipe, filter);
}

private mapPipe(pipe: EvalCommandReturn) {
Expand Down
35 changes: 26 additions & 9 deletions ts/packages/ts/src/commands/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,20 @@ describe(`commands`, () => {
});
});
describe(`ExportCommand`, () => {
const getEvalResult = async () => {
const getEvalResult = async (schema?: ConfigSchema) => {
return new EvalCommand({
store: store1,
set: set1,
schema: new ConfigSchema('mutate', {
KEY0: {
type: 'String',
},
KEY1: {
type: 'String',
},
}),
schema:
schema ||
new ConfigSchema('mutate', {
KEY0: {
type: 'String',
},
KEY1: {
type: 'String',
},
}),
configs: {
KEY0: 'KEY0',
KEY1: 'KEY1',
Expand All @@ -403,6 +405,21 @@ describe(`commands`, () => {
}).run();
expect(exportedConfigs).toStrictEqual({ KEY1: 'KEY1' });
});
test('Export with hidden configs', async () => {
const evalResult = await getEvalResult(
new ConfigSchema('mutate', {
KEY0: {
type: 'String',
},
KEY1: {
type: 'String',
hidden: true,
},
}),
);
const exportedConfigs = await new ExportCommand({ pipe: evalResult }).run();
expect(exportedConfigs).toStrictEqual({ KEY0: 'KEY0' });
});
describe(`Keys Mutation Callback`, () => {
test('Export without keys mutation callback', async () => {
const evalResult = await getEvalResult();
Expand Down
4 changes: 4 additions & 0 deletions ts/packages/ts/src/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Cfgu {
default?: string;
depends?: string[];
description?: string;
hidden?: boolean;
labels?: string[];
lazy?: boolean;
options?: string[];
Expand Down Expand Up @@ -63,6 +64,7 @@ export interface ConfigSchemaContents {
default?: string;
depends?: string[];
description?: string;
hidden?: boolean;
labels?: string[];
lazy?: boolean;
options?: string[];
Expand Down Expand Up @@ -351,6 +353,7 @@ const typeMap: any = {
{ json: "default", js: "default", typ: u(undefined, "") },
{ json: "depends", js: "depends", typ: u(undefined, a("")) },
{ json: "description", js: "description", typ: u(undefined, "") },
{ json: "hidden", js: "hidden", typ: u(undefined, true) },
{ json: "labels", js: "labels", typ: u(undefined, a("")) },
{ json: "lazy", js: "lazy", typ: u(undefined, true) },
{ json: "options", js: "options", typ: u(undefined, a("")) },
Expand All @@ -373,6 +376,7 @@ const typeMap: any = {
{ json: "default", js: "default", typ: u(undefined, "") },
{ json: "depends", js: "depends", typ: u(undefined, a("")) },
{ json: "description", js: "description", typ: u(undefined, "") },
{ json: "hidden", js: "hidden", typ: u(undefined, true) },
{ json: "labels", js: "labels", typ: u(undefined, a("")) },
{ json: "lazy", js: "lazy", typ: u(undefined, true) },
{ json: "options", js: "options", typ: u(undefined, a("")) },
Expand Down
1 change: 1 addition & 0 deletions types/Cfgu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ export interface Cfgu {
options?: string[];
lazy?: boolean;
labels?: string[];
hidden?: boolean;
}

0 comments on commit 178be75

Please sign in to comment.