@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,183 @@
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.upsertTask = exports.getTask = exports.createTask = exports.getAllTasks = void 0;
47
+ const axios_1 = __importStar(require("../lib/axios"));
48
+ const history_1 = require("./history");
49
+ const tasks_base_1 = require("./tasks.base");
50
+ /**
51
+ * Transform raw data from JSON, to JS usable data
52
+ *
53
+ * @param task Raw task
54
+ *
55
+ * @returns Parsed task
56
+ */
57
+ const parseFullTask = (task) => {
58
+ const { history, template, targets } = task, rawTask = __rest(task, ["history", "template", "targets"]);
59
+ return Object.assign(Object.assign({}, (0, tasks_base_1.parseTaskWithNamespace)(rawTask)), { history: history.map(history_1.parseHistory), template,
60
+ targets });
61
+ };
62
+ /**
63
+ * Get all available tasks
64
+ *
65
+ * Needs `namespaces[namespaceId].tasks-get` permission
66
+ *
67
+ * @param paginationOpts Options for pagination
68
+ * @param namespaces
69
+ *
70
+ * @returns All tasks' info
71
+ */
72
+ const getAllTasks = (paginationOpts, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
73
+ const _a = (yield (0, axios_1.axiosWithErrorFormatter)('get', '/tasks', {
74
+ params: Object.assign({ namespaces }, (paginationOpts !== null && paginationOpts !== void 0 ? paginationOpts : {})),
75
+ })).data, { content } = _a, response = __rest(_a, ["content"]);
76
+ return Object.assign(Object.assign({}, response), { content: content.map(tasks_base_1.parseTask) });
77
+ });
78
+ exports.getAllTasks = getAllTasks;
79
+ /**
80
+ * Create a new task
81
+ *
82
+ * Needs `namespaces[namespaceId].tasks-post` permission
83
+ *
84
+ * @param task Task's data
85
+ * @param namespaces
86
+ *
87
+ * @returns Created task's info
88
+ */
89
+ const createTask = (task, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
90
+ const _b = yield axios_1.default.$post('/tasks', task, { params: { namespaces } }), { content } = _b, response = __rest(_b, ["content"]);
91
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
92
+ });
93
+ exports.createTask = createTask;
94
+ /**
95
+ * Get task info
96
+ *
97
+ * Needs `namespaces[namespaceId].tasks-get-task` permission
98
+ *
99
+ * @param id Task's id
100
+ * @param namespaces
101
+ *
102
+ * @returns Task's info
103
+ */
104
+ const getTask = (id, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
105
+ const _c = yield axios_1.default.$get(`/tasks/${id}`, { params: { namespaces } }), { content } = _c, response = __rest(_c, ["content"]);
106
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
107
+ });
108
+ exports.getTask = getTask;
109
+ /**
110
+ * Update or create a task
111
+ *
112
+ * Needs `namespaces[namespaceId].tasks-put-task` permission
113
+ *
114
+ * @param id Task's id
115
+ * @param task Task's data
116
+ * @param namespaces
117
+ *
118
+ * @returns Updated/Created Task's info
119
+ */
120
+ const upsertTask = (id, task, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
121
+ const _d = yield axios_1.default.$put(`/tasks/${id}`, task, { params: { namespaces } }), { content } = _d, response = __rest(_d, ["content"]);
122
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
123
+ });
124
+ exports.upsertTask = upsertTask;
125
+ /**
126
+ * Update a task
127
+ *
128
+ * Needs `namespaces[namespaceId].tasks-put-task` permission
129
+ *
130
+ * @param id Task's id
131
+ * @param task New Task's data
132
+ * @param namespaces
133
+ *
134
+ * @deprecated Use `upsertTask` instead
135
+ *
136
+ * @returns Updated Task's info
137
+ */
138
+ exports.updateTask = exports.upsertTask;
139
+ /**
140
+ * Delete a task
141
+ *
142
+ * Needs `namespaces[namespaceId].tasks-delete-task` permission
143
+ *
144
+ * @param id Task's id
145
+ * @param namespaces
146
+ *
147
+ * @returns Deleted Task's info
148
+ */
149
+ const deleteTask = (id, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
150
+ yield axios_1.default.$delete(`/tasks/${id}`, { params: { namespaces } });
151
+ });
152
+ exports.deleteTask = deleteTask;
153
+ /**
154
+ * Shorthand to enable task
155
+ *
156
+ * Needs `namespaces[namespaceId].tasks-put-task-enable` permission
157
+ *
158
+ * @param id Task's id
159
+ * @param namespaces
160
+ *
161
+ * @returns Updated task's info
162
+ */
163
+ const enableTask = (id, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
164
+ const _e = yield axios_1.default.$put(`/tasks/${id}/enable`, undefined, { params: { namespaces } }), { content } = _e, response = __rest(_e, ["content"]);
165
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
166
+ });
167
+ exports.enableTask = enableTask;
168
+ /**
169
+ * Shorthand to disable task
170
+ *
171
+ * Needs `namespaces[namespaceId].tasks-put-task-disable` permission
172
+ *
173
+ * @param id Task's id
174
+ * @param namespaces
175
+ *
176
+ * @returns Updated task's info
177
+ */
178
+ const disableTask = (id, namespaces) => __awaiter(void 0, void 0, void 0, function* () {
179
+ const _f = yield axios_1.default.$put(`/tasks/${id}/disable`, undefined, { params: { namespaces } }), { content } = _f, response = __rest(_f, ["content"]);
180
+ return Object.assign(Object.assign({}, response), { content: parseFullTask(content) });
181
+ });
182
+ exports.disableTask = disableTask;
183
+ //# sourceMappingURL=tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../../src/modules/t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ClC,MAAM,KAA2B,MAAM,eAAK,CAAC,IAAI,CAC/C,UAAU,EAAE,SAAS,EACrB,SAAS,EACT,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,CAC3B,EAJK,EAAE,OAAO,OAId,EAJmB,QAAQ,cAAtB,WAAwB,CAI7B,CAAC;IAEF,uCACK,QAAQ,KACX,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,IAC/B;AACJ,CAAC,CAAA,CAAC;AAdW,QAAA,UAAU,cAcrB;AAEF;;;;;;;;;GASG;AACI,MAAM,WAAW,GAAG,CACzB,EAAc,EACd,UAA8B,EACE,EAAE;IAClC,MAAM,KAA2B,MAAM,eAAK,CAAC,IAAI,CAC/C,UAAU,EAAE,UAAU,EACtB,SAAS,EACT,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,CAC3B,EAJK,EAAE,OAAO,OAId,EAJmB,QAAQ,cAAtB,WAAwB,CAI7B,CAAC;IAEF,uCACK,QAAQ,KACX,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,IAC/B;AACJ,CAAC,CAAA,CAAC;AAdW,QAAA,WAAW,eActB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Recurrence = exports.disableTask = exports.enableTask = exports.deleteTask = exports.upsertTask = exports.updateTask = exports.createTask = exports.getTask = exports.getAllTasks = void 0;
4
+ var tasks_1 = require("./tasks");
5
+ Object.defineProperty(exports, "getAllTasks", { enumerable: true, get: function () { return tasks_1.getAllTasks; } });
6
+ Object.defineProperty(exports, "getTask", { enumerable: true, get: function () { return tasks_1.getTask; } });
7
+ Object.defineProperty(exports, "createTask", { enumerable: true, get: function () { return tasks_1.createTask; } });
8
+ Object.defineProperty(exports, "updateTask", { enumerable: true, get: function () { return tasks_1.updateTask; } });
9
+ Object.defineProperty(exports, "upsertTask", { enumerable: true, get: function () { return tasks_1.upsertTask; } });
10
+ Object.defineProperty(exports, "deleteTask", { enumerable: true, get: function () { return tasks_1.deleteTask; } });
11
+ Object.defineProperty(exports, "enableTask", { enumerable: true, get: function () { return tasks_1.enableTask; } });
12
+ Object.defineProperty(exports, "disableTask", { enumerable: true, get: function () { return tasks_1.disableTask; } });
13
+ var tasks_base_1 = require("./tasks.base");
14
+ Object.defineProperty(exports, "Recurrence", { enumerable: true, get: function () { return tasks_base_1.Recurrence; } });
15
+ //# sourceMappingURL=tasks.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.public.js","sourceRoot":"","sources":["../../../../src/modules/tasks.public.ts"],"names":[],"mappings":";;;AAAA,iCAWiB;AARf,oGAAA,WAAW,OAAA;AACX,gGAAA,OAAO,OAAA;AACP,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,oGAAA,WAAW,OAAA;AAGb,2CAIsB;AAHpB,wGAAA,UAAU,OAAA"}
@@ -0,0 +1,135 @@
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.deleteTemplate = exports.updateTemplate = exports.upsertTemplate = exports.createTemplate = exports.getTemplate = exports.getAllTemplates = 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 template Raw template
33
+ *
34
+ * @returns Parsed template
35
+ */
36
+ const parseTemplate = (template) => (Object.assign(Object.assign({}, template), { createdAt: (0, date_fns_1.parseISO)(template.createdAt), updatedAt: template.updatedAt ? (0, date_fns_1.parseISO)(template.updatedAt) : undefined }));
37
+ /**
38
+ * Transform raw data from JSON, to JS usable data
39
+ *
40
+ * @param template Raw full template
41
+ *
42
+ * @returns Parsed template
43
+ */
44
+ const parseFullTemplate = (template) => {
45
+ const { body } = template, rawTemplate = __rest(template, ["body"]);
46
+ return Object.assign(Object.assign({}, parseTemplate(rawTemplate)), { body });
47
+ };
48
+ /**
49
+ * Get all available templates
50
+ *
51
+ * Needs `general.templates-get` permission
52
+ *
53
+ * @returns All templates' info
54
+ */
55
+ const getAllTemplates = () => __awaiter(void 0, void 0, void 0, function* () {
56
+ const _a = yield axios_1.default.$get('/templates'), { content } = _a, response = __rest(_a, ["content"]);
57
+ return Object.assign(Object.assign({}, response), { content: content.map(parseTemplate) });
58
+ });
59
+ exports.getAllTemplates = getAllTemplates;
60
+ /**
61
+ * Get template info
62
+ *
63
+ * Needs `general.templates-get-name(*)` permission
64
+ *
65
+ * @param name Template's name
66
+ *
67
+ * @returns Template info
68
+ */
69
+ const getTemplate = (name) => __awaiter(void 0, void 0, void 0, function* () {
70
+ const _b = yield axios_1.default.$get(`/templates/${name}`), { content } = _b, response = __rest(_b, ["content"]);
71
+ return Object.assign(Object.assign({}, response), { content: parseFullTemplate(content) });
72
+ });
73
+ exports.getTemplate = getTemplate;
74
+ /**
75
+ * Create a new template
76
+ *
77
+ * Needs `general.templates-post` permission
78
+ *
79
+ * @param template Template's data
80
+ * @param namespaces
81
+ *
82
+ * @deprecated use `upsertTemplate` instead
83
+ *
84
+ * @returns Created template's info
85
+ */
86
+ const createTemplate = (template) => __awaiter(void 0, void 0, void 0, function* () {
87
+ const _c = yield axios_1.default.$post('/templates', template), { content } = _c, response = __rest(_c, ["content"]);
88
+ return Object.assign(Object.assign({}, response), { content: parseFullTemplate(content) });
89
+ });
90
+ exports.createTemplate = createTemplate;
91
+ /**
92
+ * Update or create a template
93
+ *
94
+ * Needs `general.templates-put-name(*)` permission
95
+ *
96
+ * @param id Template's id
97
+ * @param template Template's data
98
+ * @param namespaces
99
+ *
100
+ * @returns Updated/Created Template's info
101
+ */
102
+ const upsertTemplate = (name, template) => __awaiter(void 0, void 0, void 0, function* () {
103
+ const _d = yield axios_1.default.$put(`/templates/${name}`, template), { content } = _d, response = __rest(_d, ["content"]);
104
+ return Object.assign(Object.assign({}, response), { content: parseFullTemplate(content) });
105
+ });
106
+ exports.upsertTemplate = upsertTemplate;
107
+ /**
108
+ * Update a template
109
+ *
110
+ * Needs `general.templates-put-name(*)` permission
111
+ *
112
+ * @param id Template's id
113
+ * @param template New Template's data
114
+ * @param namespaces
115
+ *
116
+ * @deprecated use `upsertTemplate` instead
117
+ *
118
+ * @returns Updated Template's info
119
+ */
120
+ exports.updateTemplate = exports.upsertTemplate;
121
+ /**
122
+ * Delete a template
123
+ *
124
+ * Needs `general.templates-delete-name(*)` permission
125
+ *
126
+ * @param id Template's id
127
+ * @param namespaces
128
+ *
129
+ * @returns Deleted Template's info
130
+ */
131
+ const deleteTemplate = (name) => __awaiter(void 0, void 0, void 0, function* () {
132
+ yield axios_1.default.$delete(`/templates/${name}`);
133
+ });
134
+ exports.deleteTemplate = delete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AAC;IAEzF,uCACK,QAAQ,KACX,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,IACnC;AACJ,CAAC,CAAA,CAAC;AAPW,QAAA,WAAW,eAOtB;AAEF;;;;;;;;;;;GAWG;AACI,MAAM,cAAc,GAAG,CAC5B,QAAoD,EAChB,EAAE;IACtC,MAAM,KAA2B,MAAM,eAAK,CAAC,KAAK,CAChD,YAAY,EACZ,QAAQ,CACT,EAHK,EAAE,OAAO,OAGd,EAHmB,QAAQ,cAAtB,WAAwB,CAG7B,CAAC;IAEF,uCACK,QAAQ,KACX,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,IACnC;AACJ,CAAC,CAAA,CAAC;AAZW,QAAA,cAAc,kBAYzB;AAEF;;;;;;;;;;GAUG;AACI,MAAM,cAAc,GAAG,CAC5B,IAAsB,EACtB,QAAuB,EACa,EAAE;IACtC,MAAM,KAA2B,MAAM,eAAK,CAAC,IAAI,CAC/C,cAAc,IAAI,EAAE,EACpB,QAAQ,CACT,EAHK,EAAE,OAAO,OAGd,EAHmB,QAAQ,cAAtB,WAAwB,CAG7B,CAAC;IAEF,uCACK,QAAQ,KACX,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,IACnC;AACJ,CAAC,CAAA,CAAC;AAbW,QAAA,cAAc,kBAazB;AAEF;;;;;;;;;;;;GAYG;AACU,QAAA,cAAc,GAAG,sBAAc,CAAC;AAE7C;;;;;;;;;GASG;AACI,MAAM,cAAc,GAAG,CAAO,IAAsB,EAAiB,EAAE;IAC5E,MAAM,eAAK,CAAC,OAAO,CAAkB,cAAc,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAA,CAAC;AAFW,QAAA,cAAc,kBAEzB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteTemplate = exports.upsertTemplate = exports.updateTemplate = exports.createTemplate = exports.getTemplate = exports.getAllTemplates = void 0;
4
+ var templates_1 = require("./templates");
5
+ Object.defineProperty(exports, "getAllTemplates", { enumerable: true, get: function () { return templates_1.getAllTemplates; } });
6
+ Object.defineProperty(exports, "getTemplate", { enumerable: true, get: function () { return templates_1.getTemplate; } });
7
+ Object.defineProperty(exports, "createTemplate", { enumerable: true, get: function () { return templates_1.createTemplate; } });
8
+ Object.defineProperty(exports, "updateTemplate", { enumerable: true, get: function () { return templates_1.updateTemplate; } });
9
+ Object.defineProperty(exports, "upsertTemplate", { enumerable: true, get: function () { return templates_1.upsertTemplate; } });
10
+ Object.defineProperty(exports, "deleteTemplate", { enumerable: true, get: function () { return templates_1.deleteTemplate; } });
11
+ //# sourceMappingURL=templates.public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.public.js","sourceRoot":"","sources":["../../../../src/modules/templates.public.ts"],"names":[],"mappings":";;;AAAA,yCAYqB;AANnB,4GAAA,eAAe,OAAA;AACf,wGAAA,WAAW,OAAA;AACX,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA"}
@@ -1,11 +1,13 @@
1
1
  import EventEmitter from 'events';
2
- interface EventEmitterBase {
3
- on: (...p: Parameters<EventEmitter['on']>) => this;
4
- once: (...p: Parameters<EventEmitter['once']>) => this;
5
- off: (...p: Parameters<EventEmitter['off']>) => this;
6
- emit: (...p: Parameters<EventEmitter['emit']>) => this;
2
+ interface EventfulListener<E extends Record<string, any[]>> {
3
+ on: <P extends keyof E>(eventName: P, listener: (...args: E[P]) => void) => this;
4
+ once: <P extends keyof E>(eventName: P, listener: (...args: E[P]) => void) => this;
5
+ off: <P extends keyof E>(eventName: P, listener: (...args: E[P]) => void) => this;
7
6
  }
8
- export type EventfulPromise<T> = Promise<T> & EventEmitterBase;
7
+ interface EventfulEmitter<E extends Record<string, any[]>> {
8
+ emit: <P extends keyof E>(eventName: P, ...args: E[P]) => this;
9
+ }
10
+ export type EventfulPromise<T, E extends Record<string, any[]>> = Promise<T> & EventfulListener<E>;
9
11
  /**
10
12
  * Attach a `EventEmitter` to a `Promise` returned by the `executor`
11
13
  *
@@ -14,5 +16,5 @@ export type EventfulPromise<T> = Promise<T> & EventEmitterBase;
14
16
  *
15
17
  * @returns The EventfulPromise
16
18
  */
17
- declare const createEventfulPromise: <T>(executor: (emitter: EventEmitter | EventEmitterBase) => Promise<T>, emitter?: EventEmitter) => EventfulPromise<T>;
19
+ declare const createEventfulPromise: <T, E extends Record<string, any[]> = Record<string, any[]>>(executor: (emitter: EventfulEmitter<E>) => Promise<T>, emitter?: EventEmitter) => EventfulPromise<T, E>;
18
20
  export default createEventfulPromise;
@@ -73,6 +73,10 @@ export type GenerationProgressEvent = {
73
73
  progress: number;
74
74
  status: FullReportJob['status'];
75
75
  };
76
+ type GenerationEvents = {
77
+ 'started': [GenerationStartedEvent];
78
+ 'progress': [GenerationProgressEvent];
79
+ };
76
80
  /**
77
81
  * Start generation of a report and track progress
78
82
  *
@@ -101,7 +105,7 @@ export declare const startAndListenGeneration: (taskId: string, params?: {
101
105
  * Override period, must match task's recurrence
102
106
  */
103
107
  period?: Period | undefined;
104
- } | undefined, namespaces?: string[] | undefined) => import("../lib/promises").EventfulPromise<ReportResult>;
108
+ } | undefined, namespaces?: string[] | undefined) => import("../lib/promises").EventfulPromise<ReportResult, GenerationEvents>;
105
109
  interface ResponseTypeMap {
106
110
  arraybuffer: ArrayBuffer;
107
111
  blob: Blob;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezpaarse-project/ezreeport-sdk-js",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "JS SDK to communicate with ezReeport API",
5
5
  "homepage": "https://github.com/ezpaarse-project/ezreeport#readme",
6
6
  "bugs": {
package/CHANGELOG.md DELETED
@@ -1,42 +0,0 @@
1
- # @ezpaarse-project/ezreeport-sdk-js 1.0.0-beta.1 (2023-05-02)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * **sdk:** fix type on getAllTemplates ([4309030](https://github.com/ezpaarse-project/ezreeport/commit/4309030938b47d7289a72736b84d99540bd40784))
7
- * **sdk:** fixed export of crons methods ([46d1dbc](https://github.com/ezpaarse-project/ezreeport/commit/46d1dbc081a1c2206c2a63737088c4627990f7ca))
8
- * **sdk:** fixed export of reccurence ([7d88766](https://github.com/ezpaarse-project/ezreeport/commit/7d8876676256de55766b4724c57c5c9b27effe5e))
9
- * **sdk:** fixed namespace in task in history ([a992199](https://github.com/ezpaarse-project/ezreeport/commit/a992199ecb4c2748112fe928ba93f5e9a6e8a4df))
10
- * **sdk:** fixed type of InputTask ([3feaade](https://github.com/ezpaarse-project/ezreeport/commit/3feaade67d014cf24a47d222af0a4a284a0c466f))
11
- * **sdk:** fixed type of paginated data ([7113f7d](https://github.com/ezpaarse-project/ezreeport/commit/7113f7d42d2f0e98f351202d8efcc47126f7c0e3))
12
- * **sdk:** fixed type on figures ([74e3467](https://github.com/ezpaarse-project/ezreeport/commit/74e3467b3edb2a698ccb460a9da4b32760b0c5d8))
13
- * **sdk:** fixed types by replacing objects with json values ([ae1a501](https://github.com/ezpaarse-project/ezreeport/commit/ae1a50192531308aa097cd3f7f2c8218cc2c880d))
14
- * **sdk:** fixed types on report ([89542e1](https://github.com/ezpaarse-project/ezreeport/commit/89542e1c547dbbfa67f4685020e55a18c9b0bb14))
15
- * **sdk:** fixed wrong name for updating template ([b75dad6](https://github.com/ezpaarse-project/ezreeport/commit/b75dad69899df59cefeac246e33f9243307cf200))
16
- * **sdk:** updating auth module following API ([947084d](https://github.com/ezpaarse-project/ezreeport/commit/947084d8827c41c2ec4fbb3ff64eaf24a5bd9fd5))
17
- * **vue:** fixed generation permissions ([afbeea2](https://github.com/ezpaarse-project/ezreeport/commit/afbeea21c38da0d2fe7686f0b88666b4abcf3bde))
18
-
19
-
20
- ### Features
21
-
22
- * **sdk:** added list of user's available institution ([80412de](https://github.com/ezpaarse-project/ezreeport/commit/80412de76f1f01f1f1692f17070cf24709cc8d40))
23
- * **sdk:** added support for responseType with reports ([4997076](https://github.com/ezpaarse-project/ezreeport/commit/4997076b67722fd256c7cd0e9c8fc8e9c44144a1))
24
- * **sdk:** added support for tags in template ([d9285b0](https://github.com/ezpaarse-project/ezreeport/commit/d9285b083c426b96fcc636cb0bf4ae7a0026dd99))
25
- * **sdk:** added template management ([e67ae37](https://github.com/ezpaarse-project/ezreeport/commit/e67ae37a3524ba4490bc328b7939926537dbd811))
26
- * **sdk:** can retrieve version ([e0eea2c](https://github.com/ezpaarse-project/ezreeport/commit/e0eea2ca07c3854e597f84eb534b43969f451fc8))
27
- * **sdk:** delete no longer returns something ([743308f](https://github.com/ezpaarse-project/ezreeport/commit/743308f52e75ad329fd067c9282bbb80dbbcb42a))
28
- * **sdk:** following api changes about queues ([d49fd3f](https://github.com/ezpaarse-project/ezreeport/commit/d49fd3f99243186cdc697f8f026af565dc569bad))
29
- * **sdk:** following reporting api changes ([4a52e7c](https://github.com/ezpaarse-project/ezreeport/commit/4a52e7c2a5ffd83f3ee2d471484d4b49115adcbb))
30
- * **sdk:** moved institutions to dedicated modules ([4e81396](https://github.com/ezpaarse-project/ezreeport/commit/4e813967ab1faff1f26728878e25a456600e9054))
31
- * **sdk:** task is now included in history list ([d094471](https://github.com/ezpaarse-project/ezreeport/commit/d094471d702cbef36f2f58fde9f3049c327a0ccc))
32
- * **sdk:** using namespaces instead of institutions, following API ([9950309](https://github.com/ezpaarse-project/ezreeport/commit/99503094c972aede02c18677b3c81e718d820214))
33
- * **vue:** added base to work on vue plugin ([7d2dd35](https://github.com/ezpaarse-project/ezreeport/commit/7d2dd35f2c157115ccbf706860bdb9473196e9fd))
34
- * **vue:** added global data for sdk ([f2ad20f](https://github.com/ezpaarse-project/ezreeport/commit/f2ad20f5beaf446d200ad0987cad567495fba0c8))
35
- * **vue:** moved from `Histoire` to `Storybook` ([4f41efe](https://github.com/ezpaarse-project/ezreeport/commit/4f41efefcd75c063fbc5dbfc63f03d15c191fb6c))
36
- * **vue:** switched to the new permission system ([a0a59a0](https://github.com/ezpaarse-project/ezreeport/commit/a0a59a050a216f1ca4a17060fb57395deb5c443a))
37
-
38
-
39
- ### BREAKING CHANGES
40
-
41
- * **sdk:** institution parameter is now an array of strings
42
- * **sdk:** institution module is dropped