@digipair/skill-logger 0.113.1 → 0.114.1
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/README.md +7 -0
- package/{index.cjs.js → dist/index.cjs.js} +7 -16
- package/dist/index.esm.js +42750 -0
- package/{libs/skill-logger → dist}/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{libs/skill-logger → dist}/src/lib/skill-logger.d.ts +1 -0
- package/dist/src/lib/skill-logger.d.ts.map +1 -0
- package/package.json +26 -5
- package/index.d.ts +0 -1
- package/index.esm.js +0 -122
- /package/{index.cjs.d.ts → dist/index.d.ts} +0 -0
- /package/{schema.fr.json → dist/schema.fr.json} +0 -0
- /package/{schema.json → dist/schema.json} +0 -0
package/README.md
ADDED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var engine = require('@digipair/engine');
|
|
6
4
|
var fs = require('fs');
|
|
7
5
|
|
|
8
|
-
var _process_env_DIGIPAIR_LOGS_PATH;
|
|
9
6
|
let LoggerService = class LoggerService {
|
|
10
|
-
async initialize(path =
|
|
7
|
+
async initialize(path = process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs') {
|
|
11
8
|
// create logs directory if it doesn't exist
|
|
12
9
|
await fs.promises.mkdir(`${path}/factory`, {
|
|
13
10
|
recursive: true
|
|
@@ -22,8 +19,7 @@ let LoggerService = class LoggerService {
|
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
async addLog(context, type, message, data) {
|
|
25
|
-
|
|
26
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
22
|
+
const DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs';
|
|
27
23
|
const current = new Date();
|
|
28
24
|
const line = {
|
|
29
25
|
date: current.getTime(),
|
|
@@ -36,8 +32,7 @@ let LoggerService = class LoggerService {
|
|
|
36
32
|
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/factory/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
37
33
|
}
|
|
38
34
|
async addConsumption(context, service, model, promptTokens, completionTokens) {
|
|
39
|
-
|
|
40
|
-
const DIGIPAIR_LOGS_PATH = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
|
|
35
|
+
const DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs';
|
|
41
36
|
const current = new Date();
|
|
42
37
|
const line = {
|
|
43
38
|
date: current.getTime(),
|
|
@@ -51,8 +46,7 @@ let LoggerService = class LoggerService {
|
|
|
51
46
|
await fs.promises.appendFile(`${DIGIPAIR_LOGS_PATH}/consumption-daily/${current.toISOString().split('T')[0]}.jsonl`, '\n' + JSON.stringify(line), 'utf8');
|
|
52
47
|
}
|
|
53
48
|
async computeDailyConsumption(params, _pinsSettingsList, context) {
|
|
54
|
-
|
|
55
|
-
const { date, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
49
|
+
const { date, path = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs' } = params;
|
|
56
50
|
let result;
|
|
57
51
|
try {
|
|
58
52
|
const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
|
|
@@ -82,8 +76,7 @@ let LoggerService = class LoggerService {
|
|
|
82
76
|
await fs.promises.appendFile(`${path}/consumption-monthly/${date.substring(0, 7)}.jsonl`, '\n' + dayLines.map((line)=>JSON.stringify(line)).join('\n'), 'utf8');
|
|
83
77
|
}
|
|
84
78
|
async read(params, _pinsSettingsList, context) {
|
|
85
|
-
|
|
86
|
-
const { date, type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
79
|
+
const { date, type = 'factory', path = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs' } = params;
|
|
87
80
|
let result;
|
|
88
81
|
try {
|
|
89
82
|
const text = await fs.promises.readFile(`${path}/${type}/${date}.jsonl`, 'utf8');
|
|
@@ -95,14 +88,12 @@ let LoggerService = class LoggerService {
|
|
|
95
88
|
return result;
|
|
96
89
|
}
|
|
97
90
|
async list(params, _pinsSettingsList, context) {
|
|
98
|
-
|
|
99
|
-
const { type = 'factory', path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
91
|
+
const { type = 'factory', path = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs' } = params;
|
|
100
92
|
const files = (await fs.promises.readdir(`${path}/${type}`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
|
|
101
93
|
return files;
|
|
102
94
|
}
|
|
103
95
|
async cleaning(params, _pinsSettingsList, context) {
|
|
104
|
-
|
|
105
|
-
const { type = 'factory', to, path = (_ref = (_context_privates_DIGIPAIR_LOGS_PATH = context.privates.DIGIPAIR_LOGS_PATH) != null ? _context_privates_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
|
|
96
|
+
const { type = 'factory', to, path = context.privates.DIGIPAIR_LOGS_PATH ?? process.env['DIGIPAIR_LOGS_PATH'] ?? './factory/logs' } = params;
|
|
106
97
|
const files = await fs.promises.readdir(`${path}/${type}`);
|
|
107
98
|
for (const file of files){
|
|
108
99
|
const stats = await fs.promises.stat(`${path}/${type}/${file}`);
|