@pnp/cli-microsoft365 7.0.0-beta.68abdfc → 7.0.0-beta.7e7b4f8

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 (114) hide show
  1. package/dist/Command.js +1 -1
  2. package/dist/cli/Cli.js +23 -8
  3. package/dist/m365/aad/commands/user/user-get.js +7 -1
  4. package/dist/m365/booking/commands/business/business-get.js +14 -15
  5. package/dist/m365/cli/commands/config/config-set.js +1 -1
  6. package/dist/m365/pa/commands/app/app-owner-set.js +115 -0
  7. package/dist/m365/pa/commands/app/app-permission-list.js +104 -0
  8. package/dist/m365/pa/commands.js +2 -0
  9. package/dist/m365/planner/commands/bucket/bucket-add.js +14 -10
  10. package/dist/m365/planner/commands/bucket/bucket-get.js +25 -19
  11. package/dist/m365/planner/commands/bucket/bucket-list.js +14 -10
  12. package/dist/m365/planner/commands/bucket/bucket-remove.js +26 -20
  13. package/dist/m365/planner/commands/bucket/bucket-set.js +26 -28
  14. package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +19 -17
  15. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +19 -17
  16. package/dist/m365/search/commands/externalconnection/externalconnection-remove.js +35 -34
  17. package/dist/m365/spfx/commands/project/project-externalize/rules/DynamicRule.js +59 -51
  18. package/dist/m365/spo/commands/file/file-list.js +3 -14
  19. package/dist/m365/spo/commands/folder/folder-remove.js +30 -28
  20. package/dist/m365/spo/commands/list/list-retentionlabel-ensure.js +0 -4
  21. package/dist/m365/spo/commands/list/list-retentionlabel-get.js +0 -4
  22. package/dist/m365/spo/commands/list/list-roleassignment-add.js +9 -47
  23. package/dist/m365/spo/commands/page/page-remove.js +33 -31
  24. package/dist/m365/spo/commands/roledefinition/roledefinition-remove.js +25 -23
  25. package/dist/m365/spo/commands/site/site-apppermission-add.js +3 -3
  26. package/dist/m365/spo/commands/site/site-commsite-enable.js +9 -18
  27. package/dist/m365/spo/commands/site/site-set.js +10 -2
  28. package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +13 -16
  29. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +80 -2
  30. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +48 -48
  31. package/dist/m365/spo/commands/theme/theme-get.js +1 -2
  32. package/dist/m365/spo/commands.js +0 -2
  33. package/dist/m365/teams/commands/chat/chat-get.js +4 -4
  34. package/dist/m365/teams/commands/chat/chat-member-add.js +117 -0
  35. package/dist/m365/teams/commands/chat/chat-message-send.js +4 -4
  36. package/dist/m365/teams/commands/team/team-app-list.js +1 -1
  37. package/dist/m365/teams/commands.js +1 -0
  38. package/dist/utils/spo.js +74 -0
  39. package/docs/docs/_clisettings.mdx +1 -1
  40. package/docs/docs/cmd/_global.mdx +1 -1
  41. package/docs/docs/cmd/aad/user/user-get.mdx +118 -25
  42. package/docs/docs/cmd/pa/app/app-owner-set.mdx +60 -0
  43. package/docs/docs/cmd/pa/app/app-permission-list.mdx +132 -0
  44. package/docs/docs/cmd/planner/bucket/bucket-add.mdx +21 -4
  45. package/docs/docs/cmd/planner/bucket/bucket-get.mdx +22 -5
  46. package/docs/docs/cmd/planner/bucket/bucket-list.mdx +21 -4
  47. package/docs/docs/cmd/planner/bucket/bucket-remove.mdx +21 -4
  48. package/docs/docs/cmd/planner/bucket/bucket-set.mdx +22 -5
  49. package/docs/docs/cmd/spo/file/file-list.mdx +6 -10
  50. package/docs/docs/cmd/spo/list/list-retentionlabel-ensure.mdx +0 -6
  51. package/docs/docs/cmd/spo/list/list-retentionlabel-get.mdx +0 -6
  52. package/docs/docs/cmd/spo/site/site-add.mdx +35 -0
  53. package/docs/docs/cmd/spo/site/site-appcatalog-add.mdx +5 -1
  54. package/docs/docs/cmd/spo/site/site-appcatalog-list.mdx +14 -0
  55. package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +4 -0
  56. package/docs/docs/cmd/spo/site/site-apppermission-add.mdx +68 -0
  57. package/docs/docs/cmd/spo/site/site-apppermission-get.mdx +55 -0
  58. package/docs/docs/cmd/spo/site/site-apppermission-list.mdx +55 -0
  59. package/docs/docs/cmd/spo/site/site-apppermission-remove.mdx +4 -0
  60. package/docs/docs/cmd/spo/site/site-apppermission-set.mdx +66 -0
  61. package/docs/docs/cmd/spo/site/site-chrome-set.mdx +4 -0
  62. package/docs/docs/cmd/spo/site/site-commsite-enable.mdx +11 -1
  63. package/docs/docs/cmd/spo/site/site-ensure.mdx +70 -0
  64. package/docs/docs/cmd/spo/site/site-get.mdx +179 -0
  65. package/docs/docs/cmd/spo/site/site-groupify.mdx +54 -0
  66. package/docs/docs/cmd/spo/site/site-hubsite-connect.mdx +4 -0
  67. package/docs/docs/cmd/spo/site/site-hubsite-disconnect.mdx +4 -0
  68. package/docs/docs/cmd/spo/site/site-hubsite-theme-sync.mdx +5 -1
  69. package/docs/docs/cmd/spo/site/site-inplacerecordsmanagement-set.mdx +4 -0
  70. package/docs/docs/cmd/spo/site/site-list.mdx +303 -0
  71. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +80 -0
  72. package/docs/docs/cmd/spo/site/site-recyclebinitem-restore.mdx +4 -0
  73. package/docs/docs/cmd/spo/site/site-remove.mdx +4 -0
  74. package/docs/docs/cmd/spo/site/site-rename.mdx +92 -0
  75. package/docs/docs/cmd/spo/site/site-set.mdx +13 -0
  76. package/docs/docs/cmd/spo/sitedesign/sitedesign-add.mdx +116 -0
  77. package/docs/docs/cmd/spo/sitedesign/sitedesign-apply.mdx +125 -0
  78. package/docs/docs/cmd/spo/sitedesign/sitedesign-get.mdx +117 -0
  79. package/docs/docs/cmd/spo/sitedesign/sitedesign-list.mdx +94 -0
  80. package/docs/docs/cmd/spo/sitedesign/sitedesign-remove.mdx +4 -0
  81. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-grant.mdx +4 -0
  82. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-list.mdx +54 -0
  83. package/docs/docs/cmd/spo/sitedesign/sitedesign-rights-revoke.mdx +4 -0
  84. package/docs/docs/cmd/spo/sitedesign/sitedesign-run-list.mdx +66 -0
  85. package/docs/docs/cmd/spo/sitedesign/sitedesign-run-status-get.mdx +65 -0
  86. package/docs/docs/cmd/spo/sitedesign/sitedesign-set.mdx +117 -0
  87. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-get.mdx +61 -0
  88. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-list.mdx +60 -0
  89. package/docs/docs/cmd/spo/sitedesign/sitedesign-task-remove.mdx +4 -0
  90. package/docs/docs/cmd/spo/sitescript/sitescript-add.mdx +75 -0
  91. package/docs/docs/cmd/spo/sitescript/sitescript-get.mdx +62 -0
  92. package/docs/docs/cmd/spo/sitescript/sitescript-list.mdx +60 -0
  93. package/docs/docs/cmd/spo/sitescript/sitescript-remove.mdx +4 -0
  94. package/docs/docs/cmd/spo/sitescript/sitescript-set.mdx +63 -0
  95. package/docs/docs/cmd/spo/storageentity/storageentity-get.mdx +53 -0
  96. package/docs/docs/cmd/spo/storageentity/storageentity-list.mdx +54 -0
  97. package/docs/docs/cmd/spo/storageentity/storageentity-remove.mdx +4 -0
  98. package/docs/docs/cmd/spo/storageentity/storageentity-set.mdx +4 -0
  99. package/docs/docs/cmd/spo/tenant/tenant-appcatalog-add.mdx +4 -0
  100. package/docs/docs/cmd/spo/tenant/tenant-appcatalogurl-get.mdx +35 -0
  101. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +12 -3
  102. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-list.mdx +67 -0
  103. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-remove.mdx +4 -0
  104. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +50 -0
  105. package/docs/docs/cmd/spo/tenant/tenant-settings-list.mdx +729 -0
  106. package/docs/docs/cmd/spo/tenant/tenant-settings-set.mdx +5 -0
  107. package/docs/docs/cmd/spo/theme/theme-apply.mdx +35 -0
  108. package/docs/docs/cmd/spo/theme/theme-get.mdx +74 -0
  109. package/docs/docs/cmd/spo/theme/theme-list.mdx +52 -0
  110. package/docs/docs/cmd/spo/theme/theme-remove.mdx +4 -0
  111. package/docs/docs/cmd/spo/theme/theme-set.mdx +4 -0
  112. package/docs/docs/cmd/teams/chat/chat-member-add.mdx +66 -0
  113. package/npm-shrinkwrap.json +212 -212
  114. package/package.json +10 -10
@@ -23,6 +23,8 @@ const validation_1 = require("../../../../utils/validation");
23
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
24
  const commands_1 = require("../../commands");
25
25
  const os = require("os");
26
+ const Cli_1 = require("../../../../cli/Cli");
27
+ const spoListItemListCommand = require("../listitem/listitem-list");
26
28
  const request_1 = require("../../../../request");
27
29
  class SpoTenantApplicationCustomizerSetCommand extends SpoCommand_1.default {
28
30
  get name() {
@@ -46,6 +48,20 @@ class SpoTenantApplicationCustomizerSetCommand extends SpoCommand_1.default {
46
48
  if (!appCatalogUrl) {
47
49
  throw 'No app catalog URL found';
48
50
  }
51
+ if (args.options.newClientSideComponentId !== undefined) {
52
+ const componentManifest = yield this.getComponentManifest(appCatalogUrl, args.options.newClientSideComponentId, logger);
53
+ const clientComponentManifest = JSON.parse(componentManifest.ClientComponentManifest);
54
+ if (clientComponentManifest.extensionType !== "ApplicationCustomizer") {
55
+ throw `The extension type of this component is not of type 'ApplicationCustomizer' but of type '${clientComponentManifest.extensionType}'`;
56
+ }
57
+ const solution = yield this.getSolutionFromAppCatalog(appCatalogUrl, componentManifest.SolutionId, logger);
58
+ if (!solution.ContainsTenantWideExtension) {
59
+ throw `The solution does not contain an extension that can be deployed to all sites. Make sure that you've entered the correct component Id.`;
60
+ }
61
+ else if (!solution.SkipFeatureDeployment) {
62
+ throw 'The solution has not been deployed to all sites. Make sure to deploy this solution to all sites.';
63
+ }
64
+ }
49
65
  const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(appCatalogUrl, '/lists/TenantWideExtensions');
50
66
  const listItemId = yield this.getListItemId(appCatalogUrl, args.options, listServerRelativeUrl, logger);
51
67
  yield this.updateTenantWideExtension(appCatalogUrl, args.options, listServerRelativeUrl, listItemId, logger);
@@ -72,9 +88,59 @@ class SpoTenantApplicationCustomizerSetCommand extends SpoCommand_1.default {
72
88
  return listItemInstances[0].Id;
73
89
  });
74
90
  }
91
+ getComponentManifest(appCatalogUrl, clientSideComponentId, logger) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ if (this.verbose) {
94
+ logger.logToStderr('Retrieving component manifest item from the ComponentManifests list on the app catalog site so that we get the solution id');
95
+ }
96
+ const camlQuery = `<View><ViewFields><FieldRef Name='ClientComponentId'></FieldRef><FieldRef Name='SolutionId'></FieldRef><FieldRef Name='ClientComponentManifest'></FieldRef></ViewFields><Query><Where><Eq><FieldRef Name='ClientComponentId' /><Value Type='Guid'>${clientSideComponentId}</Value></Eq></Where></Query></View>`;
97
+ const commandOptions = {
98
+ webUrl: appCatalogUrl,
99
+ listUrl: `${urlUtil_1.urlUtil.getServerRelativeSiteUrl(appCatalogUrl)}/Lists/ComponentManifests`,
100
+ camlQuery: camlQuery,
101
+ verbose: this.verbose,
102
+ debug: this.debug,
103
+ output: 'json'
104
+ };
105
+ const output = yield Cli_1.Cli.executeCommandWithOutput(spoListItemListCommand, { options: Object.assign(Object.assign({}, commandOptions), { _: [] }) });
106
+ if (this.verbose) {
107
+ logger.logToStderr(output.stderr);
108
+ }
109
+ const outputParsed = JSON.parse(output.stdout);
110
+ if (outputParsed.length === 0) {
111
+ throw 'No component found with the specified clientSideComponentId found in the component manifest list. Make sure that the application is added to the application catalog';
112
+ }
113
+ return outputParsed[0];
114
+ });
115
+ }
116
+ getSolutionFromAppCatalog(appCatalogUrl, solutionId, logger) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ if (this.verbose) {
119
+ logger.logToStderr(`Retrieving solution with id ${solutionId} from the application catalog`);
120
+ }
121
+ const camlQuery = `<View><ViewFields><FieldRef Name='SkipFeatureDeployment'></FieldRef><FieldRef Name='ContainsTenantWideExtension'></FieldRef></ViewFields><Query><Where><Eq><FieldRef Name='AppProductID' /><Value Type='Guid'>${solutionId}</Value></Eq></Where></Query></View>`;
122
+ const commandOptions = {
123
+ webUrl: appCatalogUrl,
124
+ listUrl: `${urlUtil_1.urlUtil.getServerRelativeSiteUrl(appCatalogUrl)}/AppCatalog`,
125
+ camlQuery: camlQuery,
126
+ verbose: this.verbose,
127
+ debug: this.debug,
128
+ output: 'json'
129
+ };
130
+ const output = yield Cli_1.Cli.executeCommandWithOutput(spoListItemListCommand, { options: Object.assign(Object.assign({}, commandOptions), { _: [] }) });
131
+ if (this.verbose) {
132
+ logger.logToStderr(output.stderr);
133
+ }
134
+ const outputParsed = JSON.parse(output.stdout);
135
+ if (outputParsed.length === 0) {
136
+ throw `No component found with the solution id ${solutionId}. Make sure that the solution is available in the app catalog`;
137
+ }
138
+ return outputParsed[0];
139
+ });
140
+ }
75
141
  updateTenantWideExtension(appCatalogUrl, options, listServerRelativeUrl, itemId, logger) {
76
142
  return __awaiter(this, void 0, void 0, function* () {
77
- const { title, id, clientSideComponentId, newTitle, clientSideComponentProperties, webTemplate } = options;
143
+ const { title, id, clientSideComponentId, newTitle, newClientSideComponentId, clientSideComponentProperties, webTemplate } = options;
78
144
  if (this.verbose) {
79
145
  logger.logToStderr(`Updating tenant-wide application customizer: "${title || id || clientSideComponentId}"...`);
80
146
  }
@@ -85,6 +151,12 @@ class SpoTenantApplicationCustomizerSetCommand extends SpoCommand_1.default {
85
151
  FieldValue: newTitle
86
152
  });
87
153
  }
154
+ if (newClientSideComponentId !== undefined) {
155
+ formValues.push({
156
+ FieldName: 'TenantWideExtensionComponentId',
157
+ FieldValue: newClientSideComponentId
158
+ });
159
+ }
88
160
  if (clientSideComponentProperties !== undefined) {
89
161
  formValues.push({
90
162
  FieldName: 'TenantWideExtensionComponentProperties',
@@ -118,6 +190,7 @@ _SpoTenantApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoTenantA
118
190
  id: typeof args.options.id !== 'undefined',
119
191
  clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
120
192
  newTitle: typeof args.options.newTitle !== 'undefined',
193
+ newClientSideComponentId: typeof args.options.newClientSideComponentId !== 'undefined',
121
194
  clientSideComponentProperties: typeof args.options.clientSideComponentProperties !== 'undefined',
122
195
  webTemplate: typeof args.options.webTemplate !== 'undefined'
123
196
  });
@@ -131,6 +204,8 @@ _SpoTenantApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoTenantA
131
204
  option: '-c, --clientSideComponentId [clientSideComponentId]'
132
205
  }, {
133
206
  option: '--newTitle [newTitle]'
207
+ }, {
208
+ option: '--newClientSideComponentId [newClientSideComponentId]'
134
209
  }, {
135
210
  option: '-p, --clientSideComponentProperties [clientSideComponentProperties]'
136
211
  }, {
@@ -144,7 +219,10 @@ _SpoTenantApplicationCustomizerSetCommand_instances = new WeakSet(), _SpoTenantA
144
219
  if (args.options.clientSideComponentId && !validation_1.validation.isValidGuid(args.options.clientSideComponentId)) {
145
220
  return `${args.options.clientSideComponentId} is not a valid GUID`;
146
221
  }
147
- if (!args.options.newTitle && !args.options.clientSideComponentProperties && !args.options.webTemplate) {
222
+ if (args.options.newClientSideComponentId && !validation_1.validation.isValidGuid(args.options.newClientSideComponentId)) {
223
+ return `${args.options.newClientSideComponentId} is not a valid GUID`;
224
+ }
225
+ if (!args.options.newTitle && !args.options.newClientSideComponentId && !args.options.clientSideComponentProperties && !args.options.webTemplate) {
148
226
  return `Please specify an option to be updated`;
149
227
  }
150
228
  return true;
@@ -39,54 +39,8 @@ class SpoTenantRecycleBinItemRemoveCommand extends SpoCommand_1.default {
39
39
  }
40
40
  commandAction(logger, args) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- const removeDeletedSite = () => __awaiter(this, void 0, void 0, function* () {
43
- try {
44
- this.spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
45
- const res = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
46
- if (this.verbose) {
47
- logger.logToStderr(`Removing deleted site collection ${args.options.siteUrl}...`);
48
- }
49
- const requestOptions = {
50
- url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
51
- headers: {
52
- 'X-RequestDigest': res.FormDigestValue
53
- },
54
- data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="16" ObjectPathId="15" /><Query Id="17" ObjectPathId="15"><Query SelectAllProperties="false"><Properties><Property Name="PollingInterval" ScalarProperty="true" /><Property Name="IsComplete" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="15" ParentId="1" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.siteUrl)}</Parameter></Parameters></Method><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
55
- };
56
- const processQuery = yield request_1.default.post(requestOptions);
57
- const json = JSON.parse(processQuery);
58
- const response = json[0];
59
- if (response.ErrorInfo) {
60
- throw response.ErrorInfo.ErrorMessage;
61
- }
62
- else {
63
- const operation = json[json.length - 1];
64
- const isComplete = operation.IsComplete;
65
- if (!args.options.wait || isComplete) {
66
- return;
67
- }
68
- yield new Promise((resolve, reject) => {
69
- setTimeout(() => {
70
- spo_1.spo.waitUntilFinished({
71
- operationId: JSON.stringify(operation._ObjectIdentity_),
72
- siteUrl: this.spoAdminUrl,
73
- resolve,
74
- reject,
75
- logger,
76
- currentContext: this.context,
77
- debug: this.debug,
78
- verbose: this.verbose
79
- });
80
- }, operation.PollingInterval);
81
- });
82
- }
83
- }
84
- catch (err) {
85
- this.handleRejectedODataJsonPromise(err);
86
- }
87
- });
88
42
  if (args.options.force) {
89
- yield removeDeletedSite();
43
+ yield this.removeDeletedSite(logger, args);
90
44
  }
91
45
  else {
92
46
  const result = yield Cli_1.Cli.prompt({
@@ -96,11 +50,57 @@ class SpoTenantRecycleBinItemRemoveCommand extends SpoCommand_1.default {
96
50
  message: `Are you sure you want to remove the deleted site collection ${args.options.siteUrl} from tenant recycle bin?`
97
51
  });
98
52
  if (result.continue) {
99
- yield removeDeletedSite();
53
+ yield this.removeDeletedSite(logger, args);
100
54
  }
101
55
  }
102
56
  });
103
57
  }
58
+ removeDeletedSite(logger, args) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ try {
61
+ const spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
62
+ const res = yield spo_1.spo.ensureFormDigest(spoAdminUrl, logger, this.context, this.debug);
63
+ if (this.verbose) {
64
+ logger.logToStderr(`Removing deleted site collection ${args.options.siteUrl}...`);
65
+ }
66
+ const requestOptions = {
67
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
68
+ headers: {
69
+ 'X-RequestDigest': res.FormDigestValue
70
+ },
71
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="16" ObjectPathId="15" /><Query Id="17" ObjectPathId="15"><Query SelectAllProperties="false"><Properties><Property Name="PollingInterval" ScalarProperty="true" /><Property Name="IsComplete" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="15" ParentId="1" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(args.options.siteUrl)}</Parameter></Parameters></Method><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
72
+ };
73
+ const processQuery = yield request_1.default.post(requestOptions);
74
+ const json = JSON.parse(processQuery);
75
+ const response = json[0];
76
+ if (response.ErrorInfo) {
77
+ throw response.ErrorInfo.ErrorMessage;
78
+ }
79
+ const operation = json[json.length - 1];
80
+ const isComplete = operation.IsComplete;
81
+ if (!args.options.wait || isComplete) {
82
+ return;
83
+ }
84
+ yield new Promise((resolve, reject) => {
85
+ setTimeout(() => {
86
+ spo_1.spo.waitUntilFinished({
87
+ operationId: JSON.stringify(operation._ObjectIdentity_),
88
+ siteUrl: spoAdminUrl,
89
+ resolve,
90
+ reject,
91
+ logger,
92
+ currentContext: this.context,
93
+ debug: this.debug,
94
+ verbose: this.verbose
95
+ });
96
+ }, operation.PollingInterval);
97
+ });
98
+ }
99
+ catch (err) {
100
+ this.handleRejectedODataJsonPromise(err);
101
+ }
102
+ });
103
+ }
104
104
  }
105
105
  _SpoTenantRecycleBinItemRemoveCommand_instances = new WeakSet(), _SpoTenantRecycleBinItemRemoveCommand_initTelemetry = function _SpoTenantRecycleBinItemRemoveCommand_initTelemetry() {
106
106
  this.telemetry.push((args) => {
@@ -54,8 +54,7 @@ class SpoThemeGetCommand extends SpoCommand_1.default {
54
54
  if (contents && contents.ErrorInfo) {
55
55
  throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
56
56
  }
57
- const json2 = yield Promise.resolve(json);
58
- const theme = json2[6];
57
+ const theme = json[6];
59
58
  delete theme._ObjectType_;
60
59
  logger.log(theme);
61
60
  }
@@ -132,8 +132,6 @@ exports.default = {
132
132
  LIST_CONTENTTYPE_REMOVE: `${prefix} list contenttype remove`,
133
133
  LIST_CONTENTTYPE_DEFAULT_SET: `${prefix} list contenttype default set`,
134
134
  LIST_GET: `${prefix} list get`,
135
- LIST_LABEL_GET: `${prefix} list label get`,
136
- LIST_LABEL_SET: `${prefix} list label set`,
137
135
  LIST_LIST: `${prefix} list list`,
138
136
  LIST_REMOVE: `${prefix} list remove`,
139
137
  LIST_RETENTIONLABEL_ENSURE: `${prefix} list retentionlabel ensure`,
@@ -79,7 +79,7 @@ class TeamsChatGetCommand extends GraphCommand_1.default {
79
79
  const currentUserEmail = accessToken_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken).toLowerCase();
80
80
  const existingChats = yield chatUtil_1.chatUtil.findExistingChatsByParticipants([currentUserEmail, ...participants]);
81
81
  if (!existingChats || existingChats.length === 0) {
82
- throw new Error('No chat conversation was found with these participants.');
82
+ throw 'No chat conversation was found with these participants.';
83
83
  }
84
84
  if (existingChats.length === 1) {
85
85
  return existingChats[0].id;
@@ -87,14 +87,14 @@ class TeamsChatGetCommand extends GraphCommand_1.default {
87
87
  const disambiguationText = existingChats.map(c => {
88
88
  return `- ${c.id}${c.topic && ' - '}${c.topic} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()}`;
89
89
  }).join(os.EOL);
90
- throw new Error(`Multiple chat conversations with these participants found. Please disambiguate:${os.EOL}${disambiguationText}`);
90
+ throw `Multiple chat conversations with these participants found. Please disambiguate:${os.EOL}${disambiguationText}`;
91
91
  });
92
92
  }
93
93
  getChatIdByName(name) {
94
94
  return __awaiter(this, void 0, void 0, function* () {
95
95
  const existingChats = yield chatUtil_1.chatUtil.findExistingGroupChatsByName(name);
96
96
  if (!existingChats || existingChats.length === 0) {
97
- throw new Error('No chat conversation was found with this name.');
97
+ throw 'No chat conversation was found with this name.';
98
98
  }
99
99
  if (existingChats.length === 1) {
100
100
  return existingChats[0].id;
@@ -103,7 +103,7 @@ class TeamsChatGetCommand extends GraphCommand_1.default {
103
103
  const memberstring = c.members.map(m => m.email).join(', ');
104
104
  return `- ${c.id} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()} - ${memberstring}`;
105
105
  }).join(os.EOL);
106
- throw new Error(`Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`);
106
+ throw `Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`;
107
107
  });
108
108
  }
109
109
  }
@@ -0,0 +1,117 @@
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 _TeamsChatMemberAddCommand_instances, _TeamsChatMemberAddCommand_initTelemetry, _TeamsChatMemberAddCommand_initOptions, _TeamsChatMemberAddCommand_initValidators, _TeamsChatMemberAddCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const validation_1 = require("../../../../utils/validation");
19
+ const GraphCommand_1 = require("../../../base/GraphCommand");
20
+ const commands_1 = require("../../commands");
21
+ const request_1 = require("../../../../request");
22
+ const formatting_1 = require("../../../../utils/formatting");
23
+ class TeamsChatMemberAddCommand extends GraphCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.CHAT_MEMBER_ADD;
26
+ }
27
+ get description() {
28
+ return 'Adds a member to a Microsoft Teams chat conversation.';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _TeamsChatMemberAddCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _TeamsChatMemberAddCommand_instances, "m", _TeamsChatMemberAddCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _TeamsChatMemberAddCommand_instances, "m", _TeamsChatMemberAddCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _TeamsChatMemberAddCommand_instances, "m", _TeamsChatMemberAddCommand_initValidators).call(this);
36
+ __classPrivateFieldGet(this, _TeamsChatMemberAddCommand_instances, "m", _TeamsChatMemberAddCommand_initOptionSets).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ try {
41
+ if (this.verbose) {
42
+ logger.logToStderr(`Adding member ${args.options.userId || args.options.userName} to chat with id ${args.options.chatId}...`);
43
+ }
44
+ const chatMemberAddOptions = {
45
+ url: `${this.resource}/v1.0/chats/${args.options.chatId}/members`,
46
+ headers: {
47
+ accept: 'application/json;odata.metadata=none'
48
+ },
49
+ responseType: 'json',
50
+ data: {
51
+ '@odata.type': '#microsoft.graph.aadUserConversationMember',
52
+ 'user@odata.bind': `https://graph.microsoft.com/v1.0/users/${args.options.userId || formatting_1.formatting.encodeQueryParameter(args.options.userName)}`,
53
+ visibleHistoryStartDateTime: args.options.includeAllHistory ? '0001-01-01T00:00:00Z' : args.options.visibleHistoryStartDateTime,
54
+ roles: [args.options.role || 'owner']
55
+ }
56
+ };
57
+ yield request_1.default.post(chatMemberAddOptions);
58
+ }
59
+ catch (err) {
60
+ this.handleRejectedODataJsonPromise(err);
61
+ }
62
+ });
63
+ }
64
+ }
65
+ _TeamsChatMemberAddCommand_instances = new WeakSet(), _TeamsChatMemberAddCommand_initTelemetry = function _TeamsChatMemberAddCommand_initTelemetry() {
66
+ this.telemetry.push((args) => {
67
+ Object.assign(this.telemetryProperties, {
68
+ userId: typeof args.options.userId !== 'undefined',
69
+ userName: typeof args.options.userName !== 'undefined',
70
+ role: typeof args.options.role !== 'undefined',
71
+ visibleHistoryStartDateTime: typeof args.options.visibleHistoryStartDateTime !== 'undefined',
72
+ includeAllHistory: !!args.options.includeAllHistory
73
+ });
74
+ });
75
+ }, _TeamsChatMemberAddCommand_initOptions = function _TeamsChatMemberAddCommand_initOptions() {
76
+ this.options.unshift({
77
+ option: '-i, --chatId <chatId>'
78
+ }, {
79
+ option: '--userId [userId]'
80
+ }, {
81
+ option: '--userName [userName]'
82
+ }, {
83
+ option: '--role [role]',
84
+ autocomplete: TeamsChatMemberAddCommand.roles
85
+ }, {
86
+ option: '--visibleHistoryStartDateTime [visibleHistoryStartDateTime]'
87
+ }, {
88
+ option: '--includeAllHistory'
89
+ });
90
+ }, _TeamsChatMemberAddCommand_initValidators = function _TeamsChatMemberAddCommand_initValidators() {
91
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
92
+ if (!validation_1.validation.isValidTeamsChatId(args.options.chatId)) {
93
+ return `${args.options.chatId} is not a valid chatId.`;
94
+ }
95
+ if (args.options.userId && !validation_1.validation.isValidGuid(args.options.userId)) {
96
+ return `${args.options.userId} is not a valid userId.`;
97
+ }
98
+ if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
99
+ return `${args.options.userName} is not a valid userName.`;
100
+ }
101
+ if (args.options.role && TeamsChatMemberAddCommand.roles.indexOf(args.options.role) < 0) {
102
+ return `${args.options.role} is not a valid role. Allowed values are ${TeamsChatMemberAddCommand.roles.join(', ')}`;
103
+ }
104
+ if (args.options.visibleHistoryStartDateTime && !validation_1.validation.isValidISODateTime(args.options.visibleHistoryStartDateTime)) {
105
+ return `'${args.options.visibleHistoryStartDateTime}' is not a valid visibleHistoryStartDateTime.`;
106
+ }
107
+ return true;
108
+ }));
109
+ }, _TeamsChatMemberAddCommand_initOptionSets = function _TeamsChatMemberAddCommand_initOptionSets() {
110
+ this.optionSets.push({ options: ['userId', 'userName'] }, {
111
+ options: ['visibleHistoryStartDateTime', 'includeAllHistory'],
112
+ runsWhen: (args) => args.options.visibleHistoryStartDateTime || args.options.includeAllHistory
113
+ });
114
+ };
115
+ TeamsChatMemberAddCommand.roles = ['owner', 'guest'];
116
+ module.exports = new TeamsChatMemberAddCommand();
117
+ //# sourceMappingURL=chat-member-add.js.map
@@ -74,14 +74,14 @@ class TeamsChatMessageSendCommand extends GraphCommand_1.default {
74
74
  const disambiguationText = existingChats.map(c => {
75
75
  return `- ${c.id}${c.topic && ' - '}${c.topic} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()}`;
76
76
  }).join(os.EOL);
77
- throw new Error(`Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`);
77
+ throw `Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`;
78
78
  });
79
79
  }
80
80
  getChatIdByName(chatName) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  const existingChats = yield chatUtil_1.chatUtil.findExistingGroupChatsByName(chatName);
83
83
  if (!existingChats || existingChats.length === 0) {
84
- throw new Error('No chat conversation was found with this name.');
84
+ throw 'No chat conversation was found with this name.';
85
85
  }
86
86
  if (existingChats.length === 1) {
87
87
  return existingChats[0].id;
@@ -90,7 +90,7 @@ class TeamsChatMessageSendCommand extends GraphCommand_1.default {
90
90
  const memberstring = c.members.map(m => m.email).join(', ');
91
91
  return `- ${c.id} - ${c.createdDateTime && new Date(c.createdDateTime).toLocaleString()} - ${memberstring}`;
92
92
  }).join(os.EOL);
93
- throw new Error(`Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`);
93
+ throw `Multiple chat conversations with this name found. Please disambiguate:${os.EOL}${disambiguationText}`;
94
94
  });
95
95
  }
96
96
  // This Microsoft Graph API request throws an intermittent 404 exception, saying that it cannot find the principal.
@@ -146,7 +146,7 @@ class TeamsChatMessageSendCommand extends GraphCommand_1.default {
146
146
  }
147
147
  }
148
148
  };
149
- yield request_1.default.post(requestOptions);
149
+ return request_1.default.post(requestOptions);
150
150
  });
151
151
  }
152
152
  }
@@ -43,7 +43,7 @@ class TeamsTeamAppListCommand extends GraphCommand_1.default {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
44
  try {
45
45
  if (this.verbose) {
46
- logger.logToStderr(`Retrieving installed apps for team '${args.options.teamId || args.options.teamId}'`);
46
+ logger.logToStderr(`Retrieving installed apps for team '${args.options.teamId || args.options.teamName}'`);
47
47
  }
48
48
  const teamId = yield this.getTeamId(args);
49
49
  const res = yield odata_1.odata.getAllItems(`${this.resource}/v1.0/teams/${teamId}/installedApps?$expand=teamsApp,teamsAppDefinition`);
@@ -20,6 +20,7 @@ exports.default = {
20
20
  CHANNEL_SET: `${prefix} channel set`,
21
21
  CHAT_GET: `${prefix} chat get`,
22
22
  CHAT_LIST: `${prefix} chat list`,
23
+ CHAT_MEMBER_ADD: `${prefix} chat member add`,
23
24
  CHAT_MEMBER_LIST: `${prefix} chat member list`,
24
25
  CHAT_MEMBER_REMOVE: `${prefix} chat member remove`,
25
26
  CHAT_MESSAGE_LIST: `${prefix} chat message list`,
package/dist/utils/spo.js CHANGED
@@ -19,6 +19,7 @@ const base_permissions_1 = require("../m365/spo/base-permissions");
19
19
  const request_1 = require("../request");
20
20
  const formatting_1 = require("./formatting");
21
21
  const odata_1 = require("./odata");
22
+ const RoleType_1 = require("../m365/spo/commands/roledefinition/RoleType");
22
23
  exports.spo = {
23
24
  getRequestDigest(siteUrl) {
24
25
  const requestOptions = {
@@ -569,6 +570,30 @@ exports.spo = {
569
570
  return res.AadObjectId.NameId;
570
571
  });
571
572
  },
573
+ /**
574
+ * Retrieves the spo user by email.
575
+ * @param webUrl Web url
576
+ * @param email The email of the user
577
+ * @param logger the Logger object
578
+ * @param debug set if debug logging should be logged
579
+ */
580
+ getUserByEmail(webUrl, email, logger, debug) {
581
+ return __awaiter(this, void 0, void 0, function* () {
582
+ if (debug) {
583
+ logger.logToStderr(`Retrieving the spo user by email ${email}`);
584
+ }
585
+ const requestUrl = `${webUrl}/_api/web/siteusers/GetByEmail('${formatting_1.formatting.encodeQueryParameter(email)}')`;
586
+ const requestOptions = {
587
+ url: requestUrl,
588
+ headers: {
589
+ 'accept': 'application/json;odata=nometadata'
590
+ },
591
+ responseType: 'json'
592
+ };
593
+ const userInstance = yield request_1.default.get(requestOptions);
594
+ return userInstance;
595
+ });
596
+ },
572
597
  /**
573
598
  * Retrieves the menu state for the quick launch.
574
599
  * @param webUrl Web url
@@ -628,6 +653,55 @@ exports.spo = {
628
653
  };
629
654
  return request_1.default.post(requestOptions);
630
655
  });
656
+ },
657
+ /**
658
+ * Retrieves the spo group by name.
659
+ * @param webUrl Web url
660
+ * @param name The name of the group
661
+ * @param logger the Logger object
662
+ * @param debug set if debug logging should be logged
663
+ */
664
+ getGroupByName(webUrl, name, logger, debug) {
665
+ return __awaiter(this, void 0, void 0, function* () {
666
+ if (debug) {
667
+ logger.logToStderr(`Retrieving the group by name ${name}`);
668
+ }
669
+ const requestUrl = `${webUrl}/_api/web/sitegroups/GetByName('${formatting_1.formatting.encodeQueryParameter(name)}')`;
670
+ const requestOptions = {
671
+ url: requestUrl,
672
+ headers: {
673
+ 'accept': 'application/json;odata=nometadata'
674
+ },
675
+ responseType: 'json'
676
+ };
677
+ const groupInstance = yield request_1.default.get(requestOptions);
678
+ return groupInstance;
679
+ });
680
+ },
681
+ /**
682
+ * Retrieves the role definition by name.
683
+ * @param webUrl Web url
684
+ * @param name the name of the role definition
685
+ * @param logger the Logger object
686
+ * @param debug set if debug logging should be logged
687
+ */
688
+ getRoleDefinitionByName(webUrl, name, logger, debug) {
689
+ return __awaiter(this, void 0, void 0, function* () {
690
+ if (debug) {
691
+ logger.logToStderr(`Retrieving the role definitions for ${name}`);
692
+ }
693
+ const roledefinitions = yield odata_1.odata.getAllItems(`${webUrl}/_api/web/roledefinitions`);
694
+ const roledefinition = roledefinitions.find((role) => role.Name === name);
695
+ if (!roledefinition) {
696
+ throw `No roledefinition is found for ${name}`;
697
+ }
698
+ const permissions = new base_permissions_1.BasePermissions();
699
+ permissions.high = roledefinition.BasePermissions.High;
700
+ permissions.low = roledefinition.BasePermissions.Low;
701
+ roledefinition.BasePermissionsValue = permissions.parse();
702
+ roledefinition.RoleTypeKindValue = RoleType_1.RoleType[roledefinition.RoleTypeKind];
703
+ return roledefinition;
704
+ });
631
705
  }
632
706
  };
633
707
  //# sourceMappingURL=spo.js.map
@@ -10,7 +10,7 @@ Setting name|Definition|Default value
10
10
  `disableTelemetry`|Disables sending of telemetry data|`false`
11
11
  `errorOutput`|Defines if errors should be written to `stdout` or `stderr`|`stderr`
12
12
  `helpMode`|Defines what part of command's help to display. Allowed values are `options`, `examples`, `remarks`, `response`, `full`|`full`
13
- `output`|Defines the default output when issuing a command|`json`
13
+ `output`|Defines the default output when issuing a command. Allowed values are `json`, `text`, `csv`, `md`, `none`|`json`
14
14
  `printErrorsAsPlainText`|When output mode is set to `json`, print error messages as plain-text rather than JSON|`true`
15
15
  `prompt`|Prompts for missing values in required options and enables interactive selection when multiple values are available for a command that requires a specific value to be retrieved.|`false`
16
16
  `showHelpOnFailure`|Automatically display help when executing a command failed|`true`
@@ -6,7 +6,7 @@
6
6
  : JMESPath query string. See [http://jmespath.org/](http://jmespath.org/) for more information and examples.
7
7
 
8
8
  `-o, --output [output]`
9
- : Output type. `json`, `text`, `csv`, `md`. Default `json`.
9
+ : Output type. `json`, `text`, `csv`, `md`, `none`. Default `json`.
10
10
 
11
11
  `--verbose`
12
12
  : Runs command with verbose logging.