n8n-nodes-steyi-ss 1.0.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.
- package/README.md +192 -0
- package/dist/credentials/SteyiSmartsheetCreds.credentials.d.ts +9 -0
- package/dist/credentials/SteyiSmartsheetCreds.credentials.js +38 -0
- package/dist/nodes/SteyiSmartsheet/SteyiGenericFunction.d.ts +3 -0
- package/dist/nodes/SteyiSmartsheet/SteyiGenericFunction.js +58 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheet.node.d.ts +19 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheet.node.js +1988 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheetApi.d.ts +24 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheetApi.js +174 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheetTrigger.node.d.ts +17 -0
- package/dist/nodes/SteyiSmartsheet/SteyiSmartsheetTrigger.node.js +173 -0
- package/dist/nodes/SteyiSmartsheet/executors/Admin.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Admin.js +180 -0
- package/dist/nodes/SteyiSmartsheet/executors/Columns.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Columns.js +53 -0
- package/dist/nodes/SteyiSmartsheet/executors/Reports.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Reports.js +27 -0
- package/dist/nodes/SteyiSmartsheet/executors/Rows.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Rows.js +845 -0
- package/dist/nodes/SteyiSmartsheet/executors/Sheets.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Sheets.js +85 -0
- package/dist/nodes/SteyiSmartsheet/executors/Webhooks.d.ts +2 -0
- package/dist/nodes/SteyiSmartsheet/executors/Webhooks.js +67 -0
- package/dist/nodes/SteyiSmartsheet/steyi-smartsheet.svg +6 -0
- package/package.json +56 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare function listSheets(this: IExecuteFunctions | ILoadOptionsFunctions, includeAll?: boolean): Promise<any>;
|
|
3
|
+
export declare function listColumns(this: IExecuteFunctions | ILoadOptionsFunctions, sheetId: number): Promise<any>;
|
|
4
|
+
export declare function listWebhooks(this: IExecuteFunctions | ILoadOptionsFunctions): Promise<any>;
|
|
5
|
+
export declare function createWebhook(this: IExecuteFunctions | ILoadOptionsFunctions, body: any): Promise<any>;
|
|
6
|
+
export declare function updateWebhook(this: IExecuteFunctions | ILoadOptionsFunctions, webhookId: number, body: any): Promise<any>;
|
|
7
|
+
export declare function deleteWebhook(this: IExecuteFunctions | ILoadOptionsFunctions, webhookId: number): Promise<any>;
|
|
8
|
+
export declare function listReports(this: IExecuteFunctions | ILoadOptionsFunctions, includeAll?: boolean): Promise<any>;
|
|
9
|
+
export declare function getReport(this: IExecuteFunctions | ILoadOptionsFunctions, reportId: number, include?: string[], exclude?: string[]): Promise<any>;
|
|
10
|
+
export declare function listWorkspaces(this: IExecuteFunctions | ILoadOptionsFunctions): Promise<any>;
|
|
11
|
+
export declare function listFolders(this: IExecuteFunctions | ILoadOptionsFunctions, workspaceId: number): Promise<any>;
|
|
12
|
+
export declare function listUsers(this: IExecuteFunctions | ILoadOptionsFunctions, includeAll?: boolean): Promise<any>;
|
|
13
|
+
export declare function getUser(this: IExecuteFunctions | ILoadOptionsFunctions, userId: number): Promise<any>;
|
|
14
|
+
export declare function addUser(this: IExecuteFunctions | ILoadOptionsFunctions, body: any): Promise<any>;
|
|
15
|
+
export declare function updateUser(this: IExecuteFunctions | ILoadOptionsFunctions, userId: number, body: any): Promise<any>;
|
|
16
|
+
export declare function deleteUser(this: IExecuteFunctions | ILoadOptionsFunctions, userId: number): Promise<any>;
|
|
17
|
+
export declare function listGroups(this: IExecuteFunctions | ILoadOptionsFunctions, includeAll?: boolean): Promise<any>;
|
|
18
|
+
export declare function getGroup(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number): Promise<any>;
|
|
19
|
+
export declare function createGroup(this: IExecuteFunctions | ILoadOptionsFunctions, body: any): Promise<any>;
|
|
20
|
+
export declare function updateGroup(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number, body: any): Promise<any>;
|
|
21
|
+
export declare function deleteGroup(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number): Promise<any>;
|
|
22
|
+
export declare function listGroupMembers(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number): Promise<any>;
|
|
23
|
+
export declare function addGroupMembers(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number, members: any[]): Promise<any>;
|
|
24
|
+
export declare function removeGroupMember(this: IExecuteFunctions | ILoadOptionsFunctions, groupId: number, userId: number): Promise<any>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeGroupMember = exports.addGroupMembers = exports.listGroupMembers = exports.deleteGroup = exports.updateGroup = exports.createGroup = exports.getGroup = exports.listGroups = exports.deleteUser = exports.updateUser = exports.addUser = exports.getUser = exports.listUsers = exports.listFolders = exports.listWorkspaces = exports.getReport = exports.listReports = exports.deleteWebhook = exports.updateWebhook = exports.createWebhook = exports.listWebhooks = exports.listColumns = exports.listSheets = void 0;
|
|
4
|
+
const SteyiGenericFunction_1 = require("./SteyiGenericFunction");
|
|
5
|
+
async function listSheets(includeAll = true) {
|
|
6
|
+
let allSheets = [];
|
|
7
|
+
let page = 1;
|
|
8
|
+
let totalPages = 1;
|
|
9
|
+
do {
|
|
10
|
+
const endpoint = includeAll
|
|
11
|
+
? `/sheets?page=${page}&pageSize=100&includeAll=true`
|
|
12
|
+
: `/sheets?page=${page}&pageSize=100`;
|
|
13
|
+
const response = await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', endpoint, {}, 0);
|
|
14
|
+
if (response && response.data) {
|
|
15
|
+
allSheets = allSheets.concat(response.data);
|
|
16
|
+
totalPages = response.totalPages || 1;
|
|
17
|
+
page++;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
} while (includeAll && page <= totalPages);
|
|
23
|
+
return { data: allSheets };
|
|
24
|
+
}
|
|
25
|
+
exports.listSheets = listSheets;
|
|
26
|
+
async function listColumns(sheetId) {
|
|
27
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/sheets/${sheetId}/columns`, {}, 0);
|
|
28
|
+
}
|
|
29
|
+
exports.listColumns = listColumns;
|
|
30
|
+
async function listWebhooks() {
|
|
31
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', '/webhooks', {}, 0);
|
|
32
|
+
}
|
|
33
|
+
exports.listWebhooks = listWebhooks;
|
|
34
|
+
async function createWebhook(body) {
|
|
35
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'POST', '/webhooks', body, 0);
|
|
36
|
+
}
|
|
37
|
+
exports.createWebhook = createWebhook;
|
|
38
|
+
async function updateWebhook(webhookId, body) {
|
|
39
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'PUT', `/webhooks/${webhookId}`, body, 0);
|
|
40
|
+
}
|
|
41
|
+
exports.updateWebhook = updateWebhook;
|
|
42
|
+
async function deleteWebhook(webhookId) {
|
|
43
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'DELETE', `/webhooks/${webhookId}`, {}, 0);
|
|
44
|
+
}
|
|
45
|
+
exports.deleteWebhook = deleteWebhook;
|
|
46
|
+
async function listReports(includeAll = true) {
|
|
47
|
+
let allReports = [];
|
|
48
|
+
let page = 1;
|
|
49
|
+
let totalPages = 1;
|
|
50
|
+
do {
|
|
51
|
+
const endpoint = includeAll
|
|
52
|
+
? `/reports?page=${page}&pageSize=100&includeAll=true`
|
|
53
|
+
: `/reports?page=${page}&pageSize=100`;
|
|
54
|
+
const response = await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', endpoint, {}, 0);
|
|
55
|
+
if (response && response.data) {
|
|
56
|
+
allReports = allReports.concat(response.data);
|
|
57
|
+
totalPages = response.totalPages || 1;
|
|
58
|
+
page++;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
} while (includeAll && page <= totalPages);
|
|
64
|
+
return { data: allReports };
|
|
65
|
+
}
|
|
66
|
+
exports.listReports = listReports;
|
|
67
|
+
async function getReport(reportId, include, exclude) {
|
|
68
|
+
const queryParams = [];
|
|
69
|
+
if (include && include.length > 0) {
|
|
70
|
+
queryParams.push(`include=${include.join(',')}`);
|
|
71
|
+
}
|
|
72
|
+
if (exclude && exclude.length > 0) {
|
|
73
|
+
queryParams.push(`exclude=${exclude.join(',')}`);
|
|
74
|
+
}
|
|
75
|
+
const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
|
|
76
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/reports/${reportId}${queryString}`, {}, 0);
|
|
77
|
+
}
|
|
78
|
+
exports.getReport = getReport;
|
|
79
|
+
async function listWorkspaces() {
|
|
80
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', '/workspaces', {}, 0);
|
|
81
|
+
}
|
|
82
|
+
exports.listWorkspaces = listWorkspaces;
|
|
83
|
+
async function listFolders(workspaceId) {
|
|
84
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/workspaces/${workspaceId}/folders`, {}, 0);
|
|
85
|
+
}
|
|
86
|
+
exports.listFolders = listFolders;
|
|
87
|
+
// Admin functions
|
|
88
|
+
async function listUsers(includeAll = true) {
|
|
89
|
+
let allUsers = [];
|
|
90
|
+
let page = 1;
|
|
91
|
+
let totalPages = 1;
|
|
92
|
+
do {
|
|
93
|
+
const endpoint = includeAll
|
|
94
|
+
? `/users?page=${page}&pageSize=100&includeAll=true`
|
|
95
|
+
: `/users?page=${page}&pageSize=100`;
|
|
96
|
+
const response = await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', endpoint, {}, 0);
|
|
97
|
+
if (response && response.data) {
|
|
98
|
+
allUsers = allUsers.concat(response.data);
|
|
99
|
+
totalPages = response.totalPages || 1;
|
|
100
|
+
page++;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
} while (includeAll && page <= totalPages);
|
|
106
|
+
return { data: allUsers };
|
|
107
|
+
}
|
|
108
|
+
exports.listUsers = listUsers;
|
|
109
|
+
async function getUser(userId) {
|
|
110
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/users/${userId}`, {}, 0);
|
|
111
|
+
}
|
|
112
|
+
exports.getUser = getUser;
|
|
113
|
+
async function addUser(body) {
|
|
114
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'POST', '/users', body, 0);
|
|
115
|
+
}
|
|
116
|
+
exports.addUser = addUser;
|
|
117
|
+
async function updateUser(userId, body) {
|
|
118
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'PUT', `/users/${userId}`, body, 0);
|
|
119
|
+
}
|
|
120
|
+
exports.updateUser = updateUser;
|
|
121
|
+
async function deleteUser(userId) {
|
|
122
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'DELETE', `/users/${userId}`, {}, 0);
|
|
123
|
+
}
|
|
124
|
+
exports.deleteUser = deleteUser;
|
|
125
|
+
async function listGroups(includeAll = true) {
|
|
126
|
+
let allGroups = [];
|
|
127
|
+
let page = 1;
|
|
128
|
+
let totalPages = 1;
|
|
129
|
+
do {
|
|
130
|
+
const endpoint = includeAll
|
|
131
|
+
? `/groups?page=${page}&pageSize=100&includeAll=true`
|
|
132
|
+
: `/groups?page=${page}&pageSize=100`;
|
|
133
|
+
const response = await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', endpoint, {}, 0);
|
|
134
|
+
if (response && response.data) {
|
|
135
|
+
allGroups = allGroups.concat(response.data);
|
|
136
|
+
totalPages = response.totalPages || 1;
|
|
137
|
+
page++;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
} while (includeAll && page <= totalPages);
|
|
143
|
+
return { data: allGroups };
|
|
144
|
+
}
|
|
145
|
+
exports.listGroups = listGroups;
|
|
146
|
+
async function getGroup(groupId) {
|
|
147
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/groups/${groupId}`, {}, 0);
|
|
148
|
+
}
|
|
149
|
+
exports.getGroup = getGroup;
|
|
150
|
+
async function createGroup(body) {
|
|
151
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'POST', '/groups', body, 0);
|
|
152
|
+
}
|
|
153
|
+
exports.createGroup = createGroup;
|
|
154
|
+
async function updateGroup(groupId, body) {
|
|
155
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'PUT', `/groups/${groupId}`, body, 0);
|
|
156
|
+
}
|
|
157
|
+
exports.updateGroup = updateGroup;
|
|
158
|
+
async function deleteGroup(groupId) {
|
|
159
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'DELETE', `/groups/${groupId}`, {}, 0);
|
|
160
|
+
}
|
|
161
|
+
exports.deleteGroup = deleteGroup;
|
|
162
|
+
async function listGroupMembers(groupId) {
|
|
163
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'GET', `/groups/${groupId}/members`, {}, 0);
|
|
164
|
+
}
|
|
165
|
+
exports.listGroupMembers = listGroupMembers;
|
|
166
|
+
async function addGroupMembers(groupId, members) {
|
|
167
|
+
// Smartsheet API expects the body to be an array directly, not wrapped in an object
|
|
168
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'POST', `/groups/${groupId}/members`, members, 0);
|
|
169
|
+
}
|
|
170
|
+
exports.addGroupMembers = addGroupMembers;
|
|
171
|
+
async function removeGroupMember(groupId, userId) {
|
|
172
|
+
return await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'DELETE', `/groups/${groupId}/members/${userId}`, {}, 0);
|
|
173
|
+
}
|
|
174
|
+
exports.removeGroupMember = removeGroupMember;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IWebhookFunctions, IHookFunctions, INodeType, INodeTypeDescription, IWebhookResponseData, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
export declare class SteyiSmartsheetTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getSheets(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
webhookMethods: {
|
|
10
|
+
default: {
|
|
11
|
+
checkExists(this: IHookFunctions): Promise<boolean>;
|
|
12
|
+
create(this: IHookFunctions): Promise<boolean>;
|
|
13
|
+
delete(this: IHookFunctions): Promise<boolean>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SteyiSmartsheetTrigger = void 0;
|
|
4
|
+
const SteyiSmartsheetApi_1 = require("./SteyiSmartsheetApi");
|
|
5
|
+
class SteyiSmartsheetTrigger {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Steyi Smartsheet Trigger',
|
|
9
|
+
name: 'steyiSmartsheetTrigger',
|
|
10
|
+
icon: 'file:steyi-smartsheet.svg',
|
|
11
|
+
group: ['trigger'],
|
|
12
|
+
version: 1,
|
|
13
|
+
description: 'Starts the workflow when Smartsheet events occur (Steyi)',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: 'Steyi Smartsheet Trigger',
|
|
16
|
+
},
|
|
17
|
+
inputs: [],
|
|
18
|
+
outputs: ['main'],
|
|
19
|
+
credentials: [
|
|
20
|
+
{
|
|
21
|
+
name: 'steyiSmartsheetCreds',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
webhooks: [
|
|
26
|
+
{
|
|
27
|
+
name: 'default',
|
|
28
|
+
httpMethod: 'POST',
|
|
29
|
+
responseMode: 'onReceived',
|
|
30
|
+
path: 'webhook',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
properties: [
|
|
34
|
+
{
|
|
35
|
+
displayName: 'Type',
|
|
36
|
+
name: 'webhookType',
|
|
37
|
+
type: 'options',
|
|
38
|
+
options: [
|
|
39
|
+
{
|
|
40
|
+
name: 'Sheet',
|
|
41
|
+
value: 'sheet',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
default: 'sheet',
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Sheet Name or ID',
|
|
49
|
+
name: 'sheetId',
|
|
50
|
+
type: 'options',
|
|
51
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
|
52
|
+
typeOptions: {
|
|
53
|
+
loadOptionsMethod: 'getSheets',
|
|
54
|
+
},
|
|
55
|
+
displayOptions: {
|
|
56
|
+
show: {
|
|
57
|
+
webhookType: ['sheet'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
default: '',
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
this.methods = {
|
|
66
|
+
loadOptions: {
|
|
67
|
+
async getSheets() {
|
|
68
|
+
const sheets = await SteyiSmartsheetApi_1.listSheets.call(this, true);
|
|
69
|
+
if (!sheets || !sheets.data) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return sheets.data.map((sheet) => ({
|
|
73
|
+
name: sheet.name,
|
|
74
|
+
value: sheet.id ? String(sheet.id) : '',
|
|
75
|
+
}));
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
this.webhookMethods = {
|
|
80
|
+
default: {
|
|
81
|
+
async checkExists() {
|
|
82
|
+
const webhooks = await SteyiSmartsheetApi_1.listWebhooks.call(this);
|
|
83
|
+
if (!webhooks || !webhooks.data) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
87
|
+
for (const webhook of webhooks.data) {
|
|
88
|
+
if (webhook.callbackUrl === webhookUrl) {
|
|
89
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
90
|
+
webhookData.webhookId = webhook.id || webhook.webhookId;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
},
|
|
96
|
+
async create() {
|
|
97
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
98
|
+
if (webhookUrl === undefined || webhookUrl === null) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const sheetId = this.getNodeParameter('sheetId');
|
|
102
|
+
if (sheetId === undefined || sheetId === null || sheetId === '') {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const sheetIdNum = typeof sheetId === 'string' ? parseInt(sheetId, 10) : sheetId;
|
|
106
|
+
if (isNaN(sheetIdNum)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const body = {
|
|
110
|
+
name: `n8n - Webhook [Sheet ID: ${sheetIdNum}]`,
|
|
111
|
+
callbackUrl: webhookUrl,
|
|
112
|
+
events: ['*.*'],
|
|
113
|
+
version: 1,
|
|
114
|
+
scopeObjectId: sheetIdNum,
|
|
115
|
+
scope: 'sheet',
|
|
116
|
+
};
|
|
117
|
+
const responseData = await SteyiSmartsheetApi_1.createWebhook.call(this, body);
|
|
118
|
+
if (!responseData || responseData.message !== 'SUCCESS') {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const createdWebhookId = responseData.result?.id || responseData.result?.webhookId || responseData.id;
|
|
122
|
+
if (!createdWebhookId) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const updateResponseData = await SteyiSmartsheetApi_1.updateWebhook.call(this, createdWebhookId, { enabled: true });
|
|
126
|
+
if (!updateResponseData || updateResponseData.message !== 'SUCCESS') {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
130
|
+
webhookData.webhookId = createdWebhookId;
|
|
131
|
+
return true;
|
|
132
|
+
},
|
|
133
|
+
async delete() {
|
|
134
|
+
const webhookData = this.getWorkflowStaticData('node');
|
|
135
|
+
const webhookId = webhookData.webhookId;
|
|
136
|
+
if (webhookId === undefined || webhookId === null) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
// Safely convert webhookId to number
|
|
140
|
+
const webhookIdNum = typeof webhookId === 'number'
|
|
141
|
+
? webhookId
|
|
142
|
+
: (typeof webhookId === 'string' ? parseInt(webhookId, 10) : Number(webhookId));
|
|
143
|
+
if (isNaN(webhookIdNum)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const response = await SteyiSmartsheetApi_1.deleteWebhook.call(this, webhookIdNum);
|
|
147
|
+
if (!response || response.message !== 'SUCCESS') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
delete webhookData.webhookId;
|
|
151
|
+
return true;
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async webhook() {
|
|
157
|
+
const req = this.getRequestObject();
|
|
158
|
+
const headers = this.getHeaderData();
|
|
159
|
+
let response = req.body;
|
|
160
|
+
// Handle webhook challenge
|
|
161
|
+
if (response.challenge) {
|
|
162
|
+
const challenge = headers['smartsheet-hook-challenge'];
|
|
163
|
+
const webhookResponse = JSON.stringify({ smartsheetHookResponse: challenge });
|
|
164
|
+
return {
|
|
165
|
+
webhookResponse,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
workflowData: [this.helpers.returnJsonArray(response)],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.SteyiSmartsheetTrigger = SteyiSmartsheetTrigger;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeAdminOperation = void 0;
|
|
4
|
+
const SteyiSmartsheetApi_1 = require("../SteyiSmartsheetApi");
|
|
5
|
+
async function executeAdminOperation(operation, itemIndex) {
|
|
6
|
+
let responseData;
|
|
7
|
+
switch (operation) {
|
|
8
|
+
case 'user': {
|
|
9
|
+
const userOperation = this.getNodeParameter('userOperation', itemIndex);
|
|
10
|
+
switch (userOperation) {
|
|
11
|
+
case 'listUsers': {
|
|
12
|
+
responseData = await SteyiSmartsheetApi_1.listUsers.call(this, true);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
case 'getUser': {
|
|
16
|
+
const userInputMethod = this.getNodeParameter('userInputMethod', itemIndex, 'list');
|
|
17
|
+
const userId = userInputMethod === 'id'
|
|
18
|
+
? this.getNodeParameter('userIdManual', itemIndex)
|
|
19
|
+
: this.getNodeParameter('userId', itemIndex);
|
|
20
|
+
responseData = await SteyiSmartsheetApi_1.getUser.call(this, parseInt(userId.toString()));
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'addUser': {
|
|
24
|
+
const email = this.getNodeParameter('email', itemIndex);
|
|
25
|
+
const firstName = this.getNodeParameter('firstName', itemIndex, '');
|
|
26
|
+
const lastName = this.getNodeParameter('lastName', itemIndex, '');
|
|
27
|
+
const admin = this.getNodeParameter('admin', itemIndex, false);
|
|
28
|
+
const licensedSheetCreator = this.getNodeParameter('licensedSheetCreator', itemIndex, false);
|
|
29
|
+
const body = {
|
|
30
|
+
email,
|
|
31
|
+
};
|
|
32
|
+
if (firstName)
|
|
33
|
+
body.firstName = firstName;
|
|
34
|
+
if (lastName)
|
|
35
|
+
body.lastName = lastName;
|
|
36
|
+
if (admin !== undefined)
|
|
37
|
+
body.admin = admin;
|
|
38
|
+
if (licensedSheetCreator !== undefined)
|
|
39
|
+
body.licensedSheetCreator = licensedSheetCreator;
|
|
40
|
+
responseData = await SteyiSmartsheetApi_1.addUser.call(this, body);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'updateUser': {
|
|
44
|
+
const userInputMethod = this.getNodeParameter('userInputMethod', itemIndex, 'list');
|
|
45
|
+
const userId = userInputMethod === 'id'
|
|
46
|
+
? this.getNodeParameter('userIdManual', itemIndex)
|
|
47
|
+
: this.getNodeParameter('userId', itemIndex);
|
|
48
|
+
const firstName = this.getNodeParameter('firstName', itemIndex, '');
|
|
49
|
+
const lastName = this.getNodeParameter('lastName', itemIndex, '');
|
|
50
|
+
const admin = this.getNodeParameter('admin', itemIndex, undefined);
|
|
51
|
+
const licensedSheetCreator = this.getNodeParameter('licensedSheetCreator', itemIndex, undefined);
|
|
52
|
+
const body = {};
|
|
53
|
+
if (firstName)
|
|
54
|
+
body.firstName = firstName;
|
|
55
|
+
if (lastName)
|
|
56
|
+
body.lastName = lastName;
|
|
57
|
+
if (admin !== undefined)
|
|
58
|
+
body.admin = admin;
|
|
59
|
+
if (licensedSheetCreator !== undefined)
|
|
60
|
+
body.licensedSheetCreator = licensedSheetCreator;
|
|
61
|
+
responseData = await SteyiSmartsheetApi_1.updateUser.call(this, parseInt(userId.toString()), body);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case 'deleteUser': {
|
|
65
|
+
const userInputMethod = this.getNodeParameter('userInputMethod', itemIndex, 'list');
|
|
66
|
+
const userId = userInputMethod === 'id'
|
|
67
|
+
? this.getNodeParameter('userIdManual', itemIndex)
|
|
68
|
+
: this.getNodeParameter('userId', itemIndex);
|
|
69
|
+
await SteyiSmartsheetApi_1.deleteUser.call(this, parseInt(userId.toString()));
|
|
70
|
+
responseData = { success: true, message: 'User deleted successfully' };
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
throw new Error(`Unknown user operation: ${userOperation}`);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case 'group': {
|
|
79
|
+
const groupOperation = this.getNodeParameter('groupOperation', itemIndex);
|
|
80
|
+
switch (groupOperation) {
|
|
81
|
+
case 'listGroups': {
|
|
82
|
+
responseData = await SteyiSmartsheetApi_1.listGroups.call(this, true);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'getGroup': {
|
|
86
|
+
const groupInputMethod = this.getNodeParameter('groupInputMethod', itemIndex, 'list');
|
|
87
|
+
const groupId = groupInputMethod === 'id'
|
|
88
|
+
? this.getNodeParameter('groupIdManual', itemIndex)
|
|
89
|
+
: this.getNodeParameter('groupId', itemIndex);
|
|
90
|
+
responseData = await SteyiSmartsheetApi_1.getGroup.call(this, parseInt(groupId.toString()));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'createGroup': {
|
|
94
|
+
const groupName = this.getNodeParameter('groupName', itemIndex);
|
|
95
|
+
const description = this.getNodeParameter('description', itemIndex, '');
|
|
96
|
+
const body = {
|
|
97
|
+
name: groupName,
|
|
98
|
+
};
|
|
99
|
+
if (description)
|
|
100
|
+
body.description = description;
|
|
101
|
+
responseData = await SteyiSmartsheetApi_1.createGroup.call(this, body);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 'updateGroup': {
|
|
105
|
+
const groupInputMethod = this.getNodeParameter('groupInputMethod', itemIndex, 'list');
|
|
106
|
+
const groupId = groupInputMethod === 'id'
|
|
107
|
+
? this.getNodeParameter('groupIdManual', itemIndex)
|
|
108
|
+
: this.getNodeParameter('groupId', itemIndex);
|
|
109
|
+
const groupName = this.getNodeParameter('groupName', itemIndex);
|
|
110
|
+
const description = this.getNodeParameter('description', itemIndex, '');
|
|
111
|
+
const body = {
|
|
112
|
+
name: groupName,
|
|
113
|
+
};
|
|
114
|
+
if (description)
|
|
115
|
+
body.description = description;
|
|
116
|
+
responseData = await SteyiSmartsheetApi_1.updateGroup.call(this, parseInt(groupId.toString()), body);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'deleteGroup': {
|
|
120
|
+
const groupInputMethod = this.getNodeParameter('groupInputMethod', itemIndex, 'list');
|
|
121
|
+
const groupId = groupInputMethod === 'id'
|
|
122
|
+
? this.getNodeParameter('groupIdManual', itemIndex)
|
|
123
|
+
: this.getNodeParameter('groupId', itemIndex);
|
|
124
|
+
await SteyiSmartsheetApi_1.deleteGroup.call(this, parseInt(groupId.toString()));
|
|
125
|
+
responseData = { success: true, message: 'Group deleted successfully' };
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
throw new Error(`Unknown group operation: ${groupOperation}`);
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case 'groupMember': {
|
|
134
|
+
const groupMemberOperation = this.getNodeParameter('groupMemberOperation', itemIndex);
|
|
135
|
+
const groupInputMethod = this.getNodeParameter('groupInputMethod', itemIndex, 'list');
|
|
136
|
+
const groupId = groupInputMethod === 'id'
|
|
137
|
+
? this.getNodeParameter('groupIdManual', itemIndex)
|
|
138
|
+
: this.getNodeParameter('groupId', itemIndex);
|
|
139
|
+
switch (groupMemberOperation) {
|
|
140
|
+
case 'listGroupMembers': {
|
|
141
|
+
responseData = await SteyiSmartsheetApi_1.listGroupMembers.call(this, parseInt(groupId.toString()));
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'addGroupMembers': {
|
|
145
|
+
const membersData = this.getNodeParameter('members', itemIndex, {});
|
|
146
|
+
if (!membersData.member || !Array.isArray(membersData.member) || membersData.member.length === 0) {
|
|
147
|
+
throw new Error('At least one member is required');
|
|
148
|
+
}
|
|
149
|
+
// Smartsheet API expects an array of objects with email property
|
|
150
|
+
const membersArray = membersData.member
|
|
151
|
+
.map((m) => ({
|
|
152
|
+
email: m.email || undefined,
|
|
153
|
+
}))
|
|
154
|
+
.filter((m) => m.email);
|
|
155
|
+
if (membersArray.length === 0) {
|
|
156
|
+
throw new Error('At least one valid email address is required');
|
|
157
|
+
}
|
|
158
|
+
responseData = await SteyiSmartsheetApi_1.addGroupMembers.call(this, parseInt(groupId.toString()), membersArray);
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case 'removeGroupMember': {
|
|
162
|
+
const memberUserId = this.getNodeParameter('memberUserId', itemIndex);
|
|
163
|
+
await SteyiSmartsheetApi_1.removeGroupMember.call(this, parseInt(groupId.toString()), parseInt(memberUserId.toString()));
|
|
164
|
+
responseData = { success: true, message: 'Group member removed successfully' };
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
default:
|
|
168
|
+
throw new Error(`Unknown group member operation: ${groupMemberOperation}`);
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
default:
|
|
173
|
+
throw new Error(`Unknown admin operation: ${operation}`);
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
json: responseData,
|
|
177
|
+
pairedItem: { item: itemIndex },
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
exports.executeAdminOperation = executeAdminOperation;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeColumnOperation = void 0;
|
|
4
|
+
const SteyiGenericFunction_1 = require("../SteyiGenericFunction");
|
|
5
|
+
const SteyiSmartsheetApi_1 = require("../SteyiSmartsheetApi");
|
|
6
|
+
async function executeColumnOperation(operation, itemIndex) {
|
|
7
|
+
let responseData;
|
|
8
|
+
// Helper function to get sheetId
|
|
9
|
+
const getSheetId = (index) => {
|
|
10
|
+
return this.getNodeParameter('sheetId', index);
|
|
11
|
+
};
|
|
12
|
+
switch (operation) {
|
|
13
|
+
case 'getColumns': {
|
|
14
|
+
const sheetId = getSheetId(itemIndex);
|
|
15
|
+
responseData = await SteyiSmartsheetApi_1.listColumns.call(this, parseInt(sheetId));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case 'updateColumn': {
|
|
19
|
+
const sheetId = getSheetId(itemIndex);
|
|
20
|
+
const columnId = this.getNodeParameter('columnId', itemIndex);
|
|
21
|
+
const title = this.getNodeParameter('title', itemIndex, '');
|
|
22
|
+
const index = this.getNodeParameter('index', itemIndex, null);
|
|
23
|
+
const columnType = this.getNodeParameter('columnType', itemIndex);
|
|
24
|
+
const optionsData = this.getNodeParameter('options', itemIndex, {});
|
|
25
|
+
const body = {
|
|
26
|
+
type: columnType,
|
|
27
|
+
};
|
|
28
|
+
if (title) {
|
|
29
|
+
body.title = title;
|
|
30
|
+
}
|
|
31
|
+
if (index !== null && index !== undefined) {
|
|
32
|
+
body.index = index;
|
|
33
|
+
}
|
|
34
|
+
// Add options for PICKLIST and MULTI_PICKLIST types
|
|
35
|
+
if (optionsData.option && Array.isArray(optionsData.option) && optionsData.option.length > 0) {
|
|
36
|
+
body.options = optionsData.option.map((opt) => {
|
|
37
|
+
if (typeof opt === 'string')
|
|
38
|
+
return opt;
|
|
39
|
+
return opt.option || opt;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
responseData = await SteyiGenericFunction_1.smartsheetApiRequest.call(this, 'PUT', `/sheets/${sheetId}/columns/${columnId}`, body, itemIndex);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unknown column operation: ${operation}`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
json: responseData,
|
|
50
|
+
pairedItem: { item: itemIndex },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.executeColumnOperation = executeColumnOperation;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeReportOperation = void 0;
|
|
4
|
+
const SteyiSmartsheetApi_1 = require("../SteyiSmartsheetApi");
|
|
5
|
+
async function executeReportOperation(operation, itemIndex) {
|
|
6
|
+
let responseData;
|
|
7
|
+
switch (operation) {
|
|
8
|
+
case 'listReports': {
|
|
9
|
+
responseData = await SteyiSmartsheetApi_1.listReports.call(this, true);
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
case 'getReport': {
|
|
13
|
+
const reportId = this.getNodeParameter('reportId', itemIndex);
|
|
14
|
+
const include = this.getNodeParameter('include', itemIndex, []);
|
|
15
|
+
const exclude = this.getNodeParameter('exclude', itemIndex, []);
|
|
16
|
+
responseData = await SteyiSmartsheetApi_1.getReport.call(this, parseInt(reportId.toString()), include.length > 0 ? include : undefined, exclude.length > 0 ? exclude : undefined);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(`Unknown report operation: ${operation}`);
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
json: responseData,
|
|
24
|
+
pairedItem: { item: itemIndex },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.executeReportOperation = executeReportOperation;
|