@pnp/cli-microsoft365 6.8.0-beta.f473be5 → 6.9.0-beta.289ab69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/.eslintrc.js +2 -0
  2. package/README.md +6 -1
  3. package/dist/Command.js +6 -0
  4. package/dist/chili/chili.js +298 -0
  5. package/dist/chili/index.js +20 -0
  6. package/dist/cli/Cli.js +2 -2
  7. package/dist/m365/aad/commands/user/user-add.js +30 -21
  8. package/dist/m365/app/commands/permission/permission-add.js +279 -0
  9. package/dist/m365/app/commands.js +1 -0
  10. package/dist/m365/commands/commands.js +2 -0
  11. package/dist/m365/commands/docs.js +42 -0
  12. package/dist/m365/commands/login.js +1 -1
  13. package/dist/m365/commands/setup.js +180 -0
  14. package/dist/m365/commands/setupPresets.js +25 -0
  15. package/dist/m365/pa/commands/app/app-consent-set.js +101 -0
  16. package/dist/m365/pa/commands.js +1 -0
  17. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-get.js +97 -0
  18. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-list.js +85 -0
  19. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-policysettings-list.js +89 -0
  20. package/dist/m365/purview/commands.js +3 -0
  21. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.17.2.js +25 -0
  22. package/dist/m365/spfx/commands/project/project-doctor/rules/FN001035_DEP_fluentui_react.js +18 -0
  23. package/dist/m365/spfx/commands/project/project-doctor/rules/FN021009_PKG_no_duplicate_oui_deps.js +11 -4
  24. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  25. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN001035_DEP_fluentui_react.js +18 -0
  26. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.2.js +2 -0
  27. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.17.2.js +61 -0
  28. package/dist/m365/spfx/commands/project/project-upgrade.js +2 -1
  29. package/dist/m365/spfx/commands/spfx-doctor.js +29 -30
  30. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-remove.js +146 -0
  31. package/dist/m365/spo/commands/file/file-list.js +15 -4
  32. package/dist/m365/spo/commands/file/file-remove.js +3 -0
  33. package/dist/m365/spo/commands/list/list-get.js +30 -3
  34. package/dist/m365/spo/commands/list/list-list.js +39 -2
  35. package/dist/m365/spo/commands/listitem/listitem-batch-set.js +308 -0
  36. package/dist/m365/spo/commands/page/page-section-add.js +2 -3
  37. package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +119 -0
  38. package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +106 -0
  39. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +30 -39
  40. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-list.js +47 -0
  41. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-remove.js +151 -0
  42. package/dist/m365/spo/commands/tenant/tenant-commandset-remove.js +152 -0
  43. package/dist/m365/spo/commands/tenant/tenant-commandset-set.js +203 -0
  44. package/dist/m365/spo/commands/term/term-add.js +13 -4
  45. package/dist/m365/spo/commands/term/term-get.js +14 -5
  46. package/dist/m365/spo/commands/term/term-group-get.js +12 -3
  47. package/dist/m365/spo/commands/term/term-group-list.js +39 -4
  48. package/dist/m365/spo/commands/term/term-list.js +18 -9
  49. package/dist/m365/spo/commands/term/term-set-add.js +13 -4
  50. package/dist/m365/spo/commands/term/term-set-get.js +12 -3
  51. package/dist/m365/spo/commands/term/term-set-list.js +12 -3
  52. package/dist/m365/spo/commands.js +9 -0
  53. package/dist/m365/teams/commands/chat/chat-member-remove.js +137 -0
  54. package/dist/m365/teams/commands.js +1 -0
  55. package/dist/utils/formatting.js +35 -11
  56. package/dist/utils/pid.js +5 -0
  57. package/docs/docs/cmd/aad/o365group/o365group-get.md +0 -12
  58. package/docs/docs/cmd/aad/user/user-add.md +4 -0
  59. package/docs/docs/cmd/aad/user/user-set.md +2 -2
  60. package/docs/docs/cmd/adaptivecard/adaptivecard-send.md +13 -13
  61. package/docs/docs/cmd/app/app-get.md +25 -6
  62. package/docs/docs/cmd/app/app-open.md +8 -2
  63. package/docs/docs/cmd/app/permission/permission-add.md +53 -0
  64. package/docs/docs/cmd/app/permission/permission-list.md +19 -19
  65. package/docs/docs/cmd/booking/business/business-get.md +30 -8
  66. package/docs/docs/cmd/booking/business/business-list.md +17 -8
  67. package/docs/docs/cmd/cli/cli-consent.md +6 -0
  68. package/docs/docs/cmd/cli/cli-doctor.md +17 -0
  69. package/docs/docs/cmd/cli/cli-issue.md +6 -0
  70. package/docs/docs/cmd/cli/cli-reconsent.md +6 -0
  71. package/docs/docs/cmd/cli/completion/completion-sh-setup.md +6 -0
  72. package/docs/docs/cmd/cli/config/config-get.md +6 -0
  73. package/docs/docs/cmd/docs.md +51 -0
  74. package/docs/docs/cmd/flow/environment/environment-list.md +18 -0
  75. package/docs/docs/cmd/flow/flow-get.md +20 -0
  76. package/docs/docs/cmd/flow/flow-list.md +17 -0
  77. package/docs/docs/cmd/graph/changelog/changelog-list.md +52 -0
  78. package/docs/docs/cmd/graph/schemaextension/schemaextension-add.md +61 -0
  79. package/docs/docs/cmd/graph/schemaextension/schemaextension-get.md +61 -0
  80. package/docs/docs/cmd/graph/schemaextension/schemaextension-list.md +61 -0
  81. package/docs/docs/cmd/graph/schemaextension/schemaextension-remove.md +4 -0
  82. package/docs/docs/cmd/graph/schemaextension/schemaextension-set.md +4 -0
  83. package/docs/docs/cmd/graph/subscription/subscription-add.md +73 -0
  84. package/docs/docs/cmd/login.md +1 -1
  85. package/docs/docs/cmd/onedrive/onedrive-list.md +225 -0
  86. package/docs/docs/cmd/onedrive/report/report-activityfilecounts.md +39 -0
  87. package/docs/docs/cmd/onedrive/report/report-activityusercounts.md +39 -0
  88. package/docs/docs/cmd/onedrive/report/report-activityuserdetail.md +43 -0
  89. package/docs/docs/cmd/onedrive/report/report-usageaccountcounts.md +38 -0
  90. package/docs/docs/cmd/onedrive/report/report-usageaccountdetail.md +43 -0
  91. package/docs/docs/cmd/onedrive/report/report-usagefilecounts.md +38 -0
  92. package/docs/docs/cmd/onedrive/report/report-usagestorage.md +37 -0
  93. package/docs/docs/cmd/onenote/notebook/notebook-list.md +79 -0
  94. package/docs/docs/cmd/pa/app/app-consent-set.md +47 -0
  95. package/docs/docs/cmd/planner/plan/plan-get.md +1 -1
  96. package/docs/docs/cmd/planner/plan/plan-list.md +1 -1
  97. package/docs/docs/cmd/planner/roster/roster-add.md +2 -1
  98. package/docs/docs/cmd/planner/roster/roster-get.md +1 -1
  99. package/docs/docs/cmd/planner/roster/roster-remove.md +2 -1
  100. package/docs/docs/cmd/planner/task/task-get.md +0 -6
  101. package/docs/docs/cmd/planner/task/task-set.md +1 -1
  102. package/docs/docs/cmd/purview/retentionevent/retentionevent-add.md +6 -7
  103. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.md +6 -7
  104. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.md +4 -4
  105. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.md +4 -4
  106. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +10 -10
  107. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.md +11 -11
  108. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.md +10 -10
  109. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.md +10 -10
  110. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.md +10 -10
  111. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +12 -12
  112. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.md +8 -9
  113. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +8 -9
  114. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.md +8 -8
  115. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +8 -8
  116. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-get.md +118 -0
  117. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-list.md +111 -0
  118. package/docs/docs/cmd/purview/sensitivitylabel/sensitivitylabel-policysettings-list.md +97 -0
  119. package/docs/docs/cmd/search/externalconnection/externalconnection-get.md +17 -0
  120. package/docs/docs/cmd/search/externalconnection/externalconnection-list.md +17 -0
  121. package/docs/docs/cmd/setup.md +86 -0
  122. package/docs/docs/cmd/spfx/project/project-doctor.md +1 -1
  123. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  124. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.md +1 -1
  125. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-remove.md +77 -0
  126. package/docs/docs/cmd/spo/commandset/commandset-set.md +1 -1
  127. package/docs/docs/cmd/spo/contenttype/contenttype-set.md +2 -2
  128. package/docs/docs/cmd/spo/customaction/customaction-add.md +1 -1
  129. package/docs/docs/cmd/spo/customaction/customaction-set.md +1 -1
  130. package/docs/docs/cmd/spo/file/file-list.md +9 -6
  131. package/docs/docs/cmd/spo/file/file-remove.md +12 -0
  132. package/docs/docs/cmd/spo/folder/folder-copy.md +1 -1
  133. package/docs/docs/cmd/spo/list/list-get.md +10 -0
  134. package/docs/docs/cmd/spo/list/list-list.md +28 -0
  135. package/docs/docs/cmd/spo/listitem/listitem-batch-set.md +67 -0
  136. package/docs/docs/cmd/spo/listitem/listitem-list.md +1 -1
  137. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-list.md +19 -0
  138. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-remove.md +12 -0
  139. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-list.md +6 -0
  140. package/docs/docs/cmd/spo/page/page-column-get.md +15 -0
  141. package/docs/docs/cmd/spo/page/page-column-list.md +16 -0
  142. package/docs/docs/cmd/spo/page/page-control-get.md +18 -0
  143. package/docs/docs/cmd/spo/page/page-control-list.md +18 -0
  144. package/docs/docs/cmd/spo/page/page-copy.md +35 -0
  145. package/docs/docs/cmd/spo/page/page-get.md +39 -0
  146. package/docs/docs/cmd/spo/page/page-list.md +53 -0
  147. package/docs/docs/cmd/spo/page/page-section-get.md +12 -0
  148. package/docs/docs/cmd/spo/page/page-section-list.md +13 -0
  149. package/docs/docs/cmd/spo/page/page-template-list.md +31 -0
  150. package/docs/docs/cmd/spo/propertybag/propertybag-get.md +6 -0
  151. package/docs/docs/cmd/spo/propertybag/propertybag-list.md +13 -0
  152. package/docs/docs/cmd/spo/report/report-activityfilecounts.md +7 -0
  153. package/docs/docs/cmd/spo/report/report-activitypages.md +7 -0
  154. package/docs/docs/cmd/spo/report/report-activityusercounts.md +7 -0
  155. package/docs/docs/cmd/spo/report/report-activityuserdetail.md +7 -0
  156. package/docs/docs/cmd/spo/report/report-siteusagedetail.md +7 -0
  157. package/docs/docs/cmd/spo/report/report-siteusagefilecounts.md +7 -0
  158. package/docs/docs/cmd/spo/report/report-siteusagepages.md +7 -0
  159. package/docs/docs/cmd/spo/report/report-siteusagesitecounts.md +7 -0
  160. package/docs/docs/cmd/spo/report/report-siteusagestorage.md +7 -0
  161. package/docs/docs/cmd/spo/roledefinition/roledefinition-get.md +20 -0
  162. package/docs/docs/cmd/spo/roledefinition/roledefinition-list.md +20 -0
  163. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-add.md +20 -0
  164. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-list.md +18 -0
  165. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-approve.md +20 -0
  166. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-list.md +17 -0
  167. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-set.md +13 -0
  168. package/docs/docs/cmd/spo/site/site-recyclebinitem-move.md +43 -0
  169. package/docs/docs/cmd/spo/site/site-recyclebinitem-remove.md +45 -0
  170. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +1 -1
  171. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.md +103 -0
  172. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-remove.md +49 -0
  173. package/docs/docs/cmd/spo/tenant/tenant-commandset-remove.md +49 -0
  174. package/docs/docs/cmd/spo/tenant/tenant-commandset-set.md +57 -0
  175. package/docs/docs/cmd/spo/term/term-add.md +107 -6
  176. package/docs/docs/cmd/spo/term/term-get.md +111 -10
  177. package/docs/docs/cmd/spo/term/term-group-get.md +71 -5
  178. package/docs/docs/cmd/spo/term/term-group-list.md +70 -2
  179. package/docs/docs/cmd/spo/term/term-list.md +80 -8
  180. package/docs/docs/cmd/spo/term/term-set-add.md +95 -11
  181. package/docs/docs/cmd/spo/term/term-set-get.md +92 -8
  182. package/docs/docs/cmd/spo/term/term-set-list.md +85 -5
  183. package/docs/docs/cmd/teams/app/app-list.md +17 -0
  184. package/docs/docs/cmd/teams/app/app-publish.md +18 -1
  185. package/docs/docs/cmd/teams/channel/channel-add.md +20 -0
  186. package/docs/docs/cmd/teams/channel/channel-get.md +21 -0
  187. package/docs/docs/cmd/teams/channel/channel-list.md +21 -0
  188. package/docs/docs/cmd/teams/channel/channel-member-list.md +20 -0
  189. package/docs/docs/cmd/teams/channel/channel-member-set.md +21 -0
  190. package/docs/docs/cmd/teams/chat/chat-get.md +22 -0
  191. package/docs/docs/cmd/teams/chat/chat-list.md +22 -0
  192. package/docs/docs/cmd/teams/chat/chat-member-list.md +20 -0
  193. package/docs/docs/cmd/teams/chat/chat-member-remove.md +52 -0
  194. package/docs/docs/cmd/teams/chat/chat-message-list.md +23 -0
  195. package/docs/docs/cmd/teams/funsettings/funsettings-list.md +15 -0
  196. package/docs/docs/cmd/teams/guestsettings/guestsettings-list.md +13 -0
  197. package/docs/docs/cmd/teams/membersettings/membersettings-list.md +17 -0
  198. package/docs/docs/cmd/teams/tab/tab-remove.md +1 -1
  199. package/docs/docs/cmd/todo/list/list-add.md +18 -0
  200. package/docs/docs/cmd/todo/list/list-get.md +18 -0
  201. package/docs/docs/cmd/todo/list/list-list.md +18 -0
  202. package/docs/docs/cmd/todo/task/task-get.md +21 -0
  203. package/docs/docs/cmd/todo/task/task-list.md +21 -0
  204. package/docs/docs/cmd/util/accesstoken/accesstoken-get.md +6 -0
  205. package/docs/docs/cmd/version.md +1 -1
  206. package/docs/docs/cmd/viva/connections/connections-app-create.md +3 -3
  207. package/docs/docs/cmd/yammer/group/group-list.md +42 -0
  208. package/docs/docs/cmd/yammer/message/message-add.md +32 -0
  209. package/docs/docs/cmd/yammer/message/message-get.md +32 -0
  210. package/docs/docs/cmd/yammer/message/message-list.md +34 -0
  211. package/docs/docs/cmd/yammer/network/network-list.md +70 -0
  212. package/docs/docs/cmd/yammer/report/report-activitycounts.md +7 -0
  213. package/docs/docs/cmd/yammer/report/report-activityusercounts.md +7 -0
  214. package/docs/docs/cmd/yammer/report/report-activityuserdetail.md +7 -0
  215. package/docs/docs/cmd/yammer/report/report-deviceusagedistributionusercounts.md +7 -0
  216. package/docs/docs/cmd/yammer/report/report-deviceusageusercounts.md +7 -0
  217. package/docs/docs/cmd/yammer/report/report-deviceusageuserdetail.md +7 -0
  218. package/docs/docs/cmd/yammer/report/report-groupsactivitycounts.md +7 -0
  219. package/docs/docs/cmd/yammer/report/report-groupsactivitydetail.md +7 -0
  220. package/docs/docs/cmd/yammer/report/report-groupsactivitygroupcounts.md +7 -0
  221. package/docs/docs/cmd/yammer/user/user-get.md +55 -0
  222. package/docs/docs/cmd/yammer/user/user-list.md +55 -0
  223. package/docs/docs/cmd/yammer/yammer-search.md +15 -3
  224. package/npm-shrinkwrap.json +3 -2
  225. package/package.json +2 -1
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
17
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
18
+ var m = o[Symbol.asyncIterator], i;
19
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
20
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
21
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
22
+ };
23
+ var _AppPermissionAddCommand_instances, _AppPermissionAddCommand_initTelemetry, _AppPermissionAddCommand_initOptions, _AppPermissionAddCommand_initOptionSets;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const request_1 = require("../../../../request");
26
+ const formatting_1 = require("../../../../utils/formatting");
27
+ const odata_1 = require("../../../../utils/odata");
28
+ const AppCommand_1 = require("../../../base/AppCommand");
29
+ const commands_1 = require("../../commands");
30
+ var ScopeType;
31
+ (function (ScopeType) {
32
+ ScopeType["Role"] = "Role";
33
+ ScopeType["Scope"] = "Scope";
34
+ })(ScopeType || (ScopeType = {}));
35
+ class AppPermissionAddCommand extends AppCommand_1.default {
36
+ get name() {
37
+ return commands_1.default.PERMISSION_ADD;
38
+ }
39
+ get description() {
40
+ return 'Adds the specified application and/or delegated permissions to the current AAD app API permissions';
41
+ }
42
+ constructor() {
43
+ super();
44
+ _AppPermissionAddCommand_instances.add(this);
45
+ __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initTelemetry).call(this);
46
+ __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptions).call(this);
47
+ __classPrivateFieldGet(this, _AppPermissionAddCommand_instances, "m", _AppPermissionAddCommand_initOptionSets).call(this);
48
+ }
49
+ commandAction(logger, args) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ try {
52
+ const appObject = yield this.getAppObject();
53
+ const servicePrincipals = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
54
+ const appPermissions = [];
55
+ if (args.options.delegatedPermission) {
56
+ const delegatedPermissions = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.delegatedPermission, ScopeType.Scope, appPermissions, logger);
57
+ this.addPermissionsToResourceArray(delegatedPermissions, appObject.requiredResourceAccess);
58
+ }
59
+ if (args.options.applicationPermission) {
60
+ const applicationPermissions = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermission, ScopeType.Role, appPermissions, logger);
61
+ this.addPermissionsToResourceArray(applicationPermissions, appObject.requiredResourceAccess);
62
+ }
63
+ const addPermissionsRequestOptions = {
64
+ url: `${this.resource}/v1.0/myorganization/applications/${appObject.id}`,
65
+ headers: {
66
+ accept: 'application/json;odata.metadata=none'
67
+ },
68
+ responseType: 'json',
69
+ data: {
70
+ requiredResourceAccess: appObject.requiredResourceAccess
71
+ }
72
+ };
73
+ yield request_1.default.patch(addPermissionsRequestOptions);
74
+ if (args.options.grantAdminConsent) {
75
+ const appServicePrincipal = servicePrincipals.find(sp => sp.appId === this.appId);
76
+ yield this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
77
+ }
78
+ }
79
+ catch (err) {
80
+ this.handleRejectedODataJsonPromise(err);
81
+ }
82
+ });
83
+ }
84
+ getAppObject() {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const apps = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/myorganization/applications?$filter=appId eq '${formatting_1.formatting.encodeQueryParameter(this.appId)}'&$select=id,requiredResourceAccess`);
87
+ if (apps.length === 0) {
88
+ throw `App with id ${this.appId} not found in Azure Active Directory`;
89
+ }
90
+ return apps[0];
91
+ });
92
+ }
93
+ addPermissionsToResourceArray(permissions, existingArray) {
94
+ permissions.forEach(resolvedRequiredResource => {
95
+ const requiredResource = existingArray.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
96
+ if (requiredResource) {
97
+ // make sure that permission does not yet exist on the app or it will be added twice
98
+ resolvedRequiredResource.resourceAccess.forEach(resAccess => {
99
+ if (!requiredResource.resourceAccess.some(res => res.id === resAccess.id)) {
100
+ requiredResource.resourceAccess.push(resAccess);
101
+ }
102
+ });
103
+ }
104
+ else {
105
+ existingArray.push(resolvedRequiredResource);
106
+ }
107
+ });
108
+ }
109
+ getRequiredResourceAccessForApis(servicePrincipals, apis, scopeType, appPermissions, logger) {
110
+ const resolvedApis = [];
111
+ const requestedApis = apis.split(' ').map(a => a.trim());
112
+ requestedApis.forEach(api => {
113
+ const pos = api.lastIndexOf('/');
114
+ const permissionName = api.substring(pos + 1);
115
+ const servicePrincipalName = api.substring(0, pos);
116
+ if (this.verbose) {
117
+ logger.logToStderr(`Resolving ${api}...`);
118
+ logger.logToStderr(`Permission name: ${permissionName}`);
119
+ logger.logToStderr(`Service principal name: ${servicePrincipalName}`);
120
+ }
121
+ const servicePrincipal = servicePrincipals.find(sp => (sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1 ||
122
+ sp.servicePrincipalNames.indexOf(`${servicePrincipalName}/`) > -1));
123
+ if (!servicePrincipal) {
124
+ throw `Service principal ${servicePrincipalName} not found`;
125
+ }
126
+ let permission = undefined;
127
+ if (scopeType === ScopeType.Scope) {
128
+ permission = servicePrincipal.oauth2PermissionScopes.find(scope => scope.value === permissionName);
129
+ }
130
+ else if (scopeType === ScopeType.Role) {
131
+ permission = servicePrincipal.appRoles.find(scope => scope.value === permissionName);
132
+ }
133
+ if (!permission) {
134
+ throw `Permission ${permissionName} for service principal ${servicePrincipalName} not found`;
135
+ }
136
+ let resolvedApi = resolvedApis.find(a => a.resourceAppId === servicePrincipal.appId);
137
+ if (!resolvedApi) {
138
+ resolvedApi = {
139
+ resourceAppId: servicePrincipal.appId,
140
+ resourceAccess: []
141
+ };
142
+ resolvedApis.push(resolvedApi);
143
+ }
144
+ const resourceAccessPermission = {
145
+ id: permission.id,
146
+ type: scopeType
147
+ };
148
+ resolvedApi.resourceAccess.push(resourceAccessPermission);
149
+ this.updateAppPermissions(servicePrincipal.id, resourceAccessPermission, permission.value, appPermissions);
150
+ });
151
+ return resolvedApis;
152
+ }
153
+ updateAppPermissions(spId, resourceAccessPermission, oAuth2PermissionValue, appPermissions) {
154
+ let existingPermission = appPermissions.find(oauth => oauth.resourceId === spId);
155
+ if (!existingPermission) {
156
+ existingPermission = {
157
+ resourceId: spId,
158
+ resourceAccess: [],
159
+ scope: []
160
+ };
161
+ appPermissions.push(existingPermission);
162
+ }
163
+ if (resourceAccessPermission.type === ScopeType.Scope && oAuth2PermissionValue && !existingPermission.scope.find(scp => scp === oAuth2PermissionValue)) {
164
+ existingPermission.scope.push(oAuth2PermissionValue);
165
+ }
166
+ if (!existingPermission.resourceAccess.find(res => res.id === resourceAccessPermission.id)) {
167
+ existingPermission.resourceAccess.push(resourceAccessPermission);
168
+ }
169
+ }
170
+ grantAdminConsent(servicePrincipal, appPermissions, logger) {
171
+ var _a, appPermissions_1, appPermissions_1_1;
172
+ var _b, e_1, _c, _d, _e, e_2, _f, _g;
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ try {
175
+ for (_a = true, appPermissions_1 = __asyncValues(appPermissions); appPermissions_1_1 = yield appPermissions_1.next(), _b = appPermissions_1_1.done, !_b;) {
176
+ _d = appPermissions_1_1.value;
177
+ _a = false;
178
+ try {
179
+ const permission = _d;
180
+ if (permission.scope.length > 0) {
181
+ if (this.verbose) {
182
+ logger.logToStderr(`Granting consent for delegated permission(s) with resourceId ${permission.resourceId} and scope(s) ${permission.scope.join(' ')}`);
183
+ }
184
+ yield this.grantOAuth2Permission(servicePrincipal.id, permission.resourceId, permission.scope.join(' '));
185
+ }
186
+ try {
187
+ for (var _h = true, _j = (e_2 = void 0, __asyncValues(permission.resourceAccess.filter(acc => acc.type === ScopeType.Role))), _k; _k = yield _j.next(), _e = _k.done, !_e;) {
188
+ _g = _k.value;
189
+ _h = false;
190
+ try {
191
+ const access = _g;
192
+ if (this.verbose) {
193
+ logger.logToStderr(`Granting consent for application permission with resourceId ${permission.resourceId} and appRoleId ${access.id}`);
194
+ }
195
+ yield this.addRoleToServicePrincipal(servicePrincipal.id, permission.resourceId, access.id);
196
+ }
197
+ finally {
198
+ _h = true;
199
+ }
200
+ }
201
+ }
202
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
203
+ finally {
204
+ try {
205
+ if (!_h && !_e && (_f = _j.return)) yield _f.call(_j);
206
+ }
207
+ finally { if (e_2) throw e_2.error; }
208
+ }
209
+ }
210
+ finally {
211
+ _a = true;
212
+ }
213
+ }
214
+ }
215
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
216
+ finally {
217
+ try {
218
+ if (!_a && !_b && (_c = appPermissions_1.return)) yield _c.call(appPermissions_1);
219
+ }
220
+ finally { if (e_1) throw e_1.error; }
221
+ }
222
+ });
223
+ }
224
+ grantOAuth2Permission(servicePricipalId, resourceId, scope) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ const grantAdminConsentApplicationRequestOptions = {
227
+ url: `${this.resource}/v1.0/myorganization/oauth2PermissionGrants`,
228
+ headers: {
229
+ accept: 'application/json;odata.metadata=none'
230
+ },
231
+ responseType: 'json',
232
+ data: {
233
+ clientId: servicePricipalId,
234
+ consentType: 'AllPrincipals',
235
+ principalId: null,
236
+ resourceId: resourceId,
237
+ scope: scope
238
+ }
239
+ };
240
+ return request_1.default.post(grantAdminConsentApplicationRequestOptions);
241
+ });
242
+ }
243
+ addRoleToServicePrincipal(servicePrincipalId, resourceId, appRoleId) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ const requestOptions = {
246
+ url: `${this.resource}/v1.0/myorganization/servicePrincipals/${servicePrincipalId}/appRoleAssignments`,
247
+ headers: {
248
+ 'content-type': 'application/json'
249
+ },
250
+ responseType: 'json',
251
+ data: {
252
+ appRoleId: appRoleId,
253
+ principalId: servicePrincipalId,
254
+ resourceId: resourceId
255
+ }
256
+ };
257
+ return request_1.default.post(requestOptions);
258
+ });
259
+ }
260
+ }
261
+ _AppPermissionAddCommand_instances = new WeakSet(), _AppPermissionAddCommand_initTelemetry = function _AppPermissionAddCommand_initTelemetry() {
262
+ this.telemetry.push((args) => {
263
+ Object.assign(this.telemetryProperties, {
264
+ appId: typeof args.options.appId !== 'undefined',
265
+ applicationPermission: typeof args.options.applicationPermission !== 'undefined',
266
+ delegatedPermission: typeof args.options.delegatedPermission !== 'undefined',
267
+ grantAdminConsent: !!args.options.grantAdminConsent
268
+ });
269
+ });
270
+ }, _AppPermissionAddCommand_initOptions = function _AppPermissionAddCommand_initOptions() {
271
+ this.options.unshift({ option: '--appId [appId]' }, { option: '--applicationPermission [applicationPermission]' }, { option: '--delegatedPermission [delegatedPermission]' }, { option: '--grantAdminConsent' });
272
+ }, _AppPermissionAddCommand_initOptionSets = function _AppPermissionAddCommand_initOptionSets() {
273
+ this.optionSets.push({
274
+ options: ['applicationPermission', 'delegatedPermission'],
275
+ runsWhen: (args) => args.options.delegatedPermission === undefined && args.options.applicationPermission === undefined
276
+ });
277
+ };
278
+ module.exports = new AppPermissionAddCommand();
279
+ //# sourceMappingURL=permission-add.js.map
@@ -4,6 +4,7 @@ const prefix = 'app';
4
4
  exports.default = {
5
5
  GET: `${prefix} get`,
6
6
  OPEN: `${prefix} open`,
7
+ PERMISSION_ADD: `${prefix} permission add`,
7
8
  PERMISSION_LIST: `${prefix} permission list`
8
9
  };
9
10
  //# sourceMappingURL=commands.js.map
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
+ DOCS: 'docs',
4
5
  LOGIN: `login`,
5
6
  LOGOUT: `logout`,
6
7
  REQUEST: `request`,
8
+ SETUP: `setup`,
7
9
  STATUS: `status`,
8
10
  VERSION: 'version'
9
11
  };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const AnonymousCommand_1 = require("../base/AnonymousCommand");
13
+ const Cli_1 = require("../../cli/Cli");
14
+ const commands_1 = require("./commands");
15
+ const settingsNames_1 = require("../../settingsNames");
16
+ const packageJSON = require('../../../package.json');
17
+ class DocsCommand extends AnonymousCommand_1.default {
18
+ get name() {
19
+ return commands_1.default.DOCS;
20
+ }
21
+ get description() {
22
+ return 'Returns the CLI for Microsoft 365 docs webpage URL';
23
+ }
24
+ commandAction(logger) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ logger.log(packageJSON.homepage);
27
+ if (Cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.autoOpenLinksInBrowser, false) === false) {
28
+ return;
29
+ }
30
+ // _open is never set before hitting this line, but this check
31
+ // is implemented so that we can support lazy loading
32
+ // but also stub it for testing
33
+ /* c8 ignore next 3 */
34
+ if (!this._open) {
35
+ this._open = require('open');
36
+ }
37
+ yield this._open(packageJSON.homepage);
38
+ });
39
+ }
40
+ }
41
+ module.exports = new DocsCommand();
42
+ //# sourceMappingURL=docs.js.map
@@ -145,7 +145,7 @@ _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function
145
145
  }, {
146
146
  option: '--tenant [tenant]'
147
147
  }, {
148
- option: '--secret [secret]'
148
+ option: '-s, --secret [secret]'
149
149
  }, {
150
150
  option: '--cloud [cloud]',
151
151
  autocomplete: misc_1.misc.getEnums(Auth_1.CloudType)
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SetupCommand_instances, _SetupCommand_initTelemetry, _SetupCommand_initOptions, _SetupCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const chalk = require("chalk");
19
+ const os = require("os");
20
+ const Cli_1 = require("../../cli/Cli");
21
+ const formatting_1 = require("../../utils/formatting");
22
+ const pid_1 = require("../../utils/pid");
23
+ const AnonymousCommand_1 = require("../base/AnonymousCommand");
24
+ const commands_1 = require("./commands");
25
+ const setupPresets_1 = require("./setupPresets");
26
+ class SetupCommand extends AnonymousCommand_1.default {
27
+ get name() {
28
+ return commands_1.default.SETUP;
29
+ }
30
+ get description() {
31
+ return 'Sets up CLI for Microsoft 365 based on your preferences';
32
+ }
33
+ constructor() {
34
+ super();
35
+ _SetupCommand_instances.add(this);
36
+ // used for injecting answers from tests
37
+ this.answers = {};
38
+ __classPrivateFieldGet(this, _SetupCommand_instances, "m", _SetupCommand_initTelemetry).call(this);
39
+ __classPrivateFieldGet(this, _SetupCommand_instances, "m", _SetupCommand_initOptions).call(this);
40
+ __classPrivateFieldGet(this, _SetupCommand_instances, "m", _SetupCommand_initValidators).call(this);
41
+ }
42
+ commandAction(logger, args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ let settings;
45
+ if (args.options.interactive || args.options.scripting) {
46
+ settings = {};
47
+ if (args.options.interactive) {
48
+ Object.assign(settings, setupPresets_1.interactivePreset);
49
+ }
50
+ else if (args.options.scripting) {
51
+ Object.assign(settings, setupPresets_1.scriptingPreset);
52
+ }
53
+ if (pid_1.pid.isPowerShell()) {
54
+ Object.assign(settings, setupPresets_1.powerShellPreset);
55
+ }
56
+ this.configureSettings(settings, true, logger);
57
+ return;
58
+ }
59
+ logger.logToStderr(`Welcome to the CLI for Microsoft 365 setup!`);
60
+ logger.logToStderr(`This command will guide you through the process of configuring the CLI for your needs.`);
61
+ logger.logToStderr(`Please, answer the following questions and we'll define a set of settings to best match how you intend to use the CLI.`);
62
+ logger.logToStderr('');
63
+ const preferences = yield Cli_1.Cli.prompt([
64
+ {
65
+ type: 'list',
66
+ name: 'usageMode',
67
+ message: 'How do you plan to use the CLI?',
68
+ choices: [
69
+ 'Interactively',
70
+ 'Scripting'
71
+ ]
72
+ },
73
+ {
74
+ type: 'confirm',
75
+ name: 'usedInPowerShell',
76
+ message: 'Are you going to use the CLI in PowerShell?',
77
+ when: (answers) => answers.usageMode === 'Scripting',
78
+ default: pid_1.pid.isPowerShell()
79
+ },
80
+ {
81
+ type: 'list',
82
+ name: 'experience',
83
+ message: 'How experienced are you in using the CLI?',
84
+ choices: [
85
+ 'Beginner',
86
+ 'Proficient'
87
+ ]
88
+ },
89
+ {
90
+ type: 'confirm',
91
+ name: 'summary',
92
+ // invoked by inquirer
93
+ /* c8 ignore next 4 */
94
+ message: (answers) => {
95
+ settings = this.getSettings(answers);
96
+ return this.getSummaryMessage(settings);
97
+ }
98
+ }
99
+ ], this.answers);
100
+ if (preferences.summary) {
101
+ // used only for testing. Normally, we'd get the settings from the answers
102
+ /* c8 ignore next 3 */
103
+ if (!settings) {
104
+ settings = this.getSettings(preferences);
105
+ }
106
+ logger.logToStderr('');
107
+ logger.logToStderr('Configuring settings...');
108
+ logger.logToStderr('');
109
+ this.configureSettings(settings, false, logger);
110
+ if (!this.verbose) {
111
+ logger.logToStderr('');
112
+ logger.logToStderr(chalk.green('DONE'));
113
+ }
114
+ }
115
+ });
116
+ }
117
+ getSummaryMessage(settings) {
118
+ const messageLines = [`Based on your preferences, we'll configure the following settings:`];
119
+ for (const [key, value] of Object.entries(settings)) {
120
+ messageLines.push(`- ${key}: ${value}`);
121
+ }
122
+ messageLines.push('', 'You can change any of these settings later using the `m365 cli config set` command or reset them to default using `m365 cli config reset`.', '', 'Do you want to apply these settings now?');
123
+ return messageLines.join(os.EOL);
124
+ }
125
+ getSettings(answers) {
126
+ const settings = {};
127
+ switch (answers.usageMode) {
128
+ case 'Interactively':
129
+ Object.assign(settings, setupPresets_1.interactivePreset);
130
+ break;
131
+ case 'Scripting':
132
+ Object.assign(settings, setupPresets_1.scriptingPreset);
133
+ break;
134
+ }
135
+ if (answers.usedInPowerShell === true) {
136
+ Object.assign(settings, setupPresets_1.powerShellPreset);
137
+ }
138
+ switch (answers.experience) {
139
+ case 'Beginner':
140
+ settings.helpMode = 'full';
141
+ break;
142
+ case 'Proficient':
143
+ settings.helpMode = 'options';
144
+ break;
145
+ }
146
+ return settings;
147
+ }
148
+ configureSettings(settings, silent, logger) {
149
+ if (this.debug) {
150
+ logger.logToStderr('Configuring settings...');
151
+ logger.logToStderr(JSON.stringify(settings, null, 2));
152
+ }
153
+ for (const [key, value] of Object.entries(settings)) {
154
+ Cli_1.Cli.getInstance().config.set(key, value);
155
+ if (!silent) {
156
+ logger.logToStderr(formatting_1.formatting.getStatus(formatting_1.CheckStatus.Success, `${key}: ${value}`));
157
+ }
158
+ }
159
+ }
160
+ }
161
+ _SetupCommand_instances = new WeakSet(), _SetupCommand_initTelemetry = function _SetupCommand_initTelemetry() {
162
+ this.telemetry.push((args) => {
163
+ const properties = {
164
+ interactive: args.options.interactive,
165
+ scripting: args.options.scripting
166
+ };
167
+ Object.assign(this.telemetryProperties, properties);
168
+ });
169
+ }, _SetupCommand_initOptions = function _SetupCommand_initOptions() {
170
+ this.options.unshift({ option: '--interactive' }, { option: '--scripting' });
171
+ }, _SetupCommand_initValidators = function _SetupCommand_initValidators() {
172
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
173
+ if (args.options.interactive && args.options.scripting) {
174
+ return 'Specify either interactive or scripting but not both';
175
+ }
176
+ return true;
177
+ }));
178
+ };
179
+ module.exports = new SetupCommand();
180
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.powerShellPreset = exports.scriptingPreset = exports.interactivePreset = void 0;
4
+ exports.interactivePreset = {
5
+ autoOpenLinksInBrowser: true,
6
+ copyDeviceCodeToClipboard: true,
7
+ output: 'text',
8
+ printErrorsAsPlainText: true,
9
+ prompt: true,
10
+ showHelpOnFailure: true,
11
+ showSpinner: true
12
+ };
13
+ exports.scriptingPreset = {
14
+ autoOpenLinksInBrowser: false,
15
+ copyDeviceCodeToClipboard: false,
16
+ output: 'json',
17
+ printErrorsAsPlainText: false,
18
+ prompt: false,
19
+ showHelpOnFailure: false,
20
+ showSpinner: false
21
+ };
22
+ exports.powerShellPreset = {
23
+ errorOutput: 'stdout'
24
+ };
25
+ //# sourceMappingURL=setupPresets.js.map
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _PaAppConsentSetCommand_instances, _PaAppConsentSetCommand_initOptions, _PaAppConsentSetCommand_initValidators, _PaAppConsentSetCommand_initTypes;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const PowerAppsCommand_1 = require("../../../base/PowerAppsCommand");
22
+ const commands_1 = require("../../commands");
23
+ class PaAppConsentSetCommand extends PowerAppsCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.APP_CONSENT_SET;
26
+ }
27
+ get description() {
28
+ return 'Configures if users can bypass the API Consent window for the selected canvas app';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _PaAppConsentSetCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _PaAppConsentSetCommand_instances, "m", _PaAppConsentSetCommand_initOptions).call(this);
34
+ __classPrivateFieldGet(this, _PaAppConsentSetCommand_instances, "m", _PaAppConsentSetCommand_initValidators).call(this);
35
+ __classPrivateFieldGet(this, _PaAppConsentSetCommand_instances, "m", _PaAppConsentSetCommand_initTypes).call(this);
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ if (this.verbose) {
40
+ logger.logToStderr(`Setting the bypass consent for the Microsoft Power App ${args.options.name}... to ${args.options.bypass}`);
41
+ }
42
+ if (args.options.confirm) {
43
+ yield this.consentPaApp(args);
44
+ }
45
+ else {
46
+ const result = yield Cli_1.Cli.prompt({
47
+ type: 'confirm',
48
+ name: 'continue',
49
+ default: false,
50
+ message: `Are you sure you bypass the consent for the Microsoft Power App ${args.options.name} to ${args.options.bypass}?`
51
+ });
52
+ if (result.continue) {
53
+ yield this.consentPaApp(args);
54
+ }
55
+ }
56
+ });
57
+ }
58
+ consentPaApp(args) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const requestOptions = {
61
+ url: `${this.resource}/providers/Microsoft.PowerApps/scopes/admin/environments/${args.options.environment}/apps/${args.options.name}/setPowerAppConnectionDirectConsentBypass?api-version=2021-02-01`,
62
+ headers: {
63
+ accept: 'application/json;odata.metadata=none'
64
+ },
65
+ responseType: 'json',
66
+ data: {
67
+ bypassconsent: args.options.bypass
68
+ }
69
+ };
70
+ try {
71
+ yield request_1.default.post(requestOptions);
72
+ }
73
+ catch (err) {
74
+ this.handleRejectedODataJsonPromise(err);
75
+ }
76
+ });
77
+ }
78
+ }
79
+ _PaAppConsentSetCommand_instances = new WeakSet(), _PaAppConsentSetCommand_initOptions = function _PaAppConsentSetCommand_initOptions() {
80
+ this.options.unshift({
81
+ option: '-e, --environment <environment>'
82
+ }, {
83
+ option: '-n, --name <name>'
84
+ }, {
85
+ option: '-b, --bypass <bypass>',
86
+ autocomplete: ['true', 'false']
87
+ }, {
88
+ option: '--confirm'
89
+ });
90
+ }, _PaAppConsentSetCommand_initValidators = function _PaAppConsentSetCommand_initValidators() {
91
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
92
+ if (!validation_1.validation.isValidGuid(args.options.name)) {
93
+ return `${args.options.name} is not a valid GUID`;
94
+ }
95
+ return true;
96
+ }));
97
+ }, _PaAppConsentSetCommand_initTypes = function _PaAppConsentSetCommand_initTypes() {
98
+ this.types.boolean.push('bypass');
99
+ };
100
+ module.exports = new PaAppConsentSetCommand();
101
+ //# sourceMappingURL=app-consent-set.js.map
@@ -6,6 +6,7 @@ exports.default = {
6
6
  APP_GET: `${prefix} app get`,
7
7
  APP_LIST: `${prefix} app list`,
8
8
  APP_REMOVE: `${prefix} app remove`,
9
+ APP_CONSENT_SET: `${prefix} app consent set`,
9
10
  CONNECTOR_EXPORT: `${prefix} connector export`,
10
11
  CONNECTOR_LIST: `${prefix} connector list`,
11
12
  ENVIRONMENT_GET: `${prefix} environment get`,