From 2dbe809a9b87cde0fa9bc2c0df28b6a562cdc81b Mon Sep 17 00:00:00 2001 From: Nanddeep Nachan Date: Wed, 4 Oct 2023 14:46:40 +0000 Subject: [PATCH 1/4] rename 'externalconnection' commands --- .../connection/connection-add.mdx} | 26 +++++---- .../connection/connection-get.mdx} | 27 ++++++---- .../connection/connection-list.mdx} | 19 ++++--- .../external/connection/connection-remove.mdx | 54 +++++++++++++++++++ .../connection/connection-schema-add.mdx | 41 ++++++++++++++ .../externalconnection-remove.mdx | 48 ----------------- .../externalconnection-schema-add.mdx | 35 ------------ docs/src/config/sidebars.js | 24 ++++----- src/index.spec.ts | 9 +++- src/m365/external/commands.ts | 15 ++++++ .../connection/connection-add.spec.ts} | 11 ++-- .../commands/connection/connection-add.ts} | 13 +++-- .../connection/connection-get.spec.ts} | 15 ++++-- .../commands/connection/connection-get.ts} | 13 +++-- .../connection/connection-list.spec.ts} | 13 +++-- .../commands/connection/connection-list.ts} | 11 ++-- .../connection/connection-remove.spec.ts} | 15 ++++-- .../commands/connection/connection-remove.ts} | 15 ++++-- .../connection/connection-schema-add.spec.ts} | 11 ++-- .../connection/connection-schema-add.ts} | 17 +++--- src/m365/search/commands.ts | 9 ---- 21 files changed, 266 insertions(+), 175 deletions(-) rename docs/docs/cmd/{search/externalconnection/externalconnection-add.mdx => external/connection/connection-add.mdx} (69%) rename docs/docs/cmd/{search/externalconnection/externalconnection-get.mdx => external/connection/connection-get.mdx} (79%) rename docs/docs/cmd/{search/externalconnection/externalconnection-list.mdx => external/connection/connection-list.mdx} (83%) create mode 100644 docs/docs/cmd/external/connection/connection-remove.mdx create mode 100644 docs/docs/cmd/external/connection/connection-schema-add.mdx delete mode 100644 docs/docs/cmd/search/externalconnection/externalconnection-remove.mdx delete mode 100644 docs/docs/cmd/search/externalconnection/externalconnection-schema-add.mdx create mode 100644 src/m365/external/commands.ts rename src/m365/{search/commands/externalconnection/externalconnection-add.spec.ts => external/commands/connection/connection-add.spec.ts} (96%) rename src/m365/{search/commands/externalconnection/externalconnection-add.ts => external/commands/connection/connection-add.ts} (90%) rename src/m365/{search/commands/externalconnection/externalconnection-get.spec.ts => external/commands/connection/connection-get.spec.ts} (90%) rename src/m365/{search/commands/externalconnection/externalconnection-get.ts => external/commands/connection/connection-get.ts} (85%) rename src/m365/{search/commands/externalconnection/externalconnection-list.spec.ts => external/commands/connection/connection-list.spec.ts} (89%) rename src/m365/{search/commands/externalconnection/externalconnection-list.ts => external/commands/connection/connection-list.ts} (71%) rename src/m365/{search/commands/externalconnection/externalconnection-remove.spec.ts => external/commands/connection/connection-remove.spec.ts} (95%) rename src/m365/{search/commands/externalconnection/externalconnection-remove.ts => external/commands/connection/connection-remove.ts} (89%) rename src/m365/{search/commands/externalconnection/externalconnection-schema-add.spec.ts => external/commands/connection/connection-schema-add.spec.ts} (94%) rename src/m365/{search/commands/externalconnection/externalconnection-schema-add.ts => external/commands/connection/connection-schema-add.ts} (85%) delete mode 100644 src/m365/search/commands.ts diff --git a/docs/docs/cmd/search/externalconnection/externalconnection-add.mdx b/docs/docs/cmd/external/connection/connection-add.mdx similarity index 69% rename from docs/docs/cmd/search/externalconnection/externalconnection-add.mdx rename to docs/docs/cmd/external/connection/connection-add.mdx index 623e3c84927..ffd861e0ac0 100644 --- a/docs/docs/cmd/search/externalconnection/externalconnection-add.mdx +++ b/docs/docs/cmd/external/connection/connection-add.mdx @@ -1,26 +1,32 @@ import Global from '/docs/cmd/_global.mdx'; -# search externalconnection add +# external connection add -Add a new external connection to be defined for Microsoft Search +Add a new external connection ## Usage ```sh -m365 search externalconnection add [options] +m365 external connection add [options] +``` + +## Alias + +```sh +m365 search externalconnection add ``` ## Options ```md definition-list `-i, --id ` -: Developer-provided unique ID of the connection within the Azure Active Directory tenant +: Developer-provided unique ID of the connection within the Azure Active Directory tenant. `-n, --name ` -: The display name of the connection to be displayed in the Microsoft 365 admin center. Maximum length of 128 characters +: The display name of the connection to be displayed in the Microsoft 365 admin center. Maximum length of 128 characters. `-d, --description ` -: Description of the connection displayed in the Microsoft 365 admin center +: Description of the connection displayed in the Microsoft 365 admin center. `--authorizedAppIds [authorizedAppIds]` : Comma-separated collection of application IDs for registered Azure Active Directory apps that are allowed to manage the external connection and to index content in the external connection. @@ -34,16 +40,16 @@ The `id` must be at least 3 and no more than 32 characters long. It can contain ## Examples -Adds a new external connection with name and description of test app +Adds a new external connection with name and description of test app. ```sh -m365 search externalconnection add --id MyApp --name "Test" --description "Test" +m365 external connection add --id MyApp --name "Test" --description "Test" ``` -Adds a new external connection with a limited number of authorized apps +Adds a new external connection with a limited number of authorized apps. ```sh -m365 search externalconnection add --id MyApp --name "Test" --description "Test" --authorizedAppIds "00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002" +m365 external connection add --id MyApp --name "Test" --description "Test" --authorizedAppIds "00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001,00000000-0000-0000-0000-000000000002" ``` ## Response diff --git a/docs/docs/cmd/search/externalconnection/externalconnection-get.mdx b/docs/docs/cmd/external/connection/connection-get.mdx similarity index 79% rename from docs/docs/cmd/search/externalconnection/externalconnection-get.mdx rename to docs/docs/cmd/external/connection/connection-get.mdx index 1b8c25fe226..259273476b4 100644 --- a/docs/docs/cmd/search/externalconnection/externalconnection-get.mdx +++ b/docs/docs/cmd/external/connection/connection-get.mdx @@ -2,40 +2,46 @@ import Global from '/docs/cmd/_global.mdx'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# search externalconnection get +# external connection get -Allow the administrator to get a specific external connection for use in Microsoft Search. +Allow the administrator to get a specific external connection ## Usage ```sh -m365 search externalconnection get [options] +m365 external connection get [options] +``` + +## Alias + +```sh +m365 search externalconnection get ``` ## Options ```md definition-list `-i, --id [id]` -: ID of the External Connection to get. Specify either `id` or `name` +: ID of the External Connection to get. Specify either `id` or `name`. `-n, --name [name]` -: Name of the External Connection to get. Specify either `id` or `name` +: Name of the External Connection to get. Specify either `id` or `name`. ``` ## Examples -Get the External Connection by its id +Get the External Connection by its id. ```sh -m365 search externalconnection get --id "MyApp" +m365 external connection get --id "MyApp" ``` -Get the External Connection by its name +Get the External Connection by its name. ```sh -m365 search externalconnection get --name "Test" +m365 external connection get --name "Test" ``` ## Response @@ -83,7 +89,7 @@ m365 search externalconnection get --name "Test" ```md - # search externalconnection get --id "CLITest" + # external connection get --id "CLITest" Date: 2022-11-05 @@ -99,4 +105,3 @@ m365 search externalconnection get --name "Test" - diff --git a/docs/docs/cmd/search/externalconnection/externalconnection-list.mdx b/docs/docs/cmd/external/connection/connection-list.mdx similarity index 83% rename from docs/docs/cmd/search/externalconnection/externalconnection-list.mdx rename to docs/docs/cmd/external/connection/connection-list.mdx index 1a19110a65a..656916e922d 100644 --- a/docs/docs/cmd/search/externalconnection/externalconnection-list.mdx +++ b/docs/docs/cmd/external/connection/connection-list.mdx @@ -2,14 +2,20 @@ import Global from '/docs/cmd/_global.mdx'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -# search externalconnection list +# external connection list -Lists external connections defined in Microsoft Search +Lists external connections ## Usage ```sh -m365 search externalconnection list [options] +m365 external connection list [options] +``` + +## Alias + +```sh +m365 search externalconnection list ``` ## Options @@ -18,10 +24,10 @@ m365 search externalconnection list [options] ## Examples -List external connections defined in Microsoft Search +List external connections. ```sh -m365 search externalconnection list +m365 external connection list ``` ## Response @@ -69,7 +75,7 @@ m365 search externalconnection list ```md - # search externalconnection list + # external connection list Date: 2022-09-05 @@ -85,4 +91,3 @@ m365 search externalconnection list - diff --git a/docs/docs/cmd/external/connection/connection-remove.mdx b/docs/docs/cmd/external/connection/connection-remove.mdx new file mode 100644 index 00000000000..7edf9f98b05 --- /dev/null +++ b/docs/docs/cmd/external/connection/connection-remove.mdx @@ -0,0 +1,54 @@ +import Global from '/docs/cmd/_global.mdx'; + +# external connection remove + +Allow the administrator to remove a specific external connection + +## Usage + +```sh +m365 external connection remove [options] +``` + +## Alias + +```sh +m365 search externalconnection remove +``` + +## Options + +```md definition-list +`-i, --id [id]` +: ID of the External Connection to remove. Specify either `id` or `name`. + +`-n, --name [name]` +: Name of the External Connection to remove. Specify either `id` or `name`. + +`-f, --force` +: Don't prompt for confirming removing the connection. +``` + + + +## Remarks + +If the command finds multiple external connections with the specified name, it will prompt you to disambiguate which external connection it should remove, listing the discovered IDs. + +## Examples + +Removes external connection by its id. + +```sh +m365 external connection remove --id "MyApp" +``` + +Removes external connection by its name. Will NOT prompt for confirmation before removing. + +```sh +m365 external connection remove --name "Test" --force +``` + +## Response + +The command won't return a response on success. diff --git a/docs/docs/cmd/external/connection/connection-schema-add.mdx b/docs/docs/cmd/external/connection/connection-schema-add.mdx new file mode 100644 index 00000000000..67209f7f002 --- /dev/null +++ b/docs/docs/cmd/external/connection/connection-schema-add.mdx @@ -0,0 +1,41 @@ +import Global from '/docs/cmd/_global.mdx'; + +# external connection schema add + +Allow the administrator to add a schema to a specific external connection + +## Usage + +```sh +m365 external connection schema add [options] +``` + +## Alias + +```sh +m365 search externalconnection schema add +``` + +## Options + +```md definition-list +`-i, --externalConnectionId ` +: ID of the External Connection. + +`-s, --schema [schema]` +: The schema object to be added. +``` + + + +## Examples + +Adds a new schema to a specific external connection. + +```sh +m365 external connection schema add --externalConnectionId 'CliConnectionId' --schema '{"baseType":"microsoft.graph.externalItem","properties":[{"name":"ticketTitle","type":"String","isSearchable":"true","isRetrievable":"true","labels":["title"]},{"name":"priority","type":"String","isQueryable":"true","isRetrievable":"true","isSearchable":"false"},{"name":"assignee","type":"String","isRetrievable":"true"}]}' +``` + +## Response + +The command won't return a response on success. diff --git a/docs/docs/cmd/search/externalconnection/externalconnection-remove.mdx b/docs/docs/cmd/search/externalconnection/externalconnection-remove.mdx deleted file mode 100644 index 257b1386c1b..00000000000 --- a/docs/docs/cmd/search/externalconnection/externalconnection-remove.mdx +++ /dev/null @@ -1,48 +0,0 @@ -import Global from '/docs/cmd/_global.mdx'; - -# search externalconnection remove - -Allow the administrator to remove a specific external connection used in Microsoft Search. - -## Usage - -```sh -m365 search externalconnection remove [options] -``` - -## Options - -```md definition-list -`-i, --id [id]` -: ID of the External Connection to remove. Specify either `id` or `name` - -`-n, --name [name]` -: Name of the External Connection to remove. Specify either `id` or `name` - -`-f, --force` -: Don't prompt for confirming removing the connection -``` - - - -## Remarks - -If the command finds multiple external connections used in Microsoft Search with the specified name, it will prompt you to disambiguate which external connection it should remove, listing the discovered IDs. - -## Examples - -Removes external connection with id _MyApp_ - -```sh -m365 search externalconnection remove --id "MyApp" -``` - -Removes external connection with name _Test_. Will NOT prompt for confirmation before removing. - -```sh -m365 search externalconnection remove --name "Test" --force -``` - -## Response - -The command won't return a response on success. diff --git a/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.mdx b/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.mdx deleted file mode 100644 index 95a1c4180f9..00000000000 --- a/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.mdx +++ /dev/null @@ -1,35 +0,0 @@ -import Global from '/docs/cmd/_global.mdx'; - -# search externalconnection schema add - -This command allows the administrator to add a schema to a specific external connection for use in Microsoft Search. - -## Usage - -```sh -m365 search externalconnection schema add [options] -``` - -## Options - -```md definition-list -`-i, --externalConnectionId ` -: ID of the External Connection. - -`-s, --schema [schema]` -: The schema object to be added. -``` - - - -## Examples - -Adds a new schema to a specific external connection. - -```sh -m365 search externalconnection schema add --externalConnectionId 'CliConnectionId' --schema '{"baseType":"microsoft.graph.externalItem","properties":[{"name":"ticketTitle","type":"String","isSearchable":"true","isRetrievable":"true","labels":["title"]},{"name":"priority","type":"String","isQueryable":"true","isRetrievable":"true","isSearchable":"false"},{"name":"assignee","type":"String","isRetrievable":"true"}]}' -``` - -## Response - -The command won't return a response on success. diff --git a/docs/src/config/sidebars.js b/docs/src/config/sidebars.js index 28f8a409d37..794ccc28f01 100644 --- a/docs/src/config/sidebars.js +++ b/docs/src/config/sidebars.js @@ -1637,33 +1637,33 @@ const sidebars = { ] }, { - 'Search (search)': [ + 'External (external)': [ { - externalconnection: [ + connection: [ { type: 'doc', - label: 'externalconnection add', - id: 'cmd/search/externalconnection/externalconnection-add' + label: 'connection add', + id: 'cmd/external/connection-add' }, { type: 'doc', - label: 'externalconnection get', - id: 'cmd/search/externalconnection/externalconnection-get' + label: 'connection get', + id: 'cmd/external/connection-get' }, { type: 'doc', - label: 'externalconnection list', - id: 'cmd/search/externalconnection/externalconnection-list' + label: 'connection list', + id: 'cmd/external/connection-list' }, { type: 'doc', - label: 'externalconnection remove', - id: 'cmd/search/externalconnection/externalconnection-remove' + label: 'connection remove', + id: 'cmd/external/connection-remove' }, { type: 'doc', - label: 'externalconnection schema add', - id: 'cmd/search/externalconnection/externalconnection-schema-add' + label: 'connection schema add', + id: 'cmd/external/connection-schema-add' } ] } diff --git a/src/index.spec.ts b/src/index.spec.ts index cae2a4a0a4b..329cfd5878a 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -12,7 +12,8 @@ import * as outlookCommands from './m365/outlook/commands.js'; import * as paCommands from './m365/pa/commands.js'; import * as ppCommands from './m365/pp/commands.js'; import * as plannerCommands from './m365/planner/commands.js'; -import * as searchCommands from './m365/search/commands.js'; +import * as searchCommands from './m365/external/commands.js'; +import * as externalCommands from './m365/external/commands.js'; import * as spfxCommands from './m365/spfx/commands.js'; import * as spoCommands from './m365/spo/commands.js'; import * as teamsCommands from './m365/teams/commands.js'; @@ -36,6 +37,7 @@ describe('Lazy loading commands', () => { ppCommands.default, plannerCommands.default, searchCommands.default, + externalCommands.default, spfxCommands.default, spoCommands.default, teamsCommands.default, @@ -47,6 +49,11 @@ describe('Lazy loading commands', () => { 'consent', 'flow connector export', 'flow connector list', + 'search externalconnection add', + 'search externalconnection get', + 'search externalconnection list', + 'search externalconnection remove', + 'search externalconnection schema add', 'spo page template remove', 'spo sp grant add', 'spo sp grant list', diff --git a/src/m365/external/commands.ts b/src/m365/external/commands.ts new file mode 100644 index 00000000000..b0d5655052f --- /dev/null +++ b/src/m365/external/commands.ts @@ -0,0 +1,15 @@ +const prefix: string = 'external'; +const searchPrefix: string = 'search'; + +export default { + CONNECTION_ADD: `${prefix} connection add`, + CONNECTION_GET: `${prefix} connection get`, + CONNECTION_LIST: `${prefix} connection list`, + CONNECTION_REMOVE: `${prefix} connection remove`, + CONNECTION_SCHEMA_ADD: `${prefix} connection schema add`, + EXTERNALCONNECTION_ADD: `${searchPrefix} externalconnection add`, + EXTERNALCONNECTION_GET: `${searchPrefix} externalconnection get`, + EXTERNALCONNECTION_LIST: `${searchPrefix} externalconnection list`, + EXTERNALCONNECTION_REMOVE: `${searchPrefix} externalconnection remove`, + EXTERNALCONNECTION_SCHEMA_ADD: `${searchPrefix} externalconnection schema add` +}; \ No newline at end of file diff --git a/src/m365/search/commands/externalconnection/externalconnection-add.spec.ts b/src/m365/external/commands/connection/connection-add.spec.ts similarity index 96% rename from src/m365/search/commands/externalconnection/externalconnection-add.spec.ts rename to src/m365/external/commands/connection/connection-add.spec.ts index f8ab78d2e1f..7eba05c7819 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-add.spec.ts +++ b/src/m365/external/commands/connection/connection-add.spec.ts @@ -12,9 +12,9 @@ import { pid } from '../../../../utils/pid.js'; import { session } from '../../../../utils/session.js'; import { sinonUtil } from '../../../../utils/sinonUtil.js'; import commands from '../../commands.js'; -import command from './externalconnection-add.js'; +import command from './connection-add.js'; -describe(commands.EXTERNALCONNECTION_ADD, () => { +describe(commands.CONNECTION_ADD, () => { let log: string[]; let logger: Logger; let commandInfo: CommandInfo; @@ -78,13 +78,18 @@ describe(commands.EXTERNALCONNECTION_ADD, () => { }); it('has correct name', () => { - assert.strictEqual(command.name, commands.EXTERNALCONNECTION_ADD); + assert.strictEqual(command.name, commands.CONNECTION_ADD); }); it('has a description', () => { assert.notStrictEqual(command.description, null); }); + it('defines alias', () => { + const alias = command.alias(); + assert.notStrictEqual(typeof alias, 'undefined'); + }); + it('adds an external connection', async () => { const postStub = sinon.stub(request, 'post').callsFake(async (opts: any) => { if (opts.url === `https://graph.microsoft.com/v1.0/external/connections`) { diff --git a/src/m365/search/commands/externalconnection/externalconnection-add.ts b/src/m365/external/commands/connection/connection-add.ts similarity index 90% rename from src/m365/search/commands/externalconnection/externalconnection-add.ts rename to src/m365/external/commands/connection/connection-add.ts index 3b94af05e8d..0b445c6853d 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-add.ts +++ b/src/m365/external/commands/connection/connection-add.ts @@ -3,6 +3,7 @@ import { Logger } from '../../../../cli/Logger.js'; import GlobalOptions from '../../../../GlobalOptions.js'; import request from '../../../../request.js'; import GraphCommand from '../../../base/GraphCommand.js'; +import searchCommands from '../../commands.js'; import commands from '../../commands.js'; interface CommandArgs { @@ -16,13 +17,17 @@ interface Options extends GlobalOptions { authorizedAppIds?: string; } -class SearchExternalConnectionAddCommand extends GraphCommand { +class ExternalConnectionAddCommand extends GraphCommand { public get name(): string { - return commands.EXTERNALCONNECTION_ADD; + return commands.CONNECTION_ADD; } public get description(): string { - return 'Adds a new External Connection for Microsoft Search'; + return 'Adds a new external connection'; + } + + public alias(): string[] | undefined { + return [searchCommands.EXTERNALCONNECTION_ADD]; } constructor() { @@ -139,4 +144,4 @@ class SearchExternalConnectionAddCommand extends GraphCommand { } } -export default new SearchExternalConnectionAddCommand(); +export default new ExternalConnectionAddCommand(); diff --git a/src/m365/search/commands/externalconnection/externalconnection-get.spec.ts b/src/m365/external/commands/connection/connection-get.spec.ts similarity index 90% rename from src/m365/search/commands/externalconnection/externalconnection-get.spec.ts rename to src/m365/external/commands/connection/connection-get.spec.ts index 14fb471114b..dd328ac83fc 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-get.spec.ts +++ b/src/m365/external/commands/connection/connection-get.spec.ts @@ -10,9 +10,9 @@ import { pid } from '../../../../utils/pid.js'; import { session } from '../../../../utils/session.js'; import { sinonUtil } from '../../../../utils/sinonUtil.js'; import commands from '../../commands.js'; -import command from './externalconnection-get.js'; +import command from './connection-get.js'; -describe(commands.EXTERNALCONNECTION_GET, () => { +describe(commands.CONNECTION_GET, () => { let log: string[]; let logger: Logger; let loggerLogSpy: sinon.SinonSpy; @@ -67,13 +67,18 @@ describe(commands.EXTERNALCONNECTION_GET, () => { }); it('has correct name', () => { - assert.strictEqual(command.name, commands.EXTERNALCONNECTION_GET); + assert.strictEqual(command.name, commands.CONNECTION_GET); }); it('has a description', () => { assert.notStrictEqual(command.description, null); }); + it('defines alias', () => { + const alias = command.alias(); + assert.notStrictEqual(typeof alias, 'undefined'); + }); + it('correctly handles error', async () => { sinon.stub(request, 'get').callsFake(() => { throw 'An error has occurred'; @@ -85,7 +90,7 @@ describe(commands.EXTERNALCONNECTION_GET, () => { }), new CommandError('An error has occurred')); }); - it('should get external connection information for the Microsoft Search by id (debug)', async () => { + it('should get external connection information by id (debug)', async () => { sinon.stub(request, 'get').callsFake(async (opts) => { if (opts.url === `https://graph.microsoft.com/v1.0/external/connections/contosohr`) { return externalConnection; @@ -107,7 +112,7 @@ describe(commands.EXTERNALCONNECTION_GET, () => { assert.strictEqual(call.args[0].state, 'draft'); }); - it('should get external connection information for the Microsoft Search by name', async () => { + it('should get external connection information by name', async () => { sinon.stub(request, 'get').callsFake(async (opts) => { if ((opts.url as string).indexOf(`/v1.0/external/connections?$filter=name eq '`) > -1) { return { diff --git a/src/m365/search/commands/externalconnection/externalconnection-get.ts b/src/m365/external/commands/connection/connection-get.ts similarity index 85% rename from src/m365/search/commands/externalconnection/externalconnection-get.ts rename to src/m365/external/commands/connection/connection-get.ts index e9dc224df91..c302232ee74 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-get.ts +++ b/src/m365/external/commands/connection/connection-get.ts @@ -3,6 +3,7 @@ import GlobalOptions from '../../../../GlobalOptions.js'; import request from '../../../../request.js'; import { formatting } from '../../../../utils/formatting.js'; import GraphCommand from '../../../base/GraphCommand.js'; +import searchCommands from '../../commands.js'; import commands from '../../commands.js'; interface CommandArgs { @@ -14,13 +15,17 @@ interface Options extends GlobalOptions { name?: string; } -class SearchExternalConnectionGetCommand extends GraphCommand { +class ExternalConnectionGetCommand extends GraphCommand { public get name(): string { - return commands.EXTERNALCONNECTION_GET; + return commands.CONNECTION_GET; } public get description(): string { - return 'Get a specific external connection for use in Microsoft Search'; + return 'Get a specific external connection'; + } + + public alias(): string[] | undefined { + return [searchCommands.EXTERNALCONNECTION_GET]; } constructor() { @@ -91,4 +96,4 @@ class SearchExternalConnectionGetCommand extends GraphCommand { } } -export default new SearchExternalConnectionGetCommand(); \ No newline at end of file +export default new ExternalConnectionGetCommand(); \ No newline at end of file diff --git a/src/m365/search/commands/externalconnection/externalconnection-list.spec.ts b/src/m365/external/commands/connection/connection-list.spec.ts similarity index 89% rename from src/m365/search/commands/externalconnection/externalconnection-list.spec.ts rename to src/m365/external/commands/connection/connection-list.spec.ts index 22f54c19ffa..16b7985b12d 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-list.spec.ts +++ b/src/m365/external/commands/connection/connection-list.spec.ts @@ -10,9 +10,9 @@ import { pid } from '../../../../utils/pid.js'; import { session } from '../../../../utils/session.js'; import { sinonUtil } from '../../../../utils/sinonUtil.js'; import commands from '../../commands.js'; -import command from './externalconnection-list.js'; +import command from './connection-list.js'; -describe(commands.EXTERNALCONNECTION_LIST, () => { +describe(commands.CONNECTION_LIST, () => { let log: string[]; let logger: Logger; let loggerLogSpy: sinon.SinonSpy; @@ -69,13 +69,18 @@ describe(commands.EXTERNALCONNECTION_LIST, () => { }); it('has correct name', () => { - assert.strictEqual(command.name, commands.EXTERNALCONNECTION_LIST); + assert.strictEqual(command.name, commands.CONNECTION_LIST); }); it('has a description', () => { assert.notStrictEqual(command.description, null); }); + it('defines alias', () => { + const alias = command.alias(); + assert.notStrictEqual(typeof alias, 'undefined'); + }); + it('defines correct properties for the default output', () => { assert.deepStrictEqual(command.defaultProperties(), ['id', 'name', 'state']); }); @@ -91,7 +96,7 @@ describe(commands.EXTERNALCONNECTION_LIST, () => { }), new CommandError('An error has occurred')); }); - it('retrieves list of external connections defined in the Microsoft Search', async () => { + it('retrieves list of external connections', async () => { sinon.stub(request, 'get').callsFake(async (opts: any) => { if (opts.url === `https://graph.microsoft.com/v1.0/external/connections`) { return externalConnections; diff --git a/src/m365/search/commands/externalconnection/externalconnection-list.ts b/src/m365/external/commands/connection/connection-list.ts similarity index 71% rename from src/m365/search/commands/externalconnection/externalconnection-list.ts rename to src/m365/external/commands/connection/connection-list.ts index 219d4e501fd..d51f36d92ba 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-list.ts +++ b/src/m365/external/commands/connection/connection-list.ts @@ -1,17 +1,22 @@ import { Logger } from '../../../../cli/Logger.js'; import { odata } from '../../../../utils/odata.js'; import GraphCommand from '../../../base/GraphCommand.js'; +import searchCommands from '../../commands.js'; import commands from '../../commands.js'; -class SearchExternalConnectionListCommand extends GraphCommand { +class ExternalConnectionListCommand extends GraphCommand { public get name(): string { - return commands.EXTERNALCONNECTION_LIST; + return commands.CONNECTION_LIST; } public get description(): string { return 'Lists external connections defined in the Microsoft Search'; } + public alias(): string[] | undefined { + return [searchCommands.EXTERNALCONNECTION_LIST]; + } + public defaultProperties(): string[] | undefined { return ['id', 'name', 'state']; } @@ -27,4 +32,4 @@ class SearchExternalConnectionListCommand extends GraphCommand { } } -export default new SearchExternalConnectionListCommand(); \ No newline at end of file +export default new ExternalConnectionListCommand(); \ No newline at end of file diff --git a/src/m365/search/commands/externalconnection/externalconnection-remove.spec.ts b/src/m365/external/commands/connection/connection-remove.spec.ts similarity index 95% rename from src/m365/search/commands/externalconnection/externalconnection-remove.spec.ts rename to src/m365/external/commands/connection/connection-remove.spec.ts index a2201b3a339..b45034f5fc1 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-remove.spec.ts +++ b/src/m365/external/commands/connection/connection-remove.spec.ts @@ -10,10 +10,10 @@ import { pid } from '../../../../utils/pid.js'; import { session } from '../../../../utils/session.js'; import { sinonUtil } from '../../../../utils/sinonUtil.js'; import commands from '../../commands.js'; -import command from './externalconnection-remove.js'; +import command from './connection-remove.js'; import { settingsNames } from '../../../../settingsNames.js'; -describe(commands.EXTERNALCONNECTION_REMOVE, () => { +describe(commands.CONNECTION_REMOVE, () => { let cli: Cli; let log: string[]; let logger: Logger; @@ -64,13 +64,18 @@ describe(commands.EXTERNALCONNECTION_REMOVE, () => { }); it('has correct name', () => { - assert.strictEqual(command.name, commands.EXTERNALCONNECTION_REMOVE); + assert.strictEqual(command.name, commands.CONNECTION_REMOVE); }); it('has a description', () => { assert.notStrictEqual(command.description, null); }); + it('defines alias', () => { + const alias = command.alias(); + assert.notStrictEqual(typeof alias, 'undefined'); + }); + it('prompts before removing the specified external connection by id when confirm option not passed', async () => { await command.action(logger, { options: { @@ -185,7 +190,7 @@ describe(commands.EXTERNALCONNECTION_REMOVE, () => { return { value: [] }; } - throw 'The specified connection does not exist in Microsoft Search'; + throw 'The specified connection does not exist'; }); await assert.rejects(command.action(logger, { @@ -193,7 +198,7 @@ describe(commands.EXTERNALCONNECTION_REMOVE, () => { name: "Fabrikam HR", force: true } - } as any), new CommandError("The specified connection does not exist in Microsoft Search")); + } as any), new CommandError("The specified connection does not exist")); }); it('fails when multiple external connections with same name exists', async () => { diff --git a/src/m365/search/commands/externalconnection/externalconnection-remove.ts b/src/m365/external/commands/connection/connection-remove.ts similarity index 89% rename from src/m365/search/commands/externalconnection/externalconnection-remove.ts rename to src/m365/external/commands/connection/connection-remove.ts index e0b7f225f59..b9f5ae23fd3 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-remove.ts +++ b/src/m365/external/commands/connection/connection-remove.ts @@ -4,6 +4,7 @@ import GlobalOptions from '../../../../GlobalOptions.js'; import request from '../../../../request.js'; import { formatting } from '../../../../utils/formatting.js'; import GraphCommand from '../../../base/GraphCommand.js'; +import searchCommands from '../../commands.js'; import commands from '../../commands.js'; interface CommandArgs { @@ -16,13 +17,17 @@ interface Options extends GlobalOptions { force?: boolean; } -class SearchExternalConnectionRemoveCommand extends GraphCommand { +class ExternalConnectionRemoveCommand extends GraphCommand { public get name(): string { - return commands.EXTERNALCONNECTION_REMOVE; + return commands.CONNECTION_REMOVE; } public get description(): string { - return 'Removes a specific External Connection from Microsoft Search'; + return 'Removes a specific external connection'; + } + + public alias(): string[] | undefined { + return [searchCommands.EXTERNALCONNECTION_REMOVE]; } constructor() { @@ -75,7 +80,7 @@ class SearchExternalConnectionRemoveCommand extends GraphCommand { } if (res.value.length === 0) { - throw `The specified connection does not exist in Microsoft Search`; + throw `The specified connection does not exist`; } const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value); @@ -120,4 +125,4 @@ class SearchExternalConnectionRemoveCommand extends GraphCommand { } } -export default new SearchExternalConnectionRemoveCommand(); \ No newline at end of file +export default new ExternalConnectionRemoveCommand(); \ No newline at end of file diff --git a/src/m365/search/commands/externalconnection/externalconnection-schema-add.spec.ts b/src/m365/external/commands/connection/connection-schema-add.spec.ts similarity index 94% rename from src/m365/search/commands/externalconnection/externalconnection-schema-add.spec.ts rename to src/m365/external/commands/connection/connection-schema-add.spec.ts index 6fecce943bb..5ef6538fa3e 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-schema-add.spec.ts +++ b/src/m365/external/commands/connection/connection-schema-add.spec.ts @@ -11,9 +11,9 @@ import { pid } from '../../../../utils/pid.js'; import { session } from '../../../../utils/session.js'; import { sinonUtil } from '../../../../utils/sinonUtil.js'; import commands from '../../commands.js'; -import command from './externalconnection-schema-add.js'; +import command from './connection-schema-add.js'; -describe(commands.EXTERNALCONNECTION_SCHEMA_ADD, () => { +describe(commands.CONNECTION_SCHEMA_ADD, () => { const externalConnectionId = 'TestConnectionForCLI'; const schema = '{"baseType": "microsoft.graph.externalItem","properties": [{"name": "ticketTitle","type": "String"}]}'; @@ -57,13 +57,18 @@ describe(commands.EXTERNALCONNECTION_SCHEMA_ADD, () => { }); it('has correct name', () => { - assert.strictEqual(command.name, commands.EXTERNALCONNECTION_SCHEMA_ADD); + assert.strictEqual(command.name, commands.CONNECTION_SCHEMA_ADD); }); it('has a description', () => { assert.notStrictEqual(command.description, null); }); + it('defines alias', () => { + const alias = command.alias(); + assert.notStrictEqual(typeof alias, 'undefined'); + }); + it('adds an external connection schema', async () => { sinon.stub(request, 'post').callsFake(async (opts: any) => { if (opts.url === `https://graph.microsoft.com/v1.0/external/connections/${externalConnectionId}/schema`) { diff --git a/src/m365/search/commands/externalconnection/externalconnection-schema-add.ts b/src/m365/external/commands/connection/connection-schema-add.ts similarity index 85% rename from src/m365/search/commands/externalconnection/externalconnection-schema-add.ts rename to src/m365/external/commands/connection/connection-schema-add.ts index c9ff3df7b3e..76ac8fff33b 100644 --- a/src/m365/search/commands/externalconnection/externalconnection-schema-add.ts +++ b/src/m365/external/commands/connection/connection-schema-add.ts @@ -2,6 +2,7 @@ import { Logger } from '../../../../cli/Logger.js'; import GlobalOptions from '../../../../GlobalOptions.js'; import request, { CliRequestOptions } from '../../../../request.js'; import GraphCommand from '../../../base/GraphCommand.js'; +import searchCommands from '../../commands.js'; import commands from '../../commands.js'; interface CommandArgs { @@ -13,7 +14,7 @@ interface Options extends GlobalOptions { schema: string; } -interface SearchExternalItem { +interface ExternalItem { baseType: string; properties: Property[]; } @@ -29,13 +30,17 @@ interface Property { type: string; } -class SearchExternalConnectionSchemaAddCommand extends GraphCommand { +class ExternalConnectionSchemaAddCommand extends GraphCommand { public get name(): string { - return commands.EXTERNALCONNECTION_SCHEMA_ADD; + return commands.CONNECTION_SCHEMA_ADD; } public get description(): string { - return 'This command allows the administrator to add a schema to a specific external connection for use in Microsoft Search.'; + return 'Allows the administrator to add a schema to a specific external connection'; + } + + public alias(): string[] | undefined { + return [searchCommands.EXTERNALCONNECTION_SCHEMA_ADD]; } constructor() { @@ -74,7 +79,7 @@ class SearchExternalConnectionSchemaAddCommand extends GraphCommand { return 'ID cannot begin with Microsoft'; } - const schemaObject: SearchExternalItem = JSON.parse(args.options.schema); + const schemaObject: ExternalItem = JSON.parse(args.options.schema); if (schemaObject.baseType === undefined || schemaObject.baseType !== 'microsoft.graph.externalItem') { return `The schema needs a required property 'baseType' with value 'microsoft.graph.externalItem'`; } @@ -111,4 +116,4 @@ class SearchExternalConnectionSchemaAddCommand extends GraphCommand { } } -export default new SearchExternalConnectionSchemaAddCommand(); \ No newline at end of file +export default new ExternalConnectionSchemaAddCommand(); \ No newline at end of file diff --git a/src/m365/search/commands.ts b/src/m365/search/commands.ts deleted file mode 100644 index 56d91d3dd0e..00000000000 --- a/src/m365/search/commands.ts +++ /dev/null @@ -1,9 +0,0 @@ -const prefix: string = 'search'; - -export default { - EXTERNALCONNECTION_ADD: `${prefix} externalconnection add`, - EXTERNALCONNECTION_GET: `${prefix} externalconnection get`, - EXTERNALCONNECTION_LIST: `${prefix} externalconnection list`, - EXTERNALCONNECTION_REMOVE: `${prefix} externalconnection remove`, - EXTERNALCONNECTION_SCHEMA_ADD: `${prefix} externalconnection schema add` -}; \ No newline at end of file From 19ce719431e22d1b33853acf9fa2b50138869e85 Mon Sep 17 00:00:00 2001 From: Nanddeep Nachan Date: Wed, 4 Oct 2023 15:07:34 +0000 Subject: [PATCH 2/4] sidebar --- docs/src/config/sidebars.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/config/sidebars.js b/docs/src/config/sidebars.js index 794ccc28f01..88b58bbc7d8 100644 --- a/docs/src/config/sidebars.js +++ b/docs/src/config/sidebars.js @@ -1643,27 +1643,27 @@ const sidebars = { { type: 'doc', label: 'connection add', - id: 'cmd/external/connection-add' + id: 'cmd/external/connection/connection-add' }, { type: 'doc', label: 'connection get', - id: 'cmd/external/connection-get' + id: 'cmd/external/connection/connection-get' }, { type: 'doc', label: 'connection list', - id: 'cmd/external/connection-list' + id: 'cmd/external/connection/connection-list' }, { type: 'doc', label: 'connection remove', - id: 'cmd/external/connection-remove' + id: 'cmd/external/connection/connection-remove' }, { type: 'doc', label: 'connection schema add', - id: 'cmd/external/connection-schema-add' + id: 'cmd/external/connection/connection-schema-add' } ] } From 276080d03641d5a8d1650b9a27ac438e6d8ca161 Mon Sep 17 00:00:00 2001 From: Nanddeep Nachan Date: Wed, 4 Oct 2023 15:29:38 +0000 Subject: [PATCH 3/4] release notes --- docs/docs/about/release-notes.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/docs/about/release-notes.mdx b/docs/docs/about/release-notes.mdx index 2bcd80fd011..c0feef5643a 100644 --- a/docs/docs/about/release-notes.mdx +++ b/docs/docs/about/release-notes.mdx @@ -85,6 +85,7 @@ sidebar_position: 4 - removed Node 16 workflow - aligned options and documentation power platform. [#5411](https://github.com/pnp/cli-microsoft365/issues/5411) - renamed option for 'spo user get'. [#5515](https://github.com/pnp/cli-microsoft365/issues/5515) +- renamed 'search externalconnection [verb]' commands to 'to external connection [verb]' [#5531](https://github.com/pnp/cli-microsoft365/issues/5531) ## [v6.11.0](https://github.com/pnp/cli-microsoft365/releases/tag/v6.11.0) @@ -713,10 +714,6 @@ sidebar_position: 4 - [purview retentionlabel remove](../cmd/purview/retentionlabel/retentionlabel-remove.mdx) - deletes a retention label [#4149](https://github.com/pnp/cli-microsoft365/issues/4149) - [purview retentionlabel set](../cmd/purview/retentionlabel/retentionlabel-set.mdx) - updates a retention label [#4148](https://github.com/pnp/cli-microsoft365/issues/4148) -**Search:** - -- [search externalconnection schema add](../cmd/search/externalconnection/externalconnection-schema-add.mdx) - adds a schema to a specific external connection [#3171](https://github.com/pnp/cli-microsoft365/issues/3171) - **SharePoint:** - [spo listitem retentionlabel remove](../cmd/spo/listitem/listitem-retentionlabel-remove.mdx) - clears the retention label from a list item [#4162](https://github.com/pnp/cli-microsoft365/issues/4162) From ad8d86c0b0f18f47258e2adbc7e8f01c1fa7a9b2 Mon Sep 17 00:00:00 2001 From: Nanddeep Nachan Date: Thu, 5 Oct 2023 09:24:46 +0000 Subject: [PATCH 4/4] review comments --- docs/docs/about/release-notes.mdx | 17 ++++---- docs/src/config/sidebars.js | 66 +++++++++++++++---------------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/docs/docs/about/release-notes.mdx b/docs/docs/about/release-notes.mdx index c0feef5643a..cf6c422d4d7 100644 --- a/docs/docs/about/release-notes.mdx +++ b/docs/docs/about/release-notes.mdx @@ -85,7 +85,6 @@ sidebar_position: 4 - removed Node 16 workflow - aligned options and documentation power platform. [#5411](https://github.com/pnp/cli-microsoft365/issues/5411) - renamed option for 'spo user get'. [#5515](https://github.com/pnp/cli-microsoft365/issues/5515) -- renamed 'search externalconnection [verb]' commands to 'to external connection [verb]' [#5531](https://github.com/pnp/cli-microsoft365/issues/5531) ## [v6.11.0](https://github.com/pnp/cli-microsoft365/releases/tag/v6.11.0) @@ -714,6 +713,10 @@ sidebar_position: 4 - [purview retentionlabel remove](../cmd/purview/retentionlabel/retentionlabel-remove.mdx) - deletes a retention label [#4149](https://github.com/pnp/cli-microsoft365/issues/4149) - [purview retentionlabel set](../cmd/purview/retentionlabel/retentionlabel-set.mdx) - updates a retention label [#4148](https://github.com/pnp/cli-microsoft365/issues/4148) +**Search:** + +- [search externalconnection schema add](../cmd/external/connection/connection-schema-add.mdx) - adds a schema to a specific external connection [#3171](https://github.com/pnp/cli-microsoft365/issues/3171) + **SharePoint:** - [spo listitem retentionlabel remove](../cmd/spo/listitem/listitem-retentionlabel-remove.mdx) - clears the retention label from a list item [#4162](https://github.com/pnp/cli-microsoft365/issues/4162) @@ -1044,7 +1047,7 @@ sidebar_position: 4 **Search:** -- [search externalConnections remove](../cmd/search/externalconnection/externalconnection-remove.mdx) - allows the administrator to remove a specific external connection used in Microsoft Search [#3170](https://github.com/pnp/cli-microsoft365/issues/3170) +- [search externalConnections remove](../cmd/external/connection/connection-remove.mdx) - allows the administrator to remove a specific external connection used in Microsoft Search [#3170](https://github.com/pnp/cli-microsoft365/issues/3170) ### Changes @@ -1087,7 +1090,7 @@ sidebar_position: 4 **Search:** -- [search externalconnection get](../cmd/search/externalconnection/externalconnection-get.mdx) - allows the administrator to get a specific external connection for use in Microsoft Search [#3169](https://github.com/pnp/cli-microsoft365/issues/3169) +- [search externalconnection get](../cmd/external/connection/connection-get.mdx) - allows the administrator to get a specific external connection for use in Microsoft Search [#3169](https://github.com/pnp/cli-microsoft365/issues/3169) **SharePoint:** @@ -1217,7 +1220,7 @@ sidebar_position: 4 **Search:** -- [search externalConnections list](../cmd/search/externalconnection/externalconnection-list.mdx) - lists external connections defined in Microsoft Search [#2790](https://github.com/pnp/cli-microsoft365/issues/2790) +- [search externalConnections list](../cmd/external/connection/connection-list.mdx) - lists external connections defined in Microsoft Search [#2790](https://github.com/pnp/cli-microsoft365/issues/2790) **Tenant:** @@ -1464,7 +1467,7 @@ sidebar_position: 4 **Microsoft Search:** -- [search externalconnection add](../cmd/search/externalconnection/externalconnection-add.mdx) - adds a new external connection to be defined for Microsoft Search [#2662](https://github.com/pnp/cli-microsoft365/issues/2662) +- [search externalconnection add](../cmd/external/connection/connection-add.mdx) - adds a new external connection to be defined for Microsoft Search [#2662](https://github.com/pnp/cli-microsoft365/issues/2662) **Planner:** @@ -2563,7 +2566,7 @@ sidebar_position: 4 **SharePoint Online:** -- [spo apppage set](../cmd/spo/apppage/apppage-set.mdx) - updates the single-part app page [#875](https://github.com/pnp/cli-microsoft365/issues/875) +- [spo apppage set](../cmd/spo/apppage/apppage-set.mdx) - updates the single-part app page [#875](https://github.com/pnp/cli-microsoft365/issues/875) - [spo feature enable](../cmd/spo/feature/feature-enable.mdx) - enables feature for the specified site or web [#675](https://github.com/pnp/cli-microsoft365/issues/675) **Microsoft Teams:** @@ -3406,4 +3409,4 @@ Initial release. - [spo storageentity get](../cmd/spo/storageentity/storageentity-get.mdx) - get value of a tenant property - [spo storageentity list](../cmd/spo/storageentity/storageentity-list.mdx) - list all tenant properties - [spo storageentity remove](../cmd/spo/storageentity/storageentity-remove.mdx) - remove a tenant property -- [spo storageentity set](../cmd/spo/storageentity/storageentity-set.mdx) - set a tenant property +- [spo storageentity set](../cmd/spo/storageentity/storageentity-set.mdx) - set a tenant property \ No newline at end of file diff --git a/docs/src/config/sidebars.js b/docs/src/config/sidebars.js index 88b58bbc7d8..eeef8797701 100644 --- a/docs/src/config/sidebars.js +++ b/docs/src/config/sidebars.js @@ -573,6 +573,39 @@ const sidebars = { } ] }, + { + 'External (external)': [ + { + connection: [ + { + type: 'doc', + label: 'connection add', + id: 'cmd/external/connection/connection-add' + }, + { + type: 'doc', + label: 'connection get', + id: 'cmd/external/connection/connection-get' + }, + { + type: 'doc', + label: 'connection list', + id: 'cmd/external/connection/connection-list' + }, + { + type: 'doc', + label: 'connection remove', + id: 'cmd/external/connection/connection-remove' + }, + { + type: 'doc', + label: 'connection schema add', + id: 'cmd/external/connection/connection-schema-add' + } + ] + } + ] + }, { 'File (file)': [ { @@ -1636,39 +1669,6 @@ const sidebars = { } ] }, - { - 'External (external)': [ - { - connection: [ - { - type: 'doc', - label: 'connection add', - id: 'cmd/external/connection/connection-add' - }, - { - type: 'doc', - label: 'connection get', - id: 'cmd/external/connection/connection-get' - }, - { - type: 'doc', - label: 'connection list', - id: 'cmd/external/connection/connection-list' - }, - { - type: 'doc', - label: 'connection remove', - id: 'cmd/external/connection/connection-remove' - }, - { - type: 'doc', - label: 'connection schema add', - id: 'cmd/external/connection/connection-schema-add' - } - ] - } - ] - }, { 'Skype (skype)': [ {