@ezpaarse-project/ezreeport-sdk-js 1.0.0-beta.1 → 1.0.0-beta.2

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 (87) hide show
  1. package/dist/browser/ezreeport-sdk-js.mjs +50 -49
  2. package/dist/browser/ezreeport-sdk-js.mjs.map +1 -1
  3. package/dist/browser/ezreeport-sdk-js.umd.js +2 -2
  4. package/dist/browser/ezreeport-sdk-js.umd.js.map +1 -1
  5. package/dist/node/index.js +38 -0
  6. package/dist/node/index.js.map +1 -0
  7. package/dist/node/lib/axios.js +91 -0
  8. package/dist/node/lib/axios.js.map +1 -0
  9. package/dist/node/lib/promises.js +26 -0
  10. package/dist/node/lib/promises.js.map +1 -0
  11. package/dist/node/lib/utils.js +24 -0
  12. package/dist/node/lib/utils.js.map +1 -0
  13. package/dist/node/modules/auth.js +61 -0
  14. package/dist/node/modules/auth.js.map +1 -0
  15. package/dist/node/modules/crons.js +105 -0
  16. package/dist/node/modules/crons.js.map +1 -0
  17. package/dist/node/modules/health.js +52 -0
  18. package/dist/node/modules/health.js.map +1 -0
  19. package/dist/node/modules/history.js +60 -0
  20. package/dist/node/modules/history.js.map +1 -0
  21. package/dist/node/modules/institutions.js +61 -0
  22. package/dist/node/modules/institutions.js.map +1 -0
  23. package/dist/node/modules/queues.js +128 -0
  24. package/dist/node/modules/queues.js.map +1 -0
  25. package/dist/node/modules/reports.js +261 -0
  26. package/dist/node/modules/reports.js.map +1 -0
  27. package/dist/node/modules/setup.js +35 -0
  28. package/dist/node/modules/setup.js.map +1 -0
  29. package/dist/node/modules/tasks.js +187 -0
  30. package/dist/node/modules/tasks.js.map +1 -0
  31. package/dist/node/modules/templates.js +28 -0
  32. package/dist/node/modules/templates.js.map +1 -0
  33. package/dist/node/package.json +2 -2
  34. package/dist/node/src/index.js +39 -0
  35. package/dist/node/src/index.js.map +1 -0
  36. package/dist/node/src/lib/axios.js +91 -0
  37. package/dist/node/src/lib/axios.js.map +1 -0
  38. package/dist/node/src/lib/promises.js +41 -0
  39. package/dist/node/src/lib/promises.js.map +1 -0
  40. package/dist/node/src/lib/utils.js +24 -0
  41. package/dist/node/src/lib/utils.js.map +1 -0
  42. package/dist/node/src/modules/auth.js +111 -0
  43. package/dist/node/src/modules/auth.js.map +1 -0
  44. package/dist/node/src/modules/auth.public.js +11 -0
  45. package/dist/node/src/modules/auth.public.js.map +1 -0
  46. package/dist/node/src/modules/crons.js +105 -0
  47. package/dist/node/src/modules/crons.js.map +1 -0
  48. package/dist/node/src/modules/crons.public.js +10 -0
  49. package/dist/node/src/modules/crons.public.js.map +1 -0
  50. package/dist/node/src/modules/health.js +60 -0
  51. package/dist/node/src/modules/health.js.map +1 -0
  52. package/dist/node/src/modules/health.public.js +9 -0
  53. package/dist/node/src/modules/health.public.js.map +1 -0
  54. package/dist/node/src/modules/history.js +62 -0
  55. package/dist/node/src/modules/history.js.map +1 -0
  56. package/dist/node/src/modules/history.public.js +6 -0
  57. package/dist/node/src/modules/history.public.js.map +1 -0
  58. package/dist/node/src/modules/namespaces.js +16 -0
  59. package/dist/node/src/modules/namespaces.js.map +1 -0
  60. package/dist/node/src/modules/namespaces.public.js +3 -0
  61. package/dist/node/src/modules/namespaces.public.js.map +1 -0
  62. package/dist/node/src/modules/queues.js +136 -0
  63. package/dist/node/src/modules/queues.js.map +1 -0
  64. package/dist/node/src/modules/queues.public.js +11 -0
  65. package/dist/node/src/modules/queues.public.js.map +1 -0
  66. package/dist/node/src/modules/reports.js +266 -0
  67. package/dist/node/src/modules/reports.js.map +1 -0
  68. package/dist/node/src/modules/reports.public.js +13 -0
  69. package/dist/node/src/modules/reports.public.js.map +1 -0
  70. package/dist/node/src/modules/setup.js +35 -0
  71. package/dist/node/src/modules/setup.js.map +1 -0
  72. package/dist/node/src/modules/setup.public.js +12 -0
  73. package/dist/node/src/modules/setup.public.js.map +1 -0
  74. package/dist/node/src/modules/tasks.base.js +51 -0
  75. package/dist/node/src/modules/tasks.base.js.map +1 -0
  76. package/dist/node/src/modules/tasks.js +183 -0
  77. package/dist/node/src/modules/tasks.js.map +1 -0
  78. package/dist/node/src/modules/tasks.public.js +15 -0
  79. package/dist/node/src/modules/tasks.public.js.map +1 -0
  80. package/dist/node/src/modules/templates.js +135 -0
  81. package/dist/node/src/modules/templates.js.map +1 -0
  82. package/dist/node/src/modules/templates.public.js +11 -0
  83. package/dist/node/src/modules/templates.public.js.map +1 -0
  84. package/dist/types/lib/promises.d.ts +9 -7
  85. package/dist/types/modules/reports.d.ts +5 -1
  86. package/package.json +1 -1
  87. package/CHANGELOG.md +0 -42
