New command: spo file archive. Closes #7175#7192
New command: spo file archive. Closes #7175#7192Saurabh7019 wants to merge 1 commit intopnp:mainfrom
Conversation
|
Awesome work @Saurabh7019! We'll try to check it ASAP. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new SharePoint Online command (m365 spo file archive) to archive a file (by server-relative URL or UniqueId), including documentation, command constant wiring, Dev Proxy API spec updates, and a full unit test suite.
Changes:
- Added
spo file archivecommand implementation with Zod-based option parsing and confirmation prompt support. - Added Mocha tests covering validation, confirmation flow, success paths (by URL / by ID), and error handling.
- Updated docs navigation + new command reference page, and extended the Dev Proxy SharePoint API spec.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/m365/spo/commands/file/file-archive.ts |
Implements the new spo file archive command and SharePoint REST interactions to resolve list/item and call Archive. |
src/m365/spo/commands/file/file-archive.spec.ts |
Adds unit tests for option validation, prompting behavior, success cases, and error handling. |
src/m365/spo/commands.ts |
Registers the command name constant FILE_ARCHIVE. |
docs/src/config/sidebars.ts |
Adds the command doc to the SPO “file” commands sidebar. |
docs/docs/cmd/spo/file/file-archive.mdx |
Adds end-user documentation for the new command, including examples and sample output. |
.devproxy/api-specs/sharepoint.yaml |
Adds Dev Proxy spec entries for Archive and GetFileByServerRelativePath. |
| let options: string = '?$select=ListId&$expand=ListItemAllFields'; | ||
|
|
||
| if (url) { | ||
| const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url); | ||
| options += `&@f='${formatting.encodeQueryParameter(serverRelativePath)}'`; | ||
| } | ||
|
|
||
| const fileInfo = await request.get<{ ListId: string; ListItemAllFields: { Id: number } }>({ | ||
| url: requestUrl + options, |
There was a problem hiding this comment.
The local variable options (query string) is easy to confuse with the module-level exported options Zod schema. Rename this local variable to something more specific (for example, query/queryString) to improve readability and avoid accidental misuse during future edits.
| let options: string = '?$select=ListId&$expand=ListItemAllFields'; | |
| if (url) { | |
| const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url); | |
| options += `&@f='${formatting.encodeQueryParameter(serverRelativePath)}'`; | |
| } | |
| const fileInfo = await request.get<{ ListId: string; ListItemAllFields: { Id: number } }>({ | |
| url: requestUrl + options, | |
| let queryString: string = '?$select=ListId&$expand=ListItemAllFields'; | |
| if (url) { | |
| const serverRelativePath = urlUtil.getServerRelativePath(webUrl, url); | |
| queryString += `&@f='${formatting.encodeQueryParameter(serverRelativePath)}'`; | |
| } | |
| const fileInfo = await request.get<{ ListId: string; ListItemAllFields: { Id: number } }>({ | |
| url: requestUrl + queryString, |
| in: query | ||
| required: true | ||
| description: URL-encoded server-relative path to the file (via @f parameter) |
There was a problem hiding this comment.
This OpenAPI path defines {filePath} as a path parameter (it appears in the URL template) but the parameter is declared in: query. This makes the spec invalid/inconsistent for tooling. Define filePath as in: path (consistent with the existing .../$value endpoint below), or change the path template to use DecodedUrl=@f and declare the corresponding query parameter instead.
| in: query | |
| required: true | |
| description: URL-encoded server-relative path to the file (via @f parameter) | |
| in: path | |
| required: true | |
| description: URL-encoded server-relative path to the file |
Closes #7175