@quatrain/worker 1.2.1 → 1.2.3
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/FileSystem.js +5 -5
- package/dist/Worker.js +7 -7
- package/dist/Worker.test.js +2 -2
- package/package.json +4 -4
- package/src/FileSystem.ts +7 -7
- package/src/Helpers.ts +1 -1
- package/src/Worker.test.ts +1 -1
- package/src/Worker.ts +2 -2
package/dist/FileSystem.js
CHANGED
|
@@ -90,7 +90,7 @@ class FileSystem {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
static safeString(name) {
|
|
93
|
-
return name.
|
|
93
|
+
return name.replaceAll(/\s+/g, '_');
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Upload file to public URL and return meta data
|
|
@@ -174,13 +174,13 @@ class FileSystem {
|
|
|
174
174
|
}
|
|
175
175
|
// Worker.debug(`ffprobe getInfo: ${JSON.stringify(metadata)}`)
|
|
176
176
|
const { width, height, duration, bit_rate: bitrate, nb_frames: nbFramees, } = metadata.streams[0];
|
|
177
|
-
const nb_frames = parseFloat(nbFramees);
|
|
178
|
-
const framerate = nb_frames / parseFloat(duration);
|
|
177
|
+
const nb_frames = Number.parseFloat(nbFramees);
|
|
178
|
+
const framerate = nb_frames / Number.parseFloat(duration);
|
|
179
179
|
resolve({
|
|
180
180
|
width,
|
|
181
181
|
height,
|
|
182
|
-
framerate: parseInt(framerate.toFixed(0)),
|
|
183
|
-
duration: parseInt(duration),
|
|
182
|
+
framerate: Number.parseInt(framerate.toFixed(0)),
|
|
183
|
+
duration: Number.parseInt(duration),
|
|
184
184
|
bitrate,
|
|
185
185
|
});
|
|
186
186
|
}));
|
package/dist/Worker.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Worker = void 0;
|
|
7
7
|
const core_1 = require("@quatrain/core");
|
|
8
|
-
const
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
|
-
const
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
11
|
class Worker extends core_1.Core {
|
|
12
12
|
static endpoint = '';
|
|
13
13
|
static logger = this.addLogger('Worker');
|
|
@@ -24,7 +24,7 @@ class Worker extends core_1.Core {
|
|
|
24
24
|
Worker.info(`Executing command ${command} in ${cwd} with arguments:`);
|
|
25
25
|
args.forEach((arg) => console.log(`\t${arg}`));
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
27
|
-
const child = (0,
|
|
27
|
+
const child = (0, node_child_process_1.spawn)(command, args, { cwd, shell: false });
|
|
28
28
|
child.stdout.on('data', (data) => Worker.debug(data.toString()));
|
|
29
29
|
child.stderr.on('data', (data) => Worker.debug(data.toString()));
|
|
30
30
|
child.on('close', (code) => {
|
|
@@ -59,8 +59,8 @@ class Worker extends core_1.Core {
|
|
|
59
59
|
ts = ts === Date.now() ? Date.now() + 1 : Date.now();
|
|
60
60
|
const payload = {
|
|
61
61
|
event,
|
|
62
|
-
worker: `Container ${
|
|
63
|
-
os: `${
|
|
62
|
+
worker: `Container ${node_os_1.default.hostname}`,
|
|
63
|
+
os: `${node_os_1.default.type} ${node_os_1.default.release} (${node_os_1.default.platform} ${node_os_1.default.arch})`,
|
|
64
64
|
...data,
|
|
65
65
|
ts,
|
|
66
66
|
};
|
|
@@ -93,8 +93,8 @@ class Worker extends core_1.Core {
|
|
|
93
93
|
ts = ts === Date.now() ? Date.now() + 1 : Date.now();
|
|
94
94
|
const payload = {
|
|
95
95
|
event,
|
|
96
|
-
worker: `Container ${
|
|
97
|
-
os: `${
|
|
96
|
+
worker: `Container ${node_os_1.default.hostname}`,
|
|
97
|
+
os: `${node_os_1.default.type} ${node_os_1.default.release} (${node_os_1.default.platform} ${node_os_1.default.arch})`,
|
|
98
98
|
...data,
|
|
99
99
|
ts,
|
|
100
100
|
};
|
package/dist/Worker.test.js
CHANGED
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Worker_1 = require("./Worker");
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
9
|
// Mock dependencies
|
|
10
10
|
jest.mock('axios');
|
|
11
11
|
jest.mock('child_process');
|
|
12
12
|
const mockedAxios = axios_1.default;
|
|
13
|
-
const mockedSpawn =
|
|
13
|
+
const mockedSpawn = node_child_process_1.spawn;
|
|
14
14
|
describe('Worker', () => {
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
// Clear all mocks before each test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/worker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Container Worker helpers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"typescript": "^5.1.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@quatrain/core": "^1.2.
|
|
38
|
-
"@quatrain/queue": "^1.2.
|
|
39
|
-
"@quatrain/storage": "^1.2.
|
|
37
|
+
"@quatrain/core": "^1.2.5",
|
|
38
|
+
"@quatrain/queue": "^1.2.2",
|
|
39
|
+
"@quatrain/storage": "^1.2.3",
|
|
40
40
|
"axios": "^1.7.7",
|
|
41
41
|
"fluent-ffmpeg": "^2.1.2",
|
|
42
42
|
"fs-extra": "^11.2.0",
|
package/src/FileSystem.ts
CHANGED
|
@@ -59,7 +59,7 @@ export class FileSystem {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
static safeString(name: string) {
|
|
62
|
-
return name.
|
|
62
|
+
return name.replaceAll(/\s+/g, '_')
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -90,7 +90,7 @@ export class FileSystem {
|
|
|
90
90
|
'Content-Type': meta.contentType || mime,
|
|
91
91
|
'Content-length': String(size),
|
|
92
92
|
},
|
|
93
|
-
})
|
|
93
|
+
} as any)
|
|
94
94
|
.then(() => resolve({ ...meta, size, uploadUrl: undefined }))
|
|
95
95
|
.catch((err) => {
|
|
96
96
|
Worker.error(
|
|
@@ -134,7 +134,7 @@ export class FileSystem {
|
|
|
134
134
|
'Content-Type': meta.contentType || mime,
|
|
135
135
|
'Content-length': String(size),
|
|
136
136
|
},
|
|
137
|
-
})
|
|
137
|
+
} as any)
|
|
138
138
|
.then(() => resolve({ ...meta, size, uploadUrl: undefined }))
|
|
139
139
|
.catch((err) => {
|
|
140
140
|
Worker.error(
|
|
@@ -168,13 +168,13 @@ export class FileSystem {
|
|
|
168
168
|
bit_rate: bitrate,
|
|
169
169
|
nb_frames: nbFramees,
|
|
170
170
|
} = metadata.streams[0]
|
|
171
|
-
const nb_frames: number = parseFloat(nbFramees as string)
|
|
172
|
-
const framerate = nb_frames / parseFloat(duration as string)
|
|
171
|
+
const nb_frames: number = Number.parseFloat(nbFramees as string)
|
|
172
|
+
const framerate = nb_frames / Number.parseFloat(duration as string)
|
|
173
173
|
resolve({
|
|
174
174
|
width,
|
|
175
175
|
height,
|
|
176
|
-
framerate: parseInt(framerate.toFixed(0)),
|
|
177
|
-
duration: parseInt(duration as string),
|
|
176
|
+
framerate: Number.parseInt(framerate.toFixed(0)),
|
|
177
|
+
duration: Number.parseInt(duration as string),
|
|
178
178
|
bitrate,
|
|
179
179
|
})
|
|
180
180
|
})
|
package/src/Helpers.ts
CHANGED
package/src/Worker.test.ts
CHANGED
package/src/Worker.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Core } from '@quatrain/core'
|
|
2
|
-
import os from 'os'
|
|
2
|
+
import os from 'node:os'
|
|
3
3
|
import axios from 'axios'
|
|
4
|
-
import { spawn } from 'child_process'
|
|
4
|
+
import { spawn } from 'node:child_process'
|
|
5
5
|
import { HandlerParameters } from './types/HandlerParameters'
|
|
6
6
|
|
|
7
7
|
export class Worker extends Core {
|