diff --git a/src/m365/spo/commands/file/file-add.ts b/src/m365/spo/commands/file/file-add.ts index 3ce47d62a5e..4c3810ba898 100644 --- a/src/m365/spo/commands/file/file-add.ts +++ b/src/m365/spo/commands/file/file-add.ts @@ -81,18 +81,19 @@ class SpoFileAddCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { this.telemetry.push((args: CommandArgs) => { Object.assign(this.telemetryProperties, { - contentType: (!(!args.options.contentType)).toString(), - checkOut: args.options.checkOut || false, - checkInComment: (!(!args.options.checkInComment)).toString(), - approve: args.options.approve || false, - approveComment: (!(!args.options.approveComment)).toString(), - publish: args.options.publish || false, - publishComment: (!(!args.options.publishComment)).toString() + contentType: typeof args.options.contentType !== 'undefined', + checkOut: !!args.options.checkOut, + checkInComment: typeof args.options.checkInComment !== 'undefined', + approve: !!args.options.approve, + approveComment: typeof args.options.approveComment !== 'undefined', + publish: !!args.options.publish, + publishComment: typeof args.options.publishComment !== 'undefined' }); }); } @@ -157,6 +158,11 @@ class SpoFileAddCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folder', 'path', 'contentType', 'checkInComment', 'approveComment', 'publishComment'); + this.types.boolean.push('checkOut', 'approve', 'publish'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const folderPath: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folder); const fullPath: string = path.resolve(args.options.path); diff --git a/src/m365/spo/commands/file/file-checkin.ts b/src/m365/spo/commands/file/file-checkin.ts index 86daacc49b1..4792021c570 100644 --- a/src/m365/spo/commands/file/file-checkin.ts +++ b/src/m365/spo/commands/file/file-checkin.ts @@ -41,6 +41,7 @@ class SpoFileCheckinCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -110,6 +111,10 @@ class SpoFileCheckinCommand extends SpoCommand { this.optionSets.push({ options: ['url', 'id'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'url', 'id', 'type', 'comment'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/file/file-checkout-undo.ts b/src/m365/spo/commands/file/file-checkout-undo.ts index 1582677fd59..c6221e205eb 100644 --- a/src/m365/spo/commands/file/file-checkout-undo.ts +++ b/src/m365/spo/commands/file/file-checkout-undo.ts @@ -35,6 +35,7 @@ class SpoFileCheckoutUndoCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -85,6 +86,11 @@ class SpoFileCheckoutUndoCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const undoCheckout = async (): Promise => { try { diff --git a/src/m365/spo/commands/file/file-checkout.ts b/src/m365/spo/commands/file/file-checkout.ts index 6c4b610b599..2016bfbc5c5 100644 --- a/src/m365/spo/commands/file/file-checkout.ts +++ b/src/m365/spo/commands/file/file-checkout.ts @@ -33,6 +33,7 @@ class SpoFileCheckoutCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -81,6 +82,10 @@ class SpoFileCheckoutCommand extends SpoCommand { this.optionSets.push({ options: ['id', 'url'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'url', 'id',); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/file/file-copy.ts b/src/m365/spo/commands/file/file-copy.ts index 31d0abe196d..b386b45f8e2 100644 --- a/src/m365/spo/commands/file/file-copy.ts +++ b/src/m365/spo/commands/file/file-copy.ts @@ -37,6 +37,7 @@ class SpoFileCopyCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -108,6 +109,11 @@ class SpoFileCopyCommand extends SpoCommand { this.optionSets.push({ options: ['sourceUrl', 'sourceId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior'); + this.types.boolean.push('resetAuthorAndCreated', 'bypassSharedLock'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { try { const sourceServerRelativePath = await this.getSourcePath(logger, args.options); diff --git a/src/m365/spo/commands/file/file-get.ts b/src/m365/spo/commands/file/file-get.ts index 3ffdc25c250..34aab34d22b 100644 --- a/src/m365/spo/commands/file/file-get.ts +++ b/src/m365/spo/commands/file/file-get.ts @@ -41,6 +41,7 @@ class SpoFileGetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -129,6 +130,11 @@ class SpoFileGetCommand extends SpoCommand { this.optionSets.push({ options: ['id', 'url'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'url', 'id', 'path'); + this.types.boolean.push('asString', 'asListItem', 'asFile', 'withPermissions'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/file/file-list.ts b/src/m365/spo/commands/file/file-list.ts index 369856f03f3..436acd82f56 100644 --- a/src/m365/spo/commands/file/file-list.ts +++ b/src/m365/spo/commands/file/file-list.ts @@ -42,6 +42,7 @@ class SpoFileListCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -80,6 +81,11 @@ class SpoFileListCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl', 'fields', 'filter'); + this.types.boolean.push('recursive'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Retrieving all files in folder '${args.options.folderUrl}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`); diff --git a/src/m365/spo/commands/file/file-move.ts b/src/m365/spo/commands/file/file-move.ts index 6d517762b02..8dbdebdbcc8 100644 --- a/src/m365/spo/commands/file/file-move.ts +++ b/src/m365/spo/commands/file/file-move.ts @@ -39,6 +39,7 @@ class SpoFileMoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -109,6 +110,11 @@ class SpoFileMoveCommand extends SpoCommand { this.optionSets.push({ options: ['sourceUrl', 'sourceId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior'); + this.types.boolean.push('retainEditorAndModified', 'bypassSharedLock'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['targetUrl', 'sourceUrl']; } diff --git a/src/m365/spo/commands/file/file-remove.ts b/src/m365/spo/commands/file/file-remove.ts index a0bca6d6621..5a1c883f4b4 100644 --- a/src/m365/spo/commands/file/file-remove.ts +++ b/src/m365/spo/commands/file/file-remove.ts @@ -40,6 +40,7 @@ class SpoFileRemoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -95,6 +96,11 @@ class SpoFileRemoveCommand extends SpoCommand { this.optionSets.push({ options: ['id', 'url'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'id', 'url'); + this.types.boolean.push('recycle', 'force'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/file/file-rename.ts b/src/m365/spo/commands/file/file-rename.ts index b6ce2e57c50..17b36efa05a 100644 --- a/src/m365/spo/commands/file/file-rename.ts +++ b/src/m365/spo/commands/file/file-rename.ts @@ -50,6 +50,7 @@ class SpoFileRenameCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -83,6 +84,11 @@ class SpoFileRenameCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'sourceUrl', 'targetFileName'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const webUrl = args.options.webUrl; const originalFileServerRelativePath: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.sourceUrl); diff --git a/src/m365/spo/commands/file/file-retentionlabel-ensure.ts b/src/m365/spo/commands/file/file-retentionlabel-ensure.ts index eeeadb9a8d4..95a6d9f622d 100644 --- a/src/m365/spo/commands/file/file-retentionlabel-ensure.ts +++ b/src/m365/spo/commands/file/file-retentionlabel-ensure.ts @@ -38,6 +38,7 @@ class SpoFileRetentionLabelEnsureCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -92,6 +93,10 @@ class SpoFileRetentionLabelEnsureCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'name', 'fileUrl', 'fileId', 'assetId'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { try { const fileProperties = await this.getFileProperties(logger, args); diff --git a/src/m365/spo/commands/file/file-retentionlabel-remove.ts b/src/m365/spo/commands/file/file-retentionlabel-remove.ts index dd184c6b91c..9886427e18f 100644 --- a/src/m365/spo/commands/file/file-retentionlabel-remove.ts +++ b/src/m365/spo/commands/file/file-retentionlabel-remove.ts @@ -38,6 +38,7 @@ class SpoFileRetentionLabelRemoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -89,6 +90,11 @@ class SpoFileRetentionLabelRemoveCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (args.options.force) { await this.removeFileRetentionLabel(logger, args); diff --git a/src/m365/spo/commands/file/file-roleassignment-add.ts b/src/m365/spo/commands/file/file-roleassignment-add.ts index 6820a8bda40..75eaa063309 100644 --- a/src/m365/spo/commands/file/file-roleassignment-add.ts +++ b/src/m365/spo/commands/file/file-roleassignment-add.ts @@ -45,6 +45,7 @@ class SpoFileRoleAssignmentAddCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -123,6 +124,10 @@ class SpoFileRoleAssignmentAddCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId', 'upn', 'groupName', 'roleDefinitionName'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Adding role assignment to file in site at ${args.options.webUrl}...`); diff --git a/src/m365/spo/commands/file/file-roleassignment-remove.ts b/src/m365/spo/commands/file/file-roleassignment-remove.ts index cfc52e3c515..8538a6b694c 100644 --- a/src/m365/spo/commands/file/file-roleassignment-remove.ts +++ b/src/m365/spo/commands/file/file-roleassignment-remove.ts @@ -42,6 +42,7 @@ class SpoFileRoleAssignmentRemoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -111,6 +112,11 @@ class SpoFileRoleAssignmentRemoveCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId', 'upn', 'groupName'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const removeRoleAssignment = async (): Promise => { if (this.verbose) { diff --git a/src/m365/spo/commands/file/file-roleinheritance-break.ts b/src/m365/spo/commands/file/file-roleinheritance-break.ts index 7f74f2b05bb..171df47cb04 100644 --- a/src/m365/spo/commands/file/file-roleinheritance-break.ts +++ b/src/m365/spo/commands/file/file-roleinheritance-break.ts @@ -38,6 +38,7 @@ class SpoFileRoleInheritanceBreakCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -92,6 +93,11 @@ class SpoFileRoleInheritanceBreakCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + this.types.boolean.push('clearExistingPermissions', 'force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const breakFileRoleInheritance = async (): Promise => { if (this.verbose) { diff --git a/src/m365/spo/commands/file/file-roleinheritance-reset.ts b/src/m365/spo/commands/file/file-roleinheritance-reset.ts index 065c9f95ffc..9f88bf55de6 100644 --- a/src/m365/spo/commands/file/file-roleinheritance-reset.ts +++ b/src/m365/spo/commands/file/file-roleinheritance-reset.ts @@ -37,6 +37,7 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -87,6 +88,11 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const resetFileRoleInheritance = async (): Promise => { if (this.verbose) { diff --git a/src/m365/spo/commands/file/file-sharinginfo-get.ts b/src/m365/spo/commands/file/file-sharinginfo-get.ts index 2b2eb84086c..9451f3a6d21 100644 --- a/src/m365/spo/commands/file/file-sharinginfo-get.ts +++ b/src/m365/spo/commands/file/file-sharinginfo-get.ts @@ -64,13 +64,14 @@ class SpoFileSharingInfoGetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { this.telemetry.push((args: CommandArgs) => { Object.assign(this.telemetryProperties, { - fileId: (!(!args.options.fileId)).toString(), - fileUrl: (!(!args.options.fileUrl)).toString() + fileId: typeof args.options.fileId !== 'undefined', + fileUrl: typeof args.options.fileUrl !== 'undefined' }); }); } @@ -112,6 +113,10 @@ class SpoFileSharingInfoGetCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileId', 'fileUrl'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['fileUrl']; } diff --git a/src/m365/spo/commands/file/file-sharinglink-add.ts b/src/m365/spo/commands/file/file-sharinglink-add.ts index c6395612b6c..69f57f8998e 100644 --- a/src/m365/spo/commands/file/file-sharinglink-add.ts +++ b/src/m365/spo/commands/file/file-sharinglink-add.ts @@ -38,6 +38,7 @@ class SpoFileSharingLinkAddCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -114,6 +115,10 @@ class SpoFileSharingLinkAddCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileId', 'fileUrl', 'type', 'expirationDateTime', 'scope'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Creating a sharing link for file ${args.options.fileId || args.options.fileUrl}...`); diff --git a/src/m365/spo/commands/file/file-sharinglink-clear.ts b/src/m365/spo/commands/file/file-sharinglink-clear.ts index 7f25b5ad31f..8e969aa4256 100644 --- a/src/m365/spo/commands/file/file-sharinglink-clear.ts +++ b/src/m365/spo/commands/file/file-sharinglink-clear.ts @@ -39,6 +39,7 @@ class SpoFileSharingLinkClearCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -98,6 +99,11 @@ class SpoFileSharingLinkClearCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId', 'scope'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const clearSharingLinks: () => Promise = async (): Promise => { try { diff --git a/src/m365/spo/commands/file/file-sharinglink-get.ts b/src/m365/spo/commands/file/file-sharinglink-get.ts index 2d597f11e85..41f214512ea 100644 --- a/src/m365/spo/commands/file/file-sharinglink-get.ts +++ b/src/m365/spo/commands/file/file-sharinglink-get.ts @@ -33,6 +33,7 @@ class SpoFileSharingLinkGetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -82,6 +83,10 @@ class SpoFileSharingLinkGetCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId', 'id'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Retrieving sharing link for file ${args.options.fileUrl || args.options.fileId} with id ${args.options.id}...`); diff --git a/src/m365/spo/commands/file/file-sharinglink-list.ts b/src/m365/spo/commands/file/file-sharinglink-list.ts index 34577582b02..031fa29dc80 100644 --- a/src/m365/spo/commands/file/file-sharinglink-list.ts +++ b/src/m365/spo/commands/file/file-sharinglink-list.ts @@ -40,6 +40,7 @@ class SpoFileSharingLinkListCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -95,6 +96,10 @@ class SpoFileSharingLinkListCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileId', 'fileUrl', 'scope'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Retrieving sharing links for file ${args.options.fileId || args.options.fileUrl}...`); diff --git a/src/m365/spo/commands/file/file-sharinglink-remove.ts b/src/m365/spo/commands/file/file-sharinglink-remove.ts index 5d596789719..4190b81f860 100644 --- a/src/m365/spo/commands/file/file-sharinglink-remove.ts +++ b/src/m365/spo/commands/file/file-sharinglink-remove.ts @@ -16,7 +16,7 @@ interface Options extends GlobalOptions { fileUrl?: string; fileId?: string; id: string; - force?: boolean + force?: boolean; } class SpoFileSharingLinkRemoveCommand extends SpoCommand { @@ -35,6 +35,7 @@ class SpoFileSharingLinkRemoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -88,6 +89,11 @@ class SpoFileSharingLinkRemoveCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId', 'id'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const removeSharingLink = async (): Promise => { try { diff --git a/src/m365/spo/commands/file/file-sharinglink-set.ts b/src/m365/spo/commands/file/file-sharinglink-set.ts index d1d0288236f..d94b5de5dd0 100644 --- a/src/m365/spo/commands/file/file-sharinglink-set.ts +++ b/src/m365/spo/commands/file/file-sharinglink-set.ts @@ -34,6 +34,7 @@ class SpoFileSharingLinkSetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -94,6 +95,10 @@ class SpoFileSharingLinkSetCommand extends SpoCommand { this.optionSets.push({ options: ['fileId', 'fileUrl'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'id', 'fileId', 'fileUrl', 'expirationDateTime'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Updating sharing link of file ${args.options.fileId || args.options.fileUrl}...`); diff --git a/src/m365/spo/commands/file/file-version-clear.ts b/src/m365/spo/commands/file/file-version-clear.ts index e397e499a8e..fb7b765f440 100644 --- a/src/m365/spo/commands/file/file-version-clear.ts +++ b/src/m365/spo/commands/file/file-version-clear.ts @@ -35,6 +35,7 @@ class SpoFileVersionClearCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -42,7 +43,7 @@ class SpoFileVersionClearCommand extends SpoCommand { Object.assign(this.telemetryProperties, { fileUrl: args.options.fileUrl, fileId: args.options.fileId, - force: (!!args.options.force).toString() + force: !!args.options.force }); }); } @@ -80,6 +81,11 @@ class SpoFileVersionClearCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Deletes all version history of the file ${args.options.fileUrl || args.options.fileId} at site ${args.options.webUrl}...`); diff --git a/src/m365/spo/commands/file/file-version-get.ts b/src/m365/spo/commands/file/file-version-get.ts index b90f9b41061..2499a6916c6 100644 --- a/src/m365/spo/commands/file/file-version-get.ts +++ b/src/m365/spo/commands/file/file-version-get.ts @@ -80,7 +80,7 @@ class SpoFileVersionGetCommand extends SpoCommand { } #initTypes(): void { - this.types.string.push('label'); + this.types.string.push('webUrl', 'label', 'fileUrl', 'fileId'); } public async commandAction(logger: Logger, args: CommandArgs): Promise { diff --git a/src/m365/spo/commands/file/file-version-list.ts b/src/m365/spo/commands/file/file-version-list.ts index 271bb21df19..f929962d7b2 100644 --- a/src/m365/spo/commands/file/file-version-list.ts +++ b/src/m365/spo/commands/file/file-version-list.ts @@ -37,6 +37,7 @@ class SpoFileVersionListCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -78,6 +79,10 @@ class SpoFileVersionListCommand extends SpoCommand { this.optionSets.push({ options: ['fileUrl', 'fileId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'fileUrl', 'fileId'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Retrieving all versions of file ${args.options.fileUrl || args.options.fileId} at site ${args.options.webUrl}...`); diff --git a/src/m365/spo/commands/file/file-version-remove.ts b/src/m365/spo/commands/file/file-version-remove.ts index 405b276ff75..3c4e2d934e3 100644 --- a/src/m365/spo/commands/file/file-version-remove.ts +++ b/src/m365/spo/commands/file/file-version-remove.ts @@ -86,7 +86,8 @@ class SpoFileVersionRemoveCommand extends SpoCommand { } #initTypes(): void { - this.types.string.push('label'); + this.types.string.push('webUrl', 'label', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); } public async commandAction(logger: Logger, args: CommandArgs): Promise { diff --git a/src/m365/spo/commands/file/file-version-restore.ts b/src/m365/spo/commands/file/file-version-restore.ts index f3281970716..8fbec0f79e8 100644 --- a/src/m365/spo/commands/file/file-version-restore.ts +++ b/src/m365/spo/commands/file/file-version-restore.ts @@ -86,7 +86,8 @@ class SpoFileVersionRestoreCommand extends SpoCommand { } #initTypes(): void { - this.types.string.push('label'); + this.types.string.push('webUrl', 'label', 'fileUrl', 'fileId'); + this.types.boolean.push('force'); } public async commandAction(logger: Logger, args: CommandArgs): Promise { diff --git a/src/m365/spo/commands/folder/folder-add.ts b/src/m365/spo/commands/folder/folder-add.ts index 3cf495e8e78..1fe579cf7e0 100644 --- a/src/m365/spo/commands/folder/folder-add.ts +++ b/src/m365/spo/commands/folder/folder-add.ts @@ -32,6 +32,7 @@ class SpoFolderAddCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initOptions(): void { @@ -54,6 +55,10 @@ class SpoFolderAddCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'parentFolderUrl', 'name'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Adding folder to site ${args.options.webUrl}...`); diff --git a/src/m365/spo/commands/folder/folder-copy.ts b/src/m365/spo/commands/folder/folder-copy.ts index 0bf1e01f462..c1e082dcb75 100644 --- a/src/m365/spo/commands/folder/folder-copy.ts +++ b/src/m365/spo/commands/folder/folder-copy.ts @@ -39,6 +39,7 @@ class SpoFolderCopyCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -109,6 +110,11 @@ class SpoFolderCopyCommand extends SpoCommand { this.optionSets.push({ options: ['sourceUrl', 'sourceId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior'); + this.types.boolean.push('resetAuthorAndCreated', 'bypassSharedLock'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['targetUrl', 'sourceUrl']; } diff --git a/src/m365/spo/commands/folder/folder-get.ts b/src/m365/spo/commands/folder/folder-get.ts index 100cd18499f..b7584ee86ec 100644 --- a/src/m365/spo/commands/folder/folder-get.ts +++ b/src/m365/spo/commands/folder/folder-get.ts @@ -36,6 +36,7 @@ class SpoFolderGetCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -88,6 +89,10 @@ class SpoFolderGetCommand extends SpoCommand { this.optionSets.push({ options: ['url', 'id'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'url', 'id'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/folder/folder-list.ts b/src/m365/spo/commands/folder/folder-list.ts index d4c110b1330..b7beb73dc46 100644 --- a/src/m365/spo/commands/folder/folder-list.ts +++ b/src/m365/spo/commands/folder/folder-list.ts @@ -46,6 +46,7 @@ class SpoFolderListCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -73,7 +74,7 @@ class SpoFolderListCommand extends SpoCommand { option: '--filter [filter]' }, { - option: '-r, --recursive [recursive]' + option: '-r, --recursive' } ); } @@ -84,6 +85,11 @@ class SpoFolderListCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'parentFolderUrl', 'fields', 'filter'); + this.types.boolean.push('recursive'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Retrieving all folders in folder '${args.options.parentFolderUrl}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`); diff --git a/src/m365/spo/commands/folder/folder-move.ts b/src/m365/spo/commands/folder/folder-move.ts index a9025c434be..ec29e58a38a 100644 --- a/src/m365/spo/commands/folder/folder-move.ts +++ b/src/m365/spo/commands/folder/folder-move.ts @@ -39,6 +39,7 @@ class SpoFolderMoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -109,6 +110,11 @@ class SpoFolderMoveCommand extends SpoCommand { this.optionSets.push({ options: ['sourceUrl', 'sourceId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior'); + this.types.boolean.push('retainEditorAndModified', 'bypassSharedLock'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['targetUrl', 'sourceUrl']; } diff --git a/src/m365/spo/commands/folder/folder-remove.ts b/src/m365/spo/commands/folder/folder-remove.ts index 4f8b12a4e22..2f2d09bb77c 100644 --- a/src/m365/spo/commands/folder/folder-remove.ts +++ b/src/m365/spo/commands/folder/folder-remove.ts @@ -34,6 +34,7 @@ class SpoFolderRemoveCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -68,6 +69,11 @@ class SpoFolderRemoveCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'url'); + this.types.boolean.push('recycle', 'force'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/folder/folder-rename.ts b/src/m365/spo/commands/folder/folder-rename.ts index 1b9eec98d6e..5aecdaeec2a 100644 --- a/src/m365/spo/commands/folder/folder-rename.ts +++ b/src/m365/spo/commands/folder/folder-rename.ts @@ -32,6 +32,7 @@ class SpoFolderRenameCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initOptions(): void { @@ -54,6 +55,10 @@ class SpoFolderRenameCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'url', 'name'); + } + protected getExcludedOptionsWithUrls(): string[] | undefined { return ['url']; } diff --git a/src/m365/spo/commands/folder/folder-retentionlabel-ensure.ts b/src/m365/spo/commands/folder/folder-retentionlabel-ensure.ts index 32b87258e8d..165d3cf9f13 100644 --- a/src/m365/spo/commands/folder/folder-retentionlabel-ensure.ts +++ b/src/m365/spo/commands/folder/folder-retentionlabel-ensure.ts @@ -37,6 +37,7 @@ class SpoFolderRetentionLabelEnsureCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -87,6 +88,10 @@ class SpoFolderRetentionLabelEnsureCommand extends SpoCommand { this.optionSets.push({ options: ['folderUrl', 'folderId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'name', 'folderUrl', 'folderId'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { try { const folderProperties = await this.getFolderProperties(logger, args); diff --git a/src/m365/spo/commands/folder/folder-retentionlabel-remove.ts b/src/m365/spo/commands/folder/folder-retentionlabel-remove.ts index 656527f9f61..8120f97d890 100644 --- a/src/m365/spo/commands/folder/folder-retentionlabel-remove.ts +++ b/src/m365/spo/commands/folder/folder-retentionlabel-remove.ts @@ -38,6 +38,7 @@ class SpoFolderRetentionLabelRemoveCommand extends SpoCommand { this.#initOptions(); this.#initValidators(); this.#initOptionSets(); + this.#initTypes(); } #initTelemetry(): void { @@ -89,6 +90,11 @@ class SpoFolderRetentionLabelRemoveCommand extends SpoCommand { this.optionSets.push({ options: ['folderUrl', 'folderId'] }); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl', 'folderId'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (args.options.force) { await this.removeFolderRetentionLabel(logger, args); diff --git a/src/m365/spo/commands/folder/folder-roleassignment-add.ts b/src/m365/spo/commands/folder/folder-roleassignment-add.ts index 025b6207a97..a6efe8b1556 100644 --- a/src/m365/spo/commands/folder/folder-roleassignment-add.ts +++ b/src/m365/spo/commands/folder/folder-roleassignment-add.ts @@ -42,6 +42,7 @@ class SpoFolderRoleAssignmentAddCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -121,6 +122,10 @@ class SpoFolderRoleAssignmentAddCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl', 'upn', 'groupName', 'roleDefinitionName'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { if (this.verbose) { await logger.logToStderr(`Adding role assignment to folder in site at ${args.options.webUrl}...`); diff --git a/src/m365/spo/commands/folder/folder-roleassignment-remove.ts b/src/m365/spo/commands/folder/folder-roleassignment-remove.ts index 059e5119eb2..c72563b5aa7 100644 --- a/src/m365/spo/commands/folder/folder-roleassignment-remove.ts +++ b/src/m365/spo/commands/folder/folder-roleassignment-remove.ts @@ -39,6 +39,7 @@ class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -47,7 +48,7 @@ class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand { principalId: typeof args.options.principalId !== 'undefined', upn: typeof args.options.upn !== 'undefined', groupName: typeof args.options.groupName !== 'undefined', - force: (!(!args.options.force)).toString() + force: !!args.options.force }); }); } @@ -101,6 +102,11 @@ class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl', 'upn', 'groupName'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const removeRoleAssignment = async (): Promise => { if (this.verbose) { diff --git a/src/m365/spo/commands/folder/folder-roleinheritance-break.ts b/src/m365/spo/commands/folder/folder-roleinheritance-break.ts index 78acc3d60d7..d58a37f22b5 100644 --- a/src/m365/spo/commands/folder/folder-roleinheritance-break.ts +++ b/src/m365/spo/commands/folder/folder-roleinheritance-break.ts @@ -34,6 +34,7 @@ class SpoFolderRoleInheritanceBreakCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -68,6 +69,11 @@ class SpoFolderRoleInheritanceBreakCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl'); + this.types.boolean.push('clearExistingPermissions', 'force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const keepExistingPermissions: boolean = !args.options.clearExistingPermissions; const serverRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl); diff --git a/src/m365/spo/commands/folder/folder-roleinheritance-reset.ts b/src/m365/spo/commands/folder/folder-roleinheritance-reset.ts index 54a735b38ab..3b9deff36ba 100644 --- a/src/m365/spo/commands/folder/folder-roleinheritance-reset.ts +++ b/src/m365/spo/commands/folder/folder-roleinheritance-reset.ts @@ -33,6 +33,7 @@ class SpoFolderRoleInheritanceResetCommand extends SpoCommand { this.#initTelemetry(); this.#initOptions(); this.#initValidators(); + this.#initTypes(); } #initTelemetry(): void { @@ -63,6 +64,11 @@ class SpoFolderRoleInheritanceResetCommand extends SpoCommand { ); } + #initTypes(): void { + this.types.string.push('webUrl', 'folderUrl'); + this.types.boolean.push('force'); + } + public async commandAction(logger: Logger, args: CommandArgs): Promise { const serverRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl); const roleFolderUrl: string = urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl);