diff --git a/ts/packages/ts/src/commands/ExportCommand.ts b/ts/packages/ts/src/commands/ExportCommand.ts index 9794fb82..bb5667c7 100644 --- a/ts/packages/ts/src/commands/ExportCommand.ts +++ b/ts/packages/ts/src/commands/ExportCommand.ts @@ -39,10 +39,11 @@ export class ExportCommand extends Command { } 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) { diff --git a/ts/packages/ts/src/commands/commands.test.ts b/ts/packages/ts/src/commands/commands.test.ts index c6bc1293..0f383743 100644 --- a/ts/packages/ts/src/commands/commands.test.ts +++ b/ts/packages/ts/src/commands/commands.test.ts @@ -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', @@ -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(); diff --git a/ts/packages/ts/src/types/generated.ts b/ts/packages/ts/src/types/generated.ts index b2885267..bd56a439 100644 --- a/ts/packages/ts/src/types/generated.ts +++ b/ts/packages/ts/src/types/generated.ts @@ -26,6 +26,7 @@ export interface Cfgu { default?: string; depends?: string[]; description?: string; + hidden?: boolean; labels?: string[]; lazy?: boolean; options?: string[]; @@ -63,6 +64,7 @@ export interface ConfigSchemaContents { default?: string; depends?: string[]; description?: string; + hidden?: boolean; labels?: string[]; lazy?: boolean; options?: string[]; @@ -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("")) }, @@ -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("")) }, diff --git a/types/Cfgu.ts b/types/Cfgu.ts index e39de1b3..99853fdb 100644 --- a/types/Cfgu.ts +++ b/types/Cfgu.ts @@ -52,4 +52,5 @@ export interface Cfgu { options?: string[]; lazy?: boolean; labels?: string[]; + hidden?: boolean; }