@@ -0,0 +1,209 @@
|
||||
import type {
|
||||
INodeProperties,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { proboConnectApiRequest } from '../../GenericFunctions';
|
||||
|
||||
const roleOptions = [
|
||||
{ name: 'Owner', value: 'OWNER' },
|
||||
{ name: 'Admin', value: 'ADMIN' },
|
||||
{ name: 'Employee', value: 'EMPLOYEE' },
|
||||
{ name: 'Viewer', value: 'VIEWER' },
|
||||
{ name: 'Auditor', value: 'AUDITOR' },
|
||||
];
|
||||
|
||||
const kindOptions = [
|
||||
{ name: 'Employee', value: 'EMPLOYEE' },
|
||||
{ name: 'Contractor', value: 'CONTRACTOR' },
|
||||
{ name: 'Service Account', value: 'SERVICE_ACCOUNT' },
|
||||
];
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the organization',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Full Name',
|
||||
name: 'fullName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Full name of the user',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Email Address',
|
||||
name: 'emailAddress',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'name@example.com',
|
||||
description: 'Email address of the user',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Role',
|
||||
name: 'role',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
options: roleOptions,
|
||||
default: 'EMPLOYEE',
|
||||
description: 'Membership role to assign',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Kind',
|
||||
name: 'kind',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
options: kindOptions,
|
||||
default: 'EMPLOYEE',
|
||||
description: 'User kind (employee, contractor, or service account)',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['createUser'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Additional Email Addresses',
|
||||
name: 'additionalEmailAddresses',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated additional email addresses',
|
||||
},
|
||||
{
|
||||
displayName: 'Position',
|
||||
name: 'position',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Job or role position',
|
||||
},
|
||||
{
|
||||
displayName: 'Contract Start Date',
|
||||
name: 'contractStartDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Contract start date (ISO 8601)',
|
||||
},
|
||||
{
|
||||
displayName: 'Contract End Date',
|
||||
name: 'contractEndDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Contract end date (ISO 8601)',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
||||
const fullName = this.getNodeParameter('fullName', itemIndex) as string;
|
||||
const emailAddress = this.getNodeParameter('emailAddress', itemIndex) as string;
|
||||
const role = this.getNodeParameter('role', itemIndex) as string;
|
||||
const kind = this.getNodeParameter('kind', itemIndex) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}) as {
|
||||
additionalEmailAddresses?: string;
|
||||
position?: string;
|
||||
contractStartDate?: string;
|
||||
contractEndDate?: string;
|
||||
};
|
||||
|
||||
const input: IDataObject = {
|
||||
organizationId,
|
||||
fullName,
|
||||
emailAddress,
|
||||
role,
|
||||
kind,
|
||||
};
|
||||
if (additionalFields.additionalEmailAddresses) {
|
||||
input.additionalEmailAddresses = additionalFields.additionalEmailAddresses
|
||||
.split(',')
|
||||
.map((e: string) => e.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
if (additionalFields.position) {
|
||||
input.position = additionalFields.position;
|
||||
}
|
||||
if (additionalFields.contractStartDate) {
|
||||
input.contractStartDate = additionalFields.contractStartDate;
|
||||
}
|
||||
if (additionalFields.contractEndDate) {
|
||||
input.contractEndDate = additionalFields.contractEndDate;
|
||||
}
|
||||
|
||||
const query = `
|
||||
mutation CreateUser($input: CreateUserInput!) {
|
||||
createUser(input: $input) {
|
||||
profileEdge {
|
||||
node {
|
||||
id
|
||||
fullName
|
||||
emailAddress
|
||||
kind
|
||||
position
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
createdAt
|
||||
updatedAt
|
||||
organization { id name }
|
||||
membership { id role createdAt }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { proboConnectApiRequest } from '../../GenericFunctions';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the user (profile)',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const userId = this.getNodeParameter('userId', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
query GetUser($userId: ID!) {
|
||||
node(id: $userId) {
|
||||
... on Profile {
|
||||
id
|
||||
fullName
|
||||
emailAddress
|
||||
source
|
||||
state
|
||||
additionalEmailAddresses
|
||||
kind
|
||||
position
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
createdAt
|
||||
updatedAt
|
||||
identity { id email fullName emailVerified }
|
||||
organization { id name email }
|
||||
membership { id role createdAt }
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { userId });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
84
packages/n8n-node/nodes/Probo/actions/user/index.ts
Normal file
84
packages/n8n-node/nodes/Probo/actions/user/index.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import * as listUsersOp from './listUsers.operation';
|
||||
import * as getUserOp from './getUser.operation';
|
||||
import * as createUserOp from './createUser.operation';
|
||||
import * as inviteUserOp from './inviteUser.operation';
|
||||
import * as updateUserOp from './updateUser.operation';
|
||||
import * as updateMembershipOp from './updateMembership.operation';
|
||||
import * as removeUserOp from './removeUser.operation';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'createUser',
|
||||
description: 'Create a new user in the organization',
|
||||
action: 'Create a user',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'getUser',
|
||||
description: 'Get a user (profile) by ID',
|
||||
action: 'Get a user',
|
||||
},
|
||||
{
|
||||
name: 'Invite',
|
||||
value: 'inviteUser',
|
||||
description: 'Invite a user to the organization',
|
||||
action: 'Invite a user',
|
||||
},
|
||||
{
|
||||
name: 'List',
|
||||
value: 'listUsers',
|
||||
description: 'List all users in the organization',
|
||||
action: 'List users',
|
||||
},
|
||||
{
|
||||
name: 'Remove',
|
||||
value: 'removeUser',
|
||||
description: 'Remove a user from the organization',
|
||||
action: 'Remove a user',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'updateUser',
|
||||
description: 'Update a user (profile)',
|
||||
action: 'Update a user',
|
||||
},
|
||||
{
|
||||
name: 'Update Membership',
|
||||
value: 'updateMembership',
|
||||
description: 'Update a user\'s membership role',
|
||||
action: 'Update membership role',
|
||||
},
|
||||
],
|
||||
default: 'listUsers',
|
||||
},
|
||||
...listUsersOp.description,
|
||||
...getUserOp.description,
|
||||
...createUserOp.description,
|
||||
...inviteUserOp.description,
|
||||
...updateUserOp.description,
|
||||
...updateMembershipOp.description,
|
||||
...removeUserOp.description,
|
||||
];
|
||||
|
||||
export {
|
||||
listUsersOp as listUsers,
|
||||
getUserOp as getUser,
|
||||
createUserOp as createUser,
|
||||
inviteUserOp as inviteUser,
|
||||
updateUserOp as updateUser,
|
||||
updateMembershipOp as updateMembership,
|
||||
removeUserOp as removeUser,
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
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: ['user'],
|
||||
operation: ['inviteUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the organization',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Profile ID',
|
||||
name: 'profileId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['inviteUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the user (profile) to invite to the organization',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
||||
const profileId = this.getNodeParameter('profileId', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
mutation InviteUser($input: InviteUserInput!) {
|
||||
inviteUser(input: $input) {
|
||||
invitationEdge {
|
||||
node {
|
||||
id
|
||||
expiresAt
|
||||
status
|
||||
createdAt
|
||||
user { id fullName emailAddress }
|
||||
organization { id name }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const input = { organizationId, profileId };
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import type {
|
||||
INodeProperties,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { proboConnectApiRequestAllItems } from '../../GenericFunctions';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['listUsers'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the organization',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['listUsers'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['listUsers'],
|
||||
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 organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean;
|
||||
const limit = this.getNodeParameter('limit', itemIndex, 50) as number;
|
||||
|
||||
const query = `
|
||||
query ListUsers($organizationId: ID!, $first: Int, $after: CursorKey, $orderBy: ProfileOrder) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
profiles(first: $first, after: $after, orderBy: $orderBy) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
fullName
|
||||
emailAddress
|
||||
source
|
||||
state
|
||||
additionalEmailAddresses
|
||||
kind
|
||||
position
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
createdAt
|
||||
updatedAt
|
||||
organization { id name }
|
||||
membership { id role createdAt }
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const users = await proboConnectApiRequestAllItems.call(
|
||||
this,
|
||||
query,
|
||||
{ organizationId },
|
||||
(response: IDataObject) => {
|
||||
const data = response?.data as IDataObject | undefined;
|
||||
const node = data?.node as IDataObject | undefined;
|
||||
const org = node as IDataObject | undefined;
|
||||
return org?.profiles as IDataObject | undefined;
|
||||
},
|
||||
returnAll,
|
||||
limit,
|
||||
);
|
||||
|
||||
return {
|
||||
json: { users },
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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: ['user'],
|
||||
operation: ['removeUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the organization',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['removeUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the user (profile) to remove from the organization',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
||||
const userId = this.getNodeParameter('userId', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
mutation RemoveUser($input: RemoveUserInput!) {
|
||||
removeUser(input: $input) {
|
||||
deletedProfileId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const input = { organizationId, profileId: userId };
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { proboConnectApiRequest } from '../../GenericFunctions';
|
||||
|
||||
const roleOptions = [
|
||||
{ name: 'Owner', value: 'OWNER' },
|
||||
{ name: 'Admin', value: 'ADMIN' },
|
||||
{ name: 'Employee', value: 'EMPLOYEE' },
|
||||
{ name: 'Viewer', value: 'VIEWER' },
|
||||
{ name: 'Auditor', value: 'AUDITOR' },
|
||||
];
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateMembership'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the organization',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Membership ID',
|
||||
name: 'membershipId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateMembership'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the membership to update',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Role',
|
||||
name: 'role',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateMembership'],
|
||||
},
|
||||
},
|
||||
options: roleOptions,
|
||||
default: 'EMPLOYEE',
|
||||
description: 'New role for the membership',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
|
||||
const membershipId = this.getNodeParameter('membershipId', itemIndex) as string;
|
||||
const role = this.getNodeParameter('role', itemIndex) as string;
|
||||
|
||||
const query = `
|
||||
mutation UpdateMembership($input: UpdateMembershipInput!) {
|
||||
updateMembership(input: $input) {
|
||||
membership {
|
||||
id
|
||||
role
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const input = { organizationId, membershipId, role };
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import type {
|
||||
INodeProperties,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { proboConnectApiRequest } from '../../GenericFunctions';
|
||||
|
||||
const kindOptions = [
|
||||
{ name: 'Employee', value: 'EMPLOYEE' },
|
||||
{ name: 'Contractor', value: 'CONTRACTOR' },
|
||||
{ name: 'Service Account', value: 'SERVICE_ACCOUNT' },
|
||||
];
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the user (profile) to update',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Full Name',
|
||||
name: 'fullName',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateUser'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Full name of the user',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Kind',
|
||||
name: 'kind',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateUser'],
|
||||
},
|
||||
},
|
||||
options: kindOptions,
|
||||
default: 'EMPLOYEE',
|
||||
description: 'User kind',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['updateUser'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Additional Email Addresses',
|
||||
name: 'additionalEmailAddresses',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Comma-separated additional email addresses',
|
||||
},
|
||||
{
|
||||
displayName: 'Position',
|
||||
name: 'position',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Job or role position',
|
||||
},
|
||||
{
|
||||
displayName: 'Contract Start Date',
|
||||
name: 'contractStartDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Contract start date (ISO 8601)',
|
||||
},
|
||||
{
|
||||
displayName: 'Contract End Date',
|
||||
name: 'contractEndDate',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Contract end date (ISO 8601)',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
itemIndex: number,
|
||||
): Promise<INodeExecutionData> {
|
||||
const userId = this.getNodeParameter('userId', itemIndex) as string;
|
||||
const fullName = this.getNodeParameter('fullName', itemIndex) as string;
|
||||
const kind = this.getNodeParameter('kind', itemIndex) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}) as {
|
||||
additionalEmailAddresses?: string;
|
||||
position?: string;
|
||||
contractStartDate?: string;
|
||||
contractEndDate?: string;
|
||||
};
|
||||
|
||||
const input: IDataObject = {
|
||||
id: userId,
|
||||
fullName,
|
||||
kind,
|
||||
};
|
||||
if (additionalFields.additionalEmailAddresses !== undefined) {
|
||||
input.additionalEmailAddresses = additionalFields.additionalEmailAddresses
|
||||
? (additionalFields.additionalEmailAddresses as string)
|
||||
.split(',')
|
||||
.map((e: string) => e.trim())
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
}
|
||||
if (additionalFields.position) {
|
||||
input.position = additionalFields.position;
|
||||
}
|
||||
if (additionalFields.contractStartDate) {
|
||||
input.contractStartDate = additionalFields.contractStartDate;
|
||||
}
|
||||
if (additionalFields.contractEndDate) {
|
||||
input.contractEndDate = additionalFields.contractEndDate;
|
||||
}
|
||||
|
||||
const query = `
|
||||
mutation UpdateUser($input: UpdateUserInput!) {
|
||||
updateUser(input: $input) {
|
||||
profile {
|
||||
id
|
||||
fullName
|
||||
emailAddress
|
||||
kind
|
||||
position
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
createdAt
|
||||
updatedAt
|
||||
organization { id name }
|
||||
membership { id role createdAt }
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const responseData = await proboConnectApiRequest.call(this, query, { input });
|
||||
|
||||
return {
|
||||
json: responseData,
|
||||
pairedItem: { item: itemIndex },
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user