@pnp/cli-microsoft365 6.8.0-beta.f473be5 → 6.8.0

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 (224) 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/package.json +3 -2
package/.eslintrc.js CHANGED
@@ -66,6 +66,7 @@ const dictionary = [
66
66
  'o365',
67
67
  'permission',
68
68
  'place',
69
+ 'policy',
69
70
  'property',
70
71
  'records',
71
72
  'recycle',
@@ -73,6 +74,7 @@ const dictionary = [
73
74
  'role',
74
75
  'room',
75
76
  'schema',
77
+ 'sensitivity',
76
78
  'service',
77
79
  'set',
78
80
  'setting',
package/README.md CHANGED
@@ -74,15 +74,20 @@
74
74
  - Access all your Microsoft 365 workloads
75
75
  - Supported workloads
76
76
  - Azure Active Directory
77
+ - Bookings
77
78
  - Microsoft Teams
78
79
  - Microsoft To Do
79
80
  - OneDrive
81
+ - OneNote
80
82
  - Outlook
81
83
  - Planner
82
84
  - Power Automate
83
85
  - Power Apps
86
+ - Power Platform
87
+ - Purview
84
88
  - Skype for Business
85
89
  - SharePoint Online
90
+ - To Do
86
91
  - Yammer
87
92
  - Supported authentication methods
88
93
  - Azure Managed Identity
@@ -98,7 +103,7 @@
98
103
 
99
104
  ## Install
100
105
 
101
- To install this CLI, you will need [`node`](https://nodejs.org) `>= 8.0.0` installed.
106
+ To use the CLI for Microsoft 365 you need [`Node.js`](https://nodejs.org). The CLI has been tested with Node.js versions 18 and higher, but we recommend you to use the Node.js LTS version available at the moment.
102
107
 
103
108
  ```
104
109
  npm install -g @pnp/cli-microsoft365
package/dist/Command.js CHANGED
@@ -420,6 +420,12 @@ class Command {
420
420
  return;
421
421
  }
422
422
  const lowerCaseValue = value.toLowerCase().trim();
423
+ if (lowerCaseValue === '@meid' || lowerCaseValue === '@meusername') {
424
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
425
+ if (isAppOnlyAccessToken) {
426
+ throw `It's not possible to use ${value} with application permissions`;
427
+ }
428
+ }
423
429
  if (lowerCaseValue === '@meid') {
424
430
  args.options[option] = accessToken_1.accessToken.getUserIdFromAccessToken(token);
425
431
  }
@@ -0,0 +1,298 @@
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
+ exports.chili = void 0;
13
+ const fs = require("fs");
14
+ const inquirer = require("inquirer");
15
+ const ora = require("ora");
16
+ const path = require("path");
17
+ const Cli_1 = require("../cli/Cli");
18
+ const request_1 = require("../request");
19
+ const settingsNames_1 = require("../settingsNames");
20
+ const md_1 = require("../utils/md");
21
+ const mendableApiKey = 'd3313d54-6f8e-40e0-90d3-4095019d4be7';
22
+ let showHelp = false;
23
+ let debug = false;
24
+ let promptForRating = true;
25
+ let conversationId = 0;
26
+ let initialPrompt = '';
27
+ let history = [];
28
+ const cli = Cli_1.Cli.getInstance();
29
+ const showSpinner = cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.showSpinner, true) && typeof global.it === 'undefined';
30
+ request_1.default.logger = {
31
+ /* c8 ignore next 3 */
32
+ log: (msg) => console.log(msg),
33
+ logRaw: (msg) => console.log(msg),
34
+ logToStderr: (msg) => console.error(msg)
35
+ };
36
+ request_1.default.debug = debug;
37
+ function getPromptFromArgs(args) {
38
+ showHelp = args.indexOf('--help') > -1 || args.indexOf('-h') > -1;
39
+ if (showHelp) {
40
+ const commandsFolder = path.join(__dirname, '..', 'm365');
41
+ const pathChunks = [commandsFolder, '..', '..', 'docs', 'docs', 'user-guide', 'chili.md'];
42
+ const helpFilePath = path.join(...pathChunks);
43
+ if (fs.existsSync(helpFilePath)) {
44
+ let helpContents = fs.readFileSync(helpFilePath, 'utf8');
45
+ helpContents = md_1.md.md2plain(helpContents, path.join(commandsFolder, '..', '..', 'docs'));
46
+ console.log(helpContents);
47
+ return '';
48
+ }
49
+ else {
50
+ console.error('Help file not found');
51
+ return '';
52
+ }
53
+ }
54
+ else {
55
+ // reset to default. needed for tests
56
+ showHelp = false;
57
+ }
58
+ const debugPos = args.indexOf('--debug');
59
+ if (debugPos > -1) {
60
+ debug = true;
61
+ request_1.default.debug = true;
62
+ args.splice(debugPos, 1);
63
+ }
64
+ else {
65
+ // reset to default. needed for tests
66
+ debug = false;
67
+ }
68
+ const noRatingPos = args.indexOf('--no-rating');
69
+ if (noRatingPos > -1) {
70
+ promptForRating = false;
71
+ args.splice(noRatingPos, 1);
72
+ }
73
+ else {
74
+ // reset to default. needed for tests
75
+ promptForRating = true;
76
+ }
77
+ return args.join(' ');
78
+ }
79
+ function startConversation(args) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ history = [];
82
+ initialPrompt = getPromptFromArgs(args);
83
+ if (showHelp) {
84
+ return;
85
+ }
86
+ conversationId = yield getConversationId();
87
+ if (!initialPrompt) {
88
+ initialPrompt = yield promptForPrompt();
89
+ }
90
+ yield runConversationTurn(conversationId, initialPrompt);
91
+ });
92
+ }
93
+ function promptForPrompt() {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ const answer = yield inquirer.prompt([{
96
+ type: 'input',
97
+ name: 'prompt',
98
+ message: '🌶️ How can I help you?'
99
+ }]);
100
+ return answer.prompt;
101
+ });
102
+ }
103
+ function runConversationTurn(conversationId, question) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ console.log('');
106
+ const spinner = ora('Searching documentation...');
107
+ /* c8 ignore next 3 */
108
+ if (showSpinner) {
109
+ spinner.start();
110
+ }
111
+ const response = yield runMendableChat(conversationId, question);
112
+ history.push({
113
+ prompt: question,
114
+ response: response.answer.text
115
+ });
116
+ /* c8 ignore next 3 */
117
+ if (showSpinner) {
118
+ spinner.stop();
119
+ }
120
+ console.log(md_1.md.md2plain(response.answer.text, ''));
121
+ console.log('');
122
+ console.log('Source:');
123
+ // remove duplicates
124
+ const sources = response.sources.filter((src, index, self) => index === self.findIndex(s => s.link === src.link));
125
+ sources.forEach(src => console.log(`⬥ ${src.link}`));
126
+ console.log('');
127
+ if (promptForRating) {
128
+ try {
129
+ yield rateResponse(response.message_id);
130
+ }
131
+ catch (err) {
132
+ if (debug) {
133
+ console.error(`An error has occurred while rating the response: ${err}`);
134
+ }
135
+ }
136
+ console.log('');
137
+ }
138
+ const result = yield inquirer.prompt([{
139
+ type: 'list',
140
+ name: 'chat',
141
+ message: 'What would you like to do next?',
142
+ choices: [
143
+ {
144
+ name: '📝 I want to know more',
145
+ value: 'ask'
146
+ },
147
+ {
148
+ name: '👋 I know enough. Thanks!',
149
+ value: 'end'
150
+ },
151
+ {
152
+ name: '🔄 I want to ask about something else',
153
+ value: 'new'
154
+ }
155
+ ]
156
+ }]);
157
+ switch (result.chat) {
158
+ case 'ask':
159
+ const prompt = yield promptForPrompt();
160
+ return yield runConversationTurn(conversationId, prompt);
161
+ case 'end':
162
+ yield endConversation(conversationId);
163
+ console.log('');
164
+ console.log('🌶️ Bye!');
165
+ return;
166
+ case 'new':
167
+ initialPrompt = '';
168
+ return startConversation([]);
169
+ }
170
+ });
171
+ }
172
+ function rateResponse(messageId) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const result = yield inquirer.prompt([{
175
+ type: 'list',
176
+ name: 'rating',
177
+ message: 'Was this helpful?',
178
+ choices: [
179
+ {
180
+ name: '👍 Yes',
181
+ value: 1
182
+ },
183
+ {
184
+ name: '👎 No',
185
+ value: -1
186
+ },
187
+ {
188
+ name: '🤔 Not sure/skip',
189
+ value: 0
190
+ }
191
+ ]
192
+ }]);
193
+ if (result.rating === 0) {
194
+ return;
195
+ }
196
+ console.log('Thanks for letting us know! 😊');
197
+ const requestOptions = {
198
+ url: 'https://api.mendable.ai/v0/rateMessage',
199
+ headers: {
200
+ 'content-type': 'application/json',
201
+ 'x-anonymous': true
202
+ },
203
+ responseType: 'json',
204
+ data: {
205
+ // eslint-disable-next-line camelcase
206
+ api_key: mendableApiKey,
207
+ // eslint-disable-next-line camelcase
208
+ conversation_id: conversationId,
209
+ // eslint-disable-next-line camelcase
210
+ message_id: messageId,
211
+ // eslint-disable-next-line camelcase
212
+ rating_value: result.rating
213
+ }
214
+ };
215
+ const spinner = ora('Sending rating...');
216
+ /* c8 ignore next 3 */
217
+ if (showSpinner) {
218
+ spinner.start();
219
+ }
220
+ yield request_1.default.post(requestOptions);
221
+ /* c8 ignore next 3 */
222
+ if (showSpinner) {
223
+ spinner.stop();
224
+ }
225
+ });
226
+ }
227
+ function endConversation(conversationId) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ const requestOptions = {
230
+ url: 'https://api.mendable.ai/v0/endConversation',
231
+ headers: {
232
+ 'content-type': 'application/json',
233
+ 'x-anonymous': true
234
+ },
235
+ responseType: 'json',
236
+ data: {
237
+ // eslint-disable-next-line camelcase
238
+ api_key: mendableApiKey,
239
+ // eslint-disable-next-line camelcase
240
+ conversation_id: conversationId
241
+ }
242
+ };
243
+ const spinner = ora('Ending conversation...');
244
+ /* c8 ignore next 3 */
245
+ if (showSpinner) {
246
+ spinner.start();
247
+ }
248
+ yield request_1.default.post(requestOptions);
249
+ /* c8 ignore next 3 */
250
+ if (showSpinner) {
251
+ spinner.stop();
252
+ }
253
+ });
254
+ }
255
+ function runMendableChat(conversationId, question) {
256
+ return __awaiter(this, void 0, void 0, function* () {
257
+ const requestOptions = {
258
+ url: 'https://api.mendable.ai/v0/mendableChat',
259
+ headers: {
260
+ 'content-type': 'application/json',
261
+ 'x-anonymous': true
262
+ },
263
+ responseType: 'json',
264
+ data: {
265
+ // eslint-disable-next-line camelcase
266
+ api_key: mendableApiKey,
267
+ // eslint-disable-next-line camelcase
268
+ conversation_id: conversationId,
269
+ question,
270
+ history,
271
+ shouldStream: false
272
+ }
273
+ };
274
+ return yield request_1.default.post(requestOptions);
275
+ });
276
+ }
277
+ function getConversationId() {
278
+ return __awaiter(this, void 0, void 0, function* () {
279
+ const requestOptions = {
280
+ url: 'https://api.mendable.ai/v0/newConversation',
281
+ headers: {
282
+ 'content-type': 'application/json',
283
+ 'x-anonymous': true
284
+ },
285
+ responseType: 'json',
286
+ data: {
287
+ // eslint-disable-next-line camelcase
288
+ api_key: mendableApiKey
289
+ }
290
+ };
291
+ const response = yield request_1.default.post(requestOptions);
292
+ return response.conversation_id;
293
+ });
294
+ }
295
+ exports.chili = {
296
+ startConversation
297
+ };
298
+ //# sourceMappingURL=chili.js.map
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const chili_1 = require("./chili");
14
+ try {
15
+ (() => __awaiter(void 0, void 0, void 0, function* () { return yield chili_1.chili.startConversation(process.argv.slice(2)); }))();
16
+ }
17
+ catch (err) {
18
+ console.error(`🛑 An error has occurred while searching documentation: ${err}`);
19
+ }
20
+ //# sourceMappingURL=index.js.map
package/dist/cli/Cli.js CHANGED
@@ -783,7 +783,7 @@ class Cli {
783
783
  console.error(message, ...optionalParams);
784
784
  }
