UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

60 lines 2.86 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _SpoNavigationNodeGetCommand_instances, _SpoNavigationNodeGetCommand_initOptions, _SpoNavigationNodeGetCommand_initValidators; import request from '../../../../request.js'; import { validation } from '../../../../utils/validation.js'; import SpoCommand from '../../../base/SpoCommand.js'; import commands from '../../commands.js'; class SpoNavigationNodeGetCommand extends SpoCommand { get name() { return commands.NAVIGATION_NODE_GET; } get description() { return 'Retrieve information about a specific navigation node'; } constructor() { super(); _SpoNavigationNodeGetCommand_instances.add(this); __classPrivateFieldGet(this, _SpoNavigationNodeGetCommand_instances, "m", _SpoNavigationNodeGetCommand_initOptions).call(this); __classPrivateFieldGet(this, _SpoNavigationNodeGetCommand_instances, "m", _SpoNavigationNodeGetCommand_initValidators).call(this); } async commandAction(logger, args) { if (this.verbose) { await logger.logToStderr(`Retrieving information about navigation node with id ${args.options.id}`); } const requestOptions = { url: `${args.options.webUrl}/_api/web/navigation/GetNodeById(${args.options.id})`, headers: { 'accept': 'application/json;odata=nometadata' }, responseType: 'json' }; try { const listInstance = await request.get(requestOptions); await logger.log(listInstance); } catch (err) { this.handleRejectedODataJsonPromise(err); } } } _SpoNavigationNodeGetCommand_instances = new WeakSet(), _SpoNavigationNodeGetCommand_initOptions = function _SpoNavigationNodeGetCommand_initOptions() { this.options.unshift({ option: '-u, --webUrl <webUrl>' }, { option: '--id <id>' }); }, _SpoNavigationNodeGetCommand_initValidators = function _SpoNavigationNodeGetCommand_initValidators() { this.validators.push(async (args) => { const id = parseInt(args.options.id); if (isNaN(id)) { return `${args.options.id} is not a valid number`; } return validation.isValidSharePointUrl(args.options.webUrl); }); }; export default new SpoNavigationNodeGetCommand(); //# sourceMappingURL=navigation-node-get.js.map