forked from ivov/eslint-plugin-n8n-nodes-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.ts
219 lines (185 loc) · 5.72 KB
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/**
* Minimum number of options in an options-type or multi-options-type
* node parameter that require alphabetization based on `name`.
*
* Also, minimum number of node params in a collection-type or
* fixed-collection-type node param that require alphabetization
* based on `displayName`.
*/
export const MIN_ITEMS_TO_ALPHABETIZE = 5;
export const MIN_ITEMS_TO_ALPHABETIZE_SPELLED_OUT = "five";
export const WEAK_DESCRIPTIONS = [
"Resource to consume",
"Resource to operate on",
"Operation to perform",
"Action to perform",
"Method of authentication",
];
export const SVG_ICON_SOURCES = [
"https://vecta.io/symbols",
"https://github.com/gilbarbara/logos",
];
export const RESOURCE_DESCRIPTION_SUFFIX = "Description.ts";
const EXPRESSIONS_DOCS_URL = "https://docs.n8n.io/code-examples/expressions/";
export const DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER = {
DISPLAY_NAME_SUFFIX: "Names or IDs",
DESCRIPTION: `Choose from the list, or specify IDs using an <a href="${EXPRESSIONS_DOCS_URL}">expression</a>`,
};
export const DYNAMIC_OPTIONS_NODE_PARAMETER = {
DISPLAY_NAME_SUFFIX: "Name or ID",
DESCRIPTION: `Choose from the list, or specify an ID using an <a href="${EXPRESSIONS_DOCS_URL}">expression</a>`,
};
export const NODE_CLASS_DESCRIPTION_SUBTITLE =
'={{ $parameter["operation"] + ": " + $parameter["resource"] }}';
export const LIMIT_NODE_PARAMETER = {
DEFAULT_VALUE: 50,
DESCRIPTION: "Max number of results to return",
};
export const UPSERT_NODE_PARAMETER = {
DESCRIPTION:
"Create a new record, or update the current one if it already exists (upsert)",
};
export const UPDATE_FIELDS_NODE_PARAM_DISPLAY_NAME = "Update Fields";
export const SIMPLIFY_NODE_PARAMETER = {
DISPLAY_NAME: "Simplify",
DESCRIPTION:
"Whether to return a simplified version of the response instead of the raw data",
};
export const RETURN_ALL_NODE_PARAMETER = {
DISPLAY_NAME: "Return All",
DESCRIPTION: "Whether to return all results or only up to a given limit",
};
export const IGNORE_SSL_ISSUES_NODE_PARAMETER = {
DISPLAY_NAME: "Ignore SSL Issues",
DESCRIPTION:
"Whether to connect even if SSL certificate validation is not possible",
};
export const TOP_LEVEL_FIXED_COLLECTION: {
[key: Uppercase<string>]: { [key: Uppercase<string>]: string };
} = {
STANDARD_DISPLAY_NAME: {
CREATE: "Additional Fields",
UPDATE: "Update Fields",
GETALL: "Options",
},
};
export const EMAIL_PLACEHOLDER = "[email protected]";
// ----------------------------------
// regexes
// ----------------------------------
export const MISCASED_ID_REGEX = /\b(i|I)d(s?)\b/;
export const MISCASED_URL_REGEX = /\b(u|U)rl(s?)\b/;
export const MISCASED_JSON_REGEX = /\b(j|J)son\b/;
export const VALID_HTML_TAG_REGEX = /<\/?(h\d|p|b|em|i|a|ol|ul|li|code|br)>/;
export const LINE_BREAK_HTML_TAG_REGEX = /<\/? ?br ?\/?>/;
export const VERSION_REGEX = /^v\d+\.\d+$/;
// ----------------------------------
// community package.json
// ----------------------------------
export const COMMUNITY_PACKAGE_JSON = {
NAME: "n8n-nodes-<...>",
DESCRIPTION: "",
OFFICIAL_TAG: "n8n-community-node-package",
LICENSE: "MIT",
AUTHOR_NAME: "",
AUTHOR_EMAIL: "",
REPOSITORY_URL: "https://github.com/<...>/n8n-nodes-<...>.git",
CREDENTIALS: [
"dist/credentials/ExampleCredentials.credentials.js",
"dist/credentials/HttpBinApi.credentials.js",
],
NODES: [
"dist/nodes/ExampleNode/ExampleNode.node.js",
"dist/nodes/HttpBin/HttpBin.node.js",
],
SCRIPTS: `{
"dev": "npm run watch",
"build": "tsc && gulp",
"lint": "tslint -p tsconfig.json -c tslint.json && node_modules/eslint/bin/eslint.js ./nodes",
"lintfix": "tslint --fix -p tsconfig.json -c tslint.json && node_modules/eslint/bin/eslint.js --fix ./nodes",
"watch": "tsc --watch",
"test": "jest"
}`,
DEV_DEPENDENCIES: `{
"@types/express": "^4.17.6",
"@types/request-promise-native": "~1.0.15",
"@typescript-eslint/parser": "^5.29.0",
"eslint-plugin-n8n-nodes-base": "^1.0.43",
"gulp": "^4.0.2",
"jest": "^26.4.2",
"n8n-workflow": "~0.104.0",
"ts-jest": "^26.3.0",
"tslint": "^6.1.2",
"typescript": "~4.3.5"
}`,
};
// ----------------------------------
// docs
// ----------------------------------
export const DOCUMENTATION = {
APPLICABLE_BY_EXTENSION_TO_NAME:
"Applicable by extension to `name` in options-type or multi-options-type node parameter.",
APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION:
"Applicable by extension to `description` in option in options-type and multi-options-type node parameter.",
};
// ----------------------------------
// misc
// ----------------------------------
export const N8N_NODE_ERROR_TYPES = ["NodeOperationError", "NodeApiError"];
/**
* Credentials exempted from these rules:
* - `cred-class-name-unsuffixed`
* - `cred-class-field-name-unsuffixed`
*/
export const CREDS_EXEMPTED_FROM_API_SUFFIX = [
"Amqp",
"Aws",
"CrateDb",
"FileMaker",
"Ftp",
"GitPassword",
"GmailOAuth2Api",
"GoogleAnalyticsOAuth2Api",
"HttpBasicAuth",
"HttpDigestAuth",
"HttpHeaderAuth",
"HttpQueryAuth",
"HubspotAppToken",
"Imap",
"Kafka",
"MicrosoftSql",
"MongoDb",
"Mqtt",
"MySql",
"NocoDb",
"Postgres",
"QuestDb",
"RabbitMQ",
"Redis",
"S3",
"Sftp",
"Smtp",
"Snowflake",
"SshPassword",
"SshPrivateKey",
"TimescaleDb",
];
// ----------------------------------
// formatting
// ----------------------------------
/**
* From: https://raw.githubusercontent.com/n8n-io/n8n/master/.prettierrc.js
*/
export const PRETTIER_CONFIG = {
semi: true,
trailingComma: 'all',
bracketSpacing: true,
useTabs: true,
tabWidth: 2,
arrowParens: 'always',
singleQuote: true,
quoteProps: 'as-needed',
endOfLine: 'lf',
printWidth: 100,
parser: 'babel-ts' // to silence warning, not part of n8n's config
} as const;