@pelygo/janus 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2496 -56
- package/dist/index.js +786 -144
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,257 +1,899 @@
|
|
|
1
|
-
import { createAuthApi as
|
|
2
|
-
function
|
|
1
|
+
import { createAuthApi as L } from "@pelygo/auth/core";
|
|
2
|
+
function T(t) {
|
|
3
3
|
return {
|
|
4
4
|
async getAll() {
|
|
5
5
|
return t.get("/clients");
|
|
6
6
|
},
|
|
7
|
-
async
|
|
8
|
-
return t.get(
|
|
7
|
+
async getWithActiveIntegrations() {
|
|
8
|
+
return t.get("/clients/activeIntegrations");
|
|
9
9
|
},
|
|
10
|
-
async
|
|
11
|
-
return t.
|
|
10
|
+
async previewNotification(e, r) {
|
|
11
|
+
return t.get(`/clients/preview-notification?type=${encodeURIComponent(e)}&client_id=${r}`);
|
|
12
12
|
},
|
|
13
|
-
async
|
|
14
|
-
return t.get(`/clients/${
|
|
13
|
+
async getById(e) {
|
|
14
|
+
return t.get(`/clients/${e}`);
|
|
15
15
|
},
|
|
16
|
-
async
|
|
17
|
-
return t.get(`/clients/${
|
|
16
|
+
async getByIdMinimal(e) {
|
|
17
|
+
return t.get(`/clients/${e}?type=m`);
|
|
18
18
|
},
|
|
19
|
-
async
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
async create(e) {
|
|
20
|
+
return t.post("/clients", e);
|
|
21
|
+
},
|
|
22
|
+
async replace(e, r) {
|
|
23
|
+
return t.put(`/clients/${e}`, r);
|
|
23
24
|
},
|
|
24
|
-
async
|
|
25
|
-
return t.
|
|
25
|
+
async update(e, r) {
|
|
26
|
+
return t.patch(`/clients/${e}`, r);
|
|
26
27
|
},
|
|
27
|
-
async
|
|
28
|
+
async getReturnReasons(e) {
|
|
29
|
+
return t.get(`/clients/${e}/returnreasons`);
|
|
30
|
+
},
|
|
31
|
+
async addReturnReason(e, r) {
|
|
28
32
|
const n = {
|
|
29
|
-
client: { id:
|
|
30
|
-
return_reason: { id:
|
|
33
|
+
client: { id: e },
|
|
34
|
+
return_reason: { id: r }
|
|
31
35
|
};
|
|
32
|
-
return t.post(`/clients/${
|
|
36
|
+
return t.post(`/clients/${e}/returnreasons`, n);
|
|
37
|
+
},
|
|
38
|
+
async updateReturnReasons(e, r) {
|
|
39
|
+
return t.put(`/clients/${e}/returnreasons`, r);
|
|
40
|
+
},
|
|
41
|
+
async removeReturnReason(e, r) {
|
|
42
|
+
return t.delete(`/clients/${e}/returnreasons/${r}`);
|
|
43
|
+
},
|
|
44
|
+
async getCourierServices(e) {
|
|
45
|
+
return t.get(`/clients/${e}/courierservices`);
|
|
46
|
+
},
|
|
47
|
+
async getCourierServiceById(e, r) {
|
|
48
|
+
return t.get(`/clients/${e}/courierservices/${r}`);
|
|
49
|
+
},
|
|
50
|
+
async addCourierService(e, r) {
|
|
51
|
+
return t.post(`/clients/${e}/courierservices`, r);
|
|
52
|
+
},
|
|
53
|
+
async updateCourierService(e, r) {
|
|
54
|
+
if (!r.id)
|
|
55
|
+
throw new Error("Service ID is required for update");
|
|
56
|
+
return t.patch(`/clients/${e}/courierservices/${r.id}`, r);
|
|
57
|
+
},
|
|
58
|
+
async deleteCourierService(e, r) {
|
|
59
|
+
return t.delete(`/clients/${e}/courierservices/${r}`);
|
|
60
|
+
},
|
|
61
|
+
async createIntegration(e, r) {
|
|
62
|
+
return t.post(`/clients/${e}/integration`, r);
|
|
63
|
+
},
|
|
64
|
+
async getOrderByRef(e, r) {
|
|
65
|
+
return t.get(`/clients/${e}/orderbyref/${encodeURIComponent(r)}`);
|
|
66
|
+
},
|
|
67
|
+
async getFiles(e) {
|
|
68
|
+
return t.get(`/clients/${e}/files`);
|
|
69
|
+
},
|
|
70
|
+
async uploadFile(e, r, n) {
|
|
71
|
+
return t.post(`/clients/${e}/files/${r}`, n);
|
|
33
72
|
},
|
|
34
|
-
async
|
|
35
|
-
return t.delete(`/clients/${
|
|
73
|
+
async deleteFile(e, r) {
|
|
74
|
+
return t.delete(`/clients/${e}/files/${encodeURIComponent(r)}`);
|
|
36
75
|
},
|
|
37
|
-
async
|
|
38
|
-
return t.
|
|
76
|
+
async getSettings(e) {
|
|
77
|
+
return t.get(`/clients/${e}/settings`);
|
|
39
78
|
}
|
|
40
79
|
};
|
|
41
80
|
}
|
|
42
|
-
function
|
|
81
|
+
function O(t) {
|
|
43
82
|
if (!t)
|
|
44
83
|
return "";
|
|
45
|
-
const
|
|
46
|
-
for (const [
|
|
47
|
-
n != null && n !== "" &&
|
|
48
|
-
return
|
|
84
|
+
const e = new URLSearchParams();
|
|
85
|
+
for (const [r, n] of Object.entries(t))
|
|
86
|
+
n != null && n !== "" && e.append(r, String(n));
|
|
87
|
+
return e.toString();
|
|
49
88
|
}
|
|
50
|
-
function u(t,
|
|
51
|
-
if (!
|
|
89
|
+
function u(t, e) {
|
|
90
|
+
if (!e || Object.keys(e).length === 0)
|
|
52
91
|
return t;
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
92
|
+
const r = O(e);
|
|
93
|
+
if (!r)
|
|
55
94
|
return t;
|
|
56
95
|
const n = t.includes("?") ? "&" : "?";
|
|
57
|
-
return `${t}${n}${
|
|
96
|
+
return `${t}${n}${r}`;
|
|
58
97
|
}
|
|
59
|
-
function
|
|
98
|
+
function P(t) {
|
|
99
|
+
return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
100
|
+
}
|
|
101
|
+
function F(t) {
|
|
102
|
+
const e = {};
|
|
103
|
+
for (const [r, n] of Object.entries(t))
|
|
104
|
+
e[P(r)] = n;
|
|
105
|
+
return e;
|
|
106
|
+
}
|
|
107
|
+
function l(t, e) {
|
|
108
|
+
return e ? u(t, F(e)) : t;
|
|
109
|
+
}
|
|
110
|
+
function o(t, e) {
|
|
111
|
+
if (e.clientId == null)
|
|
112
|
+
throw new Error("clientId is required for this endpoint");
|
|
113
|
+
return l(t, e);
|
|
114
|
+
}
|
|
115
|
+
function b(t) {
|
|
60
116
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
117
|
+
// ── Core returns ─────────────────────────────────────────────
|
|
118
|
+
async query(e) {
|
|
119
|
+
const r = u("/returns/", e);
|
|
120
|
+
return t.get(r);
|
|
64
121
|
},
|
|
65
|
-
async
|
|
66
|
-
|
|
122
|
+
async queryPost(e) {
|
|
123
|
+
return t.post("/returns/query", e);
|
|
124
|
+
},
|
|
125
|
+
async getById(e, r) {
|
|
126
|
+
const n = u(`/returns/${e}`, r);
|
|
67
127
|
return t.get(n);
|
|
68
128
|
},
|
|
69
|
-
async create(
|
|
70
|
-
return t.post("/helpers/returns",
|
|
129
|
+
async create(e) {
|
|
130
|
+
return t.post("/helpers/returns", e);
|
|
131
|
+
},
|
|
132
|
+
async createDirect(e) {
|
|
133
|
+
return t.post("/returns", e);
|
|
134
|
+
},
|
|
135
|
+
async replace(e, r) {
|
|
136
|
+
return t.put(`/returns/${e}`, r);
|
|
137
|
+
},
|
|
138
|
+
async update(e, r) {
|
|
139
|
+
return t.patch(`/returns/${e}`, r);
|
|
71
140
|
},
|
|
72
|
-
async
|
|
73
|
-
return t.
|
|
141
|
+
async delete(e) {
|
|
142
|
+
return t.delete(`/returns/${e}`);
|
|
74
143
|
},
|
|
75
|
-
async
|
|
76
|
-
|
|
144
|
+
async setApproval(e, r) {
|
|
145
|
+
const n = { approve: r };
|
|
146
|
+
return t.post(`/returns/${e}/approval`, n);
|
|
77
147
|
},
|
|
78
|
-
async
|
|
79
|
-
return t.get(`/returns
|
|
148
|
+
async getEmail(e) {
|
|
149
|
+
return t.get(`/returns/email?ref=${encodeURIComponent(e)}`);
|
|
80
150
|
},
|
|
81
|
-
|
|
151
|
+
// ── Return items ─────────────────────────────────────────────
|
|
152
|
+
async getItems(e) {
|
|
153
|
+
return t.get(`/returns/${e}/returnitems`);
|
|
154
|
+
},
|
|
155
|
+
async getItemById(e, r) {
|
|
156
|
+
return t.get(`/returns/${e}/returnitems/${r}`);
|
|
157
|
+
},
|
|
158
|
+
async addItem(e, r) {
|
|
159
|
+
return t.post(`/returns/${e}/returnitems`, r);
|
|
160
|
+
},
|
|
161
|
+
async updateItem(e, r, n) {
|
|
162
|
+
return t.patch(`/returns/${e}/returnitems/${r}`, n);
|
|
163
|
+
},
|
|
164
|
+
async updateItems(e, r) {
|
|
165
|
+
return t.patch(`/returns/${e}/returnitems`, r);
|
|
166
|
+
},
|
|
167
|
+
// ── Return statuses (per-return) ─────────────────────────────
|
|
168
|
+
async getStatuses(e) {
|
|
169
|
+
return t.get(`/returns/${e}/statuses`);
|
|
170
|
+
},
|
|
171
|
+
async addStatus(e, r) {
|
|
82
172
|
const n = {
|
|
83
|
-
return: { id:
|
|
84
|
-
return_status: { id:
|
|
173
|
+
return: { id: e },
|
|
174
|
+
return_status: { id: r },
|
|
85
175
|
created_by: { id: 1 }
|
|
86
176
|
};
|
|
87
|
-
return t.post(`/returns/${
|
|
177
|
+
return t.post(`/returns/${e}/statuses`, n);
|
|
88
178
|
},
|
|
89
|
-
async removeStatus(
|
|
90
|
-
return t.delete(`/returns/${
|
|
179
|
+
async removeStatus(e, r) {
|
|
180
|
+
return t.delete(`/returns/${e}/statuses/${r}`);
|
|
91
181
|
},
|
|
92
|
-
|
|
93
|
-
|
|
182
|
+
// ── Return comments (per-return) ─────────────────────────────
|
|
183
|
+
async getComments(e) {
|
|
184
|
+
return t.get(`/returns/${e}/comments`);
|
|
94
185
|
},
|
|
95
|
-
async
|
|
96
|
-
return t.
|
|
186
|
+
async getCommentById(e, r) {
|
|
187
|
+
return t.get(`/returns/${e}/comments/${r}`);
|
|
97
188
|
},
|
|
98
|
-
async
|
|
99
|
-
|
|
189
|
+
async addComment(e, r) {
|
|
190
|
+
const n = { comment: r };
|
|
191
|
+
return t.post(`/returns/${e}/comments`, n);
|
|
100
192
|
},
|
|
101
|
-
async
|
|
102
|
-
return t.
|
|
193
|
+
async removeComment(e, r) {
|
|
194
|
+
return t.delete(`/returns/${e}/comments/${r}`);
|
|
103
195
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return t.
|
|
196
|
+
// ── Reference data: reasons ──────────────────────────────────
|
|
197
|
+
async getReasons() {
|
|
198
|
+
return t.get("/returns/reasons");
|
|
107
199
|
},
|
|
108
|
-
async
|
|
109
|
-
return t.
|
|
200
|
+
async getReasonById(e) {
|
|
201
|
+
return t.get(`/returns/reasons/${e}`);
|
|
110
202
|
},
|
|
111
|
-
async
|
|
112
|
-
|
|
113
|
-
return t.post(`/returns/${r}/approval`, n);
|
|
203
|
+
async createReason(e) {
|
|
204
|
+
return t.post("/returns/reasons", e);
|
|
114
205
|
},
|
|
115
|
-
async
|
|
116
|
-
return t.
|
|
206
|
+
async updateReason(e, r) {
|
|
207
|
+
return t.put(`/returns/reasons/${e}`, r);
|
|
117
208
|
},
|
|
209
|
+
// ── Reference data: statuses ─────────────────────────────────
|
|
118
210
|
async getAllStatuses() {
|
|
119
211
|
return t.get("/returns/statuses");
|
|
120
212
|
},
|
|
121
|
-
async
|
|
122
|
-
return t.get(`/
|
|
213
|
+
async getStatusById(e) {
|
|
214
|
+
return t.get(`/returns/statuses/${e}`);
|
|
215
|
+
},
|
|
216
|
+
async createStatus(e) {
|
|
217
|
+
return t.post("/returns/statuses", e);
|
|
218
|
+
},
|
|
219
|
+
async updateStatus(e, r) {
|
|
220
|
+
return t.put(`/returns/statuses/${e}`, r);
|
|
221
|
+
},
|
|
222
|
+
async deleteStatus(e) {
|
|
223
|
+
return t.delete(`/returns/statuses/${e}`);
|
|
224
|
+
},
|
|
225
|
+
// ── Reference data: categories ───────────────────────────────
|
|
226
|
+
async getCategories() {
|
|
227
|
+
return t.get("/returns/categories");
|
|
228
|
+
},
|
|
229
|
+
async getCategoryById(e) {
|
|
230
|
+
return t.get(`/returns/categories/${e}`);
|
|
231
|
+
},
|
|
232
|
+
async createCategory(e) {
|
|
233
|
+
return t.post("/returns/categories", e);
|
|
234
|
+
},
|
|
235
|
+
async updateCategory(e, r) {
|
|
236
|
+
return t.put(`/returns/categories/${e}`, r);
|
|
237
|
+
},
|
|
238
|
+
// ── Reference data: sources ──────────────────────────────────
|
|
239
|
+
async getSources() {
|
|
240
|
+
return t.get("/returns/sources");
|
|
241
|
+
},
|
|
242
|
+
async getSourceById(e) {
|
|
243
|
+
return t.get(`/returns/sources/${e}`);
|
|
244
|
+
},
|
|
245
|
+
async createSource(e) {
|
|
246
|
+
return t.post("/returns/sources", e);
|
|
247
|
+
},
|
|
248
|
+
async updateSource(e, r) {
|
|
249
|
+
return t.put(`/returns/sources/${e}`, r);
|
|
250
|
+
},
|
|
251
|
+
async deleteSource(e) {
|
|
252
|
+
return t.delete(`/returns/sources/${e}`);
|
|
253
|
+
},
|
|
254
|
+
// ── Reference data: comments (global) ────────────────────────
|
|
255
|
+
async getAllComments() {
|
|
256
|
+
return t.get("/returns/comments");
|
|
257
|
+
},
|
|
258
|
+
async getGlobalCommentById(e) {
|
|
259
|
+
return t.get(`/returns/comments/${e}`);
|
|
260
|
+
},
|
|
261
|
+
// ── Filter options ───────────────────────────────────────────
|
|
262
|
+
async getFilterOptions(e) {
|
|
263
|
+
return t.get(`/orders/returns/filter-types?clientId=${e}`);
|
|
123
264
|
}
|
|
124
265
|
};
|
|
125
266
|
}
|
|
126
|
-
function
|
|
267
|
+
function x(t) {
|
|
127
268
|
return {
|
|
128
|
-
async returnsSummary(
|
|
129
|
-
const
|
|
130
|
-
return t.get(
|
|
269
|
+
async returnsSummary(e) {
|
|
270
|
+
const r = u("/reports/returns/summary/", e);
|
|
271
|
+
return t.get(r);
|
|
131
272
|
},
|
|
132
|
-
async returnsSummaryCsv(
|
|
133
|
-
const
|
|
273
|
+
async returnsSummaryCsv(e) {
|
|
274
|
+
const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/summary/", r);
|
|
134
275
|
return t.get(n);
|
|
135
276
|
},
|
|
136
|
-
async returnsReasons(
|
|
137
|
-
const
|
|
138
|
-
return t.get(
|
|
277
|
+
async returnsReasons(e) {
|
|
278
|
+
const r = u("/reports/returns/reasons/", e);
|
|
279
|
+
return t.get(r);
|
|
139
280
|
},
|
|
140
|
-
async returnsReasonsCsv(
|
|
141
|
-
const
|
|
281
|
+
async returnsReasonsCsv(e) {
|
|
282
|
+
const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/reasons/", r);
|
|
142
283
|
return t.get(n);
|
|
143
284
|
},
|
|
144
|
-
async returnsOverview(
|
|
145
|
-
const
|
|
146
|
-
return t.get(
|
|
285
|
+
async returnsOverview(e) {
|
|
286
|
+
const r = u("/reports/returns/overview/", e);
|
|
287
|
+
return t.get(r);
|
|
147
288
|
},
|
|
148
|
-
async returnsOverviewCsv(
|
|
149
|
-
const
|
|
289
|
+
async returnsOverviewCsv(e) {
|
|
290
|
+
const r = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/overview/", r);
|
|
150
291
|
return t.get(n);
|
|
151
292
|
},
|
|
152
|
-
async returnsStats(
|
|
153
|
-
return t.get(`/reports/returns/stats?clientId=${
|
|
293
|
+
async returnsStats(e) {
|
|
294
|
+
return t.get(`/reports/returns/stats?clientId=${e}`);
|
|
154
295
|
}
|
|
155
296
|
};
|
|
156
297
|
}
|
|
157
|
-
function
|
|
158
|
-
const { baseUrl:
|
|
159
|
-
async function
|
|
160
|
-
const
|
|
298
|
+
function N(t) {
|
|
299
|
+
const { baseUrl: e } = t;
|
|
300
|
+
async function r(n, s) {
|
|
301
|
+
const c = await fetch(n, {
|
|
161
302
|
headers: {
|
|
162
303
|
"Content-Type": "application/json"
|
|
163
304
|
},
|
|
164
305
|
...s
|
|
165
306
|
});
|
|
166
|
-
if (!
|
|
167
|
-
const a = await
|
|
168
|
-
throw new Error(`HTTP ${
|
|
307
|
+
if (!c.ok) {
|
|
308
|
+
const a = await c.text().catch(() => "Unknown error");
|
|
309
|
+
throw new Error(`HTTP ${c.status}: ${a}`);
|
|
169
310
|
}
|
|
170
|
-
return
|
|
311
|
+
return c.json();
|
|
171
312
|
}
|
|
172
313
|
return {
|
|
173
314
|
async getClientSettingsByName(n) {
|
|
174
|
-
return
|
|
175
|
-
`${
|
|
315
|
+
return r(
|
|
316
|
+
`${e}/helpers/clientsettings/${encodeURIComponent(n)}`
|
|
176
317
|
);
|
|
177
318
|
},
|
|
178
319
|
async getNotificationSettings(n) {
|
|
179
|
-
return
|
|
180
|
-
`${
|
|
320
|
+
return r(
|
|
321
|
+
`${e}/helpers/settings/${encodeURIComponent(n)}`
|
|
181
322
|
);
|
|
182
323
|
},
|
|
183
|
-
async customerLogin(n, s,
|
|
184
|
-
return
|
|
324
|
+
async customerLogin(n, s, c) {
|
|
325
|
+
return r(`${e}/helpers/customerlogin`, {
|
|
185
326
|
method: "POST",
|
|
186
327
|
body: JSON.stringify({
|
|
187
328
|
client_id: n,
|
|
188
329
|
order_ref: s,
|
|
189
|
-
postcode:
|
|
330
|
+
postcode: c
|
|
190
331
|
})
|
|
191
332
|
});
|
|
192
333
|
}
|
|
193
334
|
};
|
|
194
335
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
336
|
+
function z(t) {
|
|
337
|
+
return {
|
|
338
|
+
async getAll() {
|
|
339
|
+
return t.get("/couriers");
|
|
340
|
+
},
|
|
341
|
+
async getById(e) {
|
|
342
|
+
return t.get(`/couriers/${e}`);
|
|
343
|
+
},
|
|
344
|
+
async create(e) {
|
|
345
|
+
return t.post("/couriers", e);
|
|
346
|
+
},
|
|
347
|
+
async update(e, r) {
|
|
348
|
+
return t.put(`/couriers/${e}`, r);
|
|
349
|
+
},
|
|
350
|
+
async getServices(e) {
|
|
351
|
+
return t.get(`/couriers/${e}/services`);
|
|
352
|
+
},
|
|
353
|
+
async getServiceById(e, r) {
|
|
354
|
+
return t.get(`/couriers/${e}/services/${r}`);
|
|
355
|
+
},
|
|
356
|
+
async createService(e, r) {
|
|
357
|
+
return t.post(`/couriers/${e}/services`, r);
|
|
358
|
+
},
|
|
359
|
+
async updateService(e, r, n) {
|
|
360
|
+
return t.put(`/couriers/${e}/services/${r}`, n);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function j(t) {
|
|
365
|
+
return {
|
|
366
|
+
async getAll(e) {
|
|
367
|
+
const r = u("/orders", e);
|
|
368
|
+
return t.get(r);
|
|
369
|
+
},
|
|
370
|
+
async getStats(e) {
|
|
371
|
+
const r = u("/orders/stats", e);
|
|
372
|
+
return t.get(r);
|
|
373
|
+
},
|
|
374
|
+
async getReturns(e) {
|
|
375
|
+
const r = u("/orders/returns", e);
|
|
376
|
+
return t.get(r);
|
|
377
|
+
},
|
|
378
|
+
async getByRef(e, r) {
|
|
379
|
+
const n = u(`/orders/${encodeURIComponent(e)}`, r != null ? { clientId: r } : void 0);
|
|
380
|
+
return t.get(n);
|
|
381
|
+
},
|
|
382
|
+
async getReturnFilterOptions(e) {
|
|
383
|
+
return t.get(`/orders/returns/filter-types?clientId=${e}`);
|
|
384
|
+
},
|
|
385
|
+
async getFilterTypes(e) {
|
|
386
|
+
const r = u("/orders/filter-types", e != null ? { clientId: e } : void 0);
|
|
387
|
+
return t.get(r);
|
|
388
|
+
},
|
|
389
|
+
async create(e) {
|
|
390
|
+
return t.post("/orders", e);
|
|
391
|
+
},
|
|
392
|
+
async updateOrder(e, r) {
|
|
393
|
+
return t.put(`/orders/${e}`, r);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function q(t) {
|
|
398
|
+
return {
|
|
399
|
+
async getAll() {
|
|
400
|
+
return t.get("/integrations");
|
|
401
|
+
},
|
|
402
|
+
async getByClientId(e) {
|
|
403
|
+
return t.get(`/integrations/${e}`);
|
|
404
|
+
},
|
|
405
|
+
async getByCustomerAndName(e, r) {
|
|
406
|
+
return t.get(`/integrations/${e}/${encodeURIComponent(r)}`);
|
|
407
|
+
},
|
|
408
|
+
async getActive() {
|
|
409
|
+
return t.get("/integrations/active");
|
|
410
|
+
},
|
|
411
|
+
async getNamesOnly() {
|
|
412
|
+
return t.get("/integrations/namesOnly");
|
|
413
|
+
},
|
|
414
|
+
async create(e) {
|
|
415
|
+
return t.post("/integrations", e);
|
|
416
|
+
},
|
|
417
|
+
async update(e, r) {
|
|
418
|
+
return t.put(`/integrations/${e}`, r);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function J(t) {
|
|
423
|
+
return {
|
|
424
|
+
async getAll(e) {
|
|
425
|
+
const r = l("/users", e);
|
|
426
|
+
return t.get(r);
|
|
427
|
+
},
|
|
428
|
+
async getById(e) {
|
|
429
|
+
return t.get(`/users/${e}`);
|
|
430
|
+
},
|
|
431
|
+
async create(e) {
|
|
432
|
+
return t.post("/users", e);
|
|
433
|
+
},
|
|
434
|
+
async update(e) {
|
|
435
|
+
return t.patch("/users", e);
|
|
436
|
+
},
|
|
437
|
+
async replace(e, r) {
|
|
438
|
+
return t.put(`/users/${e}`, r);
|
|
439
|
+
},
|
|
440
|
+
async delete(e) {
|
|
441
|
+
return t.delete(`/users/${e}`);
|
|
442
|
+
},
|
|
443
|
+
async changePassword(e) {
|
|
444
|
+
return t.post("/users/change-password", e);
|
|
445
|
+
},
|
|
446
|
+
async resetPassword(e) {
|
|
447
|
+
return t.get(`/users/reset-password?link=${encodeURIComponent(e)}`);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function D(t) {
|
|
452
|
+
return {
|
|
453
|
+
async createActivity(e) {
|
|
454
|
+
return t.post("/logs/activity", e);
|
|
455
|
+
},
|
|
456
|
+
async createOrderIssue(e) {
|
|
457
|
+
return t.post("/logs/orderissue", e);
|
|
458
|
+
},
|
|
459
|
+
async updateOrderIssue(e) {
|
|
460
|
+
return t.patch("/logs/orderissue", e);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function H(t) {
|
|
465
|
+
return {
|
|
466
|
+
async getByUuid(e) {
|
|
467
|
+
return t.get(`/tasks/histories/${encodeURIComponent(e)}`);
|
|
468
|
+
},
|
|
469
|
+
async getAll(e) {
|
|
470
|
+
const r = u("/tasks/histories", e);
|
|
471
|
+
return t.get(r);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function V(t) {
|
|
476
|
+
const { baseUrl: e } = t;
|
|
477
|
+
async function r(s, c) {
|
|
478
|
+
const a = await fetch(s, {
|
|
479
|
+
headers: { "Content-Type": "application/json" },
|
|
480
|
+
...c
|
|
481
|
+
});
|
|
482
|
+
if (!a.ok) {
|
|
483
|
+
const y = await a.text().catch(() => "Unknown error");
|
|
484
|
+
throw new Error(`HTTP ${a.status}: ${y}`);
|
|
485
|
+
}
|
|
486
|
+
return a.json();
|
|
487
|
+
}
|
|
488
|
+
async function n(s) {
|
|
489
|
+
const c = await fetch(s);
|
|
490
|
+
if (!c.ok) {
|
|
491
|
+
const a = await c.text().catch(() => "Unknown error");
|
|
492
|
+
throw new Error(`HTTP ${c.status}: ${a}`);
|
|
493
|
+
}
|
|
494
|
+
return c.text();
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
async tracking(s, c, a) {
|
|
498
|
+
const y = new URLSearchParams({
|
|
499
|
+
order_ref: s,
|
|
500
|
+
postcode: c,
|
|
501
|
+
client_id: String(a)
|
|
502
|
+
});
|
|
503
|
+
return r(`${e}/customer/tracking?${y}`);
|
|
504
|
+
},
|
|
505
|
+
async track(s) {
|
|
506
|
+
return r(`${e}/customer/track?ref=${encodeURIComponent(s)}`);
|
|
507
|
+
},
|
|
508
|
+
async login(s) {
|
|
509
|
+
return r(`${e}/customer/login`, {
|
|
510
|
+
method: "POST",
|
|
511
|
+
body: JSON.stringify(s)
|
|
512
|
+
});
|
|
513
|
+
},
|
|
514
|
+
async viewEmail(s) {
|
|
515
|
+
return n(`${e}/customer/view-email?ref=${encodeURIComponent(s)}`);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function W(t) {
|
|
520
|
+
return {
|
|
521
|
+
async getCouriers() {
|
|
522
|
+
return t.get("/legacy-couriers");
|
|
523
|
+
},
|
|
524
|
+
async getPostServices() {
|
|
525
|
+
return t.get("/legacy-postservices");
|
|
526
|
+
},
|
|
527
|
+
async getPostServicesByCarrier(e) {
|
|
528
|
+
return t.get(`/legacy-postservices/${encodeURIComponent(e)}`);
|
|
529
|
+
},
|
|
530
|
+
/** @deprecated Use janus.products.getAll() instead. */
|
|
531
|
+
async queryProducts(e) {
|
|
532
|
+
return t.post("/legacy/products/query", e);
|
|
533
|
+
},
|
|
534
|
+
async getPrintList() {
|
|
535
|
+
return t.get("/legacy-printlist");
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function G(t) {
|
|
540
|
+
return {
|
|
541
|
+
async getAll(e) {
|
|
542
|
+
const r = o("/products", e);
|
|
543
|
+
return t.get(r);
|
|
544
|
+
},
|
|
545
|
+
async getById(e) {
|
|
546
|
+
return t.get(`/products/${e}`);
|
|
547
|
+
},
|
|
548
|
+
async create(e) {
|
|
549
|
+
return t.post("/products", e);
|
|
550
|
+
},
|
|
551
|
+
async update(e, r) {
|
|
552
|
+
return t.put(`/products/${e}`, r);
|
|
553
|
+
},
|
|
554
|
+
async delete(e) {
|
|
555
|
+
return t.delete(`/products/${e}`);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function K(t) {
|
|
560
|
+
return {
|
|
561
|
+
async getAll(e) {
|
|
562
|
+
const r = o("/product-categories", e);
|
|
563
|
+
return t.get(r);
|
|
564
|
+
},
|
|
565
|
+
async getById(e) {
|
|
566
|
+
return t.get(`/product-categories/${e}`);
|
|
567
|
+
},
|
|
568
|
+
async create(e) {
|
|
569
|
+
return t.post("/product-categories", e);
|
|
570
|
+
},
|
|
571
|
+
async update(e, r) {
|
|
572
|
+
return t.put(`/product-categories/${e}`, r);
|
|
573
|
+
},
|
|
574
|
+
async delete(e) {
|
|
575
|
+
return t.delete(`/product-categories/${e}`);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function M(t) {
|
|
580
|
+
return {
|
|
581
|
+
async getAll(e) {
|
|
582
|
+
const r = o("/stocks", e);
|
|
583
|
+
return t.get(r);
|
|
584
|
+
},
|
|
585
|
+
async getById(e) {
|
|
586
|
+
return t.get(`/stocks/${e}`);
|
|
587
|
+
},
|
|
588
|
+
async create(e) {
|
|
589
|
+
return t.post("/stocks", e);
|
|
590
|
+
},
|
|
591
|
+
async update(e, r) {
|
|
592
|
+
return t.put(`/stocks/${e}`, r);
|
|
593
|
+
},
|
|
594
|
+
async delete(e) {
|
|
595
|
+
return t.delete(`/stocks/${e}`);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function Q(t) {
|
|
600
|
+
return {
|
|
601
|
+
async getAll(e) {
|
|
602
|
+
const r = o("/transactions", e);
|
|
603
|
+
return t.get(r);
|
|
604
|
+
},
|
|
605
|
+
async getById(e) {
|
|
606
|
+
return t.get(`/transactions/${e}`);
|
|
607
|
+
},
|
|
608
|
+
async create(e) {
|
|
609
|
+
return t.post("/transactions", e);
|
|
610
|
+
},
|
|
611
|
+
async update(e, r) {
|
|
612
|
+
return t.put(`/transactions/${e}`, r);
|
|
613
|
+
},
|
|
614
|
+
async delete(e) {
|
|
615
|
+
return t.delete(`/transactions/${e}`);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function Z(t) {
|
|
620
|
+
return {
|
|
621
|
+
async getAll(e) {
|
|
622
|
+
const r = o("/allocations", e);
|
|
623
|
+
return t.get(r);
|
|
624
|
+
},
|
|
625
|
+
async getById(e) {
|
|
626
|
+
return t.get(`/allocations/${e}`);
|
|
627
|
+
},
|
|
628
|
+
async create(e) {
|
|
629
|
+
return t.post("/allocations", e);
|
|
630
|
+
},
|
|
631
|
+
async update(e, r) {
|
|
632
|
+
return t.put(`/allocations/${e}`, r);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function X(t) {
|
|
637
|
+
return {
|
|
638
|
+
async getAll(e) {
|
|
639
|
+
const r = o("/locations", e);
|
|
640
|
+
return t.get(r);
|
|
641
|
+
},
|
|
642
|
+
async getById(e) {
|
|
643
|
+
return t.get(`/locations/${e}`);
|
|
644
|
+
},
|
|
645
|
+
async create(e) {
|
|
646
|
+
return t.post("/locations", e);
|
|
647
|
+
},
|
|
648
|
+
async update(e, r) {
|
|
649
|
+
return t.put(`/locations/${e}`, r);
|
|
650
|
+
},
|
|
651
|
+
async delete(e) {
|
|
652
|
+
return t.delete(`/locations/${e}`);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function Y(t) {
|
|
657
|
+
return {
|
|
658
|
+
async getAll(e) {
|
|
659
|
+
const r = o("/audits", e);
|
|
660
|
+
return t.get(r);
|
|
661
|
+
},
|
|
662
|
+
async getById(e) {
|
|
663
|
+
return t.get(`/audits/${e}`);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function ee(t) {
|
|
668
|
+
return {
|
|
669
|
+
// ── ASN CRUD ─────────────────────────────────
|
|
670
|
+
async getAll(e) {
|
|
671
|
+
const r = o("/asns", e);
|
|
672
|
+
return t.get(r);
|
|
673
|
+
},
|
|
674
|
+
async getById(e) {
|
|
675
|
+
return t.get(`/asns/${e}`);
|
|
676
|
+
},
|
|
677
|
+
async create(e) {
|
|
678
|
+
return t.post("/asns", e);
|
|
679
|
+
},
|
|
680
|
+
async update(e, r) {
|
|
681
|
+
return t.put(`/asns/${e}`, r);
|
|
682
|
+
},
|
|
683
|
+
async delete(e) {
|
|
684
|
+
return t.delete(`/asns/${e}`);
|
|
685
|
+
},
|
|
686
|
+
// ── ASN Lines ────────────────────────────────
|
|
687
|
+
async getLines(e, r) {
|
|
688
|
+
const n = o(`/asns/${e}/lines`, r);
|
|
689
|
+
return t.get(n);
|
|
690
|
+
},
|
|
691
|
+
async getLineById(e, r) {
|
|
692
|
+
return t.get(`/asns/${e}/lines/${r}`);
|
|
693
|
+
},
|
|
694
|
+
async createLine(e, r) {
|
|
695
|
+
const { client_id: n, asn_id: s, ...c } = r;
|
|
696
|
+
return t.post(`/asns/${e}/lines`, {
|
|
697
|
+
client_id: n,
|
|
698
|
+
asn_id: e,
|
|
699
|
+
asn_lines: [c]
|
|
700
|
+
});
|
|
701
|
+
},
|
|
702
|
+
async updateLine(e, r, n) {
|
|
703
|
+
return t.put(`/asns/${e}/lines/${r}`, {
|
|
704
|
+
...n,
|
|
705
|
+
asn_id: e
|
|
706
|
+
});
|
|
707
|
+
},
|
|
708
|
+
async deleteLine(e, r) {
|
|
709
|
+
return t.delete(`/asns/${e}/lines/${r}`);
|
|
710
|
+
},
|
|
711
|
+
// ── ASN Receipts ─────────────────────────────
|
|
712
|
+
async getReceipts(e, r, n) {
|
|
713
|
+
const s = o(`/asns/${e}/lines/${r}/receipts`, n);
|
|
714
|
+
return t.get(s);
|
|
715
|
+
},
|
|
716
|
+
async getReceiptById(e, r, n) {
|
|
717
|
+
return t.get(`/asns/${e}/lines/${r}/receipts/${n}`);
|
|
718
|
+
},
|
|
719
|
+
async createReceipt(e, r, n) {
|
|
720
|
+
return t.post(`/asns/${e}/lines/${r}/receipts`, n);
|
|
721
|
+
},
|
|
722
|
+
async updateReceipt(e, r, n, s) {
|
|
723
|
+
return t.put(`/asns/${e}/lines/${r}/receipts/${n}`, {
|
|
724
|
+
...s,
|
|
725
|
+
asn_id: e,
|
|
726
|
+
asn_line_id: r
|
|
727
|
+
});
|
|
728
|
+
},
|
|
729
|
+
async deleteReceipt(e, r, n) {
|
|
730
|
+
return t.delete(`/asns/${e}/lines/${r}/receipts/${n}`);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function te(t) {
|
|
735
|
+
return {
|
|
736
|
+
async getAll(e) {
|
|
737
|
+
const r = o("/dispatches", e);
|
|
738
|
+
return t.get(r);
|
|
739
|
+
},
|
|
740
|
+
async getById(e) {
|
|
741
|
+
return t.get(`/dispatches/${e}`);
|
|
742
|
+
},
|
|
743
|
+
async create(e) {
|
|
744
|
+
return t.post("/dispatches", e);
|
|
745
|
+
},
|
|
746
|
+
async update(e, r) {
|
|
747
|
+
return t.put(`/dispatches/${e}`, r);
|
|
748
|
+
},
|
|
749
|
+
async delete(e) {
|
|
750
|
+
return t.delete(`/dispatches/${e}`);
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function re(t) {
|
|
755
|
+
return {
|
|
756
|
+
async getByDispatchId(e) {
|
|
757
|
+
return t.get(`/consignments/${e}`);
|
|
758
|
+
},
|
|
759
|
+
async create(e) {
|
|
760
|
+
return t.post("/consignments", e);
|
|
761
|
+
},
|
|
762
|
+
async update(e, r) {
|
|
763
|
+
return t.put(`/consignments/${e}`, r);
|
|
764
|
+
},
|
|
765
|
+
async delete(e) {
|
|
766
|
+
return t.delete(`/consignments/${e}`);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function ne(t) {
|
|
771
|
+
return {
|
|
772
|
+
// ── Invoice CRUD ────────────────────────────────────────────
|
|
773
|
+
async getAll(e) {
|
|
774
|
+
const r = o("/invoices", e);
|
|
775
|
+
return t.get(r);
|
|
776
|
+
},
|
|
777
|
+
async getById(e) {
|
|
778
|
+
return t.get(`/invoices/${e}`);
|
|
779
|
+
},
|
|
780
|
+
async create(e) {
|
|
781
|
+
return t.post("/invoices", e);
|
|
782
|
+
},
|
|
783
|
+
async update(e, r) {
|
|
784
|
+
return t.put(`/invoices/${e}`, r);
|
|
785
|
+
},
|
|
786
|
+
async delete(e) {
|
|
787
|
+
return t.delete(`/invoices/${e}`);
|
|
788
|
+
},
|
|
789
|
+
// ── Invoice Lines ───────────────────────────────────────────
|
|
790
|
+
async getLines(e, r) {
|
|
791
|
+
const n = o(`/invoices/${e}/lines`, r);
|
|
792
|
+
return t.get(n);
|
|
793
|
+
},
|
|
794
|
+
async getLineById(e, r) {
|
|
795
|
+
return t.get(`/invoices/${e}/lines/${r}`);
|
|
796
|
+
},
|
|
797
|
+
async createLine(e, r) {
|
|
798
|
+
const { client_id: n, invoice_id: s, ...c } = r;
|
|
799
|
+
return t.post(`/invoices/${e}/lines`, {
|
|
800
|
+
client_id: n,
|
|
801
|
+
invoice_id: e,
|
|
802
|
+
invoice_lines: [{ ...c, invoice_id: e }]
|
|
803
|
+
});
|
|
804
|
+
},
|
|
805
|
+
async updateLine(e, r, n) {
|
|
806
|
+
return t.put(`/invoices/${e}/lines/${r}`, {
|
|
807
|
+
...n,
|
|
808
|
+
invoice_id: e
|
|
809
|
+
});
|
|
810
|
+
},
|
|
811
|
+
async deleteLine(e, r) {
|
|
812
|
+
return t.delete(`/invoices/${e}/lines/${r}`);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
const se = "https://api.janus.pelygo.com";
|
|
817
|
+
function oe(t = {}) {
|
|
818
|
+
const e = t.baseUrl || se, r = {
|
|
819
|
+
baseUrl: e,
|
|
199
820
|
authUrl: t.authUrl,
|
|
200
821
|
onUnauthorized: t.onUnauthorized,
|
|
201
822
|
onLoginSuccess: t.onLoginSuccess,
|
|
202
823
|
onLoginError: t.onLoginError
|
|
203
|
-
}, n =
|
|
824
|
+
}, n = L(r), s = T(n), c = b(n), a = x(n), y = N({ baseUrl: e }), g = z(n), d = j(n), $ = q(n), m = J(n), f = D(n), v = H(n), h = V({ baseUrl: e }), R = W(n), p = G(n), S = K(n), I = M(n), C = Q(n), A = Z(n), B = X(n), U = Y(n), w = ee(n), k = te(n), _ = re(n), E = ne(n);
|
|
204
825
|
return {
|
|
205
826
|
clients: s,
|
|
206
|
-
returns:
|
|
827
|
+
returns: c,
|
|
207
828
|
reports: a,
|
|
208
|
-
helpers:
|
|
829
|
+
helpers: y,
|
|
830
|
+
couriers: g,
|
|
831
|
+
orders: d,
|
|
832
|
+
integrations: $,
|
|
833
|
+
users: m,
|
|
834
|
+
logs: f,
|
|
835
|
+
tasks: v,
|
|
836
|
+
customer: h,
|
|
837
|
+
legacy: R,
|
|
838
|
+
products: p,
|
|
839
|
+
productCategories: S,
|
|
840
|
+
stocks: I,
|
|
841
|
+
stockTransactions: C,
|
|
842
|
+
stockAllocations: A,
|
|
843
|
+
locations: B,
|
|
844
|
+
audits: U,
|
|
845
|
+
asns: w,
|
|
846
|
+
dispatches: k,
|
|
847
|
+
consignments: _,
|
|
848
|
+
invoices: E,
|
|
209
849
|
auth: n
|
|
210
850
|
};
|
|
211
851
|
}
|
|
212
|
-
class
|
|
213
|
-
constructor(
|
|
214
|
-
super(
|
|
852
|
+
class i extends Error {
|
|
853
|
+
constructor(e, r, n) {
|
|
854
|
+
super(e), this.name = "JanusApiError", this.status = r, this.response = n;
|
|
215
855
|
const s = Error;
|
|
216
|
-
s.captureStackTrace && s.captureStackTrace(this,
|
|
856
|
+
s.captureStackTrace && s.captureStackTrace(this, i);
|
|
217
857
|
}
|
|
218
858
|
}
|
|
219
|
-
class
|
|
220
|
-
constructor(
|
|
221
|
-
super(
|
|
859
|
+
class ce extends i {
|
|
860
|
+
constructor(e = "Unauthorized", r) {
|
|
861
|
+
super(e, 401, r), this.name = "UnauthorizedError";
|
|
222
862
|
}
|
|
223
863
|
}
|
|
224
|
-
class
|
|
225
|
-
constructor(
|
|
226
|
-
super(
|
|
864
|
+
class ae extends i {
|
|
865
|
+
constructor(e = "Forbidden", r) {
|
|
866
|
+
super(e, 403, r), this.name = "ForbiddenError";
|
|
227
867
|
}
|
|
228
868
|
}
|
|
229
|
-
class
|
|
230
|
-
constructor(
|
|
231
|
-
super(
|
|
869
|
+
class ie extends i {
|
|
870
|
+
constructor(e = "Not Found", r) {
|
|
871
|
+
super(e, 404, r), this.name = "NotFoundError";
|
|
232
872
|
}
|
|
233
873
|
}
|
|
234
|
-
class
|
|
235
|
-
constructor(
|
|
236
|
-
super(
|
|
874
|
+
class ye extends i {
|
|
875
|
+
constructor(e = "Validation Error", r, n) {
|
|
876
|
+
super(e, 400, n), this.name = "ValidationError", this.errors = r;
|
|
237
877
|
}
|
|
238
878
|
}
|
|
239
|
-
function
|
|
240
|
-
return t instanceof
|
|
879
|
+
function le(t) {
|
|
880
|
+
return t instanceof i;
|
|
241
881
|
}
|
|
242
|
-
function
|
|
243
|
-
return t instanceof
|
|
882
|
+
function ge(t) {
|
|
883
|
+
return t instanceof ce;
|
|
244
884
|
}
|
|
245
885
|
export {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
886
|
+
se as DEFAULT_JANUS_URL,
|
|
887
|
+
ae as ForbiddenError,
|
|
888
|
+
i as JanusApiError,
|
|
889
|
+
ie as NotFoundError,
|
|
890
|
+
ce as UnauthorizedError,
|
|
891
|
+
ye as ValidationError,
|
|
892
|
+
o as buildClientScopedPaginatedUrl,
|
|
893
|
+
l as buildPaginatedUrl,
|
|
894
|
+
O as buildQueryString,
|
|
253
895
|
u as buildUrl,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
896
|
+
oe as createJanusApi,
|
|
897
|
+
le as isJanusApiError,
|
|
898
|
+
ge as isUnauthorizedError
|
|
257
899
|
};
|