785
785
  }
786
- static prompt(options) {
786
+ static prompt(options, answers) {
787
787
  return __awaiter(this, void 0, void 0, function* () {
788
788
  const inquirer = require('inquirer');
789
789
  const cli = Cli.getInstance();
@@ -792,7 +792,7 @@ class Cli {
792
792
  if (spinnerSpinning) {
793
793
  cli.spinner.stop();
794
794
  }
795
- const response = yield inquirer.prompt(options);
795
+ const response = yield inquirer.prompt(options, answers);
796
796
  // Restart the spinner if it was running before the prompt
797
797
  /* c8 ignore next 3 */
798
798
  if (spinnerSpinning) {
@@ -26,6 +26,9 @@ class AadUserAddCommand extends GraphCommand_1.default {
26
26
  get description() {
27
27
  return 'Creates a new user';
28
28
  }
29
+ allowUnknownOptions() {
30
+ return true;
31
+ }
29
32
  constructor() {
30
33
  super();
31
34
  _AadUserAddCommand_instances.add(this);
@@ -36,37 +39,19 @@ class AadUserAddCommand extends GraphCommand_1.default {
36
39
  __classPrivateFieldGet(this, _AadUserAddCommand_instances, "m", _AadUserAddCommand_initTypes).call(this);
37
40
  }
38
41
  commandAction(logger, args) {
39
- var _a, _b, _c;
40
42
  return __awaiter(this, void 0, void 0, function* () {
41
43
  if (this.verbose) {
42
44
  logger.logToStderr(`Adding user to AAD with displayName ${args.options.displayName} and userPrincipalName ${args.options.userName}`);
43
45
  }
44
46
  try {
47
+ const manifest = this.mapRequestBody(args.options);
45
48
  const requestOptions = {
46
49
  url: `${this.resource}/v1.0/users`,
47
50
  headers: {
48
51
  accept: 'application/json;odata.metadata=none'
49
52
  },
50
53
  responseType: 'json',
51
- data: {
52
- accountEnabled: (_a = args.options.accountEnabled) !== null && _a !== void 0 ? _a : true,
53
- displayName: args.options.displayName,
54
- userPrincipalName: args.options.userName,
55
- mailNickName: (_b = args.options.mailNickname) !== null && _b !== void 0 ? _b : args.options.userName.split('@')[0],
56
- passwordProfile: {
57
- forceChangePasswordNextSignIn: args.options.forceChangePasswordNextSignIn || false,
58
- forceChangePasswordNextSignInWithMfa: args.options.forceChangePasswordNextSignInWithMfa || false,
59
- password: (_c = args.options.password) !== null && _c !== void 0 ? _c : this.generatePassword()
60
- },
61
- givenName: args.options.firstName,
62
- surName: args.options.lastName,
63
- usageLocation: args.options.usageLocation,
64
- officeLocation: args.options.officeLocation,
65
- jobTitle: args.options.jobTitle,
66
- companyName: args.options.companyName,
67
- department: args.options.department,
68
- preferredLanguage: args.options.preferredLanguage
69
- }
54
+ data: manifest
70
55
  };
71
56
  const user = yield request_1.default.post(requestOptions);
72
57
  user.password = requestOptions.data.passwordProfile.password;
@@ -89,8 +74,32 @@ class AadUserAddCommand extends GraphCommand_1.default {
89
74
  }
90
75
  });
91
76
  }
77
+ mapRequestBody(options) {
78
+ var _a, _b, _c;
79
+ const requestBody = {
80
+ accountEnabled: (_a = options.accountEnabled) !== null && _a !== void 0 ? _a : true,
81
+ displayName: options.displayName,
82
+ userPrincipalName: options.userName,
83
+ mailNickName: (_b = options.mailNickname) !== null && _b !== void 0 ? _b : options.userName.split('@')[0],
84
+ passwordProfile: {
85
+ forceChangePasswordNextSignIn: options.forceChangePasswordNextSignIn || false,
86
+ forceChangePasswordNextSignInWithMfa: options.forceChangePasswordNextSignInWithMfa || false,
87
+ password: (_c = options.password) !== null && _c !== void 0 ? _c : this.generatePassword()
88
+ },
89
+ givenName: options.firstName,
90
+ surName: options.lastName,
91
+ usageLocation: options.usageLocation,
92
+ officeLocation: options.officeLocation,
93
+ jobTitle: options.jobTitle,
94
+ companyName: options.companyName,
95
+ department: options.department,
96
+ preferredLanguage: options.preferredLanguage
97
+ };
98
+ this.addUnknownOptionsToPayload(requestBody, options);
99
+ return requestBody;
100
+ }
92
101
  /**
93
- * Generate a password with at least: one digit, one lowercase chracter, one uppercase character and special character.
102
+ * Generate a password with at least: one digit, one lowercase character, one uppercase character, and a special character.
94
103
  */
95
104
  generatePassword() {
96
105
  const numberChars = '0123456789';