@ezpaarse-project/ezreeport-sdk-js 1.0.0-beta.5 → 1.0.0-beta.6

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 (83) hide show
  1. package/README.md +19 -752
  2. package/dist/browser/ezreeport-sdk-js.mjs +529 -495
  3. package/dist/browser/ezreeport-sdk-js.mjs.map +1 -1
  4. package/dist/browser/ezreeport-sdk-js.umd.js +3 -3
  5. package/dist/browser/ezreeport-sdk-js.umd.js.map +1 -1
  6. package/dist/node/package.json +7 -9
  7. package/dist/node/src/index.js +3 -2
  8. package/dist/node/src/index.js.map +1 -1
  9. package/dist/node/src/modules/auth.js.map +1 -1
  10. package/dist/node/src/modules/crons.js +12 -8
  11. package/dist/node/src/modules/crons.js.map +1 -1
  12. package/dist/node/src/modules/queues.js +23 -12
  13. package/dist/node/src/modules/queues.js.map +1 -1
  14. package/dist/node/src/modules/reports.js +10 -9
  15. package/dist/node/src/modules/reports.js.map +1 -1
  16. package/dist/node/src/modules/tasks.base.js.map +1 -1
  17. package/dist/node/src/modules/tasks.js +59 -21
  18. package/dist/node/src/modules/tasks.js.map +1 -1
  19. package/dist/node/src/modules/tasks.public.js +3 -1
  20. package/dist/node/src/modules/tasks.public.js.map +1 -1
  21. package/dist/node/{modules/history.js → src/modules/tasksActivity.js} +13 -11
  22. package/dist/node/src/modules/tasksActivity.js.map +1 -0
  23. package/dist/node/src/modules/tasksActivity.public.js +6 -0
  24. package/dist/node/src/modules/tasksActivity.public.js.map +1 -0
  25. package/dist/node/src/modules/templates.js +23 -22
  26. package/dist/node/src/modules/templates.js.map +1 -1
  27. package/dist/types/{index.d.ts → src/index.d.ts} +5 -2
  28. package/dist/types/{lib → src/lib}/promises.d.ts +1 -0
  29. package/dist/types/{modules → src/modules}/crons.d.ts +8 -8
  30. package/dist/types/{modules → src/modules}/queues.d.ts +12 -12
  31. package/dist/types/{modules → src/modules}/reports.d.ts +15 -14
  32. package/dist/types/{modules → src/modules}/tasks.d.ts +65 -23
  33. package/dist/types/src/modules/tasks.public.d.ts +2 -0
  34. package/dist/types/src/modules/tasksActivity.d.ts +38 -0
  35. package/dist/types/src/modules/tasksActivity.public.d.ts +5 -0
  36. package/dist/types/{modules → src/modules}/templates.d.ts +37 -21
  37. package/package.json +12 -10
  38. package/dist/node/index.js +0 -38
  39. package/dist/node/index.js.map +0 -1
  40. package/dist/node/lib/axios.js +0 -91
  41. package/dist/node/lib/axios.js.map +0 -1
  42. package/dist/node/lib/promises.js +0 -26
  43. package/dist/node/lib/promises.js.map +0 -1
  44. package/dist/node/lib/utils.js +0 -24
  45. package/dist/node/lib/utils.js.map +0 -1
  46. package/dist/node/modules/auth.js +0 -61
  47. package/dist/node/modules/auth.js.map +0 -1
  48. package/dist/node/modules/crons.js +0 -105
  49. package/dist/node/modules/crons.js.map +0 -1
  50. package/dist/node/modules/health.js +0 -52
  51. package/dist/node/modules/health.js.map +0 -1
  52. package/dist/node/modules/history.js.map +0 -1
  53. package/dist/node/modules/institutions.js +0 -61
  54. package/dist/node/modules/institutions.js.map +0 -1
  55. package/dist/node/modules/queues.js +0 -128
  56. package/dist/node/modules/queues.js.map +0 -1
  57. package/dist/node/modules/reports.js +0 -261
  58. package/dist/node/modules/reports.js.map +0 -1
  59. package/dist/node/modules/setup.js +0 -35
  60. package/dist/node/modules/setup.js.map +0 -1
  61. package/dist/node/modules/tasks.js +0 -187
  62. package/dist/node/modules/tasks.js.map +0 -1
  63. package/dist/node/modules/templates.js +0 -28
  64. package/dist/node/modules/templates.js.map +0 -1
  65. package/dist/types/modules/institutions.d.ts +0 -56
  66. package/dist/types/modules/tasks.public.d.ts +0 -2
  67. /package/dist/types/{lib → src/lib}/axios.d.ts +0 -0
  68. /package/dist/types/{lib → src/lib}/utils.d.ts +0 -0
  69. /package/dist/types/{modules → src/modules}/auth.d.ts +0 -0
  70. /package/dist/types/{modules → src/modules}/auth.public.d.ts +0 -0
  71. /package/dist/types/{modules → src/modules}/crons.public.d.ts +0 -0
  72. /package/dist/types/{modules → src/modules}/health.d.ts +0 -0
  73. /package/dist/types/{modules → src/modules}/health.public.d.ts +0 -0
  74. /package/dist/types/{modules → src/modules}/history.d.ts +0 -0
  75. /package/dist/types/{modules → src/modules}/history.public.d.ts +0 -0
  76. /package/dist/types/{modules → src/modules}/namespaces.d.ts +0 -0
  77. /package/dist/types/{modules → src/modules}/namespaces.public.d.ts +0 -0
  78. /package/dist/types/{modules → src/modules}/queues.public.d.ts +0 -0
  79. /package/dist/types/{modules → src/modules}/reports.public.d.ts +0 -0
  80. /package/dist/types/{modules → src/modules}/setup.d.ts +0 -0
  81. /package/dist/types/{modules → src/modules}/setup.public.d.ts +0 -0
  82. /package/dist/types/{modules → src/modules}/tasks.base.d.ts +0 -0
  83. /package/dist/types/{modules → src/modules}/templates.public.d.ts +0 -0
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getInstitution = exports.getInstitutions = void 0;
27
- const date_fns_1 = require("date-fns");
28
- const axios_1 = __importDefault(require("../lib/axios"));
29
- /**
30
- * Transform raw data from JSON, to JS usable data
31
- *
32
- * @param institution Raw institution
33
- *
34
- * @returns Parsed institution
35
- */
36
- const parseInstitution = (institution) => (Object.assign(Object.assign({}, institution), { createdAt: (0, date_fns_1.parseISO)(institution.createdAt), updatedAt: institution.updatedAt ? (0, date_fns_1.parseISO)(institution.updatedAt) : undefined, sushiReadySince: institution.sushiReadySince ? (0, date_fns_1.parseISO)(institution.sushiReadySince) : undefined }));
37
- /**
38
- * Get all available institutions for authed user
39
- *
40
- * Needs `institutions-get` permission
41
- *
42
- * @returns Available institutions
43
- */
44
- const getInstitutions = () => __awaiter(void 0, void 0, void 0, function* () {
45
- const _a = yield axios_1.default.$get('/institutions'), { content } = _a, response = __rest(_a, ["content"]);
46
- return Object.assign(Object.assign({}, response), { content: content.map(parseInstitution) });
47
- });
48
- exports.getInstitutions = getInstitutions;
49
- /**
50
- * Get specific institution that is available for authed user
51
- *
52
- * Needs `institutions-get-id` permission
53
- *
54
- * @returns Available institution
55
- */
56
- const getInstitution = (id) => __awaiter(void 0, void 0, void 0, function* () {
57
- const _b = yield axios_1.default.$get(`/institutions/${id}`), { content } = _b, response = __rest(_b, ["content"]);
58
- return Object.assign(Object.assign({}, response), { content: parseInstitution(content) });
59
- });
60
- exports.getInstitution = getInstitution;
61
- //# sourceMappingURL=institutions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"institutions.js","sourceRoot":"","sources":["../../../src/modules/institutions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,yDAAuD;AA0CvD;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAC,WAA2B,EAAe,EAAE,CAAC,iCAClE,WAAW,KACd,SAAS,EAAE,IAAA,mBAAQ,EAAC,WAAW,CAAC,SAAS,CAAC,EAC1C,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAC9E,eAAe,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,IAChG,CAAC;AAEH;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,GAA8C,EAAE;IAC7E,MAAM,KAA2B,MAAM,eAAK,CAAC,IAAI,CAAmB,eAAe,CAAC,EAA9E,EAAE,OAAO,OAAqE,EAAhE,QAAQ,cAAtB,WAAwB,CAAsD,CAAC;IACrF,uCACK,QAAQ,KACX,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IACtC;AACJ,CAAC,CAAA,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAO,EAAqB,EAAqC,EAAE;IAC/F,MAAM,KAA2B,MAAM,eAAK,CAAC,IAAI,CAAiB,iBAAiB,EAAE,EAAE,CAAC,EAAlF,EAAE,OAAO,OAAyE,EAApE,QAAQ,cAAtB,WAAwB,CAA0D,CAAC;IACzF,uCACK,QAAQ,KACX,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,IAClC;AACJ,CAAC,CAAA,CAAC;AANW,QAAA,cAAc,kBAMzB"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.retryJob = exports.getJob = exports.resumeQueue = exports.pauseQueue = exports.getQueue = exports.getAllQueues = void 0;
27
- const date_fns_1 = require("date-fns");
28
- const axios_1 = __importDefault(require("../lib/axios"));
29
- /**
30
- * Transform raw data from JSON, to JS usable data
31
- *
32
- * @param job Raw job
33
- *
34
- * @returns Parsed job
35
- */
36
- const parseFullJob = (job) => (Object.assign(Object.assign({}, job), { added: (0, date_fns_1.parseISO)(job.added), started: job.started ? (0, date_fns_1.parseISO)(job.started) : undefined, ended: job.ended ? (0, date_fns_1.parseISO)(job.ended) : undefined }));
37
- /**
38
- * Transform raw data from JSON, to JS usable data
39
- *
40
- * @param queue Raw queue
41
- *
42
- * @returns Parsed queue
43
- */
44
- const parseQueue = (queue) => (Object.assign(Object.assign({}, queue), { jobs: queue.jobs.map(parseFullJob) }));
45
- /**
46
- * Get all available queues
47
- *
48
- * Needs `queues-get` permission
49
- *
50
- * @returns All queues' names
51
- */
52
- const getAllQueues = () => axios_1.default.$get('/queues');
53
- exports.getAllQueues = getAllQueues;
54
- /**
55
- * Get queue info
56
- *
57
- * Needs `queues-get-queue` permission
58
- *
59
- * @param queueName Name of the queue
60
- *
61
- * @returns queue info
62
- */
63
- const getQueue = (queueName) => __awaiter(void 0, void 0, void 0, function* () {
64
- const _a = yield axios_1.default.$get(`/queues/${queueName}`), { content } = _a, response = __rest(_a, ["content"]);
65
- return Object.assign(Object.assign({}, response), { content: parseQueue(content) });
66
- });
67
- exports.getQueue = getQueue;
68
- /**
69
- * Pause queue
70
- *
71
- * Needs `queues-put-queue-pause` permission
72
- *
73
- * @param queueName Name of the queue
74
- *
75
- * @returns queue info
76
- */
77
- const pauseQueue = (queueName) => __awaiter(void 0, void 0, void 0, function* () {
78
- const _b = yield axios_1.default.$put(`/queues/${queueName}/pause`), { content } = _b, response = __rest(_b, ["content"]);
79
- return Object.assign(Object.assign({}, response), { content: parseQueue(content) });
80
- });
81
- exports.pauseQueue = pauseQueue;
82
- /**
83
- * Resume queue
84
- *
85
- * Needs `queues-put-queue-resume` permission
86
- *
87
- * @param queueName Name of the queue
88
- *
89
- * @returns queue info
90
- */
91
- const resumeQueue = (queueName) => __awaiter(void 0, void 0, void 0, function* () {
92
- const _c = yield axios_1.default.$put(`/queues/${queueName}/resume`), { content } = _c, response = __rest(_c, ["content"]);
93
- return Object.assign(Object.assign({}, response), { content: parseQueue(content) });
94
- });
95
- exports.resumeQueue = resumeQueue;
96
- /**
97
- * Get job info
98
- *
99
- * Needs `queues-get-queue-jobId` permission
100
- *
101
- * @param queueName Name of queue where job is
102
- * @param jobId Id of the job in queue
103
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
104
- *
105
- * @returns Job full info
106
- */
107
- const getJob = (queueName, jobId, institution) => __awaiter(void 0, void 0, void 0, function* () {
108
- const _d = yield axios_1.default.$get(`/queues/${queueName}/${jobId}`, { params: { institution } }), { content } = _d, response = __rest(_d, ["content"]);
109
- return Object.assign(Object.assign({}, response), { content: parseFullJob(content) });
110
- });
111
- exports.getJob = getJob;
112
- /**
113
- * Retry job that failed
114
- *
115
- * Needs `queues-post-queue-jobId-retry` permission
116
- *
117
- * @param queueName Name of queue where job is
118
- * @param jobId Id of the job in queue
119
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
120
- *
121
- * @returns queue info
122
- */
123
- const retryJob = (queueName, jobId, institution) => __awaiter(void 0, void 0, void 0, function* () {
124
- const _e = yield axios_1.default.$post(`/queues/${queueName}/${jobId}/retry`, { params: { institution } }), { content } = _e, response = __rest(_e, ["content"]);
125
- return Object.assign(Object.assign({}, response), { content: parseFullJob(content) });
126
- });
127
- exports.retryJob = retryJob;
128
- //# sourceMappingURL=queues.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queues.js","sourceRoot":"","sources":["../../../src/modules/queues.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,yDAAuD;AAmCvD;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CACnB,GAA6B,EACN,EAAE,CAAC,iCACrB,GAAG,KACN,KAAK,EAAE,IAAA,mBAAQ,EAAC,GAAG,CAAC,KAAK,CAAC,EAC1B,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,EACxD,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAClD,CAAC;AAWL;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CACjB,KAA6B,EACR,EAAE,CAAC,iCACnB,KAAK,KACR,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAClC,CAAC;AAEL;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,eAAK,CAAC,IAAI,CAAW,SAAS,CAAC,CAAC;AAArD,QAAA,YAAY,gBAAyC;AAElE;;;;;;;;GAQG;AACI,MAAM,QAAQ,GAAG,CACtB,SAA6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C1I,uCACK,QAAQ,KACX,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,IAC9B;AACJ,CAAC,CAAA,CAAC;AAVW,QAAA,MAAM,UAUjB;AAEF;;;;;;;;;;GAUG;AACI,MAAM,QAAQ,GAAG,CACtB,SAA6B,EAC7B,KAAsB,EACtB,WAAoB,EACyB,EAAE;IAC/C,MAAM,KAA2B,MAAM,eAAK,CAAC,KAAK,CAA2B,WAAW,SAAS,IAAI,KAAK,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC,EAA1I,EAAE,OAAO,OAAiI,EAA5H,QAAQ,cAAtB,WAAwB,CAAkH,CAAC;IACjJ,uCACK,QAAQ,KACX,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,IAC9B;AACJ,CAAC,CAAA,CAAC;AAVW,QAAA,QAAQ,YAUnB"}
@@ -1,261 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.getReportDebugByJob = exports.getReportDebugByName = exports.getReportDetailByJob = exports.getReportDetailByName = exports.getReportFileByJob = exports.getReportFileByName = exports.startAndListenGeneration = exports.startGeneration = void 0;
39
- const date_fns_1 = require("date-fns");
40
- const axios_1 = __importStar(require("../lib/axios"));
41
- const promises_1 = __importDefault(require("../lib/promises"));
42
- const utils_1 = require("../lib/utils");
43
- const queues_1 = require("./queues");
44
- /**
45
- * Transform raw data from JSON, to JS usable data
46
- *
47
- * @param detail Raw result detail
48
- *
49
- * @returns Parsed result detail
50
- */
51
- const parseReportResultDetail = (detail) => (Object.assign(Object.assign({}, detail), { createdAt: (0, date_fns_1.parseISO)(detail.createdAt), destroyAt: (0, date_fns_1.parseISO)(detail.destroyAt), period: detail.period ? (0, utils_1.parsePeriod)(detail.period) : undefined }));
52
- /**
53
- * Transform raw data from JSON, to JS usable data
54
- *
55
- * @param result Raw result
56
- *
57
- * @returns Parsed result
58
- */
59
- const parseReportResult = (result) => (Object.assign(Object.assign({}, result), { detail: parseReportResultDetail(result.detail) }));
60
- /**
61
- * Start generation of a report
62
- *
63
- * Needs `tasks-post-task-run` permission
64
- *
65
- * @param taskId Id of the task
66
- * @param params Other params for overriding default
67
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
68
- *
69
- * @returns Job info to track progress
70
- */
71
- const startGeneration = (taskId, params, institution) => {
72
- var _a, _b;
73
- return axios_1.default.$post(`/tasks/${taskId}/run`, null, {
74
- params: {
75
- test_emails: params === null || params === void 0 ? void 0 : params.testEmails,
76
- period_start: (_a = params === null || params === void 0 ? void 0 : params.period) === null || _a === void 0 ? void 0 : _a.start,
77
- period_end: (_b = params === null || params === void 0 ? void 0 : params.period) === null || _b === void 0 ? void 0 : _b.end,
78
- institution,
79
- },
80
- });
81
- };
82
- exports.startGeneration = startGeneration;
83
- /**
84
- * Start generation of a report and track progress
85
- *
86
- * Needs `tasks-post-task-run` & `queues-get-queue-jobId` permissions
87
- *
88
- * @param taskId Id of the task
89
- * @param params Other params for overriding default
90
- * @param institution Force institution
91
- *
92
- * @fires #started When generation started. Contains job's id and queue.
93
- * @fires #progress When generation progress. Contains job's progress (>= 0 & <= 1) & status
94
- *
95
- * @throws If job's fails. **Not if generation fails !**
96
- *
97
- * @returns When generation ends, with detail
98
- */
99
- const startAndListenGeneration = (...p) => (0, promises_1.default)((events) => __awaiter(void 0, void 0, void 0, function* () {
100
- const { content: { id, queue } } = yield (0, exports.startGeneration)(...p);
101
- events.emit('started', { id, queue });
102
- // Pulling updates
103
- // TODO[feat]: WS ?
104
- let last;
105
- do {
106
- const { content: { progress, status, result, },
107
- // FIXME: What if param order changes ?
108
- // eslint-disable-next-line no-await-in-loop
109
- } = yield (0, queues_1.getJob)(queue, id, p[2]);
110
- last = { progress, status, result };
111
- events.emit('progress', { progress, status });
112
- let sleepDuration = 1000;
113
- if (last.status === 'active') {
114
- sleepDuration = 250;
115
- }
116
- // eslint-disable-next-line no-await-in-loop
117
- yield (0, utils_1.setTimeoutAsync)(sleepDuration);
118
- } while ((['completed', 'failed', 'stuck']).includes(last.status) === false);
119
- if (!last.result) {
120
- throw new Error('Generation failed with weird error');
121
- }
122
- return parseReportResult(last.result);
123
- }));
124
- exports.startAndListenGeneration = startAndListenGeneration;
125
- /**
126
- * Get report's related file
127
- *
128
- * Needs `reports-get-year-yearMonth-filename` permission
129
- *
130
- * @param pathName Path to the file
131
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
132
- * @param responseType Wanted response type
133
- *
134
- * @returns The file's content
135
- */
136
- const getFile = (pathName, institution, responseType) => __awaiter(void 0, void 0, void 0, function* () {
137
- return (yield (0, axios_1.axiosWithErrorFormatter)('get', `/reports/${pathName}`, {
138
- responseType,
139
- params: { institution },
140
- })).data;
141
- });
142
- /**
143
- * Get report main file (the result) by giving the report's name
144
- *
145
- * Needs `reports-get-year-yearMonth-filename` permission
146
- *
147
- * @param name Name of the report
148
- * @param ext The extension of the result (renderer dependent)
149
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
150
- * @param responseType Wanted response type
151
- *
152
- * @returns The report's content
153
- */
154
- const getReportFileByName = (name, institution, responseType, ext = 'pdf') => getFile(`${name}.rep.${ext}`, institution, responseType);
155
- exports.getReportFileByName = getReportFileByName;
156
- /**
157
- * Get report main file (the result) by giving job's info
158
- *
159
- * Needs `reports-get-year-yearMonth-filename` permission
160
- *
161
- * @param queueName Name of queue where job is
162
- * @param jobId Id of the job in queue
163
- * @param institution Force institution
164
- * @param responseType Wanted response type
165
- *
166
- * @returns The report's content
167
- */
168
- const getReportFileByJob = (queueName, jobId, institution, responseType) => __awaiter(void 0, void 0, void 0, function* () {
169
- var _a, _b;
170
- const { content: { result } } = yield (0, queues_1.getJob)(queueName, jobId, institution);
171
- if (!result) {
172
- throw new Error('Job have no result');
173
- }
174
- return getFile((_b = (_a = result.detail) === null || _a === void 0 ? void 0 : _a.files.report) !== null && _b !== void 0 ? _b : '', institution, responseType);
175
- });
176
- exports.getReportFileByJob = getReportFileByJob;
177
- /**
178
- * Get report detail by giving the report's name
179
- *
180
- * Needs `reports-get-year-yearMonth-filename` permission
181
- *
182
- * @param name Name of the report
183
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
184
- * @param responseType Wanted response type. **If provided with anything but `json` you will have to
185
- * cast in your type to avoid auto-completion issues.**
186
- *
187
- * @returns The detail's content
188
- */
189
- const getReportDetailByName = (name, institution, responseType) => __awaiter(void 0, void 0, void 0, function* () {
190
- const res = yield getFile(`${name}.det.json`, institution, responseType);
191
- if (!responseType || responseType === 'json') {
192
- return parseReportResult(res);
193
- }
194
- // Allowing user to ask for other response type (and then cast in wanted type)
195
- // while not breaking auto-completion
196
- return res;
197
- });
198
- exports.getReportDetailByName = getReportDetailByName;
199
- /**
200
- * Get report detail by giving job's info
201
- *
202
- * Needs `reports-get-year-yearMonth-filename` permission
203
- *
204
- * @param queueName Name of queue where job is
205
- * @param jobId Id of the job in queue
206
- * @param institution Force institution
207
- * @param responseType Wanted response type. **If provided with anything but `json` you will have to
208
- * cast in your type to avoid auto-completion issues.**
209
- *
210
- * @returns The detail's content
211
- */
212
- const getReportDetailByJob = (queueName, jobId, institution, responseType) => __awaiter(void 0, void 0, void 0, function* () {
213
- var _c, _d;
214
- const { content: { result } } = yield (0, queues_1.getJob)(queueName, jobId, institution);
215
- if (!result) {
216
- throw new Error('Job have no result');
217
- }
218
- const res = yield getFile((_d = (_c = result.detail) === null || _c === void 0 ? void 0 : _c.files.detail) !== null && _d !== void 0 ? _d : '', institution, responseType);
219
- if (!responseType || responseType === 'json') {
220
- return parseReportResult(res);
221
- }
222
- // Allowing user to ask for other response type (and then use `as`)
223
- // while not breaking auto-completion
224
- return res;
225
- });
226
- exports.getReportDetailByJob = getReportDetailByJob;
227
- /**
228
- * Get report debug file by giving the report's name
229
- *
230
- * Needs `reports-get-year-yearMonth-filename` permission
231
- *
232
- * @param name Name of the report
233
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
234
- * @param responseType Wanted response type
235
- *
236
- * @returns The debug's content
237
- */
238
- const getReportDebugByName = (name, institution, responseType) => getFile(`${name}.deb.json`, institution, responseType);
239
- exports.getReportDebugByName = getReportDebugByName;
240
- /**
241
- * Get report debug file by giving job's info
242
- *
243
- * Needs `reports-get-year-yearMonth-filename` permission
244
- *
245
- * @param queueName Name of queue where job is
246
- * @param jobId Id of the job in queue
247
- * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
248
- * @param responseType Wanted response type
249
- *
250
- * @returns The debug's content
251
- */
252
- const getReportDebugByJob = (queueName, jobId, institution, responseType) => __awaiter(void 0, void 0, void 0, function* () {
253
- var _e, _f;
254
- const { content: { result } } = yield (0, queues_1.getJob)(queueName, jobId, institution);
255
- if (!result) {
256
- throw new Error('Job have no result');
257
- }
258
- return getFile((_f = (_e = result.detail) === null || _e === void 0 ? void 0 : _e.files.debug) !== null && _f !== void 0 ? _f : '', institution, responseType);
259
- });
260
- exports.getReportDebugByJob = getReportDebugByJob;
261
- //# sourceMappingURL=reports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reports.js","sourceRoot":"","sources":["../../../src/modules/reports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AAGpC,sDAA8D;AAC9D,+DAAqD;AACrD,wCAKsB;AACtB,qCAA0D;AA8B1D;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,CAAC,MAA6B,EAAsB,EAAE,CAAC,iCAClF,MAAM,KACT,SAAS,EAAE,IAAA,mBAAQ,EAAC,MAAM,CAAC,SAAS,CAAC,EACrC,SAAS,EAAE,IAAA,mBAAQ,EAAC,MAAM,CAAC,SAAS,CAAC,EACrC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAC9D,CAAC;AAWH;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,CAAC,MAAuB,EAAgB,EAAE,CAAC,iCAChE,MAAM,KACT,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,IAC9C,CAAC;AAaH;;;;;;;;;;GAUG;AACI,MAAM,eAAe,GAAG,CAC7B,MAAyB,EACzB,MAUC,EACD,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AC/B;IACD,mEAAmE;IACnE,qCAAqC;IACrC,OAAO,GAA8B,CAAC;AACxC,CAAC,CAAA,CAAC;AArBW,QAAA,oBAAoB,wBAqB/B;AAEF;;;;;;;;;;GAUG;AACI,MAAM,oBAAoB,GAAG,CAClC,IAAY,EACZ,WAAoB,EACpB,YAAqB,EACrB,EAAE,CAAC,OAAO,CAA0B,GAAG,IAAI,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AAJxE,QAAA,oBAAoB,wBAIoD;AAErF;;;;;;;;;;;GAWG;AACI,MAAM,mBAAmB,GAAG,CACjC,SAA0B,EAC1B,KAAsB,EACtB,WAA6B,EAC7B,YAAqB,EACrB,EAAE;;IACF,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,IAAA,eAAM,EAC1C,SAAS,EACT,KAAK,EACL,WAAW,CACZ,CAAC;IACF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;IACD,OAAO,OAAO,CAA0B,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,KAAK,CAAC,KAAK,mCAAI,EAAE,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AACvG,CAAC,CAAA,CAAC;AAfW,QAAA,mBAAmB,uBAe9B"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isURLset = exports.unsetURL = exports.setURL = exports.logout = exports.login = exports.isLogged = void 0;
7
- const axios_1 = __importDefault(require("../lib/axios"));
8
- var auth_1 = require("./auth");
9
- Object.defineProperty(exports, "isLogged", { enumerable: true, get: function () { return auth_1.isLogged; } });
10
- Object.defineProperty(exports, "login", { enumerable: true, get: function () { return auth_1.login; } });
11
- Object.defineProperty(exports, "logout", { enumerable: true, get: function () { return auth_1.logout; } });
12
- /**
13
- * Set API url to axios
14
- *
15
- * @param url The url
16
- */
17
- const setURL = (url) => {
18
- axios_1.default.defaults.baseURL = url;
19
- };
20
- exports.setURL = setURL;
21
- /**
22
- * Unset API url from axios
23
- */
24
- const unsetURL = () => {
25
- axios_1.default.defaults.baseURL = undefined;
26
- };
27
- exports.unsetURL = unsetURL;
28
- /**
29
- * Check if API url is setup in axios.
30
- *
31
- * @returns If API url is setup
32
- */
33
- const isURLset = () => !!axios_1.default.defaults.baseURL;
34
- exports.isURLset = isURLset;
35
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/modules/setup.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiC;AAEjC,+BAAiD;AAAxC,gGAAA,QAAQ,OAAA;AAAE,6FAAA,KAAK,OAAA;AAAE,8FAAA,MAAM,OAAA;AAEhC;;;;GAIG;AACI,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE;IACpC,eAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,GAAG,CAAC;AAC/B,CAAC,CAAC;AAFW,QAAA,MAAM,UAEjB;AAEF;;GAEG;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,eAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB;AAEF;;;;GAIG;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;AAA1C,QAAA,QAAQ,YAAkC"}