Enhancement: Extract commonly used functions into a shared file in page commands
Hi, I have noticed that some functions are duplicated in page commands. The idea is to analyze them and extract them into a shared file, like Page.ts.
Here are the functions I have found so far.
_api/site?$select=Id used in
contenttype-add contenttype-field-remove contenttype field-set contenttype-set page-header-set site-admin-add
_api/web?$select=Id used in
contenttype-add contenttype-field-remove contenttype field-set contenttype-set page-header-set site-admin-add
/checkoutpage used in
page-clientsidewebpart-add page-header-set page-section-add
@mkm17 awesome suggestion 👍. Just to clarify before I open it up. So your idea is to create separate util methods for those functions and just reuse them in the commands you mentioned? If so do you think we could add links to those price functions to make it super clear what we want to get rid off and replace with a new util method?
@Adam-it Yes, the aim is to reduce duplication, as some functions are already exported to the "util" file named Page.ts. I will compile a list of links to certain files.
@Adam-it Yes, the aim is to reduce duplication, as some functions are already exported to the "util" file named Page.ts. I will compile a list of links to certain files.
Thanks for the confirmation. I will open it up. In the mean time we may add those links to make this super clear
Hi @Adam-it , you was right, GetSiteId, GetWebId and GetListId can be exported to spo.ts. In spo.ts there is already the getSiteId function but it is using Ms Graph endpoint.
**_api/site?$select=Id
_api/site?$select=Id used in
contenttype-add contenttype-field-remove contenttype field-set contenttype-set page-header-set site-admin-add
_api/web?$select=Id used in
contenttype-add contenttype-field-remove contenttype field-set contenttype-set page-header-set
getListId contenttype-add contenttype-field-remove contenttype-set listitem-batch-set
And this function from page.ts can be used for /checkoutpage which is used in
Hi @Adam-it what do you think, can I make this change?
Hi @Adam-it what do you think, can I make this change?
Totally 👍 Thank you for the ping. I was a bit busy in other projects and I haven't notice this notify before. Sorry for that 🙏 You Rock 🤩