@frogbotai/piece-file-helper 0.28.0 → 0.30.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/dist/actions.d.ts +1 -1
- package/dist/actions.js +172 -76
- package/dist/actions.js.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +42 -25
- package/dist/files.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/actions.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare const createFile: import("frogbot").PieceActionDefinition<z.ZodOb
|
|
|
27
27
|
export declare const readFile: import("frogbot").PieceActionDefinition<z.ZodObject<{
|
|
28
28
|
file: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
29
29
|
format: z.ZodEnum<{
|
|
30
|
-
base64: "base64";
|
|
31
30
|
text: "text";
|
|
31
|
+
base64: "base64";
|
|
32
32
|
}>;
|
|
33
33
|
}, z.core.$strip>, z.ZodUnion<readonly [z.ZodObject<{
|
|
34
34
|
text: z.ZodString;
|
package/dist/actions.js
CHANGED
|
@@ -4,43 +4,84 @@ import { z } from 'zod';
|
|
|
4
4
|
import { encoding } from './config.js';
|
|
5
5
|
import { defineAction } from './define.js';
|
|
6
6
|
import { fileId, loadFile, savedFile, saveFile } from './files.js';
|
|
7
|
-
const passwordOptions = z
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const passwordOptions = z.object({
|
|
8
|
+
password: z.string().min(1).meta({
|
|
9
|
+
label: 'Password'
|
|
10
|
+
}),
|
|
11
|
+
encryptionMethod: z.enum([
|
|
12
|
+
'zipcrypto',
|
|
13
|
+
'aes-256'
|
|
14
|
+
]).default('zipcrypto').optional()
|
|
15
|
+
}).optional();
|
|
13
16
|
const createFileInput = z.object({
|
|
14
|
-
content: z.string().meta({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
content: z.string().meta({
|
|
18
|
+
label: 'Content'
|
|
19
|
+
}),
|
|
20
|
+
fileName: z.string().min(1).meta({
|
|
21
|
+
label: 'File name'
|
|
22
|
+
}),
|
|
23
|
+
encoding: encoding.default('utf8').meta({
|
|
24
|
+
label: 'Encoding'
|
|
25
|
+
})
|
|
17
26
|
});
|
|
18
27
|
const readFileInput = z.object({
|
|
19
|
-
file: fileId.meta({
|
|
20
|
-
|
|
28
|
+
file: fileId.meta({
|
|
29
|
+
label: 'File'
|
|
30
|
+
}),
|
|
31
|
+
format: z.enum([
|
|
32
|
+
'text',
|
|
33
|
+
'base64'
|
|
34
|
+
]).meta({
|
|
35
|
+
label: 'Output format'
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
const getFileNameInput = z.object({
|
|
39
|
+
file: fileId.meta({
|
|
40
|
+
label: 'File'
|
|
41
|
+
})
|
|
21
42
|
});
|
|
22
|
-
const getFileNameInput = z.object({ file: fileId.meta({ label: 'File' }) });
|
|
23
43
|
const checkFileTypeInput = z.object({
|
|
24
|
-
file: fileId.meta({
|
|
25
|
-
|
|
44
|
+
file: fileId.meta({
|
|
45
|
+
label: 'File to check'
|
|
46
|
+
}),
|
|
47
|
+
mimeType: z.string().min(1).meta({
|
|
48
|
+
label: 'MIME type'
|
|
49
|
+
})
|
|
26
50
|
});
|
|
27
51
|
const changeFileEncodingInput = z.object({
|
|
28
|
-
inputFile: fileId.meta({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
inputFile: fileId.meta({
|
|
53
|
+
label: 'Source file'
|
|
54
|
+
}),
|
|
55
|
+
inputEncoding: encoding.meta({
|
|
56
|
+
label: 'Source encoding'
|
|
57
|
+
}),
|
|
58
|
+
outputFileName: z.string().min(1).meta({
|
|
59
|
+
label: 'Output file name'
|
|
60
|
+
}),
|
|
61
|
+
outputEncoding: encoding.meta({
|
|
62
|
+
label: 'Output encoding'
|
|
63
|
+
})
|
|
32
64
|
});
|
|
33
65
|
const zipFilesInput = z.object({
|
|
34
|
-
files: z.array(z.object({
|
|
35
|
-
|
|
66
|
+
files: z.array(z.object({
|
|
67
|
+
file: fileId,
|
|
68
|
+
filePath: z.string().min(1).optional()
|
|
69
|
+
})).min(1),
|
|
70
|
+
outputFileName: z.string().min(1).meta({
|
|
71
|
+
label: 'Name of zipped file'
|
|
72
|
+
}),
|
|
36
73
|
usePassword: z.boolean().default(false).optional(),
|
|
37
|
-
passwordOptions
|
|
74
|
+
passwordOptions
|
|
38
75
|
});
|
|
39
76
|
const unzipFileInput = z.object({
|
|
40
|
-
file: fileId.meta({
|
|
77
|
+
file: fileId.meta({
|
|
78
|
+
label: 'ZIP file'
|
|
79
|
+
}),
|
|
41
80
|
maxResults: z.number().int().nonnegative().default(0).optional(),
|
|
42
81
|
usePassword: z.boolean().default(false).optional(),
|
|
43
|
-
passwordOptions: passwordOptions.transform((value)
|
|
82
|
+
passwordOptions: passwordOptions.transform((value)=>value ? {
|
|
83
|
+
password: value.password
|
|
84
|
+
} : undefined)
|
|
44
85
|
});
|
|
45
86
|
export const createFile = defineAction({
|
|
46
87
|
slug: 'createFile',
|
|
@@ -48,10 +89,14 @@ export const createFile = defineAction({
|
|
|
48
89
|
description: 'Create a file from content',
|
|
49
90
|
input: createFileInput,
|
|
50
91
|
output: savedFile,
|
|
51
|
-
async run({ input, req }) {
|
|
92
|
+
async run ({ input, req }) {
|
|
52
93
|
const data = Buffer.from(input.content, input.encoding);
|
|
53
|
-
return saveFile({
|
|
54
|
-
|
|
94
|
+
return saveFile({
|
|
95
|
+
req,
|
|
96
|
+
data,
|
|
97
|
+
filename: input.fileName
|
|
98
|
+
});
|
|
99
|
+
}
|
|
55
100
|
});
|
|
56
101
|
export const readFile = defineAction({
|
|
57
102
|
slug: 'readFile',
|
|
@@ -59,39 +104,67 @@ export const readFile = defineAction({
|
|
|
59
104
|
description: 'Read a file as text or Base64',
|
|
60
105
|
input: readFileInput,
|
|
61
106
|
output: z.union([
|
|
62
|
-
z.object({
|
|
63
|
-
|
|
107
|
+
z.object({
|
|
108
|
+
text: z.string()
|
|
109
|
+
}),
|
|
110
|
+
z.object({
|
|
111
|
+
base64: z.string(),
|
|
112
|
+
base64WithMimeType: z.string()
|
|
113
|
+
})
|
|
64
114
|
]),
|
|
65
|
-
async run({ input, req }) {
|
|
66
|
-
const file = await loadFile({
|
|
67
|
-
|
|
68
|
-
|
|
115
|
+
async run ({ input, req }) {
|
|
116
|
+
const file = await loadFile({
|
|
117
|
+
req,
|
|
118
|
+
id: input.file
|
|
119
|
+
});
|
|
120
|
+
if (input.format === 'text') return {
|
|
121
|
+
text: file.data.toString('utf8')
|
|
122
|
+
};
|
|
69
123
|
const base64 = file.data.toString('base64');
|
|
70
|
-
return {
|
|
71
|
-
|
|
124
|
+
return {
|
|
125
|
+
base64,
|
|
126
|
+
base64WithMimeType: `data:${file.mimeType};base64,${base64}`
|
|
127
|
+
};
|
|
128
|
+
}
|
|
72
129
|
});
|
|
73
130
|
export const getFileName = defineAction({
|
|
74
131
|
slug: 'getFileName',
|
|
75
132
|
label: 'Get file name',
|
|
76
133
|
description: 'Get the name of a file',
|
|
77
134
|
input: getFileNameInput,
|
|
78
|
-
output: z.object({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
135
|
+
output: z.object({
|
|
136
|
+
fileName: z.string()
|
|
137
|
+
}),
|
|
138
|
+
async run ({ input, req }) {
|
|
139
|
+
const file = await loadFile({
|
|
140
|
+
req,
|
|
141
|
+
id: input.file
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
fileName: file.filename
|
|
145
|
+
};
|
|
146
|
+
}
|
|
83
147
|
});
|
|
84
148
|
export const checkFileType = defineAction({
|
|
85
149
|
slug: 'checkFileType',
|
|
86
150
|
label: 'Check file type',
|
|
87
151
|
description: 'Check whether a file matches a MIME type',
|
|
88
152
|
input: checkFileTypeInput,
|
|
89
|
-
output: z.object({
|
|
90
|
-
|
|
91
|
-
|
|
153
|
+
output: z.object({
|
|
154
|
+
mimeType: z.string(),
|
|
155
|
+
isMatch: z.boolean()
|
|
156
|
+
}),
|
|
157
|
+
async run ({ input, req }) {
|
|
158
|
+
const file = await loadFile({
|
|
159
|
+
req,
|
|
160
|
+
id: input.file
|
|
161
|
+
});
|
|
92
162
|
const mimeType = lookup(file.filename) || 'application/octet-stream';
|
|
93
|
-
return {
|
|
94
|
-
|
|
163
|
+
return {
|
|
164
|
+
mimeType,
|
|
165
|
+
isMatch: mimeType === input.mimeType
|
|
166
|
+
};
|
|
167
|
+
}
|
|
95
168
|
});
|
|
96
169
|
export const changeFileEncoding = defineAction({
|
|
97
170
|
slug: 'changeFileEncoding',
|
|
@@ -99,12 +172,19 @@ export const changeFileEncoding = defineAction({
|
|
|
99
172
|
description: 'Change the encoding of a file',
|
|
100
173
|
input: changeFileEncodingInput,
|
|
101
174
|
output: savedFile,
|
|
102
|
-
async run({ input, req }) {
|
|
103
|
-
const file = await loadFile({
|
|
175
|
+
async run ({ input, req }) {
|
|
176
|
+
const file = await loadFile({
|
|
177
|
+
req,
|
|
178
|
+
id: input.inputFile
|
|
179
|
+
});
|
|
104
180
|
const decoded = file.data.toString(input.inputEncoding);
|
|
105
181
|
const data = Buffer.from(decoded, input.outputEncoding);
|
|
106
|
-
return saveFile({
|
|
107
|
-
|
|
182
|
+
return saveFile({
|
|
183
|
+
req,
|
|
184
|
+
data,
|
|
185
|
+
filename: input.outputFileName
|
|
186
|
+
});
|
|
187
|
+
}
|
|
108
188
|
});
|
|
109
189
|
export const zipFiles = defineAction({
|
|
110
190
|
slug: 'zipFiles',
|
|
@@ -112,44 +192,58 @@ export const zipFiles = defineAction({
|
|
|
112
192
|
description: 'Create a compressed ZIP file from one or more files',
|
|
113
193
|
input: zipFilesInput,
|
|
114
194
|
output: savedFile,
|
|
115
|
-
async run({ input, req }) {
|
|
195
|
+
async run ({ input, req }) {
|
|
116
196
|
const writer = new BlobWriter('application/zip');
|
|
117
197
|
const zip = new ZipWriter(writer);
|
|
118
198
|
const options = {};
|
|
119
199
|
if (input.usePassword) {
|
|
120
|
-
if (!input.passwordOptions?.password)
|
|
121
|
-
throw new Error('A password is required.');
|
|
200
|
+
if (!input.passwordOptions?.password) throw new Error('A password is required.');
|
|
122
201
|
options.password = input.passwordOptions.password;
|
|
123
|
-
if (input.passwordOptions.encryptionMethod === 'aes-256')
|
|
124
|
-
|
|
125
|
-
else
|
|
126
|
-
options.zipCrypto = true;
|
|
202
|
+
if (input.passwordOptions.encryptionMethod === 'aes-256') options.encryptionStrength = 3;
|
|
203
|
+
else options.zipCrypto = true;
|
|
127
204
|
}
|
|
128
205
|
try {
|
|
129
|
-
for (const item of input.files)
|
|
130
|
-
const file = await loadFile({
|
|
206
|
+
for (const item of input.files){
|
|
207
|
+
const file = await loadFile({
|
|
208
|
+
req,
|
|
209
|
+
id: item.file
|
|
210
|
+
});
|
|
131
211
|
const path = item.filePath ?? file.filename;
|
|
132
|
-
await zip.add(path, new BlobReader(new Blob([
|
|
212
|
+
await zip.add(path, new BlobReader(new Blob([
|
|
213
|
+
file.data
|
|
214
|
+
])), options);
|
|
133
215
|
}
|
|
134
216
|
await zip.close();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
await zip.close().catch(() => undefined);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
await zip.close().catch(()=>undefined);
|
|
138
219
|
throw error;
|
|
139
220
|
}
|
|
140
221
|
const data = Buffer.from(await (await writer.getData()).arrayBuffer());
|
|
141
|
-
return saveFile({
|
|
142
|
-
|
|
222
|
+
return saveFile({
|
|
223
|
+
req,
|
|
224
|
+
data,
|
|
225
|
+
filename: input.outputFileName,
|
|
226
|
+
mimeType: 'application/zip'
|
|
227
|
+
});
|
|
228
|
+
}
|
|
143
229
|
});
|
|
144
230
|
export const unzipFile = defineAction({
|
|
145
231
|
slug: 'unzipFile',
|
|
146
232
|
label: 'Unzip file',
|
|
147
233
|
description: 'Extract files from a compressed ZIP file',
|
|
148
234
|
input: unzipFileInput,
|
|
149
|
-
output: z.array(z.object({
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
235
|
+
output: z.array(z.object({
|
|
236
|
+
file: savedFile,
|
|
237
|
+
filePath: z.string()
|
|
238
|
+
})),
|
|
239
|
+
async run ({ input, req }) {
|
|
240
|
+
const file = await loadFile({
|
|
241
|
+
req,
|
|
242
|
+
id: input.file
|
|
243
|
+
});
|
|
244
|
+
const reader = new ZipReader(new BlobReader(new Blob([
|
|
245
|
+
file.data
|
|
246
|
+
])));
|
|
153
247
|
try {
|
|
154
248
|
const entries = await reader.getEntries();
|
|
155
249
|
const maxResults = input.maxResults ?? 0;
|
|
@@ -160,11 +254,10 @@ export const unzipFile = defineAction({
|
|
|
160
254
|
throw new Error('A password is required.');
|
|
161
255
|
}
|
|
162
256
|
const results = [];
|
|
163
|
-
for (const entry of entries)
|
|
164
|
-
if (entry.directory)
|
|
165
|
-
continue;
|
|
257
|
+
for (const entry of entries){
|
|
258
|
+
if (entry.directory) continue;
|
|
166
259
|
const blob = await entry.getData(new BlobWriter(getMimeType(entry.filename)), {
|
|
167
|
-
password: input.usePassword ? input.passwordOptions?.password : undefined
|
|
260
|
+
password: input.usePassword ? input.passwordOptions?.password : undefined
|
|
168
261
|
});
|
|
169
262
|
const data = Buffer.from(await blob.arrayBuffer());
|
|
170
263
|
const filename = entry.filename.split('/').pop() || entry.filename;
|
|
@@ -172,15 +265,18 @@ export const unzipFile = defineAction({
|
|
|
172
265
|
req,
|
|
173
266
|
data,
|
|
174
267
|
filename,
|
|
175
|
-
mimeType: getMimeType(entry.filename)
|
|
268
|
+
mimeType: getMimeType(entry.filename)
|
|
269
|
+
});
|
|
270
|
+
results.push({
|
|
271
|
+
file: saved,
|
|
272
|
+
filePath: entry.filename
|
|
176
273
|
});
|
|
177
|
-
results.push({ file: saved, filePath: entry.filename });
|
|
178
274
|
}
|
|
179
275
|
return results;
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
276
|
+
} finally{
|
|
182
277
|
await reader.close();
|
|
183
278
|
}
|
|
184
|
-
}
|
|
279
|
+
}
|
|
185
280
|
});
|
|
281
|
+
|
|
186
282
|
//# sourceMappingURL=actions.js.map
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/actions.ts"],"names":["BlobReader","BlobWriter","getMimeType","ZipReader","ZipWriter","lookup","z","encoding","defineAction","fileId","loadFile","savedFile","saveFile","passwordOptions","object","password","string","min","meta","label","encryptionMethod","enum","default","optional","createFileInput","content","fileName","readFileInput","file","format","getFileNameInput","checkFileTypeInput","mimeType","changeFileEncodingInput","inputFile","inputEncoding","outputFileName","outputEncoding","zipFilesInput","files","array","filePath","usePassword","boolean","unzipFileInput","maxResults","number","int","nonnegative","transform","value","undefined","createFile","slug","description","input","output","run","req","data","Buffer","from","filename","readFile","union","text","base64","base64WithMimeType","id","toString","getFileName","checkFileType","isMatch","changeFileEncoding","decoded","zipFiles","writer","zip","options","Error","encryptionStrength","zipCrypto","item","path","add","Blob","close","error","catch","getData","arrayBuffer","unzipFile","reader","entries","getEntries","length","results","entry","directory","blob","split","pop","saved","push"],"mappings":"AAAA,SAASA,UAAU,EAAEC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,SAAS,QAAQ,iBAAiB;AAC3F,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,aAAa;AAEnE,MAAMC,kBAAkBP,EACrBQ,MAAM,CAAC;IACNC,UAAUT,EAAEU,MAAM,GAAGC,GAAG,CAAC,GAAGC,IAAI,CAAC;QA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1C,eAAe,EAAEE,UAAU;gBACzD,MAAM,IAAIgE,MAAM;YAClB;YAEA,MAAMiB,UAAoE,EAAE;YAE5E,KAAK,MAAMC,SAASJ,QAAS;gBAC3B,IAAII,MAAMC,SAAS,EAAE;gBAErB,MAAMC,OAAO,MAAMF,MAAMR,OAAO,CAAC,IAAIxF,WAAWC,YAAY+F,MAAMnC,QAAQ,IAAI;oBAC5E/C,UAAUwC,MAAMb,WAAW,GAAGa,MAAM1C,eAAe,EAAEE,WAAWoC;gBAClE;gBACA,MAAMQ,OAAOC,OAAOC,IAAI,CAAC,MAAMsC,KAAKT,WAAW;gBAC/C,MAAM5B,WAAWmC,MAAMnC,QAAQ,CAACsC,KAAK,CAAC,KAAKC,GAAG,MAAMJ,MAAMnC,QAAQ;gBAClE,MAAMwC,QAAQ,MAAM1F,SAAS;oBAC3B8C;oBACAC;oBACAG;oBACA9B,UAAU9B,YAAY+F,MAAMnC,QAAQ;gBACtC;gBAEAkC,QAAQO,IAAI,CAAC;oBAAE3E,MAAM0E;oBAAO7D,UAAUwD,MAAMnC,QAAQ;gBAAC;YACvD;YAEA,OAAOkC;QACT,SAAU;YACR,MAAMJ,OAAON,KAAK;QACpB;IACF;AACF,GAAG","file":"actions.js"}
|
package/dist/config.js
CHANGED
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"names":["z","encodings","encoding","enum"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,YAAY;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AAEX,OAAO,MAAMC,WAAWF,EAAEG,IAAI,CAACF,WAAW","file":"config.js"}
|
package/dist/define.js
CHANGED
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/define.ts"],"names":["createPieceHelpers","defineAction"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,iBAAiB;AAEpD,OAAO,MAAM,EAAEC,YAAY,EAAE,GAAGD,qBAAqB","file":"define.js"}
|
package/dist/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,MAAM,iDAAoC,CAAC;AAExD,eAAO,MAAM,SAAS;;;;iBAIpB,CAAC;AAUH,wBAAsB,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;IAAE,GAAG,EAAE,cAAc,CAAC;IAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE;;;;GA2CvF;AAED,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,GAAG,EAAE,cAAc,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;;;;GAoBA"}
|
package/dist/files.js
CHANGED
|
@@ -1,59 +1,68 @@
|
|
|
1
|
+
import { filesCollectionSlug } from 'frogbot/pieces';
|
|
1
2
|
import { lookup } from 'mime-types';
|
|
2
3
|
import { z } from 'zod';
|
|
3
|
-
export const fileId = z.union([
|
|
4
|
+
export const fileId = z.union([
|
|
5
|
+
z.string(),
|
|
6
|
+
z.number()
|
|
7
|
+
]);
|
|
4
8
|
export const savedFile = z.object({
|
|
5
|
-
id: z.union([
|
|
9
|
+
id: z.union([
|
|
10
|
+
z.string(),
|
|
11
|
+
z.number()
|
|
12
|
+
]),
|
|
6
13
|
filename: z.string(),
|
|
7
|
-
url: z.string().optional()
|
|
14
|
+
url: z.string().optional()
|
|
8
15
|
});
|
|
9
16
|
function resolveMimeType(value, filename) {
|
|
10
|
-
if (typeof value === 'string' && value)
|
|
11
|
-
return value;
|
|
17
|
+
if (typeof value === 'string' && value) return value;
|
|
12
18
|
const detected = lookup(filename);
|
|
13
19
|
return typeof detected === 'string' ? detected : 'application/octet-stream';
|
|
14
20
|
}
|
|
15
21
|
export async function loadFile({ req, id }) {
|
|
16
|
-
const collection = req
|
|
17
|
-
if (!collection)
|
|
18
|
-
throw new Error('File Helper requires a configured files collection.');
|
|
22
|
+
const collection = filesCollectionSlug(req, 'Files Helper');
|
|
19
23
|
const doc = await req.frogbot.findByID({
|
|
20
24
|
collection,
|
|
21
25
|
id,
|
|
22
26
|
depth: 0,
|
|
23
27
|
req,
|
|
24
|
-
overrideAccess: false
|
|
28
|
+
overrideAccess: false
|
|
25
29
|
});
|
|
26
|
-
if (typeof doc.url !== 'string')
|
|
27
|
-
throw new Error(`File '${id}' is unavailable.`);
|
|
30
|
+
if (typeof doc.url !== 'string') throw new Error(`File '${id}' is unavailable.`);
|
|
28
31
|
const config = await req.frogbot.config._internal.payloadConfig;
|
|
29
32
|
const base = new URL(config.serverURL || req.url);
|
|
30
33
|
const url = new URL(doc.url, base);
|
|
31
|
-
if (![
|
|
34
|
+
if (![
|
|
35
|
+
'http:',
|
|
36
|
+
'https:'
|
|
37
|
+
].includes(url.protocol) || url.username || url.password) {
|
|
32
38
|
throw new Error('Invalid file URL.');
|
|
33
39
|
}
|
|
34
40
|
const headers = new Headers();
|
|
35
41
|
if (url.origin === base.origin) {
|
|
36
|
-
for (const name of [
|
|
42
|
+
for (const name of [
|
|
43
|
+
'authorization',
|
|
44
|
+
'cookie'
|
|
45
|
+
]){
|
|
37
46
|
const value = req.headers.get(name);
|
|
38
|
-
if (value)
|
|
39
|
-
headers.set(name, value);
|
|
47
|
+
if (value) headers.set(name, value);
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
const response = await fetch(url, {
|
|
43
51
|
headers,
|
|
44
52
|
signal: req.signal ?? undefined,
|
|
45
|
-
redirect: 'error'
|
|
53
|
+
redirect: 'error'
|
|
46
54
|
});
|
|
47
|
-
if (!response.ok)
|
|
48
|
-
throw new Error(`File '${id}' is unavailable (${response.status}).`);
|
|
55
|
+
if (!response.ok) throw new Error(`File '${id}' is unavailable (${response.status}).`);
|
|
49
56
|
const filename = String(doc.filename ?? 'file');
|
|
50
57
|
const mimeType = resolveMimeType(doc.mimeType, filename);
|
|
51
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
data: Buffer.from(await response.arrayBuffer()),
|
|
60
|
+
filename,
|
|
61
|
+
mimeType
|
|
62
|
+
};
|
|
52
63
|
}
|
|
53
|
-
export async function saveFile({ req, data, filename, mimeType
|
|
54
|
-
const collection = req
|
|
55
|
-
if (!collection)
|
|
56
|
-
throw new Error('File Helper requires a configured files collection.');
|
|
64
|
+
export async function saveFile({ req, data, filename, mimeType }) {
|
|
65
|
+
const collection = filesCollectionSlug(req, 'Files Helper');
|
|
57
66
|
req.signal?.throwIfAborted();
|
|
58
67
|
const resolvedMimeType = resolveMimeType(mimeType, filename);
|
|
59
68
|
const doc = await req.frogbot.create({
|
|
@@ -61,12 +70,20 @@ export async function saveFile({ req, data, filename, mimeType, }) {
|
|
|
61
70
|
data: {},
|
|
62
71
|
req,
|
|
63
72
|
overrideAccess: false,
|
|
64
|
-
file: {
|
|
73
|
+
file: {
|
|
74
|
+
data,
|
|
75
|
+
name: filename,
|
|
76
|
+
mimetype: resolvedMimeType,
|
|
77
|
+
size: data.length
|
|
78
|
+
}
|
|
65
79
|
});
|
|
66
80
|
return {
|
|
67
81
|
id: doc.id,
|
|
68
82
|
filename,
|
|
69
|
-
...
|
|
83
|
+
...typeof doc.url === 'string' ? {
|
|
84
|
+
url: doc.url
|
|
85
|
+
} : {}
|
|
70
86
|
};
|
|
71
87
|
}
|
|
88
|
+
|
|
72
89
|
//# sourceMappingURL=files.js.map
|
package/dist/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/files.ts"],"names":["filesCollectionSlug","lookup","z","fileId","union","string","number","savedFile","object","id","filename","url","optional","resolveMimeType","value","detected","loadFile","req","collection","doc","frogbot","findByID","depth","overrideAccess","Error","config","_internal","payloadConfig","base","URL","serverURL","includes","protocol","username","password","headers","Headers","origin","name","get","set","response","fetch","signal","undefined","redirect","ok","status","String","mimeType","data","Buffer","from","arrayBuffer","saveFile","throwIfAborted","resolvedMimeType","create","file","mimetype","size","length"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,SAASD,EAAEE,KAAK,CAAC;IAACF,EAAEG,MAAM;IAAIH,EAAEI,MAAM;CAAG,EAAE;AAExD,OAAO,MAAMC,YAAYL,EAAEM,MAAM,CAAC;IAChCC,IAAIP,EAAEE,KAAK,CAAC;QAACF,EAAEG,MAAM;QAAIH,EAAEI,MAAM;KAAG;IACpCI,UAAUR,EAAEG,MAAM;IAClBM,KAAKT,EAAEG,MAAM,GAAGO,QAAQ;AAC1B,GAAG;AAEH,SAASC,gBAAgBC,KAAc,EAAEJ,QAAgB;IACvD,IAAI,OAAOI,UAAU,YAAYA,OAAO,OAAOA;IAE/C,MAAMC,WAAWd,OAAOS;IAExB,OAAO,OAAOK,aAAa,WAAWA,WAAW;AACnD;AAEA,OAAO,eAAeC,SAAS,EAAEC,GAAG,EAAER,EAAE,EAAgD;IACtF,MAAMS,aAAalB,oBAAoBiB,KAAK;IAE5C,MAAME,MAAM,MAAMF,IAAIG,OAAO,CAACC,QAAQ,CAAC;QACrCH;QACAT;QACAa,OAAO;QACPL;QACAM,gB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EACJxC,QAAQ,EACRuC,QAAQ,EAMT;IACC,MAAM/B,aAAalB,oBAAoBiB,KAAK;IAE5CA,IAAI0B,MAAM,EAAEY;IAEZ,MAAMC,mBAAmB3C,gBAAgBoC,UAAUvC;IAEnD,MAAMS,MAAM,MAAMF,IAAIG,OAAO,CAACqC,MAAM,CAAC;QACnCvC;QACAgC,MAAM,CAAC;QACPjC;QACAM,gBAAgB;QAChBmC,MAAM;YAAER;YAAMZ,MAAM5B;YAAUiD,UAAUH;YAAkBI,MAAMV,KAAKW,MAAM;QAAC;IAC9E;IAEA,OAAO;QACLpD,IAAIU,IAAIV,EAAE;QACVC;QACA,GAAI,OAAOS,IAAIR,GAAG,KAAK,WAAW;YAAEA,KAAKQ,IAAIR,GAAG;QAAC,IAAI,CAAC,CAAC;IACzD;AACF","file":"files.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare const createFileHelper: import("frogbot").PieceFactory<{
|
|
|
8
8
|
readonly actions: readonly [import("frogbot").PieceActionDefinition<import("zod").ZodObject<{
|
|
9
9
|
file: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>;
|
|
10
10
|
format: import("zod").ZodEnum<{
|
|
11
|
-
base64: "base64";
|
|
12
11
|
text: "text";
|
|
12
|
+
base64: "base64";
|
|
13
13
|
}>;
|
|
14
14
|
}, import("zod/v4/core").$strip>, import("zod").ZodUnion<readonly [import("zod").ZodObject<{
|
|
15
15
|
text: import("zod").ZodString;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { definePiece } from 'frogbot/pieces';
|
|
2
|
-
import { changeFileEncoding, checkFileType, createFile, getFileName, readFile, unzipFile, zipFiles
|
|
2
|
+
import { changeFileEncoding, checkFileType, createFile, getFileName, readFile, unzipFile, zipFiles } from './actions.js';
|
|
3
3
|
export const createFileHelper = definePiece({
|
|
4
4
|
slug: 'file-helper',
|
|
5
5
|
label: 'Files Helper',
|
|
6
6
|
admin: {
|
|
7
7
|
description: 'Create, inspect, convert, compress, and extract files',
|
|
8
|
-
group: 'Core'
|
|
8
|
+
group: 'Core'
|
|
9
9
|
},
|
|
10
10
|
actions: [
|
|
11
11
|
readFile,
|
|
@@ -14,7 +14,8 @@ export const createFileHelper = definePiece({
|
|
|
14
14
|
checkFileType,
|
|
15
15
|
zipFiles,
|
|
16
16
|
unzipFile,
|
|
17
|
-
getFileName
|
|
18
|
-
]
|
|
17
|
+
getFileName
|
|
18
|
+
]
|
|
19
19
|
});
|
|
20
|
+
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["definePiece","changeFileEncoding","checkFileType","createFile","getFileName","readFile","unzipFile","zipFiles","createFileHelper","slug","label","admin","description","group","actions"],"mappings":"AAAA,SAASA,WAAW,QAAQ,iBAAiB;AAE7C,SACEC,kBAAkB,EAClBC,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,QAAQ,EACRC,SAAS,EACTC,QAAQ,QACH,eAAe;AAEtB,OAAO,MAAMC,mBAAmBR,YAAY;IAC1CS,MAAM;IACNC,OAAO;IACPC,OAAO;QACLC,aAAa;QACbC,OAAO;IACT;IACAC,SAAS;QACPT;QACAF;QACAF;QACAC;QACAK;QACAD;QACAF;KACD;AACH,GAAG","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frogbotai/piece-file-helper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "file-helper tools for FrogBot.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Colby Gilbert",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"frogbot": "0.
|
|
22
|
+
"frogbot": "0.30.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@zip.js/zip.js": "2.8.15",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/mime-types": "2.1.1",
|
|
31
31
|
"typescript": "5.6.2",
|
|
32
|
-
"frogbot": "0.
|
|
32
|
+
"frogbot": "0.30.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
38
|
+
"build": "node ../../../scripts/build-package.mjs",
|
|
39
39
|
"clean": "rm -rf dist",
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
}
|