@digipair/skill-logger 0.28.4 → 0.28.5

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.
Files changed (3) hide show
  1. package/index.cjs.js +10 -10
  2. package/index.esm.js +10 -10
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -6,7 +6,7 @@ var fs = require('fs');
6
6
 
7
7
  var _process_env_DIGIPAIR_LOGS_PATH;
8
8
  let LoggerService = class LoggerService {
9
- async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/digipairs/logs') {
9
+ async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
10
10
  // create logs directory if it doesn't exist
11
11
  await fs.promises.mkdir(`${path}/factory`, {
12
12
  recursive: true
@@ -22,7 +22,7 @@ let LoggerService = class LoggerService {
22
22
  }
23
23
  async addConsumption(context, service, model, promptTokens, completionTokens) {
24
24
  var _context_DIGIPAIR_LOGS_PATH, _ref;
25
- const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs';
25
+ const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
26
26
  const current = new Date();
27
27
  const line = {
28
28
  date: current.getTime(),
@@ -37,7 +37,7 @@ let LoggerService = class LoggerService {
37
37
  }
38
38
  async computeDailyConsumption(params, _pinsSettingsList, context) {
39
39
  var _context_DIGIPAIR_LOGS_PATH, _ref;
40
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
40
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
41
41
  const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
42
42
  const lines = text.split('\n').filter((line)=>line !== '');
43
43
  const result = lines.map((line)=>JSON.parse(line));
@@ -61,7 +61,7 @@ let LoggerService = class LoggerService {
61
61
  }
62
62
  async consumptions(params, _pinsSettingsList, context) {
63
63
  var _context_DIGIPAIR_LOGS_PATH, _ref;
64
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
64
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
65
65
  const text = await fs.promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
66
66
  const lines = text.split('\n').filter((line)=>line !== '');
67
67
  const result = lines.map((line)=>JSON.parse(line));
@@ -69,19 +69,19 @@ let LoggerService = class LoggerService {
69
69
  }
70
70
  async dailyConsumptions(params, _pinsSettingsList, context) {
71
71
  var _context_DIGIPAIR_LOGS_PATH, _ref;
72
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
72
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
73
73
  const files = (await fs.promises.readdir(`${path}/consumption-daily`)).map((file)=>file.split('.')[0]);
74
74
  return files;
75
75
  }
76
76
  async monthlyConsumptions(params, _pinsSettingsList, context) {
77
77
  var _context_DIGIPAIR_LOGS_PATH, _ref;
78
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
78
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
79
79
  const files = (await fs.promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
80
80
  return files;
81
81
  }
82
82
  async addLog(context, type, message) {
83
83
  var _context_DIGIPAIR_LOGS_PATH, _ref;
84
- const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs';
84
+ const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
85
85
  const current = new Date();
86
86
  const line = {
87
87
  date: current.getTime(),
@@ -94,7 +94,7 @@ let LoggerService = class LoggerService {
94
94
  }
95
95
  async logs(params, _pinsSettingsList, context) {
96
96
  var _context_DIGIPAIR_LOGS_PATH, _ref;
97
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
97
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
98
98
  const text = await fs.promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
99
99
  const lines = text.split('\n').filter((line)=>line !== '');
100
100
  const result = lines.map((line)=>JSON.parse(line));
@@ -102,13 +102,13 @@ let LoggerService = class LoggerService {
102
102
  }
103
103
  async dailyLogs(params, _pinsSettingsList, context) {
104
104
  var _context_DIGIPAIR_LOGS_PATH, _ref;
105
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
105
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
106
106
  const files = (await fs.promises.readdir(`${path}/factory`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
107
107
  return files;
108
108
  }
109
109
  async clearOldLogs(params, _pinsSettingsList, context) {
110
110
  var _context_DIGIPAIR_LOGS_PATH, _ref;
111
- const { type, to, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
111
+ const { type, to, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
112
112
  const files = await fs.promises.readdir(`${path}/${type}`);
113
113
  for (const file of files){
114
114
  const stats = await fs.promises.stat(`${path}/${type}/${file}`);
package/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { promises } from 'fs';
2
2
 
3
3
  var _process_env_DIGIPAIR_LOGS_PATH;
4
4
  let LoggerService = class LoggerService {
5
- async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/digipairs/logs') {
5
+ async initialize(path = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
6
6
  // create logs directory if it doesn't exist
7
7
  await promises.mkdir(`${path}/factory`, {
8
8
  recursive: true
@@ -18,7 +18,7 @@ let LoggerService = class LoggerService {
18
18
  }
19
19
  async addConsumption(context, service, model, promptTokens, completionTokens) {
20
20
  var _context_DIGIPAIR_LOGS_PATH, _ref;
21
- const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs';
21
+ const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
22
22
  const current = new Date();
23
23
  const line = {
24
24
  date: current.getTime(),
@@ -33,7 +33,7 @@ let LoggerService = class LoggerService {
33
33
  }
34
34
  async computeDailyConsumption(params, _pinsSettingsList, context) {
35
35
  var _context_DIGIPAIR_LOGS_PATH, _ref;
36
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
36
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
37
37
  const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
38
38
  const lines = text.split('\n').filter((line)=>line !== '');
39
39
  const result = lines.map((line)=>JSON.parse(line));
@@ -57,7 +57,7 @@ let LoggerService = class LoggerService {
57
57
  }
58
58
  async consumptions(params, _pinsSettingsList, context) {
59
59
  var _context_DIGIPAIR_LOGS_PATH, _ref;
60
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
60
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
61
61
  const text = await promises.readFile(`${path}/consumption-daily/${date}.jsonl`, 'utf8');
62
62
  const lines = text.split('\n').filter((line)=>line !== '');
63
63
  const result = lines.map((line)=>JSON.parse(line));
@@ -65,19 +65,19 @@ let LoggerService = class LoggerService {
65
65
  }
66
66
  async dailyConsumptions(params, _pinsSettingsList, context) {
67
67
  var _context_DIGIPAIR_LOGS_PATH, _ref;
68
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
68
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
69
69
  const files = (await promises.readdir(`${path}/consumption-daily`)).map((file)=>file.split('.')[0]);
70
70
  return files;
71
71
  }
72
72
  async monthlyConsumptions(params, _pinsSettingsList, context) {
73
73
  var _context_DIGIPAIR_LOGS_PATH, _ref;
74
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
74
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
75
75
  const files = (await promises.readdir(`${path}/consumption-monthly`)).map((file)=>file.split('.')[0]);
76
76
  return files;
77
77
  }
78
78
  async addLog(context, type, message) {
79
79
  var _context_DIGIPAIR_LOGS_PATH, _ref;
80
- const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs';
80
+ const DIGIPAIR_LOGS_PATH = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs';
81
81
  const current = new Date();
82
82
  const line = {
83
83
  date: current.getTime(),
@@ -90,7 +90,7 @@ let LoggerService = class LoggerService {
90
90
  }
91
91
  async logs(params, _pinsSettingsList, context) {
92
92
  var _context_DIGIPAIR_LOGS_PATH, _ref;
93
- const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
93
+ const { date, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
94
94
  const text = await promises.readFile(`${path}/factory/${date}.jsonl`, 'utf8');
95
95
  const lines = text.split('\n').filter((line)=>line !== '');
96
96
  const result = lines.map((line)=>JSON.parse(line));
@@ -98,13 +98,13 @@ let LoggerService = class LoggerService {
98
98
  }
99
99
  async dailyLogs(params, _pinsSettingsList, context) {
100
100
  var _context_DIGIPAIR_LOGS_PATH, _ref;
101
- const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
101
+ const { path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
102
102
  const files = (await promises.readdir(`${path}/factory`)).filter((file)=>/\.jsonl$/g.test(file)).map((file)=>file.split('.')[0]);
103
103
  return files;
104
104
  }
105
105
  async clearOldLogs(params, _pinsSettingsList, context) {
106
106
  var _context_DIGIPAIR_LOGS_PATH, _ref;
107
- const { type, to, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/digipairs/logs' } = params;
107
+ const { type, to, path = (_ref = (_context_DIGIPAIR_LOGS_PATH = context.DIGIPAIR_LOGS_PATH) != null ? _context_DIGIPAIR_LOGS_PATH : process.env['DIGIPAIR_LOGS_PATH']) != null ? _ref : './factory/logs' } = params;
108
108
  const files = await promises.readdir(`${path}/${type}`);
109
109
  for (const file of files){
110
110
  const stats = await promises.stat(`${path}/${type}/${file}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-logger",
3
- "version": "0.28.4",
3
+ "version": "0.28.5",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"