@flowfuse/nr-file-nodes 0.0.9-b4bc205-202512151611.0 → 0.0.9-cabebf4-202601051152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.mjs +76 -0
- package/file.html +291 -283
- package/package.json +9 -6
- package/vfs.js +2 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import html from 'eslint-plugin-html'
|
|
3
|
+
import js from '@eslint/js'
|
|
4
|
+
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
|
|
5
|
+
import stylistic from '@stylistic/eslint-plugin'
|
|
6
|
+
import noOnlyTests from 'eslint-plugin-no-only-tests'
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.js'],
|
|
11
|
+
languageOptions: {
|
|
12
|
+
globals: {
|
|
13
|
+
...globals.browser
|
|
14
|
+
},
|
|
15
|
+
sourceType: 'script'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
files: ['test/**/*.js'],
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.browser,
|
|
23
|
+
...globals.mocha
|
|
24
|
+
},
|
|
25
|
+
sourceType: 'script'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
files: ['**/*.html'],
|
|
30
|
+
plugins: { html },
|
|
31
|
+
settings: {
|
|
32
|
+
'html/indent': 'space',
|
|
33
|
+
'html/report-bad-indent': 'error'
|
|
34
|
+
},
|
|
35
|
+
languageOptions: {
|
|
36
|
+
globals: {
|
|
37
|
+
...globals.browser,
|
|
38
|
+
...globals.jquery,
|
|
39
|
+
RED: 'readonly'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
ignores: [
|
|
45
|
+
...resolveIgnoresFromGitignore()
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
js.configs.recommended,
|
|
49
|
+
// stylistic.configs['recommended-flat'],
|
|
50
|
+
...neostandard(),
|
|
51
|
+
{
|
|
52
|
+
plugins: {
|
|
53
|
+
'@stylistic': stylistic,
|
|
54
|
+
'no-only-tests': noOnlyTests
|
|
55
|
+
},
|
|
56
|
+
rules: {
|
|
57
|
+
'object-shorthand': ['error'],
|
|
58
|
+
'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error'] }],
|
|
59
|
+
|
|
60
|
+
'camelcase': 'off',
|
|
61
|
+
'eqeqeq': 'error',
|
|
62
|
+
'no-empty': ['error', { 'allowEmptyCatch': true }],
|
|
63
|
+
'no-unused-vars': ['error', {
|
|
64
|
+
'args': 'none',
|
|
65
|
+
'caughtErrors': 'none'
|
|
66
|
+
}],
|
|
67
|
+
'quotes': ['off', 'error', 'single', { 'avoidEscape': true }],
|
|
68
|
+
'yoda': 'off',
|
|
69
|
+
'@stylistic/indent': ['warn', 4], // https://eslint.style/rules/indent#options
|
|
70
|
+
'@stylistic/linebreak-style': ['error', 'unix'],
|
|
71
|
+
'@stylistic/quote-props': ['warn', 'consistent'],
|
|
72
|
+
'@stylistic/no-multi-spaces': 'error', // https://eslint.style/rules/no-multi-spaces#no-multi-spaces
|
|
73
|
+
'@stylistic/comma-dangle': ['error', 'never'] // https://eslint.style/rules/comma-dangle#comma-dangle
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
package/file.html
CHANGED
|
@@ -73,340 +73,348 @@
|
|
|
73
73
|
</script>
|
|
74
74
|
|
|
75
75
|
<script type="text/javascript">
|
|
76
|
-
(function(){
|
|
77
|
-
|
|
78
|
-
[
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
(function () {
|
|
77
|
+
const encodings = [
|
|
78
|
+
[
|
|
79
|
+
'file.encoding.native',
|
|
80
|
+
'utf8',
|
|
81
|
+
'ucs2',
|
|
82
|
+
'utf-16le',
|
|
83
|
+
'ascii',
|
|
84
|
+
'binary',
|
|
85
|
+
'base64',
|
|
86
|
+
'hex'
|
|
86
87
|
],
|
|
87
|
-
[
|
|
88
|
-
|
|
88
|
+
[
|
|
89
|
+
'file.encoding.unicode',
|
|
90
|
+
'utf-16be'
|
|
89
91
|
],
|
|
90
|
-
[
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
[
|
|
93
|
+
'file.encoding.japanese',
|
|
94
|
+
'Shift_JIS',
|
|
95
|
+
'Windows-31j',
|
|
96
|
+
'Windows932',
|
|
97
|
+
'EUC-JP'
|
|
95
98
|
],
|
|
96
|
-
[
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
[
|
|
100
|
+
'file.encoding.chinese',
|
|
101
|
+
'GB2312',
|
|
102
|
+
'GBK',
|
|
103
|
+
'GB18030',
|
|
104
|
+
'Windows936',
|
|
105
|
+
'EUC-CN'
|
|
102
106
|
],
|
|
103
|
-
[
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
[
|
|
108
|
+
'file.encoding.korean',
|
|
109
|
+
'KS_C_5601',
|
|
110
|
+
'Windows949',
|
|
111
|
+
'EUC-KR'
|
|
107
112
|
],
|
|
108
|
-
[
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
[
|
|
114
|
+
'file.encoding.taiwan',
|
|
115
|
+
'Big5',
|
|
116
|
+
'Big5-HKSCS',
|
|
117
|
+
'Windows950'
|
|
112
118
|
],
|
|
113
|
-
[
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
[
|
|
120
|
+
'file.encoding.windows',
|
|
121
|
+
'cp874',
|
|
122
|
+
'cp1250',
|
|
123
|
+
'cp1251',
|
|
124
|
+
'cp1252',
|
|
125
|
+
'cp1253',
|
|
126
|
+
'cp1254',
|
|
127
|
+
'cp1255',
|
|
128
|
+
'cp1256',
|
|
129
|
+
'cp1257',
|
|
130
|
+
'cp1258'
|
|
124
131
|
],
|
|
125
|
-
[
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
[
|
|
133
|
+
'file.encoding.iso',
|
|
134
|
+
'ISO-8859-1',
|
|
135
|
+
'ISO-8859-2',
|
|
136
|
+
'ISO-8859-3',
|
|
137
|
+
'ISO-8859-4',
|
|
138
|
+
'ISO-8859-5',
|
|
139
|
+
'ISO-8859-6',
|
|
140
|
+
'ISO-8859-7',
|
|
141
|
+
'ISO-8859-8',
|
|
142
|
+
'ISO-8859-9',
|
|
143
|
+
'ISO-8859-10',
|
|
144
|
+
'ISO-8859-11',
|
|
145
|
+
'ISO-8859-12',
|
|
146
|
+
'ISO-8859-13',
|
|
147
|
+
'ISO-8859-14',
|
|
148
|
+
'ISO-8859-15',
|
|
149
|
+
'ISO-8859-16'
|
|
142
150
|
],
|
|
143
|
-
[
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
151
|
+
[
|
|
152
|
+
'file.encoding.ibm',
|
|
153
|
+
'cp437',
|
|
154
|
+
'cp737',
|
|
155
|
+
'cp775',
|
|
156
|
+
'cp808',
|
|
157
|
+
'cp850',
|
|
158
|
+
'cp852',
|
|
159
|
+
'cp855',
|
|
160
|
+
'cp856',
|
|
161
|
+
'cp857',
|
|
162
|
+
'cp858',
|
|
163
|
+
'cp860',
|
|
164
|
+
'cp861',
|
|
165
|
+
'cp866',
|
|
166
|
+
'cp869',
|
|
167
|
+
'cp922',
|
|
168
|
+
'cp1046',
|
|
169
|
+
'cp1124',
|
|
170
|
+
'cp1125',
|
|
171
|
+
'cp1129',
|
|
172
|
+
'cp1133',
|
|
173
|
+
'cp1161',
|
|
174
|
+
'cp1162',
|
|
175
|
+
'cp1163'
|
|
167
176
|
],
|
|
168
|
-
[
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
[
|
|
178
|
+
'file.encoding.mac',
|
|
179
|
+
'maccroatian',
|
|
180
|
+
'maccyrillic',
|
|
181
|
+
'macgreek',
|
|
182
|
+
'maciceland',
|
|
183
|
+
'macroman',
|
|
184
|
+
'macromania',
|
|
185
|
+
'macthai',
|
|
186
|
+
'macturkish',
|
|
187
|
+
'macukraine',
|
|
188
|
+
'maccenteuro',
|
|
189
|
+
'macintosh'
|
|
180
190
|
],
|
|
181
|
-
[
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
[
|
|
192
|
+
'file.encoding.koi8',
|
|
193
|
+
'koi8-r',
|
|
194
|
+
'koi8-u',
|
|
195
|
+
'koi8-ru',
|
|
196
|
+
'koi8-t'
|
|
186
197
|
],
|
|
187
|
-
[
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
[
|
|
199
|
+
'file.encoding.misc',
|
|
200
|
+
'armscii8',
|
|
201
|
+
'rk1048',
|
|
202
|
+
'tcvn',
|
|
203
|
+
'georgianacademy',
|
|
204
|
+
'georgianps',
|
|
205
|
+
'pt154',
|
|
206
|
+
'viscii',
|
|
207
|
+
'iso646cn',
|
|
208
|
+
'iso646jp',
|
|
209
|
+
'hproman8',
|
|
210
|
+
'tis620'
|
|
199
211
|
]
|
|
200
|
-
]
|
|
212
|
+
]
|
|
201
213
|
|
|
202
|
-
RED.nodes.registerType('file',{
|
|
214
|
+
RED.nodes.registerType('file', {
|
|
203
215
|
category: 'storage',
|
|
204
216
|
defaults: {
|
|
205
|
-
name: {value:
|
|
206
|
-
filename: {value:
|
|
207
|
-
filenameType: {value:
|
|
208
|
-
appendNewline: {value:true},
|
|
209
|
-
createDir: {value:false},
|
|
210
|
-
overwriteFile: {value:
|
|
211
|
-
encoding: {value:
|
|
217
|
+
name: { value: '' },
|
|
218
|
+
filename: { value: '' },
|
|
219
|
+
filenameType: { value: 'str' },
|
|
220
|
+
appendNewline: { value: true },
|
|
221
|
+
createDir: { value: false },
|
|
222
|
+
overwriteFile: { value: 'false' },
|
|
223
|
+
encoding: { value: 'none' }
|
|
212
224
|
},
|
|
213
|
-
color:
|
|
214
|
-
inputs:1,
|
|
215
|
-
outputs:1,
|
|
216
|
-
icon:
|
|
217
|
-
label: function() {
|
|
218
|
-
|
|
219
|
-
if(this.filenameType
|
|
220
|
-
if(this.filenameType ===
|
|
221
|
-
if (this.overwriteFile ===
|
|
222
|
-
return this.name||this._(
|
|
225
|
+
color: 'BurlyWood',
|
|
226
|
+
inputs: 1,
|
|
227
|
+
outputs: 1,
|
|
228
|
+
icon: 'file-out.svg',
|
|
229
|
+
label: function () {
|
|
230
|
+
let fn = this.filename
|
|
231
|
+
if (this.filenameType !== 'str' && this.filenameType !== 'env') { fn = '' }
|
|
232
|
+
if (this.filenameType === 'env') { fn = 'env.' + fn }
|
|
233
|
+
if (this.overwriteFile === 'delete') {
|
|
234
|
+
return this.name || this._('file.label.deletelabel', { file: fn })
|
|
223
235
|
} else {
|
|
224
|
-
return this.name||fn||this._(
|
|
236
|
+
return this.name || fn || this._('file.label.write')
|
|
225
237
|
}
|
|
226
238
|
},
|
|
227
|
-
paletteLabel: RED._(
|
|
228
|
-
labelStyle: function() {
|
|
229
|
-
return this.name?
|
|
239
|
+
paletteLabel: RED._('node-red:file.label.write'),
|
|
240
|
+
labelStyle: function () {
|
|
241
|
+
return this.name ? 'node_label_italic' : ''
|
|
230
242
|
},
|
|
231
|
-
oneditprepare: function() {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
$(
|
|
236
|
-
value:
|
|
237
|
-
label
|
|
238
|
-
}).text(label).appendTo(encSel)
|
|
239
|
-
$(
|
|
240
|
-
value:
|
|
241
|
-
label: node._(
|
|
242
|
-
}).text(label).appendTo(encSel)
|
|
243
|
-
$(
|
|
244
|
-
default:
|
|
245
|
-
types: [{label:RED._(
|
|
246
|
-
typeField: $(
|
|
247
|
-
})
|
|
248
|
-
if(typeof node.filenameType
|
|
249
|
-
//existing node AND filenameType is not set - inplace (compatible) upgrade to new typedInput
|
|
250
|
-
if(node.filename
|
|
251
|
-
node.filename =
|
|
252
|
-
node.filenameType =
|
|
253
|
-
$(
|
|
254
|
-
$(
|
|
255
|
-
} else if(/^\${[^}]+}$/.test(node.filename)) { //was using an ${ENV_VAR}
|
|
256
|
-
node.filenameType =
|
|
257
|
-
node.filename = node.filename.replace(/\${([^}]+)}/g, function(match, name) {
|
|
258
|
-
return (name === undefined)?
|
|
259
|
-
})
|
|
260
|
-
$(
|
|
261
|
-
$(
|
|
262
|
-
} else { //was using a static filename - set typedInput type to str
|
|
263
|
-
node.filenameType =
|
|
264
|
-
$(
|
|
265
|
-
$(
|
|
243
|
+
oneditprepare: function () {
|
|
244
|
+
const node = this
|
|
245
|
+
const encSel = $('#node-input-encoding')
|
|
246
|
+
const label = node._('file.encoding.none')
|
|
247
|
+
$('<option/>', {
|
|
248
|
+
value: 'none',
|
|
249
|
+
label
|
|
250
|
+
}).text(label).appendTo(encSel)
|
|
251
|
+
$('<option/>', {
|
|
252
|
+
value: 'setbymsg',
|
|
253
|
+
label: node._('file.encoding.setbymsg')
|
|
254
|
+
}).text(label).appendTo(encSel)
|
|
255
|
+
$('#node-input-filename').typedInput({
|
|
256
|
+
default: 'str',
|
|
257
|
+
types: [{ label: RED._('node-red:file.label.path'), value: 'str', icon: '' }, 'msg', 'jsonata', 'env'],
|
|
258
|
+
typeField: $('#node-input-filenameType')
|
|
259
|
+
})
|
|
260
|
+
if (typeof node.filenameType === 'undefined') {
|
|
261
|
+
// existing node AND filenameType is not set - inplace (compatible) upgrade to new typedInput
|
|
262
|
+
if (node.filename === '') { // was using empty value to denote msg.filename - set typedInput to match
|
|
263
|
+
node.filename = 'filename'
|
|
264
|
+
node.filenameType = 'msg'
|
|
265
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
266
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
267
|
+
} else if (/^\${[^}]+}$/.test(node.filename)) { // was using an ${ENV_VAR}
|
|
268
|
+
node.filenameType = 'env'
|
|
269
|
+
node.filename = node.filename.replace(/\${([^}]+)}/g, function (match, name) {
|
|
270
|
+
return (name === undefined) ? '' : name
|
|
271
|
+
})
|
|
272
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
273
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
274
|
+
} else { // was using a static filename - set typedInput type to str
|
|
275
|
+
node.filenameType = 'str'
|
|
276
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
277
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
|
-
encodings.forEach(function(item) {
|
|
269
|
-
if(Array.isArray(item)) {
|
|
270
|
-
|
|
280
|
+
encodings.forEach(function (item) {
|
|
281
|
+
if (Array.isArray(item)) {
|
|
282
|
+
const group = $('<optgroup/>', {
|
|
271
283
|
label: node._(item[0])
|
|
272
|
-
}).appendTo(encSel)
|
|
273
|
-
for (
|
|
274
|
-
|
|
275
|
-
$(
|
|
284
|
+
}).appendTo(encSel)
|
|
285
|
+
for (let i = 1; i < item.length; i++) {
|
|
286
|
+
const enc = item[i]
|
|
287
|
+
$('<option/>', {
|
|
276
288
|
value: enc,
|
|
277
289
|
label: enc
|
|
278
|
-
}).text(enc).appendTo(group)
|
|
290
|
+
}).text(enc).appendTo(group)
|
|
279
291
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
$("<option/>", {
|
|
292
|
+
} else {
|
|
293
|
+
$('<option/>', {
|
|
283
294
|
value: item,
|
|
284
295
|
label: item
|
|
285
|
-
}).text(item).appendTo(encSel)
|
|
296
|
+
}).text(item).appendTo(encSel)
|
|
286
297
|
}
|
|
287
|
-
})
|
|
288
|
-
encSel.val(node.encoding)
|
|
289
|
-
$(
|
|
290
|
-
if (this.value ===
|
|
291
|
-
$(
|
|
292
|
-
$(
|
|
298
|
+
})
|
|
299
|
+
encSel.val(node.encoding)
|
|
300
|
+
$('#node-input-overwriteFile').on('change', function () {
|
|
301
|
+
if (this.value === 'delete') {
|
|
302
|
+
$('.form-row-file-write-options').hide()
|
|
303
|
+
$('.form-row-file-encoding').hide()
|
|
293
304
|
} else {
|
|
294
|
-
$(
|
|
295
|
-
$(
|
|
305
|
+
$('.form-row-file-write-options').show()
|
|
306
|
+
$('.form-row-file-encoding').show()
|
|
296
307
|
}
|
|
297
|
-
})
|
|
308
|
+
})
|
|
298
309
|
}
|
|
299
|
-
})
|
|
310
|
+
})
|
|
300
311
|
|
|
301
|
-
RED.nodes.registerType('file in',{
|
|
312
|
+
RED.nodes.registerType('file in', {
|
|
302
313
|
category: 'storage',
|
|
303
314
|
defaults: {
|
|
304
|
-
name: {value:
|
|
305
|
-
filename: {value:
|
|
306
|
-
filenameType: {value:
|
|
307
|
-
format: {value:
|
|
308
|
-
chunk: {value:false},
|
|
309
|
-
sendError: {value: false},
|
|
310
|
-
encoding: {value:
|
|
311
|
-
allProps: {value: false}
|
|
315
|
+
name: { value: '' },
|
|
316
|
+
filename: { value: '' },
|
|
317
|
+
filenameType: { value: 'str' },
|
|
318
|
+
format: { value: 'utf8' },
|
|
319
|
+
chunk: { value: false },
|
|
320
|
+
sendError: { value: false },
|
|
321
|
+
encoding: { value: 'none' },
|
|
322
|
+
allProps: { value: false }
|
|
312
323
|
},
|
|
313
|
-
color:
|
|
314
|
-
inputs:1,
|
|
315
|
-
outputs:1,
|
|
316
|
-
outputLabels: function(i) {
|
|
317
|
-
|
|
318
|
-
if (this.format ===
|
|
319
|
-
l =
|
|
320
|
-
} else if (this.format ===
|
|
321
|
-
l =
|
|
322
|
-
} else if (this.format ===
|
|
323
|
-
l =
|
|
324
|
+
color: 'BurlyWood',
|
|
325
|
+
inputs: 1,
|
|
326
|
+
outputs: 1,
|
|
327
|
+
outputLabels: function (i) {
|
|
328
|
+
let l
|
|
329
|
+
if (this.format === 'utf8') {
|
|
330
|
+
l = 'file.label.utf8String'
|
|
331
|
+
} else if (this.format === 'lines') {
|
|
332
|
+
l = 'file.label.utf8String_plural'
|
|
333
|
+
} else if (this.format === 'stream') {
|
|
334
|
+
l = 'file.label.binaryBuffer_plural'
|
|
324
335
|
} else {
|
|
325
|
-
l =
|
|
336
|
+
l = 'file.label.binaryBuffer'
|
|
326
337
|
}
|
|
327
|
-
return this._(l)
|
|
338
|
+
return this._(l)
|
|
328
339
|
},
|
|
329
|
-
icon:
|
|
330
|
-
label: function() {
|
|
331
|
-
|
|
332
|
-
if(this.filenameType
|
|
333
|
-
if(this.filenameType ===
|
|
334
|
-
return this.name||fn||this._(
|
|
340
|
+
icon: 'file-in.svg',
|
|
341
|
+
label: function () {
|
|
342
|
+
let fn = this.filename
|
|
343
|
+
if (this.filenameType !== 'str' && this.filenameType !== 'env') { fn = '' }
|
|
344
|
+
if (this.filenameType === 'env') { fn = 'env.' + fn }
|
|
345
|
+
return this.name || fn || this._('file.label.read')
|
|
335
346
|
},
|
|
336
|
-
paletteLabel: RED._(
|
|
337
|
-
labelStyle: function() {
|
|
338
|
-
return this.name?
|
|
347
|
+
paletteLabel: RED._('node-red:file.label.read'),
|
|
348
|
+
labelStyle: function () {
|
|
349
|
+
return this.name ? 'node_label_italic' : ''
|
|
339
350
|
},
|
|
340
|
-
oneditprepare: function() {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
$(
|
|
345
|
-
value:
|
|
346
|
-
label
|
|
347
|
-
}).text(label).appendTo(encSel)
|
|
348
|
-
$(
|
|
349
|
-
default:
|
|
350
|
-
types: [{label:RED._(
|
|
351
|
-
typeField: $(
|
|
352
|
-
})
|
|
353
|
-
if(typeof node.filenameType
|
|
354
|
-
//existing node AND filenameType is not set - inplace (compatible) upgrade to new typedInput
|
|
355
|
-
if(node.filename
|
|
356
|
-
node.filename =
|
|
357
|
-
node.filenameType =
|
|
358
|
-
$(
|
|
359
|
-
$(
|
|
360
|
-
} else if(/^\${[^}]+}$/.test(node.filename)) { //was using an ${ENV_VAR}
|
|
361
|
-
node.filenameType =
|
|
362
|
-
node.filename = node.filename.replace(/\${([^}]+)}/g, function(match, name) {
|
|
363
|
-
return (name === undefined)?
|
|
364
|
-
})
|
|
365
|
-
$(
|
|
366
|
-
$(
|
|
367
|
-
} else { //was using a static filename - set typedInput type to str
|
|
368
|
-
node.filenameType =
|
|
369
|
-
$(
|
|
370
|
-
$(
|
|
351
|
+
oneditprepare: function () {
|
|
352
|
+
const node = this
|
|
353
|
+
const encSel = $('#node-input-encoding')
|
|
354
|
+
const label = node._('file.encoding.none')
|
|
355
|
+
$('<option/>', {
|
|
356
|
+
value: 'none',
|
|
357
|
+
label
|
|
358
|
+
}).text(label).appendTo(encSel)
|
|
359
|
+
$('#node-input-filename').typedInput({
|
|
360
|
+
default: 'str',
|
|
361
|
+
types: [{ label: RED._('node-red:file.label.path'), value: 'str', icon: '' }, 'msg', 'jsonata', 'env'],
|
|
362
|
+
typeField: $('#node-input-filenameType')
|
|
363
|
+
})
|
|
364
|
+
if (typeof node.filenameType === 'undefined') {
|
|
365
|
+
// existing node AND filenameType is not set - inplace (compatible) upgrade to new typedInput
|
|
366
|
+
if (node.filename === '') { // was using empty value to denote msg.filename - set typedInput to match
|
|
367
|
+
node.filename = 'filename'
|
|
368
|
+
node.filenameType = 'msg'
|
|
369
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
370
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
371
|
+
} else if (/^\${[^}]+}$/.test(node.filename)) { // was using an ${ENV_VAR}
|
|
372
|
+
node.filenameType = 'env'
|
|
373
|
+
node.filename = node.filename.replace(/\${([^}]+)}/g, function (match, name) {
|
|
374
|
+
return (name === undefined) ? '' : name
|
|
375
|
+
})
|
|
376
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
377
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
378
|
+
} else { // was using a static filename - set typedInput type to str
|
|
379
|
+
node.filenameType = 'str'
|
|
380
|
+
$('#node-input-filename').typedInput('type', node.filenameType)
|
|
381
|
+
$('#node-input-filename').typedInput('value', node.filename)
|
|
371
382
|
}
|
|
372
383
|
}
|
|
373
|
-
encodings.forEach(function(item) {
|
|
374
|
-
if(Array.isArray(item)) {
|
|
375
|
-
|
|
384
|
+
encodings.forEach(function (item) {
|
|
385
|
+
if (Array.isArray(item)) {
|
|
386
|
+
const group = $('<optgroup/>', {
|
|
376
387
|
label: node._(item[0])
|
|
377
|
-
}).appendTo(encSel)
|
|
378
|
-
for (
|
|
379
|
-
|
|
380
|
-
$(
|
|
388
|
+
}).appendTo(encSel)
|
|
389
|
+
for (let i = 1; i < item.length; i++) {
|
|
390
|
+
const enc = item[i]
|
|
391
|
+
$('<option/>', {
|
|
381
392
|
value: enc,
|
|
382
393
|
label: enc
|
|
383
|
-
}).text(enc).appendTo(group)
|
|
394
|
+
}).text(enc).appendTo(group)
|
|
384
395
|
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
$("<option/>", {
|
|
396
|
+
} else {
|
|
397
|
+
$('<option/>', {
|
|
388
398
|
value: item,
|
|
389
399
|
label: item
|
|
390
|
-
}).text(item).appendTo(encSel)
|
|
400
|
+
}).text(item).appendTo(encSel)
|
|
391
401
|
}
|
|
392
|
-
})
|
|
393
|
-
encSel.val(node.encoding)
|
|
394
|
-
$(
|
|
395
|
-
|
|
396
|
-
if ((format ===
|
|
397
|
-
$(
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
$("#encoding-spec").hide();
|
|
401
|
-
}
|
|
402
|
-
if ((format === "lines") || (format === "stream")) {
|
|
403
|
-
$("#file-allprops").show();
|
|
402
|
+
})
|
|
403
|
+
encSel.val(node.encoding)
|
|
404
|
+
$('#node-input-format').on('change', function () {
|
|
405
|
+
const format = $('#node-input-format').val()
|
|
406
|
+
if ((format === 'utf8') || (format === 'lines')) {
|
|
407
|
+
$('#encoding-spec').show()
|
|
408
|
+
} else {
|
|
409
|
+
$('#encoding-spec').hide()
|
|
404
410
|
}
|
|
405
|
-
|
|
406
|
-
$(
|
|
411
|
+
if ((format === 'lines') || (format === 'stream')) {
|
|
412
|
+
$('#file-allprops').show()
|
|
413
|
+
} else {
|
|
414
|
+
$('#file-allprops').hide()
|
|
407
415
|
}
|
|
408
|
-
})
|
|
416
|
+
})
|
|
409
417
|
}
|
|
410
|
-
})
|
|
411
|
-
})()
|
|
418
|
+
})
|
|
419
|
+
})()
|
|
412
420
|
</script>
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowfuse/nr-file-nodes",
|
|
3
|
-
"version": "0.0.9-
|
|
3
|
+
"version": "0.0.9-cabebf4-202601051152.0",
|
|
4
4
|
"description": "Node-RED file nodes packaged for FlowFuse",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run test:files && npm run test:memory",
|
|
8
8
|
"test:memory": "mocha 'test/memory_spec.js' --timeout 5000",
|
|
9
9
|
"test:files": "mocha 'test/file_spec.js' --timeout 5000",
|
|
10
|
-
"lint": "eslint -c .
|
|
11
|
-
"lint:fix": "eslint -c .
|
|
10
|
+
"lint": "eslint -c eslint.config.mjs",
|
|
11
|
+
"lint:fix": "eslint -c eslint.config.mjs --fix"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"FlowFuse",
|
|
@@ -40,13 +40,16 @@
|
|
|
40
40
|
"node": ">=16.x"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^9.39.2",
|
|
43
44
|
"@flowforge/file-server": "^0.0.5",
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"eslint-
|
|
46
|
-
"eslint-plugin-no-only-tests": "^3.
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"eslint-plugin-html": "^8.1.3",
|
|
47
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
47
48
|
"fs-extra": "^10.1.0",
|
|
49
|
+
"globals": "^16.5.0",
|
|
48
50
|
"mocha": "^10.1.0",
|
|
49
51
|
"mocha-cli": "^1.0.1",
|
|
52
|
+
"neostandard": "^0.12.2",
|
|
50
53
|
"node-red": "^4.1.0",
|
|
51
54
|
"node-red-node-test-helper": "^0.3.4",
|
|
52
55
|
"sinon": "^14.0.2"
|
package/vfs.js
CHANGED
|
@@ -29,7 +29,7 @@ module.exports = function (RED, _teamID, _projectID, _token) {
|
|
|
29
29
|
prefixUrl: `${fileStoreURL}/v1/files/${teamID}/${projectID}`,
|
|
30
30
|
headers: {
|
|
31
31
|
'user-agent': 'FlowForge Node-RED File Nodes for Storage Server',
|
|
32
|
-
authorization: 'Bearer ' + projectToken
|
|
32
|
+
'authorization': 'Bearer ' + projectToken
|
|
33
33
|
},
|
|
34
34
|
timeout: {
|
|
35
35
|
request: 3000
|
|
@@ -132,7 +132,7 @@ module.exports = function (RED, _teamID, _projectID, _token) {
|
|
|
132
132
|
const options = {
|
|
133
133
|
headers: {
|
|
134
134
|
'Content-Type': 'application/octet-stream',
|
|
135
|
-
FF_MODE: 'append'
|
|
135
|
+
'FF_MODE': 'append'
|
|
136
136
|
},
|
|
137
137
|
body: buffer
|
|
138
138
|
}
|