@pagecrawl/n8n-nodes-pagecrawl 0.3.0 → 0.3.2
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.
|
@@ -62,9 +62,9 @@ class PageCrawl {
|
|
|
62
62
|
displayName: 'Workspace',
|
|
63
63
|
name: 'workspace',
|
|
64
64
|
type: 'resourceLocator',
|
|
65
|
-
required:
|
|
65
|
+
required: false,
|
|
66
66
|
default: { mode: 'list', value: '' },
|
|
67
|
-
description: 'Select
|
|
67
|
+
description: 'Select workspace (auto-selected if you have only one)',
|
|
68
68
|
modes: [
|
|
69
69
|
{
|
|
70
70
|
displayName: 'From List',
|
|
@@ -294,8 +294,8 @@ class PageCrawl {
|
|
|
294
294
|
url: `${baseUrl}/api/user`,
|
|
295
295
|
json: true,
|
|
296
296
|
});
|
|
297
|
-
// Extract workspaces from user response
|
|
298
|
-
let workspaces = response.workspaces || [];
|
|
297
|
+
// Extract workspaces from user response (may be nested under user)
|
|
298
|
+
let workspaces = response.workspaces || response.user?.workspaces || [];
|
|
299
299
|
if (!Array.isArray(workspaces)) {
|
|
300
300
|
return { results: [] };
|
|
301
301
|
}
|
|
@@ -404,6 +404,28 @@ class PageCrawl {
|
|
|
404
404
|
}
|
|
405
405
|
return [];
|
|
406
406
|
};
|
|
407
|
+
// Helper to get workspace ID, auto-selecting if only one exists
|
|
408
|
+
const getWorkspaceId = async (index) => {
|
|
409
|
+
const workspaceLocator = this.getNodeParameter('workspace', index, {});
|
|
410
|
+
const workspaceId = workspaceLocator?.value || '';
|
|
411
|
+
if (workspaceId) {
|
|
412
|
+
return workspaceId;
|
|
413
|
+
}
|
|
414
|
+
// Fetch workspaces and auto-select if only one
|
|
415
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'pageCrawlApi', {
|
|
416
|
+
method: 'GET',
|
|
417
|
+
url: `${baseUrl}/api/user`,
|
|
418
|
+
json: true,
|
|
419
|
+
});
|
|
420
|
+
const workspaces = response.workspaces || response.user?.workspaces || [];
|
|
421
|
+
if (workspaces.length === 1) {
|
|
422
|
+
return String(workspaces[0].id);
|
|
423
|
+
}
|
|
424
|
+
if (workspaces.length === 0) {
|
|
425
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No workspaces found', { itemIndex: index });
|
|
426
|
+
}
|
|
427
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Please select a workspace - multiple workspaces available', { itemIndex: index });
|
|
428
|
+
};
|
|
407
429
|
for (let i = 0; i < items.length; i++) {
|
|
408
430
|
const resource = this.getNodeParameter('resource', i);
|
|
409
431
|
const operation = this.getNodeParameter('operation', i);
|
|
@@ -511,6 +533,10 @@ class PageCrawl {
|
|
|
511
533
|
delete body.template_id;
|
|
512
534
|
if (!body.auth_id || body.auth_id === 0)
|
|
513
535
|
delete body.auth_id;
|
|
536
|
+
// Auto-select workspace if not set
|
|
537
|
+
if (!body.workspace_id) {
|
|
538
|
+
body.workspace_id = await getWorkspaceId(i);
|
|
539
|
+
}
|
|
514
540
|
// Transform fixedCollection fields to arrays
|
|
515
541
|
if (body.actions && typeof body.actions === 'object') {
|
|
516
542
|
body.actions = transformFixedCollection(body.actions, 'action');
|
|
@@ -148,8 +148,8 @@ class PageCrawlTrigger {
|
|
|
148
148
|
url: `${baseUrl}/api/user`,
|
|
149
149
|
json: true,
|
|
150
150
|
});
|
|
151
|
-
// Extract workspaces from user response
|
|
152
|
-
let workspaces = response.workspaces || [];
|
|
151
|
+
// Extract workspaces from user response (may be nested under user)
|
|
152
|
+
let workspaces = response.workspaces || response.user?.workspaces || [];
|
|
153
153
|
if (!Array.isArray(workspaces)) {
|
|
154
154
|
return { results: [] };
|
|
155
155
|
}
|