Replace Organization.logoUrl and horizontalLogoUrl with nested File
objects whose downloadUrl points at /api/files/v1/public/{id}, matching
the Console migration.
Org logos are FileVisibilityPublic and served without HTTP auth, so
Connect File.downloadUrl is built eagerly in NewFile with no field-level
authorize. Logo loading moves to iam.OrganizationService.LogoFile and
HorizontalLogoFile; the old URL generators are removed.
Sync IAM Relay components and n8n organization operations. Add an e2e
test for Connect multipart logo upload and ExecuteConnectWithFile.
Signed-off-by: Ludovic Vielle <ludovic@probo.com>
154 lines
3.9 KiB
TypeScript
154 lines
3.9 KiB
TypeScript
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
|
|
//
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
// copyright notice and this permission notice appear in all copies.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
import { proboConnectApiRequest } from '../../GenericFunctions';
|
|
|
|
export const description: INodeProperties[] = [
|
|
{
|
|
displayName: 'Organization ID',
|
|
name: 'organizationId',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The ID of the organization to update',
|
|
required: true,
|
|
},
|
|
{
|
|
displayName: 'Name',
|
|
name: 'name',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The name of the organization',
|
|
},
|
|
{
|
|
displayName: 'Description',
|
|
name: 'description',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The description of the organization',
|
|
},
|
|
{
|
|
displayName: 'Website URL',
|
|
name: 'websiteUrl',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The website URL of the organization',
|
|
},
|
|
{
|
|
displayName: 'Email',
|
|
name: 'email',
|
|
type: 'string',
|
|
placeholder: 'name@example.com',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The email address of the organization',
|
|
},
|
|
{
|
|
displayName: 'Headquarter Address',
|
|
name: 'headquarterAddress',
|
|
type: 'string',
|
|
displayOptions: {
|
|
show: {
|
|
resource: ['organization'],
|
|
operation: ['update'],
|
|
},
|
|
},
|
|
default: '',
|
|
description: 'The headquarter address of the organization',
|
|
},
|
|
];
|
|
|
|
export async function execute(
|
|
this: IExecuteFunctions,
|
|
itemIndex: number,
|
|
): Promise<INodeExecutionData> {
|
|
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
|
const name = this.getNodeParameter('name', itemIndex, '') as string;
|
|
const description = this.getNodeParameter('description', itemIndex, '') as string;
|
|
const websiteUrl = this.getNodeParameter('websiteUrl', itemIndex, '') as string;
|
|
const email = this.getNodeParameter('email', itemIndex, '') as string;
|
|
const headquarterAddress = this.getNodeParameter('headquarterAddress', itemIndex, '') as string;
|
|
|
|
const query = `
|
|
mutation UpdateOrganization($input: UpdateOrganizationInput!) {
|
|
updateOrganization(input: $input) {
|
|
organization {
|
|
id
|
|
name
|
|
description
|
|
websiteUrl
|
|
email
|
|
headquarterAddress
|
|
logo {
|
|
id
|
|
fileName
|
|
downloadUrl
|
|
}
|
|
horizontalLogo {
|
|
id
|
|
fileName
|
|
downloadUrl
|
|
}
|
|
createdAt
|
|
updatedAt
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
const input: Record<string, string> = { organizationId };
|
|
if (name) input.name = name;
|
|
if (description) input.description = description;
|
|
if (websiteUrl) input.websiteUrl = websiteUrl;
|
|
if (email) input.email = email;
|
|
if (headquarterAddress) input.headquarterAddress = headquarterAddress;
|
|
|
|
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
|
|
|
return {
|
|
json: responseData,
|
|
pairedItem: { item: itemIndex },
|
|
};
|
|
}
|
|
|