@pelygo/janus 0.1.1 → 0.1.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.
- package/dist/index.d.ts +617 -16
- package/dist/index.js +460 -158
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,257 +1,559 @@
|
|
|
1
|
-
import { createAuthApi as
|
|
2
|
-
function
|
|
1
|
+
import { createAuthApi as f } from "@pelygo/auth/core";
|
|
2
|
+
function S(r) {
|
|
3
3
|
return {
|
|
4
4
|
async getAll() {
|
|
5
|
-
return
|
|
5
|
+
return r.get("/clients");
|
|
6
6
|
},
|
|
7
|
-
async
|
|
8
|
-
return
|
|
7
|
+
async getWithActiveIntegrations() {
|
|
8
|
+
return r.get("/clients/activeIntegrations");
|
|
9
9
|
},
|
|
10
|
-
async
|
|
11
|
-
return
|
|
10
|
+
async previewNotification(e, t) {
|
|
11
|
+
return r.get(`/clients/preview-notification?type=${encodeURIComponent(e)}&client_id=${t}`);
|
|
12
12
|
},
|
|
13
|
-
async
|
|
14
|
-
return
|
|
13
|
+
async getById(e) {
|
|
14
|
+
return r.get(`/clients/${e}`);
|
|
15
15
|
},
|
|
16
|
-
async
|
|
17
|
-
return
|
|
16
|
+
async getByIdMinimal(e) {
|
|
17
|
+
return r.get(`/clients/${e}?type=m`);
|
|
18
18
|
},
|
|
19
|
-
async
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
async create(e) {
|
|
20
|
+
return r.post("/clients", e);
|
|
21
|
+
},
|
|
22
|
+
async replace(e, t) {
|
|
23
|
+
return r.put(`/clients/${e}`, t);
|
|
23
24
|
},
|
|
24
|
-
async
|
|
25
|
-
return
|
|
25
|
+
async update(e, t) {
|
|
26
|
+
return r.patch(`/clients/${e}`, t);
|
|
26
27
|
},
|
|
27
|
-
async
|
|
28
|
+
async getReturnReasons(e) {
|
|
29
|
+
return r.get(`/clients/${e}/returnreasons`);
|
|
30
|
+
},
|
|
31
|
+
async addReturnReason(e, t) {
|
|
28
32
|
const n = {
|
|
29
|
-
client: { id:
|
|
30
|
-
return_reason: { id:
|
|
33
|
+
client: { id: e },
|
|
34
|
+
return_reason: { id: t }
|
|
31
35
|
};
|
|
32
|
-
return
|
|
36
|
+
return r.post(`/clients/${e}/returnreasons`, n);
|
|
37
|
+
},
|
|
38
|
+
async updateReturnReasons(e, t) {
|
|
39
|
+
return r.put(`/clients/${e}/returnreasons`, t);
|
|
40
|
+
},
|
|
41
|
+
async removeReturnReason(e, t) {
|
|
42
|
+
return r.delete(`/clients/${e}/returnreasons/${t}`);
|
|
43
|
+
},
|
|
44
|
+
async getCourierServices(e) {
|
|
45
|
+
return r.get(`/clients/${e}/courierservices`);
|
|
46
|
+
},
|
|
47
|
+
async getCourierServiceById(e, t) {
|
|
48
|
+
return r.get(`/clients/${e}/courierservices/${t}`);
|
|
49
|
+
},
|
|
50
|
+
async addCourierService(e, t) {
|
|
51
|
+
return r.post(`/clients/${e}/courierservices`, t);
|
|
52
|
+
},
|
|
53
|
+
async updateCourierService(e, t) {
|
|
54
|
+
if (!t.id)
|
|
55
|
+
throw new Error("Service ID is required for update");
|
|
56
|
+
return r.patch(`/clients/${e}/courierservices/${t.id}`, t);
|
|
57
|
+
},
|
|
58
|
+
async deleteCourierService(e, t) {
|
|
59
|
+
return r.delete(`/clients/${e}/courierservices/${t}`);
|
|
60
|
+
},
|
|
61
|
+
async createIntegration(e, t) {
|
|
62
|
+
return r.post(`/clients/${e}/integration`, t);
|
|
63
|
+
},
|
|
64
|
+
async getOrderByRef(e, t) {
|
|
65
|
+
return r.get(`/clients/${e}/orderbyref/${encodeURIComponent(t)}`);
|
|
66
|
+
},
|
|
67
|
+
async getFiles(e) {
|
|
68
|
+
return r.get(`/clients/${e}/files`);
|
|
69
|
+
},
|
|
70
|
+
async uploadFile(e, t, n) {
|
|
71
|
+
return r.post(`/clients/${e}/files/${t}`, n);
|
|
33
72
|
},
|
|
34
|
-
async
|
|
35
|
-
return
|
|
73
|
+
async deleteFile(e, t) {
|
|
74
|
+
return r.delete(`/clients/${e}/files/${encodeURIComponent(t)}`);
|
|
36
75
|
},
|
|
37
|
-
async
|
|
38
|
-
return
|
|
76
|
+
async getSettings(e) {
|
|
77
|
+
return r.get(`/clients/${e}/settings`);
|
|
39
78
|
}
|
|
40
79
|
};
|
|
41
80
|
}
|
|
42
|
-
function
|
|
43
|
-
if (!
|
|
81
|
+
function R(r) {
|
|
82
|
+
if (!r)
|
|
44
83
|
return "";
|
|
45
|
-
const
|
|
46
|
-
for (const [
|
|
47
|
-
n != null && n !== "" &&
|
|
48
|
-
return
|
|
84
|
+
const e = new URLSearchParams();
|
|
85
|
+
for (const [t, n] of Object.entries(r))
|
|
86
|
+
n != null && n !== "" && e.append(t, String(n));
|
|
87
|
+
return e.toString();
|
|
49
88
|
}
|
|
50
|
-
function u(
|
|
51
|
-
if (!
|
|
52
|
-
return
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
return
|
|
56
|
-
const n =
|
|
57
|
-
return `${
|
|
89
|
+
function u(r, e) {
|
|
90
|
+
if (!e || Object.keys(e).length === 0)
|
|
91
|
+
return r;
|
|
92
|
+
const t = R(e);
|
|
93
|
+
if (!t)
|
|
94
|
+
return r;
|
|
95
|
+
const n = r.includes("?") ? "&" : "?";
|
|
96
|
+
return `${r}${n}${t}`;
|
|
58
97
|
}
|
|
59
|
-
function
|
|
98
|
+
function p(r) {
|
|
60
99
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
// ── Core returns ─────────────────────────────────────────────
|
|
101
|
+
async query(e) {
|
|
102
|
+
const t = u("/returns/", e);
|
|
103
|
+
return r.get(t);
|
|
104
|
+
},
|
|
105
|
+
async queryPost(e) {
|
|
106
|
+
return r.post("/returns/query", e);
|
|
107
|
+
},
|
|
108
|
+
async getById(e, t) {
|
|
109
|
+
const n = u(`/returns/${e}`, t);
|
|
110
|
+
return r.get(n);
|
|
111
|
+
},
|
|
112
|
+
async create(e) {
|
|
113
|
+
return r.post("/helpers/returns", e);
|
|
114
|
+
},
|
|
115
|
+
async createDirect(e) {
|
|
116
|
+
return r.post("/returns", e);
|
|
117
|
+
},
|
|
118
|
+
async replace(e, t) {
|
|
119
|
+
return r.put(`/returns/${e}`, t);
|
|
120
|
+
},
|
|
121
|
+
async update(e, t) {
|
|
122
|
+
return r.patch(`/returns/${e}`, t);
|
|
64
123
|
},
|
|
65
|
-
async
|
|
66
|
-
|
|
67
|
-
return t.get(n);
|
|
124
|
+
async delete(e) {
|
|
125
|
+
return r.delete(`/returns/${e}`);
|
|
68
126
|
},
|
|
69
|
-
async
|
|
70
|
-
|
|
127
|
+
async setApproval(e, t) {
|
|
128
|
+
const n = { approve: t };
|
|
129
|
+
return r.post(`/returns/${e}/approval`, n);
|
|
71
130
|
},
|
|
72
|
-
async
|
|
73
|
-
return
|
|
131
|
+
async getEmail(e) {
|
|
132
|
+
return r.get(`/returns/email?ref=${encodeURIComponent(e)}`);
|
|
74
133
|
},
|
|
75
|
-
|
|
76
|
-
|
|
134
|
+
// ── Return items ─────────────────────────────────────────────
|
|
135
|
+
async getItems(e) {
|
|
136
|
+
return r.get(`/returns/${e}/returnitems`);
|
|
77
137
|
},
|
|
78
|
-
async
|
|
79
|
-
return
|
|
138
|
+
async getItemById(e, t) {
|
|
139
|
+
return r.get(`/returns/${e}/returnitems/${t}`);
|
|
80
140
|
},
|
|
81
|
-
async
|
|
141
|
+
async addItem(e, t) {
|
|
142
|
+
return r.post(`/returns/${e}/returnitems`, t);
|
|
143
|
+
},
|
|
144
|
+
async updateItem(e, t, n) {
|
|
145
|
+
return r.patch(`/returns/${e}/returnitems/${t}`, n);
|
|
146
|
+
},
|
|
147
|
+
async updateItems(e, t) {
|
|
148
|
+
return r.patch(`/returns/${e}/returnitems`, t);
|
|
149
|
+
},
|
|
150
|
+
// ── Return statuses (per-return) ─────────────────────────────
|
|
151
|
+
async getStatuses(e) {
|
|
152
|
+
return r.get(`/returns/${e}/statuses`);
|
|
153
|
+
},
|
|
154
|
+
async addStatus(e, t) {
|
|
82
155
|
const n = {
|
|
83
|
-
return: { id:
|
|
84
|
-
return_status: { id:
|
|
156
|
+
return: { id: e },
|
|
157
|
+
return_status: { id: t },
|
|
85
158
|
created_by: { id: 1 }
|
|
86
159
|
};
|
|
87
|
-
return
|
|
160
|
+
return r.post(`/returns/${e}/statuses`, n);
|
|
88
161
|
},
|
|
89
|
-
async removeStatus(
|
|
90
|
-
return
|
|
162
|
+
async removeStatus(e, t) {
|
|
163
|
+
return r.delete(`/returns/${e}/statuses/${t}`);
|
|
91
164
|
},
|
|
92
|
-
|
|
93
|
-
|
|
165
|
+
// ── Return comments (per-return) ─────────────────────────────
|
|
166
|
+
async getComments(e) {
|
|
167
|
+
return r.get(`/returns/${e}/comments`);
|
|
94
168
|
},
|
|
95
|
-
async
|
|
96
|
-
return
|
|
169
|
+
async getCommentById(e, t) {
|
|
170
|
+
return r.get(`/returns/${e}/comments/${t}`);
|
|
97
171
|
},
|
|
98
|
-
async
|
|
99
|
-
|
|
172
|
+
async addComment(e, t) {
|
|
173
|
+
const n = { comment: t };
|
|
174
|
+
return r.post(`/returns/${e}/comments`, n);
|
|
100
175
|
},
|
|
101
|
-
async
|
|
102
|
-
return
|
|
176
|
+
async removeComment(e, t) {
|
|
177
|
+
return r.delete(`/returns/${e}/comments/${t}`);
|
|
103
178
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return
|
|
179
|
+
// ── Reference data: reasons ──────────────────────────────────
|
|
180
|
+
async getReasons() {
|
|
181
|
+
return r.get("/returns/reasons");
|
|
107
182
|
},
|
|
108
|
-
async
|
|
109
|
-
return
|
|
183
|
+
async getReasonById(e) {
|
|
184
|
+
return r.get(`/returns/reasons/${e}`);
|
|
110
185
|
},
|
|
111
|
-
async
|
|
112
|
-
|
|
113
|
-
return t.post(`/returns/${r}/approval`, n);
|
|
186
|
+
async createReason(e) {
|
|
187
|
+
return r.post("/returns/reasons", e);
|
|
114
188
|
},
|
|
115
|
-
async
|
|
116
|
-
return
|
|
189
|
+
async updateReason(e, t) {
|
|
190
|
+
return r.put(`/returns/reasons/${e}`, t);
|
|
117
191
|
},
|
|
192
|
+
// ── Reference data: statuses ─────────────────────────────────
|
|
118
193
|
async getAllStatuses() {
|
|
119
|
-
return
|
|
194
|
+
return r.get("/returns/statuses");
|
|
195
|
+
},
|
|
196
|
+
async getStatusById(e) {
|
|
197
|
+
return r.get(`/returns/statuses/${e}`);
|
|
120
198
|
},
|
|
121
|
-
async
|
|
122
|
-
return
|
|
199
|
+
async createStatus(e) {
|
|
200
|
+
return r.post("/returns/statuses", e);
|
|
201
|
+
},
|
|
202
|
+
async updateStatus(e, t) {
|
|
203
|
+
return r.put(`/returns/statuses/${e}`, t);
|
|
204
|
+
},
|
|
205
|
+
async deleteStatus(e) {
|
|
206
|
+
return r.delete(`/returns/statuses/${e}`);
|
|
207
|
+
},
|
|
208
|
+
// ── Reference data: categories ───────────────────────────────
|
|
209
|
+
async getCategories() {
|
|
210
|
+
return r.get("/returns/categories");
|
|
211
|
+
},
|
|
212
|
+
async getCategoryById(e) {
|
|
213
|
+
return r.get(`/returns/categories/${e}`);
|
|
214
|
+
},
|
|
215
|
+
async createCategory(e) {
|
|
216
|
+
return r.post("/returns/categories", e);
|
|
217
|
+
},
|
|
218
|
+
async updateCategory(e, t) {
|
|
219
|
+
return r.put(`/returns/categories/${e}`, t);
|
|
220
|
+
},
|
|
221
|
+
// ── Reference data: sources ──────────────────────────────────
|
|
222
|
+
async getSources() {
|
|
223
|
+
return r.get("/returns/sources");
|
|
224
|
+
},
|
|
225
|
+
async getSourceById(e) {
|
|
226
|
+
return r.get(`/returns/sources/${e}`);
|
|
227
|
+
},
|
|
228
|
+
async createSource(e) {
|
|
229
|
+
return r.post("/returns/sources", e);
|
|
230
|
+
},
|
|
231
|
+
async updateSource(e, t) {
|
|
232
|
+
return r.put(`/returns/sources/${e}`, t);
|
|
233
|
+
},
|
|
234
|
+
async deleteSource(e) {
|
|
235
|
+
return r.delete(`/returns/sources/${e}`);
|
|
236
|
+
},
|
|
237
|
+
// ── Reference data: comments (global) ────────────────────────
|
|
238
|
+
async getAllComments() {
|
|
239
|
+
return r.get("/returns/comments");
|
|
240
|
+
},
|
|
241
|
+
async getGlobalCommentById(e) {
|
|
242
|
+
return r.get(`/returns/comments/${e}`);
|
|
243
|
+
},
|
|
244
|
+
// ── Filter options ───────────────────────────────────────────
|
|
245
|
+
async getFilterOptions(e) {
|
|
246
|
+
return r.get(`/orders/returns/filter-types?clientId=${e}`);
|
|
123
247
|
}
|
|
124
248
|
};
|
|
125
249
|
}
|
|
126
|
-
function
|
|
250
|
+
function C(r) {
|
|
127
251
|
return {
|
|
128
|
-
async returnsSummary(
|
|
129
|
-
const
|
|
130
|
-
return
|
|
252
|
+
async returnsSummary(e) {
|
|
253
|
+
const t = u("/reports/returns/summary/", e);
|
|
254
|
+
return r.get(t);
|
|
131
255
|
},
|
|
132
|
-
async returnsSummaryCsv(
|
|
133
|
-
const
|
|
134
|
-
return
|
|
256
|
+
async returnsSummaryCsv(e) {
|
|
257
|
+
const t = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/summary/", t);
|
|
258
|
+
return r.get(n);
|
|
135
259
|
},
|
|
136
|
-
async returnsReasons(
|
|
137
|
-
const
|
|
138
|
-
return
|
|
260
|
+
async returnsReasons(e) {
|
|
261
|
+
const t = u("/reports/returns/reasons/", e);
|
|
262
|
+
return r.get(t);
|
|
139
263
|
},
|
|
140
|
-
async returnsReasonsCsv(
|
|
141
|
-
const
|
|
142
|
-
return
|
|
264
|
+
async returnsReasonsCsv(e) {
|
|
265
|
+
const t = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/reasons/", t);
|
|
266
|
+
return r.get(n);
|
|
143
267
|
},
|
|
144
|
-
async returnsOverview(
|
|
145
|
-
const
|
|
146
|
-
return
|
|
268
|
+
async returnsOverview(e) {
|
|
269
|
+
const t = u("/reports/returns/overview/", e);
|
|
270
|
+
return r.get(t);
|
|
147
271
|
},
|
|
148
|
-
async returnsOverviewCsv(
|
|
149
|
-
const
|
|
150
|
-
return
|
|
272
|
+
async returnsOverviewCsv(e) {
|
|
273
|
+
const t = { ...e, csv: !0, pageSize: 1e5 }, n = u("/reports/returns/overview/", t);
|
|
274
|
+
return r.get(n);
|
|
151
275
|
},
|
|
152
|
-
async returnsStats(
|
|
153
|
-
return
|
|
276
|
+
async returnsStats(e) {
|
|
277
|
+
return r.get(`/reports/returns/stats?clientId=${e}`);
|
|
154
278
|
}
|
|
155
279
|
};
|
|
156
280
|
}
|
|
157
|
-
function
|
|
158
|
-
const { baseUrl:
|
|
159
|
-
async function
|
|
160
|
-
const
|
|
281
|
+
function I(r) {
|
|
282
|
+
const { baseUrl: e } = r;
|
|
283
|
+
async function t(n, s) {
|
|
284
|
+
const c = await fetch(n, {
|
|
161
285
|
headers: {
|
|
162
286
|
"Content-Type": "application/json"
|
|
163
287
|
},
|
|
164
288
|
...s
|
|
165
289
|
});
|
|
166
|
-
if (!
|
|
167
|
-
const
|
|
168
|
-
throw new Error(`HTTP ${
|
|
290
|
+
if (!c.ok) {
|
|
291
|
+
const o = await c.text().catch(() => "Unknown error");
|
|
292
|
+
throw new Error(`HTTP ${c.status}: ${o}`);
|
|
169
293
|
}
|
|
170
|
-
return
|
|
294
|
+
return c.json();
|
|
171
295
|
}
|
|
172
296
|
return {
|
|
173
297
|
async getClientSettingsByName(n) {
|
|
174
|
-
return
|
|
175
|
-
`${
|
|
298
|
+
return t(
|
|
299
|
+
`${e}/helpers/clientsettings/${encodeURIComponent(n)}`
|
|
176
300
|
);
|
|
177
301
|
},
|
|
178
302
|
async getNotificationSettings(n) {
|
|
179
|
-
return
|
|
180
|
-
`${
|
|
303
|
+
return t(
|
|
304
|
+
`${e}/helpers/settings/${encodeURIComponent(n)}`
|
|
181
305
|
);
|
|
182
306
|
},
|
|
183
|
-
async customerLogin(n, s,
|
|
184
|
-
return
|
|
307
|
+
async customerLogin(n, s, c) {
|
|
308
|
+
return t(`${e}/helpers/customerlogin`, {
|
|
185
309
|
method: "POST",
|
|
186
310
|
body: JSON.stringify({
|
|
187
311
|
client_id: n,
|
|
188
312
|
order_ref: s,
|
|
189
|
-
postcode:
|
|
313
|
+
postcode: c
|
|
190
314
|
})
|
|
191
315
|
});
|
|
192
316
|
}
|
|
193
317
|
};
|
|
194
318
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
319
|
+
function U(r) {
|
|
320
|
+
return {
|
|
321
|
+
async getAll() {
|
|
322
|
+
return r.get("/couriers");
|
|
323
|
+
},
|
|
324
|
+
async getById(e) {
|
|
325
|
+
return r.get(`/couriers/${e}`);
|
|
326
|
+
},
|
|
327
|
+
async create(e) {
|
|
328
|
+
return r.post("/couriers", e);
|
|
329
|
+
},
|
|
330
|
+
async update(e, t) {
|
|
331
|
+
return r.put(`/couriers/${e}`, t);
|
|
332
|
+
},
|
|
333
|
+
async getServices(e) {
|
|
334
|
+
return r.get(`/couriers/${e}/services`);
|
|
335
|
+
},
|
|
336
|
+
async getServiceById(e, t) {
|
|
337
|
+
return r.get(`/couriers/${e}/services/${t}`);
|
|
338
|
+
},
|
|
339
|
+
async createService(e, t) {
|
|
340
|
+
return r.post(`/couriers/${e}/services`, t);
|
|
341
|
+
},
|
|
342
|
+
async updateService(e, t, n) {
|
|
343
|
+
return r.put(`/couriers/${e}/services/${t}`, n);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function w(r) {
|
|
348
|
+
return {
|
|
349
|
+
async getAll(e) {
|
|
350
|
+
const t = u("/orders", e);
|
|
351
|
+
return r.get(t);
|
|
352
|
+
},
|
|
353
|
+
async getStats(e) {
|
|
354
|
+
const t = u("/orders/stats", e);
|
|
355
|
+
return r.get(t);
|
|
356
|
+
},
|
|
357
|
+
async getReturns(e) {
|
|
358
|
+
const t = u("/orders/returns", e);
|
|
359
|
+
return r.get(t);
|
|
360
|
+
},
|
|
361
|
+
async getByRef(e, t) {
|
|
362
|
+
const n = u(`/orders/${encodeURIComponent(e)}`, t != null ? { clientId: t } : void 0);
|
|
363
|
+
return r.get(n);
|
|
364
|
+
},
|
|
365
|
+
async getReturnFilterOptions(e) {
|
|
366
|
+
return r.get(`/orders/returns/filter-types?clientId=${e}`);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function E(r) {
|
|
371
|
+
return {
|
|
372
|
+
async getAll() {
|
|
373
|
+
return r.get("/integrations");
|
|
374
|
+
},
|
|
375
|
+
async getByClientId(e) {
|
|
376
|
+
return r.get(`/integrations/${e}`);
|
|
377
|
+
},
|
|
378
|
+
async getByCustomerAndName(e, t) {
|
|
379
|
+
return r.get(`/integrations/${e}/${encodeURIComponent(t)}`);
|
|
380
|
+
},
|
|
381
|
+
async getActive() {
|
|
382
|
+
return r.get("/integrations/active");
|
|
383
|
+
},
|
|
384
|
+
async getNamesOnly() {
|
|
385
|
+
return r.get("/integrations/namesOnly");
|
|
386
|
+
},
|
|
387
|
+
async create(e) {
|
|
388
|
+
return r.post("/integrations", e);
|
|
389
|
+
},
|
|
390
|
+
async update(e, t) {
|
|
391
|
+
return r.put(`/integrations/${e}`, t);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function A(r) {
|
|
396
|
+
return {
|
|
397
|
+
async create(e) {
|
|
398
|
+
return r.post("/users", e);
|
|
399
|
+
},
|
|
400
|
+
async update(e) {
|
|
401
|
+
return r.patch("/users", e);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function B(r) {
|
|
406
|
+
return {
|
|
407
|
+
async createActivity(e) {
|
|
408
|
+
return r.post("/logs/activity", e);
|
|
409
|
+
},
|
|
410
|
+
async createOrderIssue(e) {
|
|
411
|
+
return r.post("/logs/orderissue", e);
|
|
412
|
+
},
|
|
413
|
+
async updateOrderIssue(e) {
|
|
414
|
+
return r.patch("/logs/orderissue", e);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function k(r) {
|
|
419
|
+
return {
|
|
420
|
+
async getByUuid(e) {
|
|
421
|
+
return r.get(`/tasks/histories/${encodeURIComponent(e)}`);
|
|
422
|
+
},
|
|
423
|
+
async getAll(e) {
|
|
424
|
+
const t = u("/tasks/histories", e);
|
|
425
|
+
return r.get(t);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function T(r) {
|
|
430
|
+
const { baseUrl: e } = r;
|
|
431
|
+
async function t(s, c) {
|
|
432
|
+
const o = await fetch(s, {
|
|
433
|
+
headers: { "Content-Type": "application/json" },
|
|
434
|
+
...c
|
|
435
|
+
});
|
|
436
|
+
if (!o.ok) {
|
|
437
|
+
const i = await o.text().catch(() => "Unknown error");
|
|
438
|
+
throw new Error(`HTTP ${o.status}: ${i}`);
|
|
439
|
+
}
|
|
440
|
+
return o.json();
|
|
441
|
+
}
|
|
442
|
+
async function n(s) {
|
|
443
|
+
const c = await fetch(s);
|
|
444
|
+
if (!c.ok) {
|
|
445
|
+
const o = await c.text().catch(() => "Unknown error");
|
|
446
|
+
throw new Error(`HTTP ${c.status}: ${o}`);
|
|
447
|
+
}
|
|
448
|
+
return c.text();
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
async tracking(s, c, o) {
|
|
452
|
+
const i = new URLSearchParams({
|
|
453
|
+
order_ref: s,
|
|
454
|
+
postcode: c,
|
|
455
|
+
client_id: String(o)
|
|
456
|
+
});
|
|
457
|
+
return t(`${e}/customer/tracking?${i}`);
|
|
458
|
+
},
|
|
459
|
+
async track(s) {
|
|
460
|
+
return t(`${e}/customer/track?ref=${encodeURIComponent(s)}`);
|
|
461
|
+
},
|
|
462
|
+
async login(s) {
|
|
463
|
+
return t(`${e}/customer/login`, {
|
|
464
|
+
method: "POST",
|
|
465
|
+
body: JSON.stringify(s)
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
async viewEmail(s) {
|
|
469
|
+
return n(`${e}/customer/view-email?ref=${encodeURIComponent(s)}`);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function O(r) {
|
|
474
|
+
return {
|
|
475
|
+
async getCouriers() {
|
|
476
|
+
return r.get("/legacy-couriers");
|
|
477
|
+
},
|
|
478
|
+
async getPostServices() {
|
|
479
|
+
return r.get("/legacy-postservices");
|
|
480
|
+
},
|
|
481
|
+
async getPostServicesByCarrier(e) {
|
|
482
|
+
return r.get(`/legacy-postservices/${encodeURIComponent(e)}`);
|
|
483
|
+
},
|
|
484
|
+
async queryProducts(e) {
|
|
485
|
+
return r.post("/legacy/products/query", e);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
const F = "https://api.janus.pelygo.com";
|
|
490
|
+
function L(r = {}) {
|
|
491
|
+
const e = r.baseUrl || F, t = {
|
|
492
|
+
baseUrl: e,
|
|
493
|
+
authUrl: r.authUrl,
|
|
494
|
+
onUnauthorized: r.onUnauthorized,
|
|
495
|
+
onLoginSuccess: r.onLoginSuccess,
|
|
496
|
+
onLoginError: r.onLoginError
|
|
497
|
+
}, n = f(t), s = S(n), c = p(n), o = C(n), i = I({ baseUrl: e }), y = U(n), g = w(n), l = E(n), d = A(n), $ = B(n), m = k(n), h = T({ baseUrl: e }), v = O(n);
|
|
204
498
|
return {
|
|
205
499
|
clients: s,
|
|
206
|
-
returns:
|
|
207
|
-
reports:
|
|
500
|
+
returns: c,
|
|
501
|
+
reports: o,
|
|
208
502
|
helpers: i,
|
|
503
|
+
couriers: y,
|
|
504
|
+
orders: g,
|
|
505
|
+
integrations: l,
|
|
506
|
+
users: d,
|
|
507
|
+
logs: $,
|
|
508
|
+
tasks: m,
|
|
509
|
+
customer: h,
|
|
510
|
+
legacy: v,
|
|
209
511
|
auth: n
|
|
210
512
|
};
|
|
211
513
|
}
|
|
212
|
-
class
|
|
213
|
-
constructor(
|
|
214
|
-
super(
|
|
514
|
+
class a extends Error {
|
|
515
|
+
constructor(e, t, n) {
|
|
516
|
+
super(e), this.name = "JanusApiError", this.status = t, this.response = n;
|
|
215
517
|
const s = Error;
|
|
216
|
-
s.captureStackTrace && s.captureStackTrace(this,
|
|
518
|
+
s.captureStackTrace && s.captureStackTrace(this, a);
|
|
217
519
|
}
|
|
218
520
|
}
|
|
219
|
-
class
|
|
220
|
-
constructor(
|
|
221
|
-
super(
|
|
521
|
+
class x extends a {
|
|
522
|
+
constructor(e = "Unauthorized", t) {
|
|
523
|
+
super(e, 401, t), this.name = "UnauthorizedError";
|
|
222
524
|
}
|
|
223
525
|
}
|
|
224
|
-
class
|
|
225
|
-
constructor(
|
|
226
|
-
super(
|
|
526
|
+
class N extends a {
|
|
527
|
+
constructor(e = "Forbidden", t) {
|
|
528
|
+
super(e, 403, t), this.name = "ForbiddenError";
|
|
227
529
|
}
|
|
228
530
|
}
|
|
229
|
-
class
|
|
230
|
-
constructor(
|
|
231
|
-
super(
|
|
531
|
+
class P extends a {
|
|
532
|
+
constructor(e = "Not Found", t) {
|
|
533
|
+
super(e, 404, t), this.name = "NotFoundError";
|
|
232
534
|
}
|
|
233
535
|
}
|
|
234
|
-
class
|
|
235
|
-
constructor(
|
|
236
|
-
super(
|
|
536
|
+
class z extends a {
|
|
537
|
+
constructor(e = "Validation Error", t, n) {
|
|
538
|
+
super(e, 400, n), this.name = "ValidationError", this.errors = t;
|
|
237
539
|
}
|
|
238
540
|
}
|
|
239
|
-
function
|
|
240
|
-
return
|
|
541
|
+
function _(r) {
|
|
542
|
+
return r instanceof a;
|
|
241
543
|
}
|
|
242
|
-
function
|
|
243
|
-
return
|
|
544
|
+
function J(r) {
|
|
545
|
+
return r instanceof x;
|
|
244
546
|
}
|
|
245
547
|
export {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
548
|
+
F as DEFAULT_JANUS_URL,
|
|
549
|
+
N as ForbiddenError,
|
|
550
|
+
a as JanusApiError,
|
|
551
|
+
P as NotFoundError,
|
|
552
|
+
x as UnauthorizedError,
|
|
553
|
+
z as ValidationError,
|
|
554
|
+
R as buildQueryString,
|
|
253
555
|
u as buildUrl,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
556
|
+
L as createJanusApi,
|
|
557
|
+
_ as isJanusApiError,
|
|
558
|
+
J as isUnauthorizedError
|
|
257
559
|
};
|