@digipair/skill-cron 0.21.11 → 0.21.12
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs.js +13 -8
- package/index.esm.js +13 -8
- package/libs/skill-cron/src/lib/skill-cron.d.ts +1 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -9959,7 +9959,8 @@ let CronService = class CronService {
|
|
9959
9959
|
}
|
9960
9960
|
async start(path) {
|
9961
9961
|
const content = await fs.promises.readFile(`${path}/planning.json`, 'utf8');
|
9962
|
-
const
|
9962
|
+
const lines = content.split('\n');
|
9963
|
+
const planning = lines.map((line)=>JSON.parse(line));
|
9963
9964
|
for (const plan of planning){
|
9964
9965
|
const job = new dist.CronJob(plan.time, async ()=>{
|
9965
9966
|
await this.startTask(path, plan.digipair, plan.reasoning);
|
@@ -10003,7 +10004,8 @@ let CronService = class CronService {
|
|
10003
10004
|
var _context_privates_EDITOR_PATH;
|
10004
10005
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs' } = params;
|
10005
10006
|
const text = await fs.promises.readFile(`${path}/planning.json`, 'utf8');
|
10006
|
-
const
|
10007
|
+
const lines = text.split('\n');
|
10008
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
10007
10009
|
return crons;
|
10008
10010
|
}
|
10009
10011
|
async addCron(params, _pinsSettingsList, context) {
|
@@ -10026,8 +10028,9 @@ let CronService = class CronService {
|
|
10026
10028
|
var _context_privates_EDITOR_PATH;
|
10027
10029
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10028
10030
|
const text = await fs.promises.readFile(`${path}/planning.json`, 'utf8');
|
10029
|
-
const
|
10030
|
-
const
|
10031
|
+
const lines = text.split('\n');
|
10032
|
+
const crons = lines.map((line)=>JSON.parse(line)).filter((cron)=>cron.id !== id);
|
10033
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10031
10034
|
this.deleteJob(id);
|
10032
10035
|
await fs.promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10033
10036
|
return {
|
@@ -10039,10 +10042,11 @@ let CronService = class CronService {
|
|
10039
10042
|
var _context_privates_EDITOR_PATH;
|
10040
10043
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10041
10044
|
const text = await fs.promises.readFile(`${path}/planning.json`, 'utf8');
|
10042
|
-
const
|
10045
|
+
const lines = text.split('\n');
|
10046
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
10043
10047
|
const cron = crons.find((cron)=>cron.id === id);
|
10044
10048
|
cron.enabled = true;
|
10045
|
-
const ndjson = crons.map(JSON.stringify).join('\n');
|
10049
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10046
10050
|
await fs.promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10047
10051
|
this.enableJob(id);
|
10048
10052
|
return cron;
|
@@ -10052,11 +10056,12 @@ let CronService = class CronService {
|
|
10052
10056
|
var _context_privates_EDITOR_PATH;
|
10053
10057
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10054
10058
|
const text = await fs.promises.readFile(`${path}/planning.json`, 'utf8');
|
10055
|
-
const
|
10059
|
+
const lines = text.split('\n');
|
10060
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
10056
10061
|
const cron = crons.find((cron)=>cron.id === id);
|
10057
10062
|
cron.enabled = false;
|
10058
10063
|
this.disableJob(id);
|
10059
|
-
const ndjson = crons.map(JSON.stringify).join('\n');
|
10064
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10060
10065
|
await fs.promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10061
10066
|
return cron;
|
10062
10067
|
}
|
package/index.esm.js
CHANGED
@@ -9951,7 +9951,8 @@ let CronService = class CronService {
|
|
9951
9951
|
}
|
9952
9952
|
async start(path) {
|
9953
9953
|
const content = await promises.readFile(`${path}/planning.json`, 'utf8');
|
9954
|
-
const
|
9954
|
+
const lines = content.split('\n');
|
9955
|
+
const planning = lines.map((line)=>JSON.parse(line));
|
9955
9956
|
for (const plan of planning){
|
9956
9957
|
const job = new dist.CronJob(plan.time, async ()=>{
|
9957
9958
|
await this.startTask(path, plan.digipair, plan.reasoning);
|
@@ -9995,7 +9996,8 @@ let CronService = class CronService {
|
|
9995
9996
|
var _context_privates_EDITOR_PATH;
|
9996
9997
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs' } = params;
|
9997
9998
|
const text = await promises.readFile(`${path}/planning.json`, 'utf8');
|
9998
|
-
const
|
9999
|
+
const lines = text.split('\n');
|
10000
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
9999
10001
|
return crons;
|
10000
10002
|
}
|
10001
10003
|
async addCron(params, _pinsSettingsList, context) {
|
@@ -10018,8 +10020,9 @@ let CronService = class CronService {
|
|
10018
10020
|
var _context_privates_EDITOR_PATH;
|
10019
10021
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10020
10022
|
const text = await promises.readFile(`${path}/planning.json`, 'utf8');
|
10021
|
-
const
|
10022
|
-
const
|
10023
|
+
const lines = text.split('\n');
|
10024
|
+
const crons = lines.map((line)=>JSON.parse(line)).filter((cron)=>cron.id !== id);
|
10025
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10023
10026
|
this.deleteJob(id);
|
10024
10027
|
await promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10025
10028
|
return {
|
@@ -10031,10 +10034,11 @@ let CronService = class CronService {
|
|
10031
10034
|
var _context_privates_EDITOR_PATH;
|
10032
10035
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10033
10036
|
const text = await promises.readFile(`${path}/planning.json`, 'utf8');
|
10034
|
-
const
|
10037
|
+
const lines = text.split('\n');
|
10038
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
10035
10039
|
const cron = crons.find((cron)=>cron.id === id);
|
10036
10040
|
cron.enabled = true;
|
10037
|
-
const ndjson = crons.map(JSON.stringify).join('\n');
|
10041
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10038
10042
|
await promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10039
10043
|
this.enableJob(id);
|
10040
10044
|
return cron;
|
@@ -10044,11 +10048,12 @@ let CronService = class CronService {
|
|
10044
10048
|
var _context_privates_EDITOR_PATH;
|
10045
10049
|
const { path = (_context_privates_EDITOR_PATH = (_context_privates = context.privates) == null ? void 0 : _context_privates.EDITOR_PATH) != null ? _context_privates_EDITOR_PATH : process.env['DIGIPAIR_FACTORY_PATH'] ? `${process.env['DIGIPAIR_FACTORY_PATH']}/digipairs` : './factory/digipairs', id } = params;
|
10046
10050
|
const text = await promises.readFile(`${path}/planning.json`, 'utf8');
|
10047
|
-
const
|
10051
|
+
const lines = text.split('\n');
|
10052
|
+
const crons = lines.map((line)=>JSON.parse(line));
|
10048
10053
|
const cron = crons.find((cron)=>cron.id === id);
|
10049
10054
|
cron.enabled = false;
|
10050
10055
|
this.disableJob(id);
|
10051
|
-
const ndjson = crons.map(JSON.stringify).join('\n');
|
10056
|
+
const ndjson = crons.map((line)=>JSON.stringify(line)).join('\n');
|
10052
10057
|
await promises.writeFile(`${path}/planning.json`, ndjson, 'utf8');
|
10053
10058
|
return cron;
|
10054
10059
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { PinsSettings } from '@digipair/engine';
|
2
2
|
export declare const initialize: (launcher: Function) => Promise<void>;
|
3
3
|
export declare const start: (path: string) => Promise<void>;
|
4
|
-
export declare const crons: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
4
|
+
export declare const crons: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any[]>;
|
5
5
|
export declare const addCron: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{
|
6
6
|
id: string;
|
7
7
|
time: any;
|