@ercioko/meblotex-api 0.1.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/LICENSE +21 -0
- package/dist/api/Api.d.ts +31 -0
- package/dist/api/Api.js +167 -0
- package/dist/api/Endpoint.d.ts +13 -0
- package/dist/api/Endpoint.js +125 -0
- package/dist/api/createApi.d.ts +52 -0
- package/dist/api/createApi.js +81 -0
- package/dist/api/error.d.ts +15 -0
- package/dist/api/error.js +18 -0
- package/dist/api/index.d.ts +50 -0
- package/dist/api/index.js +37 -0
- package/dist/api/status.d.ts +3 -0
- package/dist/api/status.js +6 -0
- package/dist/api/utils/getAlert.d.ts +6 -0
- package/dist/api/utils/getAlert.js +65 -0
- package/dist/api/utils/index.d.ts +1 -0
- package/dist/api/utils/index.js +8 -0
- package/dist/app_types.d.ts +608 -0
- package/dist/app_types.js +75 -0
- package/dist/components/StatusTag.d.ts +11 -0
- package/dist/components/StatusTag.js +86 -0
- package/dist/components/Table/DataTableWrapper.d.ts +2 -0
- package/dist/components/Table/DataTableWrapper.js +44 -0
- package/dist/components/Table/FloatingActions.d.ts +15 -0
- package/dist/components/Table/FloatingActions.js +32 -0
- package/dist/components/Table/Spinner.d.ts +2 -0
- package/dist/components/Table/Spinner.js +26 -0
- package/dist/components/Table/Summary.js +16 -0
- package/dist/components/Table/Table.d.ts +28 -0
- package/dist/components/Table/Table.js +330 -0
- package/dist/components/Table/addIndexToObject.d.ts +3 -0
- package/dist/components/Table/addIndexToObject.js +17 -0
- package/dist/components/Table/areProvidedColumnsDifferent.d.ts +2 -0
- package/dist/components/Table/areProvidedColumnsDifferent.js +16 -0
- package/dist/components/Table/clicked.js +11 -0
- package/dist/components/Table/displayActions.js +11 -0
- package/dist/components/Table/hooks/useFetchPage.d.ts +18 -0
- package/dist/components/Table/hooks/useFetchPage.js +123 -0
- package/dist/components/Table/hooks/useGetCellRenderer.d.ts +18 -0
- package/dist/components/Table/hooks/useGetCellRenderer.js +166 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +53 -0
- package/dist/components/Table/hooks/useGetDeleteRow.d.ts +9 -0
- package/dist/components/Table/hooks/useGetDeleteRow.js +74 -0
- package/dist/components/Table/hooks/useGetResizeColumn.d.ts +9 -0
- package/dist/components/Table/hooks/useGetResizeColumn.js +28 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.js +54 -0
- package/dist/components/Table/hooks/useLoadDataSource.d.ts +10 -0
- package/dist/components/Table/hooks/useLoadDataSource.js +20 -0
- package/dist/components/Table/hooks/usePageSize.d.ts +5 -0
- package/dist/components/Table/hooks/usePageSize.js +17 -0
- package/dist/components/Table/hooks/useRenderRowActions.d.ts +6 -0
- package/dist/components/Table/hooks/useRenderRowActions.js +51 -0
- package/dist/components/Table/hooks/useResizeColumns.d.ts +9 -0
- package/dist/components/Table/hooks/useResizeColumns.js +60 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +8 -0
- package/dist/components/Table/providers/OrderProvider.d.ts +9 -0
- package/dist/components/Table/providers/OrderProvider.js +17 -0
- package/dist/components/Table/styles.d.ts +6 -0
- package/dist/components/Table/styles.js +37 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +25 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +12 -0
- package/dist/db_types.d.ts +208 -0
- package/dist/db_types.js +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/useApi.d.ts +2 -0
- package/dist/hooks/useApi.js +40 -0
- package/dist/hooks/useEndpoint.d.ts +2 -0
- package/dist/hooks/useEndpoint.js +32 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/jednostka.d.ts +6 -0
- package/dist/lib/jednostkaNazwa.d.ts +6 -0
- package/dist/lib/jednostkaNazwa.js +9 -0
- package/dist/lib/typDokumentuNazwa.d.ts +6 -0
- package/dist/lib/typDokumentuNazwa.js +11 -0
- package/dist/lib/typ_dokument.d.ts +0 -0
- package/dist/lib/typ_dokumentu.d.ts +6 -0
- package/dist/lib/unit.d.ts +0 -0
- package/dist/src/api/Api.js +313 -0
- package/dist/src/api/Endpoint.js +364 -0
- package/dist/src/api/createApi.js +50 -0
- package/dist/src/api/error.js +15 -0
- package/dist/src/api/index.js +8 -0
- package/dist/src/api/status.js +3 -0
- package/dist/src/api/utils/getAlert.js +63 -0
- package/dist/src/api/utils/index.js +1 -0
- package/dist/src/app_types.js +72 -0
- package/dist/src/components/StatusTag.js +153 -0
- package/dist/src/components/Table/DataTableWrapper.js +115 -0
- package/dist/src/components/Table/FloatingActions.js +60 -0
- package/dist/src/components/Table/Spinner.js +40 -0
- package/dist/src/components/Table/Summary.js +16 -0
- package/dist/src/components/Table/Table.js +498 -0
- package/dist/src/components/Table/addIndexToObject.js +57 -0
- package/dist/src/components/Table/areProvidedColumnsDifferent.js +19 -0
- package/dist/src/components/Table/clicked.js +12 -0
- package/dist/src/components/Table/displayActions.js +11 -0
- package/dist/src/components/Table/hooks/useFetchPage.js +254 -0
- package/dist/src/components/Table/hooks/useGetCellRenderer.js +231 -0
- package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +33 -0
- package/dist/src/components/Table/hooks/useGetDeleteRow.js +181 -0
- package/dist/src/components/Table/hooks/useGetResizeColumn.js +72 -0
- package/dist/src/components/Table/hooks/useGetRowCheckbox.js +55 -0
- package/dist/src/components/Table/hooks/useLoadDataSource.js +16 -0
- package/dist/src/components/Table/hooks/usePageSize.js +15 -0
- package/dist/src/components/Table/hooks/useRenderRowActions.js +50 -0
- package/dist/src/components/Table/hooks/useResizeColumns.js +70 -0
- package/dist/src/components/Table/index.js +1 -0
- package/dist/src/components/Table/providers/OrderProvider.js +65 -0
- package/dist/src/components/Table/styles.js +66 -0
- package/dist/src/components/index.js +3 -0
- package/dist/src/config.js +10 -0
- package/dist/src/db_types.js +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/useApi.js +82 -0
- package/dist/src/hooks/useEndpoint.js +57 -0
- package/dist/src/index.js +4 -0
- package/dist/src/lib/index.js +2 -0
- package/dist/src/lib/jednostkaNazwa.js +6 -0
- package/dist/src/lib/typDokumentuNazwa.js +16 -0
- package/dist/src/utils/Query.js +73 -0
- package/dist/src/utils/getWZNumber.js +4 -0
- package/dist/src/utils/getZamowienieDokumentNumber.js +4 -0
- package/dist/src/utils/index.js +3 -0
- package/dist/utils/AlertContext.d.ts +3 -0
- package/dist/utils/AlertContext.js +3 -0
- package/dist/utils/Query.d.ts +6 -0
- package/dist/utils/Query.js +33 -0
- package/dist/utils/geNumber.d.ts +2 -0
- package/dist/utils/getDocNumber.d.ts +2 -0
- package/dist/utils/getWZNumber.js +10 -0
- package/dist/utils/getWzNumber.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber copy.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber.js +8 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +12 -0
- package/package.json +60 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _define_property(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
function _ts_generator(thisArg, body) {
|
|
63
|
+
var f, y, t, g, _ = {
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
71
|
+
};
|
|
72
|
+
return g = {
|
|
73
|
+
next: verb(0),
|
|
74
|
+
"throw": verb(1),
|
|
75
|
+
"return": verb(2)
|
|
76
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
77
|
+
return this;
|
|
78
|
+
}), g;
|
|
79
|
+
function verb(n) {
|
|
80
|
+
return function(v) {
|
|
81
|
+
return step([
|
|
82
|
+
n,
|
|
83
|
+
v
|
|
84
|
+
]);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function step(op) {
|
|
88
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
89
|
+
while(_)try {
|
|
90
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
91
|
+
if (y = 0, t) op = [
|
|
92
|
+
op[0] & 2,
|
|
93
|
+
t.value
|
|
94
|
+
];
|
|
95
|
+
switch(op[0]){
|
|
96
|
+
case 0:
|
|
97
|
+
case 1:
|
|
98
|
+
t = op;
|
|
99
|
+
break;
|
|
100
|
+
case 4:
|
|
101
|
+
_.label++;
|
|
102
|
+
return {
|
|
103
|
+
value: op[1],
|
|
104
|
+
done: false
|
|
105
|
+
};
|
|
106
|
+
case 5:
|
|
107
|
+
_.label++;
|
|
108
|
+
y = op[1];
|
|
109
|
+
op = [
|
|
110
|
+
0
|
|
111
|
+
];
|
|
112
|
+
continue;
|
|
113
|
+
case 7:
|
|
114
|
+
op = _.ops.pop();
|
|
115
|
+
_.trys.pop();
|
|
116
|
+
continue;
|
|
117
|
+
default:
|
|
118
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
119
|
+
_ = 0;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
123
|
+
_.label = op[1];
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
127
|
+
_.label = t[1];
|
|
128
|
+
t = op;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
if (t && _.label < t[2]) {
|
|
132
|
+
_.label = t[2];
|
|
133
|
+
_.ops.push(op);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (t[2]) _.ops.pop();
|
|
137
|
+
_.trys.pop();
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
op = body.call(thisArg, _);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
op = [
|
|
143
|
+
6,
|
|
144
|
+
e
|
|
145
|
+
];
|
|
146
|
+
y = 0;
|
|
147
|
+
} finally{
|
|
148
|
+
f = t = 0;
|
|
149
|
+
}
|
|
150
|
+
if (op[0] & 5) throw op[1];
|
|
151
|
+
return {
|
|
152
|
+
value: op[0] ? op[1] : void 0,
|
|
153
|
+
done: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
import config from '../config';
|
|
158
|
+
import { Query } from '../utils';
|
|
159
|
+
function handleResponse(res) {
|
|
160
|
+
return _handleResponse.apply(this, arguments);
|
|
161
|
+
}
|
|
162
|
+
function _handleResponse() {
|
|
163
|
+
_handleResponse = _async_to_generator(function(res) {
|
|
164
|
+
var ok, url, headers, status, statusText, text;
|
|
165
|
+
return _ts_generator(this, function(_state) {
|
|
166
|
+
switch(_state.label){
|
|
167
|
+
case 0:
|
|
168
|
+
if (res.status === 204) return [
|
|
169
|
+
2,
|
|
170
|
+
{}
|
|
171
|
+
];
|
|
172
|
+
if (res.status.toString().startsWith('2')) return [
|
|
173
|
+
2,
|
|
174
|
+
res.json()
|
|
175
|
+
];
|
|
176
|
+
ok = res.ok, url = res.url, headers = res.headers, status = res.status, statusText = res.statusText;
|
|
177
|
+
return [
|
|
178
|
+
4,
|
|
179
|
+
res.text()
|
|
180
|
+
];
|
|
181
|
+
case 1:
|
|
182
|
+
text = _state.sent();
|
|
183
|
+
throw new Error(JSON.stringify({
|
|
184
|
+
ok: ok,
|
|
185
|
+
url: url,
|
|
186
|
+
headers: headers,
|
|
187
|
+
status: status,
|
|
188
|
+
statusText: statusText,
|
|
189
|
+
text: text
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
return _handleResponse.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
var Api = /*#__PURE__*/ function() {
|
|
197
|
+
"use strict";
|
|
198
|
+
function Api(endpoint) {
|
|
199
|
+
_class_call_check(this, Api);
|
|
200
|
+
_define_property(this, "host", void 0);
|
|
201
|
+
_define_property(this, "namespace", void 0);
|
|
202
|
+
_define_property(this, "endpoint", void 0);
|
|
203
|
+
this.host = typeof window !== 'undefined' && window.localStorage.getItem('apiHost') || config.api.host;
|
|
204
|
+
this.namespace = '';
|
|
205
|
+
this.endpoint = endpoint;
|
|
206
|
+
}
|
|
207
|
+
_create_class(Api, [
|
|
208
|
+
{
|
|
209
|
+
key: "get",
|
|
210
|
+
value: function get() {
|
|
211
|
+
var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
212
|
+
var _this = this;
|
|
213
|
+
return _async_to_generator(function() {
|
|
214
|
+
var headers, options, url;
|
|
215
|
+
return _ts_generator(this, function(_state) {
|
|
216
|
+
headers = new Headers();
|
|
217
|
+
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
218
|
+
options = {
|
|
219
|
+
credentials: 'include',
|
|
220
|
+
headers: headers
|
|
221
|
+
};
|
|
222
|
+
url = new URL("".concat(_this.host).concat(_this.namespace, "/").concat(_this.endpoint, "/").concat(opts.id || ''));
|
|
223
|
+
url.search = opts.query ? new URLSearchParams(Query.encode(opts.query)).toString() : '';
|
|
224
|
+
return [
|
|
225
|
+
2,
|
|
226
|
+
fetch(url.href, options).then(handleResponse)
|
|
227
|
+
];
|
|
228
|
+
});
|
|
229
|
+
})();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: "post",
|
|
234
|
+
value: function post(data) {
|
|
235
|
+
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
236
|
+
var _this = this;
|
|
237
|
+
return _async_to_generator(function() {
|
|
238
|
+
var headers, body, url;
|
|
239
|
+
return _ts_generator(this, function(_state) {
|
|
240
|
+
headers = new Headers();
|
|
241
|
+
body = JSON.stringify(data);
|
|
242
|
+
headers.append('Content-Type', 'application/json');
|
|
243
|
+
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
244
|
+
url = new URL("".concat(_this.host).concat(_this.namespace, "/").concat(_this.endpoint));
|
|
245
|
+
url.search = opts.query ? new URLSearchParams(Query.encode(opts.query)).toString() : '';
|
|
246
|
+
return [
|
|
247
|
+
2,
|
|
248
|
+
fetch(url.href, {
|
|
249
|
+
method: 'POST',
|
|
250
|
+
body: body,
|
|
251
|
+
headers: headers,
|
|
252
|
+
credentials: 'include'
|
|
253
|
+
}).then(handleResponse)
|
|
254
|
+
];
|
|
255
|
+
});
|
|
256
|
+
})();
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
key: "put",
|
|
261
|
+
value: function put(id, data) {
|
|
262
|
+
var opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
263
|
+
var _this = this;
|
|
264
|
+
return _async_to_generator(function() {
|
|
265
|
+
var body, headers, url;
|
|
266
|
+
return _ts_generator(this, function(_state) {
|
|
267
|
+
body = JSON.stringify(data);
|
|
268
|
+
headers = new Headers();
|
|
269
|
+
headers.append('Content-Type', 'application/json');
|
|
270
|
+
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
271
|
+
url = new URL("".concat(_this.host).concat(_this.namespace, "/").concat(_this.endpoint).concat(opts.noId ? '' : '/').concat(id || ''));
|
|
272
|
+
url.search = opts.query ? new URLSearchParams(Query.encode(opts.query)).toString() : '';
|
|
273
|
+
return [
|
|
274
|
+
2,
|
|
275
|
+
fetch(url.href, {
|
|
276
|
+
method: 'PUT',
|
|
277
|
+
body: body,
|
|
278
|
+
headers: headers,
|
|
279
|
+
credentials: 'include'
|
|
280
|
+
}).then(handleResponse)
|
|
281
|
+
];
|
|
282
|
+
});
|
|
283
|
+
})();
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
key: "delete",
|
|
288
|
+
value: function _delete(id) {
|
|
289
|
+
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
290
|
+
var _this = this;
|
|
291
|
+
return _async_to_generator(function() {
|
|
292
|
+
var headers, url;
|
|
293
|
+
return _ts_generator(this, function(_state) {
|
|
294
|
+
headers = new Headers();
|
|
295
|
+
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
296
|
+
url = new URL("".concat(_this.host).concat(_this.namespace, "/").concat(_this.endpoint, "/").concat(id));
|
|
297
|
+
url.search = opts.query ? new URLSearchParams(Query.encode(opts.query)).toString() : '';
|
|
298
|
+
return [
|
|
299
|
+
2,
|
|
300
|
+
fetch(url.href, {
|
|
301
|
+
headers: headers,
|
|
302
|
+
method: 'DELETE',
|
|
303
|
+
credentials: 'include'
|
|
304
|
+
}).then(handleResponse)
|
|
305
|
+
];
|
|
306
|
+
});
|
|
307
|
+
})();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
]);
|
|
311
|
+
return Api;
|
|
312
|
+
}();
|
|
313
|
+
export { Api as default };
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/* eslint-disable prefer-reflect */ function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
|
+
try {
|
|
9
|
+
var info = gen[key](arg);
|
|
10
|
+
var value = info.value;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (info.done) {
|
|
16
|
+
resolve(value);
|
|
17
|
+
} else {
|
|
18
|
+
Promise.resolve(value).then(_next, _throw);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _async_to_generator(fn) {
|
|
22
|
+
return function() {
|
|
23
|
+
var self = this, args = arguments;
|
|
24
|
+
return new Promise(function(resolve, reject) {
|
|
25
|
+
var gen = fn.apply(self, args);
|
|
26
|
+
function _next(value) {
|
|
27
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
28
|
+
}
|
|
29
|
+
function _throw(err) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
31
|
+
}
|
|
32
|
+
_next(undefined);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function _class_call_check(instance, Constructor) {
|
|
37
|
+
if (!(instance instanceof Constructor)) {
|
|
38
|
+
throw new TypeError("Cannot call a class as a function");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function _defineProperties(target, props) {
|
|
42
|
+
for(var i = 0; i < props.length; i++){
|
|
43
|
+
var descriptor = props[i];
|
|
44
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
45
|
+
descriptor.configurable = true;
|
|
46
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
47
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
51
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
52
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
53
|
+
return Constructor;
|
|
54
|
+
}
|
|
55
|
+
function _define_property(obj, key, value) {
|
|
56
|
+
if (key in obj) {
|
|
57
|
+
Object.defineProperty(obj, key, {
|
|
58
|
+
value: value,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
obj[key] = value;
|
|
65
|
+
}
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
function _get(target, property, receiver) {
|
|
69
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
70
|
+
_get = Reflect.get;
|
|
71
|
+
} else {
|
|
72
|
+
_get = function get(target, property, receiver) {
|
|
73
|
+
var base = _super_prop_base(target, property);
|
|
74
|
+
if (!base) return;
|
|
75
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
76
|
+
if (desc.get) {
|
|
77
|
+
return desc.get.call(receiver || target);
|
|
78
|
+
}
|
|
79
|
+
return desc.value;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return _get(target, property, receiver || target);
|
|
83
|
+
}
|
|
84
|
+
function _get_prototype_of(o) {
|
|
85
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
86
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
87
|
+
};
|
|
88
|
+
return _get_prototype_of(o);
|
|
89
|
+
}
|
|
90
|
+
function _inherits(subClass, superClass) {
|
|
91
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
92
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
93
|
+
}
|
|
94
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
95
|
+
constructor: {
|
|
96
|
+
value: subClass,
|
|
97
|
+
writable: true,
|
|
98
|
+
configurable: true
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
102
|
+
}
|
|
103
|
+
function _possible_constructor_return(self, call) {
|
|
104
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
105
|
+
return call;
|
|
106
|
+
}
|
|
107
|
+
return _assert_this_initialized(self);
|
|
108
|
+
}
|
|
109
|
+
function _set_prototype_of(o, p) {
|
|
110
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
111
|
+
o.__proto__ = p;
|
|
112
|
+
return o;
|
|
113
|
+
};
|
|
114
|
+
return _set_prototype_of(o, p);
|
|
115
|
+
}
|
|
116
|
+
function _super_prop_base(object, property) {
|
|
117
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
118
|
+
object = _get_prototype_of(object);
|
|
119
|
+
if (object === null) break;
|
|
120
|
+
}
|
|
121
|
+
return object;
|
|
122
|
+
}
|
|
123
|
+
function _type_of(obj) {
|
|
124
|
+
"@swc/helpers - typeof";
|
|
125
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
126
|
+
}
|
|
127
|
+
function _is_native_reflect_construct() {
|
|
128
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
129
|
+
if (Reflect.construct.sham) return false;
|
|
130
|
+
if (typeof Proxy === "function") return true;
|
|
131
|
+
try {
|
|
132
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
133
|
+
return true;
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function _create_super(Derived) {
|
|
139
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
140
|
+
return function _createSuperInternal() {
|
|
141
|
+
var Super = _get_prototype_of(Derived), result;
|
|
142
|
+
if (hasNativeReflectConstruct) {
|
|
143
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
144
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
145
|
+
} else {
|
|
146
|
+
result = Super.apply(this, arguments);
|
|
147
|
+
}
|
|
148
|
+
return _possible_constructor_return(this, result);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function _ts_generator(thisArg, body) {
|
|
152
|
+
var f, y, t, g, _ = {
|
|
153
|
+
label: 0,
|
|
154
|
+
sent: function() {
|
|
155
|
+
if (t[0] & 1) throw t[1];
|
|
156
|
+
return t[1];
|
|
157
|
+
},
|
|
158
|
+
trys: [],
|
|
159
|
+
ops: []
|
|
160
|
+
};
|
|
161
|
+
return g = {
|
|
162
|
+
next: verb(0),
|
|
163
|
+
"throw": verb(1),
|
|
164
|
+
"return": verb(2)
|
|
165
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
166
|
+
return this;
|
|
167
|
+
}), g;
|
|
168
|
+
function verb(n) {
|
|
169
|
+
return function(v) {
|
|
170
|
+
return step([
|
|
171
|
+
n,
|
|
172
|
+
v
|
|
173
|
+
]);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function step(op) {
|
|
177
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
178
|
+
while(_)try {
|
|
179
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
180
|
+
if (y = 0, t) op = [
|
|
181
|
+
op[0] & 2,
|
|
182
|
+
t.value
|
|
183
|
+
];
|
|
184
|
+
switch(op[0]){
|
|
185
|
+
case 0:
|
|
186
|
+
case 1:
|
|
187
|
+
t = op;
|
|
188
|
+
break;
|
|
189
|
+
case 4:
|
|
190
|
+
_.label++;
|
|
191
|
+
return {
|
|
192
|
+
value: op[1],
|
|
193
|
+
done: false
|
|
194
|
+
};
|
|
195
|
+
case 5:
|
|
196
|
+
_.label++;
|
|
197
|
+
y = op[1];
|
|
198
|
+
op = [
|
|
199
|
+
0
|
|
200
|
+
];
|
|
201
|
+
continue;
|
|
202
|
+
case 7:
|
|
203
|
+
op = _.ops.pop();
|
|
204
|
+
_.trys.pop();
|
|
205
|
+
continue;
|
|
206
|
+
default:
|
|
207
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
208
|
+
_ = 0;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
212
|
+
_.label = op[1];
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
216
|
+
_.label = t[1];
|
|
217
|
+
t = op;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
if (t && _.label < t[2]) {
|
|
221
|
+
_.label = t[2];
|
|
222
|
+
_.ops.push(op);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
if (t[2]) _.ops.pop();
|
|
226
|
+
_.trys.pop();
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
op = body.call(thisArg, _);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
op = [
|
|
232
|
+
6,
|
|
233
|
+
e
|
|
234
|
+
];
|
|
235
|
+
y = 0;
|
|
236
|
+
} finally{
|
|
237
|
+
f = t = 0;
|
|
238
|
+
}
|
|
239
|
+
if (op[0] & 5) throw op[1];
|
|
240
|
+
return {
|
|
241
|
+
value: op[0] ? op[1] : void 0,
|
|
242
|
+
done: true
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
import Api from './Api';
|
|
247
|
+
var Endpoint = /*#__PURE__*/ function(Api) {
|
|
248
|
+
"use strict";
|
|
249
|
+
_inherits(Endpoint, Api);
|
|
250
|
+
var _super = _create_super(Endpoint);
|
|
251
|
+
function Endpoint(endpoint, errorCallback) {
|
|
252
|
+
_class_call_check(this, Endpoint);
|
|
253
|
+
var _this;
|
|
254
|
+
_this = _super.call(this, endpoint);
|
|
255
|
+
_define_property(_assert_this_initialized(_this), "endpoint", void 0);
|
|
256
|
+
_define_property(_assert_this_initialized(_this), "errorCallback", void 0);
|
|
257
|
+
_this.endpoint = endpoint;
|
|
258
|
+
_this.errorCallback = errorCallback;
|
|
259
|
+
return _this;
|
|
260
|
+
}
|
|
261
|
+
_create_class(Endpoint, [
|
|
262
|
+
{
|
|
263
|
+
key: "get",
|
|
264
|
+
value: function get(opts) {
|
|
265
|
+
var _this = this;
|
|
266
|
+
var _this1 = this, _superprop_get_get = function() {
|
|
267
|
+
return _get(_get_prototype_of(Endpoint.prototype), "get", _this);
|
|
268
|
+
};
|
|
269
|
+
return _async_to_generator(function() {
|
|
270
|
+
return _ts_generator(this, function(_state) {
|
|
271
|
+
return [
|
|
272
|
+
2,
|
|
273
|
+
_superprop_get_get().call(_this1, opts).catch(_this1.errorCallback)
|
|
274
|
+
];
|
|
275
|
+
});
|
|
276
|
+
})();
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
key: "post",
|
|
281
|
+
value: function post(data, opts) {
|
|
282
|
+
var _this = this;
|
|
283
|
+
var _this1 = this, _superprop_get_post = function() {
|
|
284
|
+
return _get(_get_prototype_of(Endpoint.prototype), "post", _this);
|
|
285
|
+
};
|
|
286
|
+
return _async_to_generator(function() {
|
|
287
|
+
return _ts_generator(this, function(_state) {
|
|
288
|
+
return [
|
|
289
|
+
2,
|
|
290
|
+
_superprop_get_post().call(_this1, data, opts)
|
|
291
|
+
];
|
|
292
|
+
});
|
|
293
|
+
})();
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: "put",
|
|
298
|
+
value: function put(id, data, opts) {
|
|
299
|
+
var _this = this;
|
|
300
|
+
var _this1 = this, _superprop_get_put = function() {
|
|
301
|
+
return _get(_get_prototype_of(Endpoint.prototype), "put", _this);
|
|
302
|
+
};
|
|
303
|
+
return _async_to_generator(function() {
|
|
304
|
+
return _ts_generator(this, function(_state) {
|
|
305
|
+
return [
|
|
306
|
+
2,
|
|
307
|
+
_superprop_get_put().call(_this1, id, data, opts)
|
|
308
|
+
];
|
|
309
|
+
});
|
|
310
|
+
})();
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
key: "delete",
|
|
315
|
+
value: function _delete(id, opts) {
|
|
316
|
+
var _this = this;
|
|
317
|
+
var _this1 = this, _superprop_get_delete = function() {
|
|
318
|
+
return _get(_get_prototype_of(Endpoint.prototype), "delete", _this);
|
|
319
|
+
};
|
|
320
|
+
return _async_to_generator(function() {
|
|
321
|
+
return _ts_generator(this, function(_state) {
|
|
322
|
+
return [
|
|
323
|
+
2,
|
|
324
|
+
_superprop_get_delete().call(_this1, id, opts)
|
|
325
|
+
];
|
|
326
|
+
});
|
|
327
|
+
})();
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
key: "toJSON",
|
|
332
|
+
value: function toJSON(proto) {
|
|
333
|
+
var jsoned = {};
|
|
334
|
+
var toConvert = proto || this;
|
|
335
|
+
Object.getOwnPropertyNames(toConvert).forEach(function(prop) {
|
|
336
|
+
var val = toConvert[prop];
|
|
337
|
+
// don't include those
|
|
338
|
+
if (prop === 'toJSON' || prop === 'constructor') {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (typeof val === 'function') {
|
|
342
|
+
jsoned[prop] = val.bind(jsoned);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
jsoned[prop] = val;
|
|
346
|
+
});
|
|
347
|
+
var inherited = Object.getPrototypeOf(toConvert);
|
|
348
|
+
if (inherited !== null) {
|
|
349
|
+
Object.keys(this.toJSON(inherited)).forEach(function(key) {
|
|
350
|
+
if (!!jsoned[key] || key === 'constructor' || key === 'toJSON') return;
|
|
351
|
+
if (typeof inherited[key] === 'function') {
|
|
352
|
+
jsoned[key] = inherited[key].bind(jsoned);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
jsoned[key] = inherited[key];
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return jsoned;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
]);
|
|
362
|
+
return Endpoint;
|
|
363
|
+
}(Api);
|
|
364
|
+
export { Endpoint as default };
|