Add third-party self-referential relations
Introduce a self-referential many-to-many relation table so a third party can have child third parties. Each relation is directional (parent to child); both directions can coexist as independent rows. Add a first_level boolean on third_parties (default true) with a filter on the list page that defaults to showing only first-level third parties. Frontend adds a "Third Parties" tab on the detail page where users can link existing third parties or create new ones from the common third party catalog (created as non-first-level). The list page gets a First Level/All toggle filter. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.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
|
||||
@@ -183,6 +183,13 @@ export const description: INodeProperties[] = [
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Root',
|
||||
name: 'firstLevel',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether this is a first-level third party',
|
||||
},
|
||||
{
|
||||
displayName: 'Security Page URL',
|
||||
name: 'securityPageUrl',
|
||||
@@ -249,6 +256,7 @@ export async function execute(
|
||||
trustPageUrl?: string;
|
||||
certifications?: string;
|
||||
countries?: string;
|
||||
firstLevel?: boolean;
|
||||
};
|
||||
|
||||
const query = `
|
||||
@@ -275,6 +283,7 @@ export async function execute(
|
||||
certifications
|
||||
countries
|
||||
showOnTrustCenter
|
||||
firstLevel
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
@@ -303,6 +312,7 @@ export async function execute(
|
||||
if (additionalFields.subprocessorsListUrl) input.subprocessorsListUrl = additionalFields.subprocessorsListUrl;
|
||||
if (additionalFields.securityPageUrl) input.securityPageUrl = additionalFields.securityPageUrl;
|
||||
if (additionalFields.trustPageUrl) input.trustPageUrl = additionalFields.trustPageUrl;
|
||||
if (additionalFields.firstLevel !== undefined) input.firstLevel = additionalFields.firstLevel;
|
||||
if (additionalFields.certifications) {
|
||||
input.certifications = additionalFields.certifications.split(',').map((c) => c.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.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
|
||||
@@ -73,6 +73,13 @@ export const description: INodeProperties[] = [
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Filter by Root',
|
||||
name: 'filterFirstLevel',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to filter by first-level third parties only',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Organization',
|
||||
name: 'includeOrganization',
|
||||
@@ -106,6 +113,7 @@ export async function execute(
|
||||
const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean;
|
||||
const limit = this.getNodeParameter('limit', itemIndex, 50) as number;
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as {
|
||||
filterFirstLevel?: boolean;
|
||||
includeOrganization?: boolean;
|
||||
includeBusinessOwner?: boolean;
|
||||
includeSecurityOwner?: boolean;
|
||||
@@ -134,11 +142,14 @@ export async function execute(
|
||||
}`
|
||||
: '';
|
||||
|
||||
const filterVariable = options.filterFirstLevel !== undefined ? ', $filter: ThirdPartyFilter' : '';
|
||||
const filterArgument = options.filterFirstLevel !== undefined ? ', filter: $filter' : '';
|
||||
|
||||
const query = `
|
||||
query GetThirdParties($organizationId: ID!, $first: Int, $after: CursorKey) {
|
||||
query GetThirdParties($organizationId: ID!, $first: Int, $after: CursorKey${filterVariable}) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
thirdParties(first: $first, after: $after) {
|
||||
thirdParties(first: $first, after: $after${filterArgument}) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
@@ -160,6 +171,7 @@ export async function execute(
|
||||
certifications
|
||||
countries
|
||||
showOnTrustCenter
|
||||
firstLevel
|
||||
${organizationFragment}
|
||||
${businessOwnerFragment}
|
||||
${securityOwnerFragment}
|
||||
@@ -177,10 +189,15 @@ export async function execute(
|
||||
}
|
||||
`;
|
||||
|
||||
const variables: IDataObject = { organizationId };
|
||||
if (options.filterFirstLevel) {
|
||||
variables.filter = { firstLevel: true };
|
||||
}
|
||||
|
||||
const thirdParties = await proboApiRequestAllItems.call(
|
||||
this,
|
||||
query,
|
||||
{ organizationId },
|
||||
variables,
|
||||
(response) => {
|
||||
const data = response?.data as IDataObject | undefined;
|
||||
const node = data?.node as IDataObject | undefined;
|
||||
|
||||
@@ -39,6 +39,9 @@ import * as updateBusinessAssociateAgreementOp from './updateBusinessAssociateAg
|
||||
import * as getDataPrivacyAgreementOp from './getDataPrivacyAgreement.operation';
|
||||
import * as deleteDataPrivacyAgreementOp from './deleteDataPrivacyAgreement.operation';
|
||||
import * as updateDataPrivacyAgreementOp from './updateDataPrivacyAgreement.operation';
|
||||
import * as linkThirdPartyOp from './linkThirdParty.operation';
|
||||
import * as unlinkThirdPartyOp from './unlinkThirdParty.operation';
|
||||
import * as listChildThirdPartiesOp from './listChildThirdParties.operation';
|
||||
import * as publishOp from './publish.operation';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
@@ -143,6 +146,12 @@ export const description: INodeProperties[] = [
|
||||
description: 'Get many third parties',
|
||||
action: 'Get many third parties',
|
||||
},
|
||||
{
|
||||
name: 'Get Many Child Third Parties',
|
||||
value: 'listChildThirdParties',
|
||||
description: 'Get child third parties linked to a parent',
|
||||
action: 'Get many child third parties',
|
||||
},
|
||||
{
|
||||
name: 'Get Many Compliance Reports',
|
||||
value: 'getAllComplianceReports',
|
||||
@@ -179,12 +188,24 @@ export const description: INodeProperties[] = [
|
||||
description: 'Get a third party service',
|
||||
action: 'Get a third party service',
|
||||
},
|
||||
{
|
||||
name: 'Link Third Party',
|
||||
value: 'linkThirdParty',
|
||||
description: 'Link a child third party to a parent third party',
|
||||
action: 'Link a child third party',
|
||||
},
|
||||
{
|
||||
name: 'Publish List',
|
||||
value: 'publish',
|
||||
description: 'Publish the third party register as a document version',
|
||||
action: 'Publish the third party register',
|
||||
},
|
||||
{
|
||||
name: 'Unlink Third Party',
|
||||
value: 'unlinkThirdParty',
|
||||
description: 'Unlink a child third party from a parent third party',
|
||||
action: 'Unlink a child third party',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
@@ -244,6 +265,9 @@ export const description: INodeProperties[] = [
|
||||
...getDataPrivacyAgreementOp.description,
|
||||
...deleteDataPrivacyAgreementOp.description,
|
||||
...updateDataPrivacyAgreementOp.description,
|
||||
...linkThirdPartyOp.description,
|
||||
...unlinkThirdPartyOp.description,
|
||||
...listChildThirdPartiesOp.description,
|
||||
...publishOp.description,
|
||||
];
|
||||
|
||||
@@ -274,5 +298,8 @@ export {
|
||||
getDataPrivacyAgreementOp as getDataPrivacyAgreement,
|
||||
deleteDataPrivacyAgreementOp as deleteDataPrivacyAgreement,
|
||||
updateDataPrivacyAgreementOp as updateDataPrivacyAgreement,
|
||||
linkThirdPartyOp as linkThirdParty,
|
||||
unlinkThirdPartyOp as unlinkThirdParty,
|
||||
listChildThirdPartiesOp as listChildThirdParties,
|
||||
publishOp as publish,
|
||||
};
|
||||
|
||||
75
packages/n8n-node/nodes/Probo/actions/thirdParty/linkThirdParty.operation.ts
vendored
Normal file
75
packages/n8n-node/nodes/Probo/actions/thirdParty/linkThirdParty.operation.ts
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.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 { proboApiRequest } from '../../GenericFunctions';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Parent Third Party ID',
|
||||
name: 'parentThirdPartyId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['linkThirdParty'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the parent third party',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Child Third Party ID',
|
||||
name: 'childThirdPartyId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['linkThirdParty'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the child third party to link',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const parentThirdPartyId = this.getNodeParameter('parentThirdPartyId', itemIndex) as string;
|
||||
const childThirdPartyId = this.getNodeParameter('childThirdPartyId', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
mutation CreateThirdPartyThirdPartyMapping($input: CreateThirdPartyThirdPartyMappingInput!) {
|
||||
createThirdPartyThirdPartyMapping(input: $input) {
|
||||
thirdPartyEdge {
|
||||
node {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const responseData = await proboApiRequest.call(this, query, { input: { parentThirdPartyId, childThirdPartyId } });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
118
packages/n8n-node/nodes/Probo/actions/thirdParty/listChildThirdParties.operation.ts
vendored
Normal file
118
packages/n8n-node/nodes/Probo/actions/thirdParty/listChildThirdParties.operation.ts
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.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, IDataObject } from 'n8n-workflow';
|
||||
import { proboApiRequestAllItems } from '../../GenericFunctions';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Third Party ID',
|
||||
name: 'thirdPartyId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['listChildThirdParties'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the parent third party',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['listChildThirdParties'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['listChildThirdParties'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const thirdPartyId = this.getNodeParameter('thirdPartyId', itemIndex) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean;
|
||||
const limit = this.getNodeParameter('limit', itemIndex, 50) as number;
|
||||
|
||||
const query = `
|
||||
query GetChildThirdParties($thirdPartyId: ID!, $first: Int, $after: CursorKey) {
|
||||
node(id: $thirdPartyId) {
|
||||
... on ThirdParty {
|
||||
childThirdParties(first: $first, after: $after) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
description
|
||||
category
|
||||
websiteUrl
|
||||
legalName
|
||||
headquarterAddress
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const childThirdParties = await proboApiRequestAllItems.call(
|
||||
this,
|
||||
query,
|
||||
{ thirdPartyId },
|
||||
(response) => {
|
||||
const data = response?.data as IDataObject | undefined;
|
||||
const node = data?.node as IDataObject | undefined;
|
||||
return node?.childThirdParties as IDataObject | undefined;
|
||||
},
|
||||
returnAll,
|
||||
limit,
|
||||
);
|
||||
|
||||
return {
|
||||
json: { childThirdParties },
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
70
packages/n8n-node/nodes/Probo/actions/thirdParty/unlinkThirdParty.operation.ts
vendored
Normal file
70
packages/n8n-node/nodes/Probo/actions/thirdParty/unlinkThirdParty.operation.ts
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2025-2026 Probo Inc <hello@getprobo.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 { proboApiRequest } from '../../GenericFunctions';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Parent Third Party ID',
|
||||
name: 'parentThirdPartyId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['unlinkThirdParty'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the parent third party',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Child Third Party ID',
|
||||
name: 'childThirdPartyId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['thirdParty'],
|
||||
operation: ['unlinkThirdParty'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the child third party to unlink',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const parentThirdPartyId = this.getNodeParameter('parentThirdPartyId', itemIndex) as string;
|
||||
const childThirdPartyId = this.getNodeParameter('childThirdPartyId', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
mutation DeleteThirdPartyThirdPartyMapping($input: DeleteThirdPartyThirdPartyMappingInput!) {
|
||||
deleteThirdPartyThirdPartyMapping(input: $input) {
|
||||
removedThirdPartyId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const responseData = await proboApiRequest.call(this, query, { input: { parentThirdPartyId, childThirdPartyId } });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user