@digipair/skill-logger 0.113.0 → 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 ADDED
@@ -0,0 +1,7 @@
1
+ # skill-test
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build skill-logger` to build the library.
@@ -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 = (_process_env_DIGIPAIR_LOGS_PATH = process.env['DIGIPAIR_LOGS_PATH']) != null ? _process_env_DIGIPAIR_LOGS_PATH : './factory/logs') {
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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
- var _context_privates_DIGIPAIR_LOGS_PATH, _ref;
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}`);