@@ -0,0 +1,128 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queues.js","sourceRoot":"","sources":["../../../src/modules/queues.ts"],"names":[],"mappings":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IACjJ,uCACK,QAAQ,KACX,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,IAC9B;AACJ,CAAC,CAAA,CAAC;AAVW,QAAA,QAAQ,YAUnB"}
@@ -0,0 +1,261 @@
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
@@ -0,0 +1 @@
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,WAAoB,EACpB,EAAE;;IAAC,OAAA,eAAK,CAAC,KAAK,CACd,UAAU,MAAM,MAAM,EACtB,IAAI,EACJ;QACE,MAAM,EAA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AqB/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"}
@@ -0,0 +1,35 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,187 @@
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 __rest = (this && this.__rest) || function (s, e) {
35
+ var t = {};
36
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
+ t[p] = s[p];
38
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
+ t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.disableTask = exports.enableTask = exports.deleteTask = exports.updateTask = exports.getTask = exports.createTask = exports.getAllTasks = exports.Recurrence = void 0;
47
+ const date_fns_1 = require("date-fns");
48
+ const axios_1 = __importStar(require("../lib/axios"));
49
+ const history_1 = require("./history");
50
+ var Recurrence;
51
+ (function (Recurrence) {
52
+ Recurrence["DAILY"] = "DAILY";
53
+ Recurrence["WEEKLY"] = "WEEKLY";
54
+ Recurrence["MONTHLY"] = "MONTHLY";
55
+ Recurrence["QUARTERLY"] = "QUARTERLY";
56
+ Recurrence["BIENNIAL"] = "BIENNIAL";
57
+ Recurrence["YEARLY"] = "YEARLY";
58
+ })(Recurrence = exports.Recurrence || (exports.Recurrence = {}));
59
+ /**
60
+ * Transform raw data from JSON, to JS usable data
61
+ *
62
+ * @param task Raw task
63
+ *
64
+ * @returns Parsed task
65
+ */
66
+ const parseTask = (task) => (Object.assign(Object.assign({}, task), { nextRun: (0, date_fns_1.parseISO)(task.nextRun), lastRun: task.lastRun ? (0, date_fns_1.parseISO)(task.lastRun) : undefined, createdAt: (0, date_fns_1.parseISO)(task.createdAt), updatedAt: task.updatedAt ? (0, date_fns_1.parseISO)(task.updatedAt) : undefined }));
67
+ /**
68
+ * Transform raw data from JSON, to JS usable data
69
+ *
70
+ * @param task Raw task
71
+ *
72
+ * @returns Parsed task
73
+ */
74
+ const parseFullTask = (task) => {
75
+ const { template, targets, history } = task, rawTask = __rest(task, ["template", "targets", "history"]);
76
+ return Object.assign(Object.assign({}, parseTask(rawTask)), { history: history.map(history_1.parseHistory), template,
77
+ targets });
78
+ };
79
+ /**
80
+ * Get all available tasks
81
+ *
82
+ * Needs `tasks-get` permission
83
+ *
84
+ * @param paginationOpts Options for pagination
85
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
86
+ *
87
+ * @returns All tasks' info
88
+ */
89
+ const getAllTasks = (paginationOpts, institution) => __awaiter(void 0, void 0, void 0, function* () {
90
+ const _a = (yield (0, axios_1.axiosWithErrorFormatter)('get', '/tasks', {
91
+ params: Object.assign({ institution }, (paginationOpts !== null && paginationOpts !== void 0 ? paginationOpts : {})),
92
+ })).data, { content } = _a, response = __rest(_a, ["content"]);
93
+ return Object.assign(Object.assign({}, response), { content: content.map(parseTask) });
94
+ });
95
+ exports.getAllTasks = getAllTasks;
96
+ /**
97
+ * Create a new task
98
+ *
99
+ * Needs `tasks-post` permission
100
+ *
101
+ * @param task Task's data
102
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
103
+ *
104
+ * @returns Created task's info
105
+ */
106
+ const createTask = (task, institution) => __awaiter(void 0, void 0, void 0, function* () {
107
+ const _b = yield axios_1.default.$post('/tasks', task, { params: { institution } }), { content } = _b, response = __rest(_b, ["content"]);
108
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
109
+ });
110
+ exports.createTask = createTask;
111
+ /**
112
+ * Get task info
113
+ *
114
+ * Needs `tasks-get-task` permission
115
+ *
116
+ * @param id Task's id
117
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
118
+ *
119
+ * @returns Task's info
120
+ */
121
+ const getTask = (id, institution) => __awaiter(void 0, void 0, void 0, function* () {
122
+ const _c = yield axios_1.default.$get(`/tasks/${id}`, { params: { institution } }), { content } = _c, response = __rest(_c, ["content"]);
123
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
124
+ });
125
+ exports.getTask = getTask;
126
+ /**
127
+ * Update a task
128
+ *
129
+ * Needs `tasks-put-task` permission
130
+ *
131
+ * @param id Task's id
132
+ * @param task New Task's data
133
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
134
+ *
135
+ * @returns Updated Task's info
136
+ */
137
+ const updateTask = (id, task, institution) => __awaiter(void 0, void 0, void 0, function* () {
138
+ const _d = yield axios_1.default.$put(`/tasks/${id}`, task, { params: { institution } }), { content } = _d, response = __rest(_d, ["content"]);
139
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
140
+ });
141
+ exports.updateTask = updateTask;
142
+ /**
143
+ * Delete a task
144
+ *
145
+ * Needs `tasks-delete-task` permission
146
+ *
147
+ * @param id Task's id
148
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
149
+ *
150
+ * @returns Deleted Task's info
151
+ */
152
+ const deleteTask = (id, institution) => __awaiter(void 0, void 0, void 0, function* () {
153
+ const _e = yield axios_1.default.$delete(`/tasks/${id}`, { params: { institution } }), { content } = _e, response = __rest(_e, ["content"]);
154
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
155
+ });
156
+ exports.deleteTask = deleteTask;
157
+ /**
158
+ * Shorthand to enable task
159
+ *
160
+ * Needs `tasks-put-task-enable` permission
161
+ *
162
+ * @param id Task's id
163
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
164
+ *
165
+ * @returns Updated task's info
166
+ */
167
+ const enableTask = (id, institution) => __awaiter(void 0, void 0, void 0, function* () {
168
+ const _f = yield axios_1.default.$put(`/tasks/${id}/enable`, undefined, { params: { institution } }), { content } = _f, response = __rest(_f, ["content"]);
169
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
170
+ });
171
+ exports.enableTask = enableTask;
172
+ /**
173
+ * Shorthand to disable task
174
+ *
175
+ * Needs `tasks-put-task-disable` permission
176
+ *
177
+ * @param id Task's id
178
+ * @param institution Force institution. Only available for SUPER_USERS, otherwise it'll be ignored.
179
+ *
180
+ * @returns Updated task's info
181
+ */
182
+ const disableTask = (id, institution) => __awaiter(void 0, void 0, void 0, function* () {
183
+ const _g = yield axios_1.default.$put(`/tasks/${id}/disable`, undefined, { params: { institution } }), { content } = _g, response = __rest(_g, ["content"]);
184
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
185
+ });
186
+ exports.disableTask = disableTask;
187
+ //# sourceMappingURL=tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/modules/tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,sDAA2G;AAC3G,uCAAwE;AAGxE,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,6BAAe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AAO,CAAC,IAC/B;AACJ,CAAC,CAAA,CAAC;AAdW,QAAA,WAAW,eActB"}
@@ -0,0 +1,28 @@
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.getTemplate = exports.getAllTemplates = void 0;
7
+ const axios_1 = __importDefault(require("../lib/axios"));
8
+ /**
9
+ * Get all available templates
10
+ *
11
+ * Needs `templates-get` permission
12
+ *
13
+ * @returns All templates' info
14
+ */
15
+ const getAllTemplates = () => axios_1.default.$get('/templates');
16
+ exports.getAllTemplates = getAllTemplates;
17
+ /**
18
+ * Get template info
19
+ *
20
+ * Needs `templates-get-name(*)` permission
21
+ *
22
+ * @param name Template's name
23
+ *
24
+ * @returns Template info
25
+ */
26
+ const getTemplate = (name) => axios_1.default.$get(`/templates/${name}`);
27
+ exports.getTemplate = getTemplate;
28
+ //# sourceMappingURL=templates.js.map