n8n/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts

381 lines
7.9 KiB
TypeScript
Raw Normal View History

import {
INodeProperties,
} from 'n8n-workflow';
import {
Operation,
Resource,
} from '../types';
export const languageOptions: INodeProperties['options'] = [
{
name: 'Danish',
value: 'da',
},
{
name: 'Dutch',
value: 'nl',
},
{
name: 'English',
value: 'en',
},
{
name: 'Finnish',
value: 'fi',
},
{
name: 'French',
value: 'fr',
},
{
name: 'German',
value: 'de',
},
{
name: 'Hungarian',
value: 'hu',
},
{
name: 'Indonesian',
value: 'id',
},
{
name: 'Japanese',
value: 'ja',
},
{
name: 'Portuguese - Portugal',
value: 'pt',
},
{
name: 'Portuguese - Brazil',
value: 'br',
},
{
name: 'Rumanian',
value: 'ru',
},
{
name: 'Spanish',
value: 'es',
},
{
name: 'Swedish',
value: 'sv',
},
{
name: 'Turkish',
value: 'tr',
},
{
name: 'Welsh',
value: 'cy',
},
];
const postalAddressesFields: INodeProperties[] = [
{
displayName: 'Primary',
name: 'primary',
type: 'boolean',
default: false,
description: 'Whether this is the person\'s primary address',
},
{
displayName: 'Address Line',
name: 'address_lines',
type: 'string', // The Action Network API expects a string array but ignores any string beyond the first, so this input field is simplified to string.
default: '',
description: 'Line for a person\'s address',
},
{
displayName: 'Locality',
name: 'locality',
type: 'string',
default: '',
description: 'City or other local administrative area. If blank, this will be filled in based on Action Network\'s geocoding.',
},
{
displayName: 'Region',
name: 'region',
type: 'string',
default: '',
description: 'State or subdivision code per ISO 3166-2',
},
{
displayName: 'Postal Code',
name: 'postal_code',
type: 'string',
default: '',
description: 'Region specific postal code, such as ZIP code',
},
{
displayName: 'Country',
name: 'country',
type: 'string',
default: '',
description: 'Country code according to ISO 3166-1 Alpha-2. Defaults to US.',
},
{
displayName: 'Language',
name: 'language',
type: 'string',
default: '',
description: 'Language in which the address is recorded, per ISO 639',
},
{
displayName: 'Location',
name: 'location',
type: 'fixedCollection',
refactor: Apply `eslint-plugin-n8n-nodes-base` autofixable rules (#3174) * :zap: Initial setup * :shirt: Update `.eslintignore` * :shirt: Autofix node-param-default-missing (#3173) * :fire: Remove duplicate key * :shirt: Add exceptions * :package: Update package-lock.json * :shirt: Apply `node-class-description-inputs-wrong-trigger-node` (#3176) * :shirt: Apply `node-class-description-inputs-wrong-regular-node` (#3177) * :shirt: Apply `node-class-description-outputs-wrong` (#3178) * :shirt: Apply `node-execute-block-double-assertion-for-items` (#3179) * :shirt: Apply `node-param-default-wrong-for-collection` (#3180) * :shirt: Apply node-param-default-wrong-for-boolean (#3181) * Autofixed default missing * Autofixed booleans, worked well * :zap: Fix params * :rewind: Undo exempted autofixes * :package: Update package-lock.json * :shirt: Apply node-class-description-missing-subtitle (#3182) * :zap: Fix missing comma * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3184) * :shirt: Add exception for `node-class-description-missing-subtitle` * :shirt: Apply `node-param-default-wrong-for-multi-options` (#3185) * :shirt: Apply `node-param-collection-type-unsorted-items` (#3186) * Missing coma * :shirt: Apply `node-param-default-wrong-for-simplify` (#3187) * :shirt: Apply `node-param-description-comma-separated-hyphen` (#3190) * :shirt: Apply `node-param-description-empty-string` (#3189) * :shirt: Apply `node-param-description-excess-inner-whitespace` (#3191) * Rule looks good * Add whitespace rule in eslint config * :zao: fix * :shirt: Apply `node-param-description-identical-to-display-name` (#3193) * :shirt: Apply `node-param-description-missing-for-ignore-ssl-issues` (#3195) * :rewind: Revert ":zao: fix" This reverts commit ef8a76f3dfedffd1bdccf3178af8a8d90cf5a55c. * :shirt: Apply `node-param-description-missing-for-simplify` (#3196) * :shirt: Apply `node-param-description-missing-final-period` (#3194) * Rule working as intended * Add rule to eslint * :shirt: Apply node-param-description-missing-for-return-all (#3197) * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: agobrech <ael.gobrecht@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com>
2022-04-22 09:29:51 -07:00
default: {},
options: [
{
displayName: 'Location Fields',
name: 'location_fields',
values: [
{
displayName: 'Latitude',
name: 'latitude',
type: 'string',
default: '',
description: 'Latitude of the location of the address',
},
{
displayName: 'Longitude',
name: 'longitude',
type: 'string',
default: '',
description: 'Longitude of the location of the address',
},
],
},
],
},
];
export const eventAdditionalFieldsOptions: INodeProperties['options'] = [
{
displayName: 'Browser URL',
name: 'browser_url',
type: 'string',
default: '',
description: 'URL to this events page on the Action Network or a third party',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'Description of the event. HTML supported.',
},
{
displayName: 'End Date',
name: 'end_date',
type: 'dateTime',
default: '',
description: 'End date and time of the event',
},
{
displayName: 'Featured Image URL',
name: 'featured_image_url',
type: 'string',
default: '',
description: 'URL to this events featured image on the Action Network',
},
{
displayName: 'Instructions',
name: 'instructions',
type: 'string',
default: '',
description: 'Event\'s instructions for activists, visible after they RSVP. HTML supported.',
},
{
displayName: 'Location',
name: 'location',
type: 'fixedCollection',
default: {},
placeholder: 'Add Location Field',
typeOptions: {
multipleValues: false,
},
options: [
// different name, identical structure
{
displayName: 'Postal Addresses Fields',
name: 'postal_addresses_fields',
placeholder: 'Add Postal Address Field',
values: postalAddressesFields,
},
],
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Internal (not public) title of the event',
},
{
displayName: 'Start Date',
name: 'start_date',
type: 'dateTime',
default: '',
description: 'Start date and time of the event',
},
];
export const personAdditionalFieldsOptions: INodeProperties['options'] = [
{
displayName: 'Family Name',
name: 'family_name',
type: 'string',
default: '',
description: 'Persons last name',
},
{
displayName: 'Given Name',
name: 'given_name',
type: 'string',
default: '',
description: 'Persons first name',
},
{
displayName: 'Language Spoken',
name: 'languages_spoken',
type: 'options', // Action Network accepts a `string[]` of language codes, but supports only one language per person - sending an array of 2+ languages will result in the first valid language being set as the preferred language for the person. Therefore, the user may select only one option in the n8n UI.
default: [],
description: 'Language spoken by the person',
options: languageOptions,
},
{
displayName: 'Phone Number', // on create, only _one_ must be passed in
name: 'phone_numbers',
type: 'fixedCollection',
default: {},
placeholder: 'Add Phone Numbers Field',
options: [
{
displayName: 'Phone Numbers Fields',
name: 'phone_numbers_fields',
placeholder: 'Add Phone Number Field',
values: [
{
displayName: 'Number',
name: 'number',
type: 'string',
default: '',
description: 'Person\'s mobile number, in international format without the plus sign',
},
{
displayName: 'Primary',
name: 'primary',
type: 'hidden',
default: true,
description: 'Whether this is the person\'s primary phone number',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
default: 'subscribed',
description: 'Subscription status of this number',
options: [
{
name: 'Bouncing',
value: 'bouncing',
},
{
name: 'Previous Bounce',
value: 'previous bounce',
},
{
name: 'Subscribed',
value: 'subscribed',
},
{
name: 'Unsubscribed',
value: 'unsubscribed',
},
],
},
],
},
],
},
{
displayName: 'Postal Addresses',
name: 'postal_addresses',
type: 'fixedCollection',
default: {},
placeholder: 'Add Postal Addresses Field',
typeOptions: {
multipleValues: true,
},
options: [
{
displayName: 'Postal Addresses Fields',
name: 'postal_addresses_fields',
placeholder: 'Add Postal Address Field',
values: postalAddressesFields,
},
],
},
];
export const petitionAdditionalFieldsOptions: INodeProperties[] = [
{
displayName: 'Browser URL',
name: 'browser_url',
type: 'string',
default: '',
description: 'URL to this petitions page on the Action Network or a third party',
},
{
displayName: 'Featured Image URL',
name: 'featured_image_url',
type: 'string',
default: '',
description: 'URL to this actions featured image on the Action Network',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Internal (not public) title of the petition',
},
{
displayName: 'Petition Text',
name: 'petition_text',
type: 'string',
default: '',
description: 'Text of the letter to the petitions target',
},
{
displayName: 'Targets',
name: 'target',
type: 'string',
default: '',
description: 'Comma-separated names of targets for this petition',
},
];
export const makeSimpleField = (resource: Resource, operation: Operation): INodeProperties => ({
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
displayName: 'Simplify',
name: 'simple',
type: 'boolean',
displayOptions: {
show: {
resource: [
resource,
],
operation: [
operation,
],
},
},
default: true,
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
description: 'Whether to return a simplified version of the response instead of the raw data',
});