Skip to content

Conversation

@Ateina
Copy link

@Ateina Ateina commented Oct 2, 2025

Closes #6535

@Adam-it
Copy link
Member

Adam-it commented Oct 2, 2025

Thank you for opening the PR 👏
We will review it ASAP

@Adam-it Adam-it self-assigned this Oct 23, 2025
@Adam-it Adam-it requested a review from Copilot October 24, 2025 13:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new command spo list defaultvalue get to retrieve a specific default column value from a SharePoint document library. The command supports retrieval by list ID, title, or URL, and can optionally filter by folder location.

Key Changes:

  • Added new command to retrieve default column values from a document library
  • Implemented XML parsing for SharePoint's client_LocationBasedDefaults.html file
  • Added comprehensive test coverage with multiple scenarios including error handling

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/list/list-defaultvalue-get.ts Core command implementation with XML parsing and API integration
src/m365/spo/commands/list/list-defaultvalue-get.spec.ts Comprehensive test suite covering all command scenarios
src/m365/spo/commands.ts Command registration in the commands list
docs/src/config/sidebars.ts Documentation navigation entry
docs/docs/cmd/spo/list/list-defaultvalue-get.mdx User-facing command documentation
.devproxy/api-specs/sharepoint.yaml API endpoint specifications for dev proxy

interface DefaultColumnValue {
fieldName: string;
fieldValue: string;
folderUrl: string
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon at the end of the property declaration.

Suggested change
folderUrl: string
folderUrl: string;

Copilot uses AI. Check for mistakes.
headers: {
accept: 'application/json;odata=nometadata'
},
responseType: 'json'
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responseType is set to 'json' (line 152) but the endpoint returns XML content. This will cause the response to be incorrectly parsed. Change responseType to 'text' since the content is XML.

Suggested change
responseType: 'json'
responseType: 'text'

Copilot uses AI. Check for mistakes.
Copy link
Member

@Adam-it Adam-it left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅Tested locally works perfectly
@Ateina amaizing work 😍
I don't have much to add. I only added two comments which will improve the reusability of our codebase. Please consider them before we proceed.
Copilot also noticed some minor things we could fixup.
Other than that seems very solid 👍
You Rock 🤩

return defaultValuesXml;
}

private convertXmlToJson(xml: string): DefaultColumnValue[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar method is already present in defaultvalue list command

private convertXmlToJson(xml: string): DefaultColumnValue[] {
const results: DefaultColumnValue[] = [];
const parser = new DOMParser();
const doc = parser.parseFromString(xml, 'application/xml');
const folderLinks = doc.getElementsByTagName('a');
for (let i = 0; i < folderLinks.length; i++) {
const folderUrl = folderLinks[i].getAttribute('href')!;
const defaultValues = folderLinks[i].getElementsByTagName('DefaultValue');
for (let j = 0; j < defaultValues.length; j++) {
const fieldName = defaultValues[j].getAttribute('FieldName')!;
const fieldValue = defaultValues[j].textContent!;
results.push({
fieldName: fieldName,
fieldValue: fieldValue,
folderUrl: decodeURIComponent(folderUrl)
});
}
}
return results;
}

I suggest we extract those and move as a new uti method to utils/formatting.ts to avoid code duplicates and improve our codebase a little

import request, { CliRequestOptions } from '../../../../request.js';
import { formatting } from '../../../../utils/formatting.js';

interface DefaultColumnValue {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in this case we already have similar interface here

interface DefaultColumnValue {
fieldName: string;
fieldValue: string;
folderUrl: string
}

lets extract this model interface to a separate file and reuse in both places 👍

@Adam-it Adam-it marked this pull request as draft October 24, 2025 22:51
@Adam-it Adam-it added the hacktoberfest-accepted Accept for hacktoberfest, will merge later label Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Accept for hacktoberfest, will merge later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New command: spo list defaultvalue get

2 participants