@digipair/skill-cron 0.38.5 → 0.39.0

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/index.cjs.js CHANGED
@@ -9957,24 +9957,28 @@ let CronService = class CronService {
9957
9957
  async initialize(startTask) {
9958
9958
  this.startTask = startTask;
9959
9959
  }
9960
- async start(path) {
9960
+ async start(path, utcOffset = 'Europe/Paris') {
9961
9961
  const content = await fs.promises.readFile(`${path}/planning.jsonl`, 'utf8');
9962
9962
  const lines = content.split('\n').filter((line)=>line !== '');
9963
9963
  const planning = lines.map((line)=>JSON.parse(line));
9964
9964
  for (const plan of planning){
9965
+ if (plan.time === '@startup') {
9966
+ await this.startTask(path, plan.digipair, plan.reasoning);
9967
+ continue;
9968
+ }
9965
9969
  const job = new dist.CronJob(plan.time, async ()=>{
9966
9970
  await this.startTask(path, plan.digipair, plan.reasoning);
9967
- }, null, !!plan.enabled, 'Europe/Paris');
9971
+ }, null, !!plan.enabled, utcOffset);
9968
9972
  if (this.jobs[plan.id]) {
9969
9973
  this.jobs[plan.id].stop();
9970
9974
  }
9971
9975
  this.jobs[plan.id] = job;
9972
9976
  }
9973
9977
  }
9974
- addJob(path, id, digipair, reasoning, time) {
9978
+ addJob(path, id, digipair, reasoning, time, utcOffset) {
9975
9979
  const job = new dist.CronJob(time, async ()=>{
9976
9980
  await this.startTask(path, digipair, reasoning);
9977
- }, null, true, 'Europe/Paris');
9981
+ }, null, true, utcOffset);
9978
9982
  if (this.jobs[id]) {
9979
9983
  this.jobs[id].stop();
9980
9984
  }
@@ -10011,7 +10015,7 @@ let CronService = class CronService {
10011
10015
  async addCron(params, _pinsSettingsList, context) {
10012
10016
  var _context_privates;
10013
10017
  var _context_privates_EDITOR_PATH;
10014
- 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', time, digipair, reasoning } = params;
10018
+ 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', utcOffset = 'Europe/Paris', time, digipair, reasoning } = params;
10015
10019
  const cron = {
10016
10020
  id: v4(),
10017
10021
  time,
@@ -10020,7 +10024,7 @@ let CronService = class CronService {
10020
10024
  enabled: true
10021
10025
  };
10022
10026
  await fs.promises.appendFile(`${path}/planning.jsonl`, '\n' + JSON.stringify(cron), 'utf8');
10023
- this.addJob(path, cron.id, digipair, reasoning, time);
10027
+ this.addJob(path, cron.id, digipair, reasoning, time, utcOffset);
10024
10028
  return cron;
10025
10029
  }
10026
10030
  async deleteCron(params, _pinsSettingsList, context) {
package/index.esm.js CHANGED
@@ -9949,24 +9949,28 @@ let CronService = class CronService {
9949
9949
  async initialize(startTask) {
9950
9950
  this.startTask = startTask;
9951
9951
  }
9952
- async start(path) {
9952
+ async start(path, utcOffset = 'Europe/Paris') {
9953
9953
  const content = await promises.readFile(`${path}/planning.jsonl`, 'utf8');
9954
9954
  const lines = content.split('\n').filter((line)=>line !== '');
9955
9955
  const planning = lines.map((line)=>JSON.parse(line));
9956
9956
  for (const plan of planning){
9957
+ if (plan.time === '@startup') {
9958
+ await this.startTask(path, plan.digipair, plan.reasoning);
9959
+ continue;
9960
+ }
9957
9961
  const job = new dist.CronJob(plan.time, async ()=>{
9958
9962
  await this.startTask(path, plan.digipair, plan.reasoning);
9959
- }, null, !!plan.enabled, 'Europe/Paris');
9963
+ }, null, !!plan.enabled, utcOffset);
9960
9964
  if (this.jobs[plan.id]) {
9961
9965
  this.jobs[plan.id].stop();
9962
9966
  }
9963
9967
  this.jobs[plan.id] = job;
9964
9968
  }
9965
9969
  }
9966
- addJob(path, id, digipair, reasoning, time) {
9970
+ addJob(path, id, digipair, reasoning, time, utcOffset) {
9967
9971
  const job = new dist.CronJob(time, async ()=>{
9968
9972
  await this.startTask(path, digipair, reasoning);
9969
- }, null, true, 'Europe/Paris');
9973
+ }, null, true, utcOffset);
9970
9974
  if (this.jobs[id]) {
9971
9975
  this.jobs[id].stop();
9972
9976
  }
@@ -10003,7 +10007,7 @@ let CronService = class CronService {
10003
10007
  async addCron(params, _pinsSettingsList, context) {
10004
10008
  var _context_privates;
10005
10009
  var _context_privates_EDITOR_PATH;
10006
- 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', time, digipair, reasoning } = params;
10010
+ 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', utcOffset = 'Europe/Paris', time, digipair, reasoning } = params;
10007
10011
  const cron = {
10008
10012
  id: v4(),
10009
10013
  time,
@@ -10012,7 +10016,7 @@ let CronService = class CronService {
10012
10016
  enabled: true
10013
10017
  };
10014
10018
  await promises.appendFile(`${path}/planning.jsonl`, '\n' + JSON.stringify(cron), 'utf8');
10015
- this.addJob(path, cron.id, digipair, reasoning, time);
10019
+ this.addJob(path, cron.id, digipair, reasoning, time, utcOffset);
10016
10020
  return cron;
10017
10021
  }
10018
10022
  async deleteCron(params, _pinsSettingsList, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-cron",
3
- "version": "0.38.5",
3
+ "version": "0.39.0",
4
4
  "dependencies": {
5
5
  "cron": "^3.1.7"
6
6
  },
package/schema.fr.json CHANGED
@@ -66,6 +66,15 @@
66
66
  "schema": {
67
67
  "type": "string"
68
68
  }
69
+ },
70
+ {
71
+ "name": "utcOffset",
72
+ "summary": "Décalage horaire",
73
+ "required": false,
74
+ "description": "Décalage horaire",
75
+ "schema": {
76
+ "type": "string"
77
+ }
69
78
  }
70
79
  ],
71
80
  "x-events": []
package/schema.json CHANGED
@@ -66,6 +66,15 @@
66
66
  "schema": {
67
67
  "type": "string"
68
68
  }
69
+ },
70
+ {
71
+ "name": "utcOffset",
72
+ "summary": "Timezone Offset",
73
+ "required": false,
74
+ "description": "Timezone offset",
75
+ "schema": {
76
+ "type": "string"
77
+ }
69
78
  }
70
79
  ],
71
80
  "x-events": []