@live-change/image-service 0.9.126 → 0.9.127
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/image.js +71 -0
- package/package.json +4 -4
package/image.js
CHANGED
|
@@ -281,6 +281,77 @@ definition.trigger({
|
|
|
281
281
|
}
|
|
282
282
|
})
|
|
283
283
|
|
|
284
|
+
|
|
285
|
+
definition.trigger({
|
|
286
|
+
name: "createImageFromDownloadedFile",
|
|
287
|
+
properties: {
|
|
288
|
+
name: {
|
|
289
|
+
type: String,
|
|
290
|
+
validation: ['nonEmpty']
|
|
291
|
+
},
|
|
292
|
+
purpose: {
|
|
293
|
+
type: String,
|
|
294
|
+
validation: ['nonEmpty']
|
|
295
|
+
},
|
|
296
|
+
downloadPath: {
|
|
297
|
+
type: String,
|
|
298
|
+
validation: ['nonEmpty']
|
|
299
|
+
},
|
|
300
|
+
cropped: {
|
|
301
|
+
type: Boolean,
|
|
302
|
+
defaultValue: true
|
|
303
|
+
},
|
|
304
|
+
ownerType: {
|
|
305
|
+
type: String,
|
|
306
|
+
validation: ['nonEmpty']
|
|
307
|
+
},
|
|
308
|
+
owner: {
|
|
309
|
+
type: String,
|
|
310
|
+
validation: ['nonEmpty']
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
waitForEvents: true,
|
|
314
|
+
async execute({ name, purpose, downloadPath, owner, ownerType }, { service, client }, emit) {
|
|
315
|
+
const image = app.generateUid()
|
|
316
|
+
|
|
317
|
+
/*
|
|
318
|
+
console.log("DOWNLOADED", url, uploadsPath, '=>', downloadPath)
|
|
319
|
+
const downloadExists = await fs.promises.access(downloadPath, fs.constants.F_OK)
|
|
320
|
+
.then(() => true)
|
|
321
|
+
.catch(() => false)
|
|
322
|
+
console.log("DOWNLOAD EXISTS", downloadExists)//*/
|
|
323
|
+
|
|
324
|
+
const data = await fs.promises.readFile(downloadPath)
|
|
325
|
+
const metadata = await sharp(data).metadata()
|
|
326
|
+
//const metadata = await sharp(downloadPath).metadata()
|
|
327
|
+
|
|
328
|
+
//console.log("IMAGE METADATA", metadata)
|
|
329
|
+
|
|
330
|
+
emit({
|
|
331
|
+
type: "ImageCreated",
|
|
332
|
+
image,
|
|
333
|
+
identifiers: {
|
|
334
|
+
owner, ownerType
|
|
335
|
+
},
|
|
336
|
+
data: {
|
|
337
|
+
name, purpose,
|
|
338
|
+
fileName: downloadPath.split('/').pop(),
|
|
339
|
+
width: metadata.width,
|
|
340
|
+
height: metadata.height,
|
|
341
|
+
extension: metadata.format,
|
|
342
|
+
crop: null
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
const dir = `${imagesPath}/${image}`
|
|
347
|
+
|
|
348
|
+
await mkdir(dir)
|
|
349
|
+
await move(downloadPath, `${dir}/original.${metadata.format}`)
|
|
350
|
+
|
|
351
|
+
return image
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
|
|
284
355
|
definition.trigger({
|
|
285
356
|
name: 'deleteImage_Image',
|
|
286
357
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/image-service",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.127",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.9.
|
|
25
|
-
"@live-change/relations-plugin": "^0.9.
|
|
24
|
+
"@live-change/framework": "^0.9.127",
|
|
25
|
+
"@live-change/relations-plugin": "^0.9.127",
|
|
26
26
|
"download": "^8.0.0",
|
|
27
27
|
"pluralize": "^8.0.0",
|
|
28
28
|
"sharp": "^0.32.5"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "acd85c886f4086b2d559eb40b5343f05d64ff294",
|
|
31
31
|
"type": "module"
|
|
32
32
|
}
|