@ercioko/meblotex-api 0.2.0 → 0.2.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/.eslintrc +6 -0
- package/.nvmrc +1 -0
- package/.prettierrc +11 -0
- package/package.json +5 -16
- package/src/api/Api.ts +140 -0
- package/src/api/Endpoint.ts +76 -0
- package/src/api/createApi.ts +116 -0
- package/src/api/error.ts +17 -0
- package/{dist/api/index.d.ts → src/api/index.ts} +1 -0
- package/src/api/status.ts +3 -0
- package/src/api/utils/getAlert.ts +75 -0
- package/src/app_types.ts +695 -0
- package/src/components/ApiHostProvider.tsx +13 -0
- package/src/components/StatusTag.tsx +83 -0
- package/src/components/Table/DataTableWrapper.tsx +28 -0
- package/src/components/Table/FloatingActions.tsx +152 -0
- package/src/components/Table/Spinner.tsx +35 -0
- package/src/components/Table/Summary.tsx +18 -0
- package/src/components/Table/Table.tsx +474 -0
- package/src/components/Table/addIndexToObject.ts +6 -0
- package/src/components/Table/areProvidedColumnsDifferent.ts +26 -0
- package/src/components/Table/clicked.js +12 -0
- package/src/components/Table/displayActions.tsx +19 -0
- package/src/components/Table/hooks/useFetchPage.tsx +83 -0
- package/src/components/Table/hooks/useGetCellRenderer.tsx +197 -0
- package/src/components/Table/hooks/useGetColumnsWithCheckbox.tsx +34 -0
- package/src/components/Table/hooks/useGetDeleteRow.tsx +37 -0
- package/src/components/Table/hooks/useGetResizeColumn.ts +33 -0
- package/src/components/Table/hooks/useGetRowCheckbox.tsx +25 -0
- package/src/components/Table/hooks/useLoadDataSource.ts +24 -0
- package/src/components/Table/hooks/usePageSize.tsx +20 -0
- package/src/components/Table/hooks/useRenderRowActions.tsx +45 -0
- package/src/components/Table/hooks/useResizeColumns.ts +61 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/providers/OrderProvider.tsx +20 -0
- package/src/components/Table/styles.ts +208 -0
- package/src/config.ts +7 -0
- package/src/db_types.ts +220 -0
- package/src/hooks/useApi.ts +43 -0
- package/src/hooks/useEndpoint.ts +35 -0
- package/src/lib/jednostkaNazwa.ts +6 -0
- package/src/lib/typDokumentuNazwa.ts +8 -0
- package/src/utils/Query.ts +30 -0
- package/src/utils/getWZNumber.ts +13 -0
- package/src/utils/getZamowienieDokumentNumber.ts +11 -0
- package/{dist/src/utils/index.js → src/utils/index.ts} +2 -2
- package/tsconfig.json +25 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/api/Api.d.ts +0 -33
- package/dist/api/Api.js +0 -152
- package/dist/api/Endpoint.d.ts +0 -13
- package/dist/api/Endpoint.js +0 -126
- package/dist/api/createApi.d.ts +0 -52
- package/dist/api/createApi.js +0 -81
- package/dist/api/error.d.ts +0 -15
- package/dist/api/error.js +0 -18
- package/dist/api/index.js +0 -34
- package/dist/api/status.d.ts +0 -3
- package/dist/api/status.js +0 -6
- package/dist/api/utils/getAlert.d.ts +0 -6
- package/dist/api/utils/getAlert.js +0 -65
- package/dist/api/utils/index.js +0 -8
- package/dist/app_types.d.ts +0 -607
- package/dist/app_types.js +0 -75
- package/dist/components/ApiHostProvider.d.ts +0 -7
- package/dist/components/ApiHostProvider.js +0 -35
- package/dist/components/StatusTag.d.ts +0 -11
- package/dist/components/StatusTag.js +0 -86
- package/dist/components/Table/DataTableWrapper.d.ts +0 -3
- package/dist/components/Table/DataTableWrapper.js +0 -44
- package/dist/components/Table/FloatingActions.d.ts +0 -14
- package/dist/components/Table/FloatingActions.js +0 -32
- package/dist/components/Table/Spinner.d.ts +0 -2
- package/dist/components/Table/Spinner.js +0 -26
- package/dist/components/Table/Summary.js +0 -16
- package/dist/components/Table/Table.d.ts +0 -28
- package/dist/components/Table/Table.js +0 -330
- package/dist/components/Table/addIndexToObject.d.ts +0 -3
- package/dist/components/Table/addIndexToObject.js +0 -17
- package/dist/components/Table/areProvidedColumnsDifferent.d.ts +0 -2
- package/dist/components/Table/areProvidedColumnsDifferent.js +0 -16
- package/dist/components/Table/clicked.js +0 -11
- package/dist/components/Table/displayActions.js +0 -11
- package/dist/components/Table/hooks/useFetchPage.d.ts +0 -18
- package/dist/components/Table/hooks/useFetchPage.js +0 -123
- package/dist/components/Table/hooks/useGetCellRenderer.d.ts +0 -25
- package/dist/components/Table/hooks/useGetCellRenderer.js +0 -166
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +0 -5
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -53
- package/dist/components/Table/hooks/useGetDeleteRow.d.ts +0 -9
- package/dist/components/Table/hooks/useGetDeleteRow.js +0 -74
- package/dist/components/Table/hooks/useGetResizeColumn.d.ts +0 -8
- package/dist/components/Table/hooks/useGetResizeColumn.js +0 -28
- package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +0 -5
- package/dist/components/Table/hooks/useGetRowCheckbox.js +0 -54
- package/dist/components/Table/hooks/useLoadDataSource.d.ts +0 -10
- package/dist/components/Table/hooks/useLoadDataSource.js +0 -20
- package/dist/components/Table/hooks/usePageSize.d.ts +0 -5
- package/dist/components/Table/hooks/usePageSize.js +0 -16
- package/dist/components/Table/hooks/useRenderRowActions.d.ts +0 -6
- package/dist/components/Table/hooks/useRenderRowActions.js +0 -51
- package/dist/components/Table/hooks/useResizeColumns.d.ts +0 -9
- package/dist/components/Table/hooks/useResizeColumns.js +0 -60
- package/dist/components/Table/index.d.ts +0 -1
- package/dist/components/Table/index.js +0 -8
- package/dist/components/Table/providers/OrderProvider.d.ts +0 -9
- package/dist/components/Table/providers/OrderProvider.js +0 -17
- package/dist/components/Table/styles.d.ts +0 -6
- package/dist/components/Table/styles.js +0 -37
- package/dist/components/index.js +0 -26
- package/dist/config.d.ts +0 -6
- package/dist/config.js +0 -8
- package/dist/db_types.d.ts +0 -208
- package/dist/db_types.js +0 -2
- package/dist/hooks/index.js +0 -10
- package/dist/hooks/useApi.d.ts +0 -2
- package/dist/hooks/useApi.js +0 -42
- package/dist/hooks/useEndpoint.d.ts +0 -2
- package/dist/hooks/useEndpoint.js +0 -34
- package/dist/index.js +0 -19
- package/dist/lib/index.js +0 -18
- package/dist/lib/jednostka.d.ts +0 -6
- package/dist/lib/jednostkaNazwa.d.ts +0 -6
- package/dist/lib/jednostkaNazwa.js +0 -9
- package/dist/lib/typDokumentuNazwa.d.ts +0 -6
- package/dist/lib/typDokumentuNazwa.js +0 -11
- package/dist/lib/typ_dokument.d.ts +0 -0
- package/dist/lib/typ_dokumentu.d.ts +0 -6
- package/dist/lib/unit.d.ts +0 -0
- package/dist/src/api/Api.js +0 -316
- package/dist/src/api/Endpoint.js +0 -365
- package/dist/src/api/createApi.js +0 -50
- package/dist/src/api/error.js +0 -15
- package/dist/src/api/index.js +0 -5
- package/dist/src/api/status.js +0 -3
- package/dist/src/api/utils/getAlert.js +0 -63
- package/dist/src/api/utils/index.js +0 -1
- package/dist/src/app_types.js +0 -72
- package/dist/src/components/ApiHostProvider.js +0 -11
- package/dist/src/components/StatusTag.js +0 -153
- package/dist/src/components/Table/DataTableWrapper.js +0 -115
- package/dist/src/components/Table/FloatingActions.js +0 -60
- package/dist/src/components/Table/Spinner.js +0 -40
- package/dist/src/components/Table/Summary.js +0 -16
- package/dist/src/components/Table/Table.js +0 -498
- package/dist/src/components/Table/addIndexToObject.js +0 -57
- package/dist/src/components/Table/areProvidedColumnsDifferent.js +0 -19
- package/dist/src/components/Table/clicked.js +0 -12
- package/dist/src/components/Table/displayActions.js +0 -11
- package/dist/src/components/Table/hooks/useFetchPage.js +0 -254
- package/dist/src/components/Table/hooks/useGetCellRenderer.js +0 -231
- package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -33
- package/dist/src/components/Table/hooks/useGetDeleteRow.js +0 -181
- package/dist/src/components/Table/hooks/useGetResizeColumn.js +0 -72
- package/dist/src/components/Table/hooks/useGetRowCheckbox.js +0 -55
- package/dist/src/components/Table/hooks/useLoadDataSource.js +0 -16
- package/dist/src/components/Table/hooks/usePageSize.js +0 -15
- package/dist/src/components/Table/hooks/useRenderRowActions.js +0 -50
- package/dist/src/components/Table/hooks/useResizeColumns.js +0 -70
- package/dist/src/components/Table/index.js +0 -1
- package/dist/src/components/Table/providers/OrderProvider.js +0 -65
- package/dist/src/components/Table/styles.js +0 -66
- package/dist/src/components/index.js +0 -4
- package/dist/src/config.js +0 -6
- package/dist/src/db_types.js +0 -1
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/useApi.js +0 -84
- package/dist/src/hooks/useEndpoint.js +0 -60
- package/dist/src/index.js +0 -3
- package/dist/src/lib/index.js +0 -2
- package/dist/src/lib/jednostkaNazwa.js +0 -6
- package/dist/src/lib/typDokumentuNazwa.js +0 -16
- package/dist/src/utils/Query.js +0 -73
- package/dist/src/utils/getWZNumber.js +0 -4
- package/dist/src/utils/getZamowienieDokumentNumber.js +0 -4
- package/dist/utils/AlertContext.d.ts +0 -3
- package/dist/utils/AlertContext.js +0 -3
- package/dist/utils/Query.d.ts +0 -6
- package/dist/utils/Query.js +0 -33
- package/dist/utils/geNumber.d.ts +0 -2
- package/dist/utils/getDocNumber.d.ts +0 -2
- package/dist/utils/getWZNumber.js +0 -10
- package/dist/utils/getWzNumber.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber copy.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber.js +0 -8
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -12
- /package/{dist/api/utils/index.d.ts → src/api/utils/index.ts} +0 -0
- /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
- /package/{dist/hooks/index.d.ts → src/hooks/index.ts} +0 -0
- /package/{dist/index.d.ts → src/index.ts} +0 -0
- /package/{dist/lib/index.d.ts → src/lib/index.ts} +0 -0
package/dist/lib/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./jednostkaNazwa"), exports);
|
|
18
|
-
__exportStar(require("./typDokumentuNazwa"), exports);
|
package/dist/lib/jednostka.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.typDokumentuNazwa = void 0;
|
|
5
|
-
var app_types_1 = require("../app_types");
|
|
6
|
-
exports.typDokumentuNazwa = (_a = {},
|
|
7
|
-
_a[app_types_1.TypDokumentu.Faktura] = 'Faktura VAT',
|
|
8
|
-
_a[app_types_1.TypDokumentu.FakturaDetal] = 'Faktura FADET',
|
|
9
|
-
_a[app_types_1.TypDokumentu.FakturaEksport] = 'Faktura Eksportowa',
|
|
10
|
-
_a[app_types_1.TypDokumentu.Paragon] = 'Paragon',
|
|
11
|
-
_a);
|
|
File without changes
|
package/dist/lib/unit.d.ts
DELETED
|
File without changes
|
package/dist/src/api/Api.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
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 { Query } from '../utils';
|
|
158
|
-
function handleResponse(res) {
|
|
159
|
-
return _handleResponse.apply(this, arguments);
|
|
160
|
-
}
|
|
161
|
-
function _handleResponse() {
|
|
162
|
-
_handleResponse = _async_to_generator(function(res) {
|
|
163
|
-
var ok, url, headers, status, statusText, text;
|
|
164
|
-
return _ts_generator(this, function(_state) {
|
|
165
|
-
switch(_state.label){
|
|
166
|
-
case 0:
|
|
167
|
-
if (res.status === 204) return [
|
|
168
|
-
2,
|
|
169
|
-
{}
|
|
170
|
-
];
|
|
171
|
-
if (res.status.toString().startsWith('2')) return [
|
|
172
|
-
2,
|
|
173
|
-
res.json()
|
|
174
|
-
];
|
|
175
|
-
ok = res.ok, url = res.url, headers = res.headers, status = res.status, statusText = res.statusText;
|
|
176
|
-
return [
|
|
177
|
-
4,
|
|
178
|
-
res.text()
|
|
179
|
-
];
|
|
180
|
-
case 1:
|
|
181
|
-
text = _state.sent();
|
|
182
|
-
throw new Error(JSON.stringify({
|
|
183
|
-
ok: ok,
|
|
184
|
-
url: url,
|
|
185
|
-
headers: headers,
|
|
186
|
-
status: status,
|
|
187
|
-
statusText: statusText,
|
|
188
|
-
text: text
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
return _handleResponse.apply(this, arguments);
|
|
194
|
-
}
|
|
195
|
-
var Api = /*#__PURE__*/ function() {
|
|
196
|
-
"use strict";
|
|
197
|
-
function Api(endpoint, host) {
|
|
198
|
-
_class_call_check(this, Api);
|
|
199
|
-
_define_property(this, "host", void 0);
|
|
200
|
-
_define_property(this, "namespace", void 0);
|
|
201
|
-
_define_property(this, "endpoint", void 0);
|
|
202
|
-
_define_property(this, "endpointUrl", void 0);
|
|
203
|
-
this.host = host;
|
|
204
|
-
this.namespace = '';
|
|
205
|
-
this.endpoint = endpoint;
|
|
206
|
-
this.endpointUrl = "".concat(this.host).concat(this.namespace, "/").concat(this.endpoint);
|
|
207
|
-
}
|
|
208
|
-
_create_class(Api, [
|
|
209
|
-
{
|
|
210
|
-
key: "get",
|
|
211
|
-
value: function get() {
|
|
212
|
-
var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
213
|
-
var _this = this;
|
|
214
|
-
return _async_to_generator(function() {
|
|
215
|
-
var headers, options, url;
|
|
216
|
-
return _ts_generator(this, function(_state) {
|
|
217
|
-
headers = new Headers();
|
|
218
|
-
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
219
|
-
options = {
|
|
220
|
-
credentials: 'include',
|
|
221
|
-
headers: headers
|
|
222
|
-
};
|
|
223
|
-
url = "".concat(_this.endpointUrl, "/").concat(opts.id || '').concat(_this.getQuery(opts.query));
|
|
224
|
-
return [
|
|
225
|
-
2,
|
|
226
|
-
fetch(url, 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 = "".concat(_this.endpointUrl).concat(_this.getQuery(opts.query));
|
|
245
|
-
return [
|
|
246
|
-
2,
|
|
247
|
-
fetch(url, {
|
|
248
|
-
method: 'POST',
|
|
249
|
-
body: body,
|
|
250
|
-
headers: headers,
|
|
251
|
-
credentials: 'include'
|
|
252
|
-
}).then(handleResponse)
|
|
253
|
-
];
|
|
254
|
-
});
|
|
255
|
-
})();
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
key: "put",
|
|
260
|
-
value: function put(id, data) {
|
|
261
|
-
var opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
262
|
-
var _this = this;
|
|
263
|
-
return _async_to_generator(function() {
|
|
264
|
-
var body, headers, url;
|
|
265
|
-
return _ts_generator(this, function(_state) {
|
|
266
|
-
body = JSON.stringify(data);
|
|
267
|
-
headers = new Headers();
|
|
268
|
-
headers.append('Content-Type', 'application/json');
|
|
269
|
-
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
270
|
-
url = "".concat(_this.endpointUrl).concat(opts.noId ? '' : '/').concat(id || '').concat(_this.getQuery(opts.query));
|
|
271
|
-
return [
|
|
272
|
-
2,
|
|
273
|
-
fetch(url, {
|
|
274
|
-
method: 'PUT',
|
|
275
|
-
body: body,
|
|
276
|
-
headers: headers,
|
|
277
|
-
credentials: 'include'
|
|
278
|
-
}).then(handleResponse)
|
|
279
|
-
];
|
|
280
|
-
});
|
|
281
|
-
})();
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
key: "delete",
|
|
286
|
-
value: function _delete(id) {
|
|
287
|
-
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
288
|
-
var _this = this;
|
|
289
|
-
return _async_to_generator(function() {
|
|
290
|
-
var headers, url;
|
|
291
|
-
return _ts_generator(this, function(_state) {
|
|
292
|
-
headers = new Headers();
|
|
293
|
-
if (opts.token) headers.append('Authorization', "Bearer ".concat(opts.token));
|
|
294
|
-
url = "".concat(_this.endpointUrl, "/").concat(id).concat(_this.getQuery(opts.query));
|
|
295
|
-
return [
|
|
296
|
-
2,
|
|
297
|
-
fetch(url, {
|
|
298
|
-
headers: headers,
|
|
299
|
-
method: 'DELETE',
|
|
300
|
-
credentials: 'include'
|
|
301
|
-
}).then(handleResponse)
|
|
302
|
-
];
|
|
303
|
-
});
|
|
304
|
-
})();
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
key: "getQuery",
|
|
309
|
-
value: function getQuery(query) {
|
|
310
|
-
return query ? "?".concat(new URLSearchParams(Query.encode(query)).toString()) : '';
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
]);
|
|
314
|
-
return Api;
|
|
315
|
-
}();
|
|
316
|
-
export { Api as default };
|