fetch osmcal and persist file obtained

master
tykayn 2 years ago committed by Baptiste Lemoine
parent df1767c778
commit 86aa7bc3ae
  1. 38
      config.ts
  2. 144
      index.js
  3. 1
      node_modules/.bin/uuid
  4. BIN
      node_modules/.cache/esm/.data.blob
  5. 1
      node_modules/.cache/esm/.data.json
  6. 18
      node_modules/.cache/esm/3ef8332645677575.js
  7. 169
      node_modules/.cache/esm/4a214f03e9b6dca2.js
  8. 20
      node_modules/.cache/esm/8bd6d8bafed72c02.js
  9. 21
      node_modules/@types/node/LICENSE
  10. 16
      node_modules/@types/node/README.md
  11. 124
      node_modules/@types/node/assert.d.ts
  12. 226
      node_modules/@types/node/async_hooks.d.ts
  13. 19
      node_modules/@types/node/base.d.ts
  14. 22
      node_modules/@types/node/buffer.d.ts
  15. 509
      node_modules/@types/node/child_process.d.ts
  16. 262
      node_modules/@types/node/cluster.d.ts
  17. 133
      node_modules/@types/node/console.d.ts
  18. 8
      node_modules/@types/node/constants.d.ts
  19. 1154
      node_modules/@types/node/crypto.d.ts
  20. 141
      node_modules/@types/node/dgram.d.ts
  21. 371
      node_modules/@types/node/dns.d.ts
  22. 24
      node_modules/@types/node/domain.d.ts
  23. 83
      node_modules/@types/node/events.d.ts
  24. 2239
      node_modules/@types/node/fs.d.ts
  25. 555
      node_modules/@types/node/fs/promises.d.ts
  26. 614
      node_modules/@types/node/globals.d.ts
  27. 1
      node_modules/@types/node/globals.global.d.ts
  28. 422
      node_modules/@types/node/http.d.ts
  29. 953
      node_modules/@types/node/http2.d.ts
  30. 37
      node_modules/@types/node/https.d.ts
  31. 61
      node_modules/@types/node/index.d.ts
  32. 3041
      node_modules/@types/node/inspector.d.ts
  33. 52
      node_modules/@types/node/module.d.ts
  34. 268
      node_modules/@types/node/net.d.ts
  35. 239
      node_modules/@types/node/os.d.ts
  36. 238
      node_modules/@types/node/package.json
  37. 153
      node_modules/@types/node/path.d.ts
  38. 271
      node_modules/@types/node/perf_hooks.d.ts
  39. 408
      node_modules/@types/node/process.d.ts
  40. 68
      node_modules/@types/node/punycode.d.ts
  41. 28
      node_modules/@types/node/querystring.d.ts
  42. 171
      node_modules/@types/node/readline.d.ts
  43. 395
      node_modules/@types/node/repl.d.ts
  44. 354
      node_modules/@types/node/stream.d.ts
  45. 7
      node_modules/@types/node/string_decoder.d.ts
  46. 16
      node_modules/@types/node/timers.d.ts
  47. 779
      node_modules/@types/node/tls.d.ts
  48. 61
      node_modules/@types/node/trace_events.d.ts
  49. 100
      node_modules/@types/node/ts3.4/assert.d.ts
  50. 56
      node_modules/@types/node/ts3.4/base.d.ts
  51. 1
      node_modules/@types/node/ts3.4/globals.global.d.ts
  52. 8
      node_modules/@types/node/ts3.4/index.d.ts
  53. 22
      node_modules/@types/node/ts3.6/base.d.ts
  54. 7
      node_modules/@types/node/ts3.6/index.d.ts
  55. 66
      node_modules/@types/node/tty.d.ts
  56. 110
      node_modules/@types/node/url.d.ts
  57. 207
      node_modules/@types/node/util.d.ts
  58. 187
      node_modules/@types/node/v8.d.ts
  59. 146
      node_modules/@types/node/vm.d.ts
  60. 86
      node_modules/@types/node/wasi.d.ts
  61. 238
      node_modules/@types/node/worker_threads.d.ts
  62. 361
      node_modules/@types/node/zlib.d.ts
  63. 7
      node_modules/buffer-writer/.travis.yml
  64. 19
      node_modules/buffer-writer/LICENSE
  65. 48
      node_modules/buffer-writer/README.md
  66. 129
      node_modules/buffer-writer/index.js
  67. 57
      node_modules/buffer-writer/package.json
  68. 1
      node_modules/buffer-writer/test/mocha.opts
  69. 218
      node_modules/buffer-writer/test/writer-tests.js
  70. 25
      node_modules/colors/LICENSE
  71. 221
      node_modules/colors/README.md
  72. 82
      node_modules/colors/examples/normal-usage.js
  73. 79
      node_modules/colors/examples/safe-string.js
  74. 136
      node_modules/colors/index.d.ts
  75. 211
      node_modules/colors/lib/colors.js
  76. 46
      node_modules/colors/lib/custom/trap.js
  77. 110
      node_modules/colors/lib/custom/zalgo.js
  78. 110
      node_modules/colors/lib/extendStringPrototype.js
  79. 13
      node_modules/colors/lib/index.js
  80. 10
      node_modules/colors/lib/maps/america.js
  81. 12
      node_modules/colors/lib/maps/rainbow.js
  82. 11
      node_modules/colors/lib/maps/random.js
  83. 5
      node_modules/colors/lib/maps/zebra.js
  84. 95
      node_modules/colors/lib/styles.js
  85. 35
      node_modules/colors/lib/system/has-flag.js
  86. 151
      node_modules/colors/lib/system/supports-colors.js
  87. 75
      node_modules/colors/package.json
  88. 48
      node_modules/colors/safe.d.ts
  89. 10
      node_modules/colors/safe.js
  90. 12
      node_modules/colors/themes/generic-logging.js
  91. 11
      node_modules/entities/LICENSE
  92. 7
      node_modules/entities/lib/decode.d.ts
  93. 1
      node_modules/entities/lib/decode.d.ts.map
  94. 54
      node_modules/entities/lib/decode.js
  95. 2
      node_modules/entities/lib/decode_codepoint.d.ts
  96. 1
      node_modules/entities/lib/decode_codepoint.d.ts.map
  97. 24
      node_modules/entities/lib/decode_codepoint.js
  98. 4
      node_modules/entities/lib/encode.d.ts
  99. 1
      node_modules/entities/lib/encode.d.ts.map
  100. 73
      node_modules/entities/lib/encode.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,20 +1,20 @@
const parserConfig = {
// sources of data
rss_feed_url: "https://www.agendadulibre.org/events.rss?tag=openstreetmap",
// https://osmcal.org/static/api.html api doc
// see also https://wiki.openstreetmap.org/wiki/Template:Calendar
osmcal_url: "https://osmcal.org/api/v2/events/", // outputs json of coming events from https://osmcal.org/
// mobilizon instance
feeder_mobilizon_user_id: "3", // organizer_actor_id pour rattacher les nouveaux évènements à un utilisateur. 3 est le premier admin créé.
mobilizon_public_url: "https://mobilizon.openstreetmap.fr", // url publique de l'instance mobilizon pour créer les url d'évènements
// database of mobilizon
db_name: "mobilizon_dev",
db_user: "mobilizon",
db_pass: "mobilizon",
// other configs
askAgendaDuLibre: false, // should we fetch the Agenda du libre feed ?
askOsmCal: false,
runAddQueriesToMobilizon: false,
debug: false,
const parserConfig = {
// sources of data
rss_feed_url: "https://www.agendadulibre.org/events.rss?tag=openstreetmap",
// https://osmcal.org/static/api.html api doc
// see also https://wiki.openstreetmap.org/wiki/Template:Calendar
osmcal_url: "https://osmcal.org/api/v2/events/", // outputs json of coming events from https://osmcal.org/
// mobilizon instance
feeder_mobilizon_user_id: "3", // organizer_actor_id pour rattacher les nouveaux évènements à un utilisateur. 3 est le premier admin créé.
mobilizon_public_url: "https://mobilizon.openstreetmap.fr", // url publique de l'instance mobilizon pour créer les url d'évènements
// database of mobilizon
db_name: "mobilizon_dev",
db_user: "mobilizon",
db_pass: "mobilizon",
// other configs
askAgendaDuLibre: false, // should we fetch the Agenda du libre feed ?
askOsmCal: true,
runAddQueriesToMobilizon: false,
debug: false,
};
export default parserConfig;
export default parserConfig;

@ -1,68 +1,59 @@
// @author tykayn contact@cipherbliss.com www.cipherbliss.com
// imports
import utils from './utils.ts';
import parserConfig from './config.ts';
import { v4 as uuidv4 } from 'uuid';
import { htmlEscape } from 'escape-goat';
import Parser from 'rss-parser';
import { Client } from 'pg';
import utils from "./utils.ts";
import parserConfig from "./config.ts";
import { v4 as uuidv4 } from "uuid";
import { htmlEscape } from "escape-goat";
import Parser from "rss-parser";
import { Client } from "pg";
const fetch = require("node-fetch");
let parser = new Parser();
// @ts-ignore
console.log(' ==============================================='.blue);
console.log(" ===============================================".blue);
// @ts-ignore
console.log(' ==== Rss Feeder for mobilizon - by tykayn ===='.blue);
console.log(" ==== Rss Feeder for mobilizon - by tykayn ====".blue);
// @ts-ignore
console.log(' ==============================================='.blue);
console.log(" ===============================================".blue);
if (parserConfig.debug) {
// @ts-ignore
console.log('configMobilizon'.blue, config);
console.log("configMobilizon".blue, config);
}
const utilsTools = new utils();
let localMobilizonEventsByTitle = [];
utilsTools.testdateconvert();
// trouver si un évènement existe déjà par son titre
// TODO à affiner au delà du titre
const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
const eventAlreadyExists =
-1 !== localMobilizonEventsByTitle.indexOf(rssEvent.title);
if (!eventAlreadyExists) {
if (parserConfig.debug) {
console.log('ajouter l event ', htmlEscape(rssEvent.title));
console.log("ajouter l event ", htmlEscape(rssEvent.title));
}
addEventQuery(rssEvent);
}
};
let createEventQueries = '';
let createEventQueries = "";
let counterOfEventsToAdd = 0;
const addEventQuery = (rssEvent) => {
if (!createEventQueries) {
createEventQueries =
'INSERT INTO events(title, description, organizer_actor_id,inserted_at,updated_at, uuid, url, status, category, options,participants_stats, begins_on, ends_on) VALUES ';
"INSERT INTO events(title, description, organizer_actor_id,inserted_at,updated_at, uuid, url, status, category, options,participants_stats, begins_on, ends_on) VALUES ";
}
if (counterOfEventsToAdd) {
createEventQueries += ` , `;
}
let title = '\'' + htmlEscape(rssEvent.title) + '\'';
let content = '\'' + htmlEscape(rssEvent.content) + '\'';
let title = "'" + htmlEscape(rssEvent.title) + "'";
let content = "'" + htmlEscape(rssEvent.content) + "'";
let uuid = uuidv4();
let uuidString = '\'' + uuid + '\'';
let eventUrl = '\'' + parserConfig.mobilizon_public_url + '/events/' + uuid + '\'';
let begins_on = '\'' + uuid + '\'';
let ends_on = '\'' + utilsTools.convertRssDate(rssEvent.date) + '\'';
let uuidString = "'" + uuid + "'";
let eventUrl =
"'" + parserConfig.mobilizon_public_url + "/events/" + uuid + "'";
let begins_on = "'" + utilsTools.convertRssDate(rssEvent.date) + "'";
let ends_on = "'" + utilsTools.convertRssDate(rssEvent.date) + "'";
let baseOptions =
'{"offers": [], "program": null, "attendees": [], "show_end_time": true, "show_start_time": true, "comment_moderation": "allow_all", "anonymous_participation": true, "participation_condition": [], "show_participation_price": false, "maximum_attendee_capacity": 0, "remaining_attendee_capacity": 0, "hide_organizer_when_group_event": false, "show_remaining_attendee_capacity": false}';
let baseStats =
@ -70,100 +61,111 @@ const addEventQuery = (rssEvent) => {
// TODO complete with date conversion
// begins_on , ends_on expecting date format like this: "2020-12-17 23:00:00"
createEventQueries += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats} )`;
createEventQueries += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats}, ${begins_on} , ${ends_on} )`;
counterOfEventsToAdd++;
};
const runCreationQuery = async () => {
createEventQueries = createEventQueries + ';';
createEventQueries = createEventQueries + ";";
utilsTools.writeFile("event_creation_query.psql", createEventQueries);
if (createEventQueries) {
console.log(' ');
console.log(' ⚙ ');
console.log(' ');
console.log(' createEventQueries');
console.log(" ");
console.log(" ⚙ ");
console.log(" ");
console.log(" createEventQueries");
console.log(createEventQueries);
const res = await client.query(createEventQueries);
console.log('res', res);
console.log("res", res);
return res;
}
};
const client = new Client({
host : 'localhost',
user : parserConfig.db_user,
host: "localhost",
user: parserConfig.db_user,
password: parserConfig.db_pass,
database: parserConfig.db_name,
});
(async () => {
console.log('⌛ interroger la BDD mobilizon postgresql');
console.log("⌛ interroger la BDD mobilizon postgresql");
await client.connect();
console.log('✅ OK connecté à postgresql');
console.log(' ');
const res = await client.query('SELECT * from events');
console.log('💾 évènements enregistrés dans mobilizon : ', res.rows.length); // Hello world!
console.log("✅ OK connecté à postgresql");
console.log(" ");
const res = await client.query("SELECT * from events");
console.log("💾 évènements enregistrés dans mobilizon : ", res.rows.length); // Hello world!
res.rows.forEach((item) => {
localMobilizonEventsByTitle.push(item.title);
console.log(' 🟢 ', item.begins_on, item.ends_on, item.title, item.url);
});
utilsTools.postgresEventsExisting = res.rows;
if (parserConfig.askAgendaDuLibre) {
// @ts-ignore
console.log(' ===================================================='.blue);
console.log(" ====================================================".blue);
// @ts-ignore
console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
console.log(" ==== demander à l'agenda du libre son flux RSS ====".blue);
// @ts-ignore
console.log(' ===================================================='.blue);
console.log(" ====================================================".blue);
console.log('⌛ lecture du flux rss : ' + parserConfig.rss_feed_url);
console.log("⌛ lecture du flux rss : " + parserConfig.rss_feed_url);
let feed = await parser.parseURL(parserConfig.rss_feed_url);
console.log('✅ flux rss obtenu');
console.log("✅ flux rss obtenu");
utilsTools.writeFile("agenda_du_libre_feed.xml", feed);
console.log(feed.title);
console.log('⚙ interprétation des évènements');
console.log("⚙ interprétation des évènements");
console.log(
'⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql',
"⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql"
);
feed.items.forEach((rssEvent) => {
console.log(rssEvent.title);
feed.items.forEach((eventFound) => {
console.log(eventFound.title);
// console.log('item', item)
doesThisEventAlreadyExistInLocalEvents(rssEvent);
utilsTools.agendadulibre.doesEventExists(eventFound);
});
}
if (parserConfig.askOsmCal) {
// @ts-ignore
console.log(' ===================================================='.blue);
console.log(" ====================================================".blue);
// @ts-ignore
console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
console.log(" ==== demander à OSM cal ====".blue);
// @ts-ignore
console.log(' ===================================================='.blue);
console.log(" ====================================================".blue);
fetch(parserConfig.osmcal_url, { method: "GET" })
.then((res) => res.json())
.then((arrayOfEvents) => {
console.log("json osmcal count", arrayOfEvents.length);
utilsTools.writeFile("osmcal.json", arrayOfEvents);
arrayOfEvents.forEach((eventFound) => {
console.log(eventFound.name);
// console.log('item', item)
utilsTools.osmCal.doesEventExists(eventFound);
});
});
}
if (parserConfig.runAddQueriesToMobilizon) {
// @ts-ignore
console.log('➕ rajouter les évènements manquants à la base mobilizon'.blue);
console.log(
"➕ rajouter les évènements manquants à la base mobilizon".blue
);
await runCreationQuery();
// @ts-ignore
console.log(' ---------- '.green);
console.log(" ---------- ".green);
// @ts-ignore
console.log(counterOfEventsToAdd, ' évènements ajoutés '.green);
console.log(counterOfEventsToAdd, " évènements ajoutés ".green);
// @ts-ignore
console.log(' ---------- '.green);
console.log(" ---------- ".green);
// @ts-ignore
console.log('✅ ça c\'est fait '.green);
console.log("✅ ça c'est fait ".green);
}
await client.end();
})();
exports = () => {
console.log('hey ho', this);
console.log("hey ho", this);
};

1
node_modules/.bin/uuid generated vendored

@ -1 +0,0 @@
../uuid/dist/bin/uuid

BIN
node_modules/.cache/esm/.data.blob generated vendored

Binary file not shown.

@ -1 +0,0 @@
{"meta":{"4a214f0323c5b60c.js":[0,7840,17,1609701952657,2,null,null,"../../../index.js",-1,469],"3ef83326c93bb5f0.js":[7840,9632,4,1609702268191,2,null,null,"../../../utils.ts",0,35],"4a214f036c2197a3.js":[9632,18832,17,1609702305847,2,null,null,"../../../index.js",0,472],"8bd6d8bafed72c02.js":[18832,20912,4,1609702292217,2,null,null,"../../../config.ts",0,35],"4ea918b634e7ddee.js":[20912,79016],"cfe8e44034e7ddee.js":[79016,82488],"b4a6e37534e7ddee.js":[82488,83856],"1e05fd5334e7ddee.js":[83856,85064],"bf10b4f234e7ddee.js":[85064,86400],"8f40bea234e7ddee.js":[86400,87512],"7e09912634e7ddee.js":[87512,88504],"2674ff5934e7ddee.js":[88504,89592],"8998963e34e7ddee.js":[89592,91136],"502bd04b34e7ddee.js":[91136,92256],"66c70c9d34e7ddee.js":[92256,93352],"8f1bb44f34e7ddee.js":[93352,94544],"434e4b9234e7ddee.js":[94544,95640],"cda6849f34e7ddee.js":[95640,96744],"e3420b7d34e7ddee.js":[96744,97648],"8b712e7434e7ddee.js":[97648,98768],"2053138034e7ddee.js":[98768,99896],"c582ecc634e7ddee.js":[99896,100672],"0bac123734e7ddee.js":[100672,103384],"1c7694f234e7ddee.js":[103384,105408],"5faa8dc034e7ddee.js":[105408,107848],"97c0385c34e7ddee.js":[107848,109936],"36df28f334e7ddee.js":[109936,112432],"eb69a67234e7ddee.js":[112432,114360],"5cfbe43834e7ddee.js":[114360,116592],"49f59e8a34e7ddee.js":[116592,127104],"d51c7bf134e7ddee.js":[127104,129496],"8a2f4c9c34e7ddee.js":[129496,131024],"10f0948334e7ddee.js":[131024,132976],"05b6411534e7ddee.js":[132976,149592],"e63a0d4134e7ddee.js":[149592,151264],"665d971034e7ddee.js":[151264,157112],"506d4c4234e7ddee.js":[157112,158936],"bc5923d134e7ddee.js":[158936,164960],"06f7b82c34e7ddee.js":[164960,166944],"c8b25ccd34e7ddee.js":[166944,172904],"1f5433a534e7ddee.js":[172904,174784],"e5bd35c434e7ddee.js":[174784,178496],"8e4a9ef134e7ddee.js":[178496,180376],"82c6418834e7ddee.js":[180376,182840],"0f45284634e7ddee.js":[182840,185816],"a46ec2ab34e7ddee.js":[185816,187880],"581626d034e7ddee.js":[187880,192080],"91804a3134e7ddee.js":[192080,194152],"6ab8978a34e7ddee.js":[194152,203800],"f875f50734e7ddee.js":[203800,208160],"93569bf434e7ddee.js":[208160,210208],"e76687d634e7ddee.js":[210208,213264],"112ad7a934e7ddee.js":[213264,215568],"d7317d4034e7ddee.js":[215568,217624],"20cf856b34e7ddee.js":[217624,218808],"4b5cde3834e7ddee.js":[218808,229632],"3d32dce434e7ddee.js":[229632,234216],"54a236fc34e7ddee.js":[234216,237776],"0284fc9e1e0f713c.js":[237776,255568],"a8f15fcc34e7ddee.js":[255568,256704],"b0a2f5d334e7ddee.js":[256704,258456],"135aeb1534e7ddee.js":[258456,260976],"3aed101f34e7ddee.js":[260976,263320],"67a658bc34e7ddee.js":[263320,267520],"92b7bd0d34e7ddee.js":[267520,270280],"51a1bfca34e7ddee.js":[270280,271432],"8b76f93b34e7ddee.js":[271432,273432],"e5dbf4c734e7ddee.js":[273432,275008],"75cfb7f334e7ddee.js":[275008,280240],"3850b3a734e7ddee.js":[280240,282168],"b771994234e7ddee.js":[282168,284344],"8785e88234e7ddee.js":[284344,285920],"7ce9446134e7ddee.js":[285920,288984],"0551020634e7ddee.js":[288984,290800],"4cbe626c34e7ddee.js":[290800,291856],"bbae285f34e7ddee.js":[291856,293416],"920f6c777d217eb1.js":[293416,296328],"6f58dc5534e7ddee.js":[296328,297232],"0cc3bc0992c47e23.js":[297232,298064],"a474b7b434e7ddee.js":[298064,300208],"972b86bf4a371210.js":[300208,301072],"cd8930bc34e7ddee.js":[301072,303704],"0eafaf3234e7ddee.js":[303704,305240],"0caa99b934e7ddee.js":[305240,306320],"d29740ff34e7ddee.js":[306320,309800],"f693a2a834e7ddee.js":[309800,311320],"00f4096434e7ddee.js":[311320,313000],"66e222ca34e7ddee.js":[313000,321208],"b6f27b6b34e7ddee.js":[321208,322016],"4618d65334e7ddee.js":[322016,323848],"47ec677034e7ddee.js":[323848,325232],"a6a949ec34e7ddee.js":[325232,326368],"3a7392a334e7ddee.js":[326368,328880],"a5de0d2834e7ddee.js":[328880,329864],"b4cc734134e7ddee.js":[329864,337112],"d3dc197e6408243f.js":[337112,337928],"6457305334e7ddee.js":[337928,340112],"2681d3c834e7ddee.js":[340112,342384],"4527f91e34e7ddee.js":[342384,343544],"af5182ed34e7ddee.js":[343544,344920],"357b6f0e34e7ddee.js":[344920,346728],"89a48c1c34e7ddee.js":[346728,348000],"e0279dc834e7ddee.js":[348000,349752],"787a006e34e7ddee.js":[349752,350704],"ebf2880534e7ddee.js":[350704,353416],"c8e1dfdc34e7ddee.js":[353416,355064],"4390ae1534e7ddee.js":[355064,358664],"8d2da48134e7ddee.js":[358664,359872],"5f16e98b34e7ddee.js":[359872,364960],"4fbbd02934e7ddee.js":[364960,368968],"f0b51d8e34e7ddee.js":[368968,370816],"06b5860134e7ddee.js":[370816,374312],"52a3a93334e7ddee.js":[374312,376224],"d8594d5534e7ddee.js":[376224,379760],"4a214f03e9b6dca2.js":[379760,389072,17,1609702667126,2,null,null,"../../../index.js",0,472],"3ef83326954c7b1f.js":[389072,391776,4,1609702667122,2,null,null,"../../../utils.ts",0,35],"3ef83326a1534815.js":[391776,394560,4,1609702893482,2,null,null,"../../../utils.ts",0,35],"3ef8332650409682.js":[394560,397272,4,1609702929886,2,null,null,"../../../utils.ts",0,35],"3ef8332645677575.js":[397272,400096,4,1609784616302,2,null,null,"../../../utils.ts",0,35]},"version":"3.2.25"}

@ -1,18 +0,0 @@
_456.x([["default",()=>_456.o]]);const moment = require("moment");
class utils {
convertRssDate(rssDate){
let converted = moment(rssDate).format('YYYY-MM-DD LTS').slice(0,-2).concat(".000000") ;// in js format like 2021-03-12T19:00:00Z
console.log('converted', converted)
// like 2021-01-03 15:31:02.918940
return converted
}
testdateconvert(){
let converted = this.convertRssDate('2021-03-12T19:00:00Z')
console.log('converted', converted)
}
}
_456.d(utils);

@ -1,169 +0,0 @@
let utils,parserConfig,uuidv4,htmlEscape,Parser,Client;_e9b.w("./utils.ts",[["default",["utils"],function(v){utils=v}]]);_e9b.w("./config.ts",[["default",["parserConfig"],function(v){parserConfig=v}]]);_e9b.w("uuid",[["v4",["uuidv4"],function(v){uuidv4=v}]]);_e9b.w("escape-goat",[["htmlEscape",["htmlEscape"],function(v){htmlEscape=v}]]);_e9b.w("rss-parser",[["default",["Parser"],function(v){Parser=v}]]);_e9b.w("pg",[["Client",["Client"],function(v){Client=v}]]);// @author tykayn contact@cipherbliss.com www.cipherbliss.com
// imports
let parser = new Parser();
// @ts-ignore
_e9b.g.console.log(' ==============================================='.blue);
// @ts-ignore
_e9b.g.console.log(' ==== Rss Feeder for mobilizon - by tykayn ===='.blue);
// @ts-ignore
_e9b.g.console.log(' ==============================================='.blue);
if (parserConfig.debug) {
// @ts-ignore
_e9b.g.console.log('configMobilizon'.blue, config);
}
const utilsTools = new utils();
let localMobilizonEventsByTitle = [];
utilsTools.testdateconvert();
// trouver si un évènement existe déjà par son titre
// TODO à affiner au delà du titre
const doesThisEventAlreadyExistInLocalEvents = (rssEvent) => {
const eventAlreadyExists =
-1 !== localMobilizonEventsByTitle.indexOf(rssEvent.title);
if (!eventAlreadyExists) {
if (parserConfig.debug) {
_e9b.g.console.log('ajouter l event ', htmlEscape(rssEvent.title));
}
addEventQuery(rssEvent);
}
};
let createEventQueries = '';
let counterOfEventsToAdd = 0;
const addEventQuery = (rssEvent) => {
if (!createEventQueries) {
createEventQueries =
'INSERT INTO events(title, description, organizer_actor_id,inserted_at,updated_at, uuid, url, status, category, options,participants_stats, begins_on, ends_on) VALUES ';
}
if (counterOfEventsToAdd) {
createEventQueries += ` , `;
}
let title = '\'' + htmlEscape(rssEvent.title) + '\'';
let content = '\'' + htmlEscape(rssEvent.content) + '\'';
let uuid = uuidv4();
let uuidString = '\'' + uuid + '\'';
let eventUrl = '\'' + parserConfig.mobilizon_public_url + '/events/' + uuid + '\'';
let begins_on = '\'' + uuid + '\'';
let ends_on = '\'' + utilsTools.convertRssDate(rssEvent.date) + '\'';
let baseOptions =
'{"offers": [], "program": null, "attendees": [], "show_end_time": true, "show_start_time": true, "comment_moderation": "allow_all", "anonymous_participation": true, "participation_condition": [], "show_participation_price": false, "maximum_attendee_capacity": 0, "remaining_attendee_capacity": 0, "hide_organizer_when_group_event": false, "show_remaining_attendee_capacity": false}';
let baseStats =
'{"creator": 1, "rejected": 0, "moderator": 0, "participant": 0, "not_approved": 0, "administrator": 0, "not_confirmed": 0}';
// TODO complete with date conversion
// begins_on , ends_on expecting date format like this: "2020-12-17 23:00:00"
createEventQueries += `( ${title}, ${content}, ${parserConfig.feeder_mobilizon_user_id}, 'now()','now()', ${uuidString}, ${eventUrl}, 'confirmed' , 'meeting', ${baseOptions}, ${baseStats} )`;
counterOfEventsToAdd++;
};
const runCreationQuery = async () => {
createEventQueries = createEventQueries + ';';
if (createEventQueries) {
console.log(' ');
console.log(' ⚙ ');
console.log(' ');
console.log(' createEventQueries');
_e9b.g.console.log(createEventQueries);
const res = await client.query(createEventQueries);
_e9b.g.console.log('res', res);
return res;
}
};
const client = new Client({
host : 'localhost',
user : parserConfig.db_user,
password: parserConfig.db_pass,
database: parserConfig.db_name,
});
(async () => {
console.log('⌛ interroger la BDD mobilizon postgresql');
await client.connect();
console.log('✅ OK connecté à postgresql');
console.log(' ');
const res = await client.query('SELECT * from events');
_e9b.g.console.log('💾 évènements enregistrés dans mobilizon : ', res.rows.length); // Hello world!
res.rows.forEach((item) => {
localMobilizonEventsByTitle.push(item.title);
_e9b.g.console.log(' 🟢 ', item.begins_on, item.ends_on, item.title, item.url);
});
if (parserConfig.askAgendaDuLibre) {
// @ts-ignore
_e9b.g.console.log(' ===================================================='.blue);
// @ts-ignore
_e9b.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
// @ts-ignore
_e9b.g.console.log(' ===================================================='.blue);
_e9b.g.console.log('⌛ lecture du flux rss : ' + parserConfig.rss_feed_url);
let feed = await parser.parseURL(parserConfig.rss_feed_url);
console.log('✅ flux rss obtenu');
_e9b.g.console.log(feed.title);
console.log('⚙ interprétation des évènements');
console.log(
'⌛ trouver les évènements qui ne font pas partie de la BDD mobilizon postgresql',
);
feed.items.forEach((rssEvent) => {
_e9b.g.console.log(rssEvent.title);
// console.log('item', item)
doesThisEventAlreadyExistInLocalEvents(rssEvent);
});
}
if (parserConfig.askOsmCal) {
// @ts-ignore
_e9b.g.console.log(' ===================================================='.blue);
// @ts-ignore
_e9b.g.console.log(' ==== demander à l\'agenda du libre son flux RSS ===='.blue);
// @ts-ignore
_e9b.g.console.log(' ===================================================='.blue);
}
if (parserConfig.runAddQueriesToMobilizon) {
// @ts-ignore
_e9b.g.console.log('➕ rajouter les évènements manquants à la base mobilizon'.blue);
await runCreationQuery();
// @ts-ignore
_e9b.g.console.log(' ---------- '.green);
// @ts-ignore
_e9b.g.console.log(counterOfEventsToAdd, ' évènements ajoutés '.green);
// @ts-ignore
_e9b.g.console.log(' ---------- '.green);
// @ts-ignore
_e9b.g.console.log('✅ ça c\'est fait '.green);
}
await client.end();
})();
exports = () => {
_e9b.g.console.log('hey ho', this);
};

@ -1,20 +0,0 @@
_fed.x([["default",()=>_fed.o]]); const parserConfig = {
// sources of data
rss_feed_url: "https://www.agendadulibre.org/events.rss?tag=openstreetmap",
// https://osmcal.org/static/api.html api doc
// see also https://wiki.openstreetmap.org/wiki/Template:Calendar
osmcal_url: "https://osmcal.org/api/v2/events/", // outputs json of coming events from https://osmcal.org/
// mobilizon instance
feeder_mobilizon_user_id: "3", // organizer_actor_id pour rattacher les nouveaux évènements à un utilisateur. 3 est le premier admin créé.
mobilizon_public_url: "https://mobilizon.openstreetmap.fr", // url publique de l'instance mobilizon pour créer les url d'évènements
// database of mobilizon
db_name: "mobilizon_dev",
db_user: "mobilizon",
db_pass: "mobilizon",
// other configs
askAgendaDuLibre: false, // should we fetch the Agenda du libre feed ?
askOsmCal: false,
runAddQueriesToMobilizon: false,
debug: false,
};
_fed.d(parserConfig);

21
node_modules/@types/node/LICENSE generated vendored

@ -1,21 +0,0 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

@ -1,16 +0,0 @@
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for Node.js (http://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Fri, 01 Jan 2021 17:54:22 GMT
* Dependencies: none
* Global values: `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Bruno Scheufler](https://github.com/brunoscheufler), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Jason Kwok](https://github.com/JasonHK), and [Victor Perin](https://github.com/victorperin).

@ -1,124 +0,0 @@
declare module 'assert' {
/** An alias of `assert.ok()`. */
function assert(value: any, message?: string | Error): asserts value;
namespace assert {
class AssertionError extends Error {
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
constructor(options?: {
/** If provided, the error message is set to this value. */
message?: string;
/** The `actual` property on the error instance. */
actual?: any;
/** The `expected` property on the error instance. */
expected?: any;
/** The `operator` property on the error instance. */
operator?: string;
/** If provided, the generated stack trace omits frames before this function. */
// tslint:disable-next-line:ban-types
stackStartFn?: Function;
});
}
class CallTracker {
calls(exact?: number): () => void;
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
report(): CallTrackerReportInformation[];
verify(): void;
}
interface CallTrackerReportInformation {
message: string;
/** The actual number of times the function was called. */
actual: number;
/** The number of times the function was expected to be called. */
expected: number;
/** The name of the function that is wrapped. */
operator: string;
/** A stack trace of the function. */
stack: object;
}
type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(
actual: any,
expected: any,
message?: string | Error,
operator?: string,
// tslint:disable-next-line:ban-types
stackStartFn?: Function,
): never;
function ok(value: any, message?: string | Error): asserts value;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function throws(block: () => any, message?: string | Error): void;
function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
function doesNotThrow(block: () => any, message?: string | Error): void;
function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
function ifError(value: any): asserts value is null | undefined;
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function rejects(
block: (() => Promise<any>) | Promise<any>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(
block: (() => Promise<any>) | Promise<any>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
function match(value: string, regExp: RegExp, message?: string | Error): void;
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
const strict: Omit<
typeof assert,
| 'equal'
| 'notEqual'
| 'deepEqual'
| 'notDeepEqual'
| 'ok'
| 'strictEqual'
| 'deepStrictEqual'
| 'ifError'
| 'strict'
> & {
(value: any, message?: string | Error): asserts value;
equal: typeof strictEqual;
notEqual: typeof notStrictEqual;
deepEqual: typeof deepStrictEqual;
notDeepEqual: typeof notDeepStrictEqual;
// Mapped types and assertion functions are incompatible?
// TS2775: Assertions require every name in the call target
// to be declared with an explicit type annotation.
ok: typeof ok;
strictEqual: typeof strictEqual;
deepStrictEqual: typeof deepStrictEqual;
ifError: typeof ifError;
strict: typeof strict;
};
}
export = assert;
}

@ -1,226 +0,0 @@
/**
* Async Hooks module: https://nodejs.org/api/async_hooks.html
*/
declare module "async_hooks" {
/**
* Returns the asyncId of the current execution context.
*/
function executionAsyncId(): number;
/**
* The resource representing the current execution.
* Useful to store data within the resource.
*
* Resource objects returned by `executionAsyncResource()` are most often internal
* Node.js handle objects with undocumented APIs. Using any functions or properties
* on the object is likely to crash your application and should be avoided.
*
* Using `executionAsyncResource()` in the top-level execution context will
* return an empty object as there is no handle or request object to use,
* but having an object representing the top-level can be helpful.
*/
function executionAsyncResource(): object;
/**
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
*/
function triggerAsyncId(): number;
interface HookCallbacks {
/**
* Called when a class is constructed that has the possibility to emit an asynchronous event.
* @param asyncId a unique ID for the async resource
* @param type the type of the async resource
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param resource reference to the resource representing the async operation, needs to be released during destroy
*/
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
/**
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
* The before callback is called just before said callback is executed.
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
*/
before?(asyncId: number): void;
/**
* Called immediately after the callback specified in before is completed.
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
*/
after?(asyncId: number): void;
/**
* Called when a promise has resolve() called. This may not be in the same execution id
* as the promise itself.
* @param asyncId the unique id for the promise that was resolve()d.
*/
promiseResolve?(asyncId: number): void;
/**
* Called after the resource corresponding to asyncId is destroyed
* @param asyncId a unique ID for the async resource
*/
destroy?(asyncId: number): void;
}
interface AsyncHook {
/**
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
*/
enable(): this;
/**
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
*/
disable(): this;
}
/**
* Registers functions to be called for different lifetime events of each async operation.
* @param options the callbacks to register
* @return an AsyncHooks instance used for disabling and enabling hooks
*/
function createHook(options: HookCallbacks): AsyncHook;
interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
*/
class AsyncResource {
/**
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 9.3)
*/
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
/**
* Binds the given function to the current execution context.
* @param fn The function to bind to the current execution context.
* @param type An optional name to associate with the underlying `AsyncResource`.
*/
static bind<Func extends (...args: any[]) => any>(fn: Func, type?: string): Func & { asyncResource: AsyncResource };
/**
* Binds the given function to execute to this `AsyncResource`'s scope.
* @param fn The function to bind to the current `AsyncResource`.
*/
bind<Func extends (...args: any[]) => any>(fn: Func): Func & { asyncResource: AsyncResource };
/**
* Call the provided function with the provided arguments in the
* execution context of the async resource. This will establish the
* context, trigger the AsyncHooks before callbacks, call the function,
* trigger the AsyncHooks after callbacks, and then restore the original
* execution context.
* @param fn The function to call in the execution context of this
* async resource.
* @param thisArg The receiver to be used for the function call.
* @param args Optional arguments to pass to the function.
*/
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
/**
* Call AsyncHooks destroy callbacks.
*/
emitDestroy(): void;
/**
* @return the unique ID assigned to this AsyncResource instance.
*/
asyncId(): number;
/**
* @return the trigger ID for this AsyncResource instance.
*/
triggerAsyncId(): number;
}
/**
* When having multiple instances of `AsyncLocalStorage`, they are independent
* from each other. It is safe to instantiate this class multiple times.
*/
class AsyncLocalStorage<T> {
/**
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
* to `asyncLocalStorage.getStore()` will return `undefined` until
* `asyncLocalStorage.run()` is called again.
*
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
* instance will be exited.
*
* Calling `asyncLocalStorage.disable()` is required before the
* `asyncLocalStorage` can be garbage collected. This does not apply to stores
* provided by the `asyncLocalStorage`, as those objects are garbage collected
* along with the corresponding async resources.
*
* This method is to be used when the `asyncLocalStorage` is not in use anymore
* in the current process.
*/
disable(): void;
/**
* This method returns the current store. If this method is called outside of an
* asynchronous context initialized by calling `asyncLocalStorage.run`, it will
* return `undefined`.
*/
getStore(): T | undefined;
/**
* This methods runs a function synchronously within a context and return its
* return value. The store is not accessible outside of the callback function or
* the asynchronous operations created within the callback.
*
* Optionally, arguments can be passed to the function. They will be passed to the
* callback function.
*
* I the callback function throws an error, it will be thrown by `run` too. The
* stacktrace will not be impacted by this call and the context will be exited.
*/
// TODO: Apply generic vararg once available
run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
/**
* This methods runs a function synchronously outside of a context and return its
* return value. The store is not accessible within the callback function or the
* asynchronous operations created within the callback.
*
* Optionally, arguments can be passed to the function. They will be passed to the
* callback function.
*
* If the callback function throws an error, it will be thrown by `exit` too. The
* stacktrace will not be impacted by this call and the context will be
* re-entered.
*/
// TODO: Apply generic vararg once available
exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
/**
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
* for the remainder of the current synchronous execution and will persist
* through any following asynchronous calls.
*/
enterWith(store: T): void;
}
}

@ -1,19 +0,0 @@
// NOTE: These definitions support NodeJS and TypeScript 3.7.
// NOTE: TypeScript version-specific augmentations can be found in the following paths:
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
// - ~/ts3.7/base.d.ts - Definitions specific to TypeScript 3.7
// - ~/ts3.7/index.d.ts - Definitions specific to TypeScript 3.7 with assert pulled in
// Reference required types from the default lib:
/// <reference lib="es2018" />
/// <reference lib="esnext.asynciterable" />
/// <reference lib="esnext.intl" />
/// <reference lib="esnext.bigint" />
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
/// <reference path="ts3.6/base.d.ts" />
// TypeScript 3.7-specific augmentations:
/// <reference path="assert.d.ts" />

@ -1,22 +0,0 @@
declare module "buffer" {
export const INSPECT_MAX_BYTES: number;
export const kMaxLength: number;
export const kStringMaxLength: number;
export const constants: {
MAX_LENGTH: number;
MAX_STRING_LENGTH: number;
};
const BuffType: typeof Buffer;
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export const SlowBuffer: {
/** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
new(size: number): Buffer;
prototype: Buffer;
};
export { BuffType as Buffer };
}

@ -1,509 +0,0 @@
declare module "child_process" {
import { BaseEncodingOptions } from 'fs';
import * as events from "events";
import * as net from "net";
import { Writable, Readable, Stream, Pipe } from "stream";
type Serializable = string | object | number | boolean;
type SendHandle = net.Socket | net.Server;
interface ChildProcess extends events.EventEmitter {
stdin: Writable | null;
stdout: Readable | null;
stderr: Readable | null;
readonly channel?: Pipe | null;
readonly stdio: [
Writable | null, // stdin
Readable | null, // stdout
Readable | null, // stderr
Readable | Writable | null | undefined, // extra
Readable | Writable | null | undefined // extra
];
readonly killed: boolean;
readonly pid: number;
readonly connected: boolean;
readonly exitCode: number | null;
readonly signalCode: NodeJS.Signals | null;
readonly spawnargs: string[];
readonly spawnfile: string;
kill(signal?: NodeJS.Signals | number): boolean;
send(message: Serializable, callback?: (error: Error | null) => void): boolean;
send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
disconnect(): void;
unref(): void;
ref(): void;
/**
* events.EventEmitter
* 1. close
* 2. disconnect
* 3. error
* 4. exit
* 5. message
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "close", code: number, signal: NodeJS.Signals): boolean;
emit(event: "disconnect"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
}
// return this object when stdio option is undefined or not specified
interface ChildProcessWithoutNullStreams extends ChildProcess {
stdin: Writable;
stdout: Readable;
stderr: Readable;
readonly stdio: [
Writable, // stdin
Readable, // stdout
Readable, // stderr
Readable | Writable | null | undefined, // extra, no modification
Readable | Writable | null | undefined // extra, no modification
];
}
// return this object when stdio option is a tuple of 3
interface ChildProcessByStdio<
I extends null | Writable,
O extends null | Readable,
E extends null | Readable,
> extends ChildProcess {
stdin: I;
stdout: O;
stderr: E;
readonly stdio: [
I,
O,
E,
Readable | Writable | null | undefined, // extra, no modification
Readable | Writable | null | undefined // extra, no modification
];
}
interface MessageOptions {
keepOpen?: boolean;
}
type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | Stream | number | null | undefined)>;
type SerializationType = 'json' | 'advanced';
interface MessagingOptions {
/**
* Specify the kind of serialization used for sending messages between processes.
* @default 'json'
*/
serialization?: SerializationType;
}
interface ProcessEnvOptions {
uid?: number;
gid?: number;
cwd?: string;
env?: NodeJS.ProcessEnv;
}
interface CommonOptions extends ProcessEnvOptions {
/**
* @default true
*/
windowsHide?: boolean;
/**
* @default 0
*/
timeout?: number;
}
interface CommonSpawnOptions extends CommonOptions, MessagingOptions {
argv0?: string;
stdio?: StdioOptions;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
}
interface SpawnOptions extends CommonSpawnOptions {
detached?: boolean;
}
interface SpawnOptionsWithoutStdio extends SpawnOptions {
stdio?: 'pipe' | Array<null | undefined | 'pipe'>;
}
type StdioNull = 'inherit' | 'ignore' | Stream;
type StdioPipe = undefined | null | 'pipe';
interface SpawnOptionsWithStdioTuple<
Stdin extends StdioNull | StdioPipe,
Stdout extends StdioNull | StdioPipe,
Stderr extends StdioNull | StdioPipe,
> extends SpawnOptions {
stdio: [Stdin, Stdout, Stderr];
}
// overloads of spawn without 'args'
function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
): ChildProcessByStdio<Writable, Readable, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
): ChildProcessByStdio<Writable, Readable, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
): ChildProcessByStdio<Writable, null, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
): ChildProcessByStdio<null, Readable, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
): ChildProcessByStdio<Writable, null, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
): ChildProcessByStdio<null, Readable, null>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
): ChildProcessByStdio<null, null, Readable>;
function spawn(
command: string,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
): ChildProcessByStdio<null, null, null>;
function spawn(command: string, options: SpawnOptions): ChildProcess;
// overloads of spawn with 'args'
function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
): ChildProcessByStdio<Writable, Readable, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
): ChildProcessByStdio<Writable, Readable, null>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
): ChildProcessByStdio<Writable, null, Readable>;
function spawn(
command: string,
args: ReadonlyArray<string>,
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
): ChildProcessByStdio<null, Readable<