@activepieces/piece-microsoft-sharepoint 0.0.18 → 0.1.1

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 (59) hide show
  1. package/package.json +2 -2
  2. package/src/i18n/de.json +81 -6
  3. package/src/i18n/es.json +81 -6
  4. package/src/i18n/fr.json +81 -6
  5. package/src/i18n/ja.json +81 -6
  6. package/src/i18n/nl.json +81 -6
  7. package/src/i18n/pt.json +81 -6
  8. package/src/i18n/translation.json +81 -6
  9. package/src/i18n/zh.json +81 -6
  10. package/src/index.js +45 -10
  11. package/src/index.js.map +1 -1
  12. package/src/lib/actions/copy-item-within-site.d.ts +8 -0
  13. package/src/lib/actions/copy-item-within-site.js +154 -0
  14. package/src/lib/actions/copy-item-within-site.js.map +1 -0
  15. package/src/lib/actions/copy-item.d.ts +10 -0
  16. package/src/lib/actions/copy-item.js +118 -0
  17. package/src/lib/actions/copy-item.js.map +1 -0
  18. package/src/lib/actions/find-file.d.ts +8 -0
  19. package/src/lib/actions/find-file.js +132 -0
  20. package/src/lib/actions/find-file.js.map +1 -0
  21. package/src/lib/actions/get-folder-contents.d.ts +9 -0
  22. package/src/lib/actions/get-folder-contents.js +107 -0
  23. package/src/lib/actions/get-folder-contents.js.map +1 -0
  24. package/src/lib/actions/get-site-information.d.ts +4 -0
  25. package/src/lib/actions/get-site-information.js +38 -0
  26. package/src/lib/actions/get-site-information.js.map +1 -0
  27. package/src/lib/actions/move-file.d.ts +7 -0
  28. package/src/lib/actions/move-file.js +149 -0
  29. package/src/lib/actions/move-file.js.map +1 -0
  30. package/src/lib/actions/publish-page.d.ts +4 -0
  31. package/src/lib/actions/publish-page.js +52 -0
  32. package/src/lib/actions/publish-page.js.map +1 -0
  33. package/src/lib/common/index.d.ts +7 -0
  34. package/src/lib/common/index.js +152 -22
  35. package/src/lib/common/index.js.map +1 -1
  36. package/src/lib/triggers/new-file-in-folder.d.ts +14 -0
  37. package/src/lib/triggers/new-file-in-folder.js +154 -0
  38. package/src/lib/triggers/new-file-in-folder.js.map +1 -0
  39. package/src/lib/triggers/new-file-in-subfolders.d.ts +14 -0
  40. package/src/lib/triggers/new-file-in-subfolders.js +150 -0
  41. package/src/lib/triggers/new-file-in-subfolders.js.map +1 -0
  42. package/src/lib/triggers/new-list-item.d.ts +11 -0
  43. package/src/lib/triggers/new-list-item.js +108 -0
  44. package/src/lib/triggers/new-list-item.js.map +1 -0
  45. package/src/lib/triggers/new-list.d.ts +8 -0
  46. package/src/lib/triggers/new-list.js +101 -0
  47. package/src/lib/triggers/new-list.js.map +1 -0
  48. package/src/lib/triggers/new-or-updated-file.d.ts +14 -0
  49. package/src/lib/triggers/new-or-updated-file.js +150 -0
  50. package/src/lib/triggers/new-or-updated-file.js.map +1 -0
  51. package/src/lib/triggers/new-or-updated-folder.d.ts +14 -0
  52. package/src/lib/triggers/new-or-updated-folder.js +150 -0
  53. package/src/lib/triggers/new-or-updated-folder.js.map +1 -0
  54. package/src/lib/triggers/new-or-updated-list.d.ts +8 -0
  55. package/src/lib/triggers/new-or-updated-list.js +101 -0
  56. package/src/lib/triggers/new-or-updated-list.js.map +1 -0
  57. package/src/lib/triggers/updated-list-item.d.ts +11 -0
  58. package/src/lib/triggers/updated-list-item.js +108 -0
  59. package/src/lib/triggers/updated-list-item.js.map +1 -0
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFolderContentsAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ exports.getFolderContentsAction = (0, pieces_framework_1.createAction)({
10
+ auth: __1.microsoftSharePointAuth,
11
+ name: 'microsoft_sharepoint_get_folder_contents',
12
+ displayName: 'Get Folder Contents',
13
+ description: 'List all files and subfolders in a specified folder, optionally with detailed metadata.',
14
+ props: {
15
+ siteId: common_1.microsoftSharePointCommon.siteId,
16
+ driveId: common_1.microsoftSharePointCommon.driveId,
17
+ folderId: pieces_framework_1.Property.Dropdown({
18
+ displayName: 'Folder',
19
+ description: 'The folder whose contents you want to list. Select "Root Folder" for the top-level folder.',
20
+ required: true,
21
+ refreshers: ['siteId', 'driveId'],
22
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
23
+ if (!auth || !siteId || !driveId) {
24
+ return {
25
+ disabled: true,
26
+ placeholder: 'Select a site and drive first.',
27
+ options: [],
28
+ };
29
+ }
30
+ const authValue = auth;
31
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
32
+ authProvider: {
33
+ getAccessToken: () => Promise.resolve(authValue.access_token),
34
+ },
35
+ });
36
+ const options = [
37
+ { label: 'Root Folder', value: 'root' },
38
+ ];
39
+ let response = yield client
40
+ .api(`/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
41
+ .get();
42
+ while (response.value.length > 0) {
43
+ for (const item of response.value) {
44
+ options.push({ label: item.name, value: item.id });
45
+ }
46
+ if (response['@odata.nextLink']) {
47
+ response = yield client.api(response['@odata.nextLink']).get();
48
+ }
49
+ else {
50
+ break;
51
+ }
52
+ }
53
+ return { disabled: false, options };
54
+ }),
55
+ }),
56
+ includeCustomFields: pieces_framework_1.Property.Checkbox({
57
+ displayName: 'Include Custom Metadata',
58
+ description: 'Check this to include SharePoint-specific metadata (custom columns). This may slow down the request.',
59
+ required: false,
60
+ defaultValue: false,
61
+ }),
62
+ top: pieces_framework_1.Property.Number({
63
+ displayName: 'Page Size',
64
+ description: 'The maximum number of items to return. The API default is 200. If more items exist, the output will contain a field `@odata.nextLink` that you can use in a custom API call to get the next page.',
65
+ required: false,
66
+ }),
67
+ select: pieces_framework_1.Property.ShortText({
68
+ displayName: 'Select Fields (Optional)',
69
+ description: 'A comma-separated list of properties to return. Example: `id,name,size,webUrl`',
70
+ required: false,
71
+ }),
72
+ orderby: pieces_framework_1.Property.ShortText({
73
+ displayName: 'Order By (Optional)',
74
+ description: 'Specifies how to sort the returned items. Example: `name asc` or `lastModifiedDateTime desc`',
75
+ required: false,
76
+ }),
77
+ },
78
+ run(context) {
79
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
80
+ const { siteId, driveId, folderId, includeCustomFields, top, select, orderby } = context.propsValue;
81
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
82
+ authProvider: {
83
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
84
+ },
85
+ });
86
+ const baseUrl = folderId === 'root'
87
+ ? `/sites/${siteId}/drive/root/children`
88
+ : `/sites/${siteId}/drive/items/${folderId}/children`;
89
+ const queryParams = {};
90
+ if (includeCustomFields) {
91
+ queryParams['$expand'] = 'listItem(expand=fields)';
92
+ }
93
+ if (top) {
94
+ queryParams['$top'] = top;
95
+ }
96
+ if (select) {
97
+ queryParams['$select'] = select;
98
+ }
99
+ if (orderby) {
100
+ queryParams['$orderby'] = orderby;
101
+ }
102
+ const result = yield client.api(baseUrl).query(queryParams).get();
103
+ return result.value || [];
104
+ });
105
+ },
106
+ });
107
+ //# sourceMappingURL=get-folder-contents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-folder-contents.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/get-folder-contents.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAKwC;AACxC,sCAAsD;AACtD,8EAA2E;AAG9D,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAClD,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,0CAA0C;IAChD,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,yFAAyF;IACtG,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,QAAQ,EAAE,2BAAQ,CAAC,QAAQ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AgB,QAAQ,WAAW,CAAC;YAG1D,MAAM,WAAW,GAAqC,EAAE,CAAC;YACzD,IAAG,mBAAmB,EAAE,CAAC;gBACrB,WAAW,CAAC,SAAS,CAAC,GAAG,yBAAyB,CAAC;YACvD,CAAC;YACD,IAAG,GAAG,EAAE,CAAC;gBACL,WAAW,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;YAC9B,CAAC;YACD,IAAG,MAAM,EAAE,CAAC;gBACR,WAAW,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;YACpC,CAAC;YACD,IAAG,OAAO,EAAE,CAAC;gBACT,WAAW,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;YACtC,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,EAAE,CAAC;YAGlE,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5B,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const getSiteInformationAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
3
+ select: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ }>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSiteInformationAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ exports.getSiteInformationAction = (0, pieces_framework_1.createAction)({
10
+ auth: __1.microsoftSharePointAuth,
11
+ name: 'microsoft_sharepoint_get_site_information',
12
+ displayName: 'Get Site Information',
13
+ description: 'Fetch metadata of a SharePoint site (site ID, title, URL, description, etc.).',
14
+ props: {
15
+ siteId: common_1.microsoftSharePointCommon.siteId,
16
+ select: pieces_framework_1.Property.ShortText({
17
+ displayName: 'Select Fields (Optional)',
18
+ description: 'A comma-separated list of properties to return. If left blank, all default properties are returned. Example: `id,displayName,webUrl,description`',
19
+ required: false,
20
+ }),
21
+ },
22
+ run(context) {
23
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ const { siteId, select } = context.propsValue;
25
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
26
+ authProvider: {
27
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
28
+ },
29
+ });
30
+ const request = client.api(`/sites/${siteId}`);
31
+ if (select) {
32
+ request.select(select.split(',').map(s => s.trim()));
33
+ }
34
+ return yield request.get();
35
+ });
36
+ },
37
+ });
38
+ //# sourceMappingURL=get-site-information.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-site-information.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/get-site-information.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAAwE;AACxE,sCAAsD;AACtD,8EAA2D;AAE9C,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,2CAA2C;IACjD,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,+EAA+E;IAC5F,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,0BAA0B;YACvC,WAAW,EAAE,kJAAkJ;YAC/J,QAAQ,EAAE,KAAK;SAClB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAE9C,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACvC,YAAY,EAAE;oBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBACjE;aACF,CAAC,CAAC;YAEH,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC;YAE/C,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const moveFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
3
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ fileId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
+ destinationFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ newName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ }>;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moveFileAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ exports.moveFileAction = (0, pieces_framework_1.createAction)({
10
+ auth: __1.microsoftSharePointAuth,
11
+ name: 'microsoft_sharepoint_move_file',
12
+ displayName: 'Move File',
13
+ description: 'Move a file from one folder to another within the same drive.',
14
+ props: {
15
+ siteId: common_1.microsoftSharePointCommon.siteId,
16
+ driveId: common_1.microsoftSharePointCommon.driveId,
17
+ fileId: pieces_framework_1.Property.Dropdown({
18
+ displayName: 'File to Move',
19
+ description: 'The file you want to move.',
20
+ required: true,
21
+ refreshers: ['siteId', 'driveId'],
22
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
23
+ if (!auth || !siteId || !driveId) {
24
+ return {
25
+ disabled: true,
26
+ placeholder: 'Select a site and drive first.',
27
+ options: [],
28
+ };
29
+ }
30
+ const authValue = auth;
31
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
32
+ authProvider: {
33
+ getAccessToken: () => Promise.resolve(authValue.access_token),
34
+ },
35
+ });
36
+ const options = [];
37
+ let response = yield client
38
+ .api(`/drives/${driveId}/root/children?$select=id,name,file`
39
+ // `/sites/${siteId}/drives/${driveId}/root/children?$select=id,name,file`
40
+ )
41
+ .get();
42
+ while (response.value.length > 0) {
43
+ for (const item of response.value) {
44
+ if (item.file) {
45
+ options.push({ label: item.name, value: item.id });
46
+ }
47
+ }
48
+ if (response['@odata.nextLink']) {
49
+ response = yield client.api(response['@odata.nextLink']).get();
50
+ }
51
+ else {
52
+ break;
53
+ }
54
+ }
55
+ return { disabled: false, options };
56
+ }),
57
+ }),
58
+ destinationFolderId: pieces_framework_1.Property.Dropdown({
59
+ displayName: 'Destination Folder',
60
+ description: 'The folder to move the file into. Select "Root" to move to the top level of the drive.',
61
+ required: true,
62
+ refreshers: ['siteId', 'driveId'],
63
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
64
+ if (!auth || !siteId || !driveId) {
65
+ return {
66
+ disabled: true,
67
+ placeholder: 'Select a site and drive first.',
68
+ options: [],
69
+ };
70
+ }
71
+ const authValue = auth;
72
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
73
+ authProvider: {
74
+ getAccessToken: () => Promise.resolve(authValue.access_token),
75
+ },
76
+ });
77
+ const options = [
78
+ { label: 'Root', value: 'root' },
79
+ ];
80
+ let response = yield client
81
+ .api(
82
+ // `/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`
83
+ `/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
84
+ .get();
85
+ while (response.value.length > 0) {
86
+ for (const item of response.value) {
87
+ options.push({ label: item.name, value: item.id });
88
+ }
89
+ if (response['@odata.nextLink']) {
90
+ response = yield client.api(response['@odata.nextLink']).get();
91
+ }
92
+ else {
93
+ break;
94
+ }
95
+ }
96
+ return { disabled: false, options };
97
+ }),
98
+ }),
99
+ newName: pieces_framework_1.Property.ShortText({
100
+ displayName: 'New Name (Optional)',
101
+ description: 'Provide a new name to rename the file during the move.',
102
+ required: false,
103
+ }),
104
+ },
105
+ run(context) {
106
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
107
+ const { driveId, fileId, destinationFolderId, newName } = context.propsValue;
108
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
109
+ authProvider: {
110
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
111
+ },
112
+ });
113
+ try {
114
+ const effectiveDestinationId = destinationFolderId === 'root'
115
+ ? (yield client.api(`/drives/${driveId}/root`).get()).id
116
+ : destinationFolderId;
117
+ const requestBody = {
118
+ parentReference: {
119
+ id: effectiveDestinationId,
120
+ },
121
+ };
122
+ if (newName) {
123
+ requestBody.name = newName;
124
+ }
125
+ const response = yield client
126
+ .api(`/drives/${driveId}/items/${fileId}`)
127
+ .patch(requestBody);
128
+ return {
129
+ success: true,
130
+ message: 'File moved successfully',
131
+ item: response,
132
+ };
133
+ }
134
+ catch (error) {
135
+ if (error.statusCode === 400) {
136
+ throw new Error(`Invalid request: ${error.message || 'Check your input parameters'}`);
137
+ }
138
+ if (error.statusCode === 403) {
139
+ throw new Error('Insufficient permissions to move this file. Requires Files.ReadWrite or higher.');
140
+ }
141
+ if (error.statusCode === 404) {
142
+ throw new Error('File or destination not found. Please verify the IDs.');
143
+ }
144
+ throw new Error(`Failed to move file: ${error.message || 'Unknown error'}`);
145
+ }
146
+ });
147
+ },
148
+ });
149
+ //# sourceMappingURL=move-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/move-file.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAKwC;AACxC,sCAAsD;AACtD,8EAA2E;AAG9D,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,+DAA+D;IAC5E,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;YACjC,OAAO,EAAE,KAAkC,EAAE,oDAA7B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;gBACvC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjC,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,gCAAgC;wBAC7C,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBACD,MAAM,SAAS,GAAG,IAEjB,CAAC;gBACF,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;oBACvC,YAAY,EAAE;wBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC;qBAC9D;iBACF,CAAC,CAAC;gBACH,MAAM,OAAO,GAA6B,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AAK,GAAG,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;gBAC3E,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const publishPageAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
3
+ pageId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ }>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishPageAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ exports.publishPageAction = (0, pieces_framework_1.createAction)({
10
+ auth: __1.microsoftSharePointAuth,
11
+ name: 'microsoft_sharepoint_publish_page',
12
+ displayName: 'Publish Page',
13
+ description: 'Publishes a SharePoint page, making it available to all users. If the page is checked out, it will be automatically checked in. Note: Pages with active approval flows will not publish until approval is complete.',
14
+ props: {
15
+ siteId: common_1.microsoftSharePointCommon.siteId,
16
+ pageId: common_1.microsoftSharePointCommon.pageId,
17
+ },
18
+ run(context) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ const { siteId, pageId } = context.propsValue;
21
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
22
+ authProvider: {
23
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
24
+ },
25
+ });
26
+ try {
27
+ yield client
28
+ .api(`/sites/${siteId}/pages/${pageId}/microsoft.graph.sitePage/publish`)
29
+ .post({});
30
+ return {
31
+ success: true,
32
+ message: 'Page published successfully',
33
+ pageId: pageId,
34
+ siteId: siteId,
35
+ };
36
+ }
37
+ catch (error) {
38
+ if (error.statusCode === 404) {
39
+ throw new Error(`Page not found. Please verify the page ID: ${pageId}`);
40
+ }
41
+ if (error.statusCode === 403) {
42
+ throw new Error('Insufficient permissions to publish this page. Requires Files.ReadWrite or higher.');
43
+ }
44
+ if (error.statusCode === 409) {
45
+ throw new Error('Page cannot be published. It may be awaiting approval or already published.');
46
+ }
47
+ throw new Error(`Failed to publish page: ${error.message || 'Unknown error'}`);
48
+ }
49
+ });
50
+ },
51
+ });
52
+ //# sourceMappingURL=publish-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-page.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/publish-page.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAA8D;AAC9D,sCAAsD;AACtD,8EAA2D;AAE9C,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,mCAAmC;IACzC,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,qNAAqN;IAClO,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,MAAM,EAAE,kCAAyB,CAAC,MAAM;KACzC;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAE9C,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACvC,YAAY,EAAE;oBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBACjE;aACF,CAAC,CAAC;YAEH,IAAI,CAAC;gBACH,MAAM,MAAM;qBACT,GAAG,CAAC,UAAU,MAAM,UAAU,MAAM,mCAAmC,CAAC;qBACxE,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEZ,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,6BAA6B;oBACtC,MAAM,EAAE,MAAM;oBACd,MAAM,EAAE,MAAM;iBACf,CAAC;YACJ,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,CAAC,8CAA8C,MAAM,EAAE,CAAC,CAAC;gBAC1E,CAAC;gBACD,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;gBACxG,CAAC;gBACD,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;oBAC7B,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;gBACjG,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,7 +1,14 @@
1
1
  export declare const microsoftSharePointCommon: {
2
2
  siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
3
3
  driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ createDriveDropdown: (params: {
5
+ displayName: string;
6
+ refreshers: string[];
7
+ }) => import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ itemId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
9
+ destinationFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
4
10
  listId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
11
  listColumns: import("@activepieces/pieces-framework").DynamicProperties<true>;
6
12
  listItemId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
13
+ pageId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
7
14
  };
@@ -4,9 +4,51 @@ exports.microsoftSharePointCommon = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const pieces_framework_1 = require("@activepieces/pieces-framework");
6
6
  const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
7
+ const createDriveDropdown = (params) => pieces_framework_1.Property.Dropdown({
8
+ displayName: params.displayName,
9
+ required: true,
10
+ refreshers: params.refreshers,
11
+ options: (_a) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
12
+ var { auth } = _a, props = tslib_1.__rest(_a, ["auth"]);
13
+ const siteId = props[params.refreshers[0]];
14
+ if (!auth || !siteId) {
15
+ return {
16
+ disabled: true,
17
+ placeholder: 'Please select a site first.',
18
+ options: [],
19
+ };
20
+ }
21
+ const authValue = auth;
22
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
23
+ authProvider: {
24
+ getAccessToken: () => Promise.resolve(authValue.access_token),
25
+ },
26
+ });
27
+ const options = [];
28
+ let response = yield client
29
+ .api(`/sites/${siteId}/drives`)
30
+ .select('id,name')
31
+ .get();
32
+ while (response.value.length > 0) {
33
+ for (const drive of response.value) {
34
+ options.push({ label: drive.name, value: drive.id });
35
+ }
36
+ if (response['@odata.nextLink']) {
37
+ response = yield client.api(response['@odata.nextLink']).get();
38
+ }
39
+ else {
40
+ break;
41
+ }
42
+ }
43
+ return {
44
+ disabled: false,
45
+ options,
46
+ };
47
+ }),
48
+ });
7
49
  exports.microsoftSharePointCommon = {
8
50
  siteId: pieces_framework_1.Property.Dropdown({
9
- displayName: 'Site ID',
51
+ displayName: 'Site',
10
52
  required: true,
11
53
  refreshers: [],
12
54
  options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
@@ -24,11 +66,8 @@ exports.microsoftSharePointCommon = {
24
66
  },
25
67
  });
26
68
  const options = [];
27
- // https://sharepoint.stackexchange.com/questions/238094/how-could-i-get-all-root-level-sites-excluding-sub-site-using-microsoft-graph
28
69
  let response = yield client
29
70
  .api('/sites?search=*&$select=displayName,id,name')
30
- // .search('*')
31
- // .select('id,name,displayName,webUrl')
32
71
  .get();
33
72
  while (response.value.length > 0) {
34
73
  for (const site of response.value) {
@@ -47,15 +86,20 @@ exports.microsoftSharePointCommon = {
47
86
  };
48
87
  }),
49
88
  }),
50
- driveId: pieces_framework_1.Property.Dropdown({
51
- displayName: 'Drive ID',
52
- required: true,
89
+ driveId: createDriveDropdown({
90
+ displayName: 'Drive',
53
91
  refreshers: ['siteId'],
54
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId }) {
55
- if (!auth || !siteId) {
92
+ }),
93
+ createDriveDropdown,
94
+ itemId: pieces_framework_1.Property.Dropdown({
95
+ displayName: 'Source File or Folder',
96
+ required: true,
97
+ refreshers: ['siteId', 'driveId'],
98
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
99
+ if (!auth || !siteId || !driveId) {
56
100
  return {
57
101
  disabled: true,
58
- placeholder: 'Please connect your account first and select site.',
102
+ placeholder: 'Please select a site and drive first.',
59
103
  options: [],
60
104
  };
61
105
  }
@@ -67,12 +111,15 @@ exports.microsoftSharePointCommon = {
67
111
  });
68
112
  const options = [];
69
113
  let response = yield client
70
- .api(`/sites/${siteId}/drives`)
71
- .select('id,name')
114
+ .api(`/sites/${siteId}/drives/${driveId}/root/children?$select=id,name,folder,file`)
72
115
  .get();
73
116
  while (response.value.length > 0) {
74
- for (const drive of response.value) {
75
- options.push({ label: drive.name, value: drive.id });
117
+ for (const item of response.value) {
118
+ const prefix = item.folder ? '[Folder] ' : '[File] ';
119
+ options.push({
120
+ label: prefix + item.name,
121
+ value: item.id,
122
+ });
76
123
  }
77
124
  if (response['@odata.nextLink']) {
78
125
  response = yield client.api(response['@odata.nextLink']).get();
@@ -81,21 +128,61 @@ exports.microsoftSharePointCommon = {
81
128
  break;
82
129
  }
83
130
  }
84
- return {
85
- disabled: false,
86
- options,
87
- };
131
+ return { disabled: false, options };
132
+ }),
133
+ }),
134
+ destinationFolderId: pieces_framework_1.Property.Dropdown({
135
+ displayName: 'Destination Folder',
136
+ description: 'The folder to copy the item into. Defaults to the root of the drive.',
137
+ required: false,
138
+ refreshers: ['destination_site_id', 'destination_drive_id'],
139
+ options: (_a) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
140
+ var { auth } = _a, props = tslib_1.__rest(_a, ["auth"]);
141
+ const siteId = props['destination_site_id'];
142
+ const driveId = props['destination_drive_id'];
143
+ if (!auth || !siteId || !driveId) {
144
+ return {
145
+ disabled: true,
146
+ placeholder: 'Select a destination site and drive first.',
147
+ options: [],
148
+ };
149
+ }
150
+ const authValue = auth;
151
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
152
+ authProvider: {
153
+ getAccessToken: () => Promise.resolve(authValue.access_token),
154
+ },
155
+ });
156
+ const options = [];
157
+ let response = yield client
158
+ .api(`/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
159
+ .get();
160
+ while (response.value.length > 0) {
161
+ for (const item of response.value) {
162
+ options.push({
163
+ label: item.name,
164
+ value: item.id,
165
+ });
166
+ }
167
+ if (response['@odata.nextLink']) {
168
+ response = yield client.api(response['@odata.nextLink']).get();
169
+ }
170
+ else {
171
+ break;
172
+ }
173
+ }
174
+ return { disabled: false, options };
88
175
  }),
89
176
  }),
90
177
  listId: pieces_framework_1.Property.Dropdown({
91
- displayName: 'List ID',
178
+ displayName: 'List',
92
179
  required: true,
93
180
  refreshers: ['siteId'],
94
181
  options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId }) {
95
182
  if (!auth || !siteId) {
96
183
  return {
97
184
  disabled: true,
98
- placeholder: 'Please connect your account first and select site.',
185
+ placeholder: 'Please select a site first.',
99
186
  options: [],
100
187
  };
101
188
  }
@@ -209,7 +296,7 @@ exports.microsoftSharePointCommon = {
209
296
  }),
210
297
  }),
211
298
  listItemId: pieces_framework_1.Property.Dropdown({
212
- displayName: 'List Item ID',
299
+ displayName: 'List Item',
213
300
  required: true,
214
301
  refreshers: ['siteId', 'listId'],
215
302
  options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, listId }) {
@@ -217,7 +304,7 @@ exports.microsoftSharePointCommon = {
217
304
  if (!auth || !siteId || !listId) {
218
305
  return {
219
306
  disabled: true,
220
- placeholder: 'Please connect your account first and select site.',
307
+ placeholder: 'Please select a site and list first.',
221
308
  options: [],
222
309
  };
223
310
  }
@@ -251,5 +338,48 @@ exports.microsoftSharePointCommon = {
251
338
  };
252
339
  }),
253
340
  }),
341
+ pageId: pieces_framework_1.Property.Dropdown({
342
+ displayName: 'Page',
343
+ required: true,
344
+ refreshers: ['siteId'],
345
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId }) {
346
+ var _b;
347
+ if (!auth || !siteId) {
348
+ return {
349
+ disabled: true,
350
+ placeholder: 'Please select a site first.',
351
+ options: [],
352
+ };
353
+ }
354
+ const authValue = auth;
355
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
356
+ authProvider: {
357
+ getAccessToken: () => Promise.resolve(authValue.access_token),
358
+ },
359
+ });
360
+ const options = [];
361
+ let response = yield client
362
+ .api(`/sites/${siteId}/pages?$select=id,title`)
363
+ .get();
364
+ while (response.value.length > 0) {
365
+ for (const page of response.value) {
366
+ options.push({
367
+ label: (_b = page.title) !== null && _b !== void 0 ? _b : `Page ${page.id}`,
368
+ value: page.id,
369
+ });
370
+ }
371
+ if (response['@odata.nextLink']) {
372
+ response = yield client.api(response['@odata.nextLink']).get();
373
+ }
374
+ else {
375
+ break;
376
+ }
377
+ }
378
+ return {
379
+ disabled: false,
380
+ options,
381
+ };
382
+ }),
383
+ }),
254
384
  };
255
385
  //# sourceMappingURL=index.js.map