kui-crm 0.0.324 → 0.0.325
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/agent/index.js +1 -269
- package/agent/package.json +1 -1
- package/hooks/index.d.ts +2 -2
- package/hooks/index.js +1 -174
- package/hooks/package.json +1 -1
- package/index.d.ts +19 -140
- package/index.js +1 -4810
- package/package.json +6 -5
- package/types/index.d.ts +20 -20
- package/types/index.js +0 -1
- package/types/package.json +1 -1
- package/utils/index.js +1 -714
- package/utils/package.json +2 -5
- package/1521f2ef9cc95488.png +0 -0
- package/agent/cjs/index.js +0 -285
- package/agent/cjs/index.js.map +0 -1
- package/agent/cjs/package.json +0 -6
- package/agent/index.js.map +0 -1
- package/cjs/1521f2ef9cc95488.png +0 -0
- package/cjs/index.js +0 -5021
- package/cjs/index.js.map +0 -1
- package/cjs/login_bg.png +0 -0
- package/hooks/cjs/index.js +0 -187
- package/hooks/cjs/index.js.map +0 -1
- package/hooks/cjs/package.json +0 -6
- package/hooks/index.js.map +0 -1
- package/index.js.map +0 -1
- package/login_bg.png +0 -0
- package/types/cjs/index.js +0 -3
- package/types/cjs/index.js.map +0 -1
- package/types/cjs/package.json +0 -6
- package/types/index.js.map +0 -1
- package/utils/cjs/index.js +0 -781
- package/utils/cjs/index.js.map +0 -1
- package/utils/cjs/package.json +0 -9
- package/utils/index.js.map +0 -1
package/agent/index.js
CHANGED
|
@@ -1,269 +1 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
import { deleteCookie, getCookie } from 'kui-utils';
|
|
3
|
-
import { setSettings } from 'kui-complex';
|
|
4
|
-
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
var __assign = function() {
|
|
21
|
-
__assign = Object.assign || function __assign(t) {
|
|
22
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
-
s = arguments[i];
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
32
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function __generator(thisArg, body) {
|
|
42
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
-
function step(op) {
|
|
46
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
-
while (_) try {
|
|
48
|
-
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;
|
|
49
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
-
switch (op[0]) {
|
|
51
|
-
case 0: case 1: t = op; break;
|
|
52
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
-
default:
|
|
56
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
-
if (t[2]) _.ops.pop();
|
|
61
|
-
_.trys.pop(); continue;
|
|
62
|
-
}
|
|
63
|
-
op = body.call(thisArg, _);
|
|
64
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var authFlag = "maroomCRMisAuth";
|
|
70
|
-
var csrfTokenKey = "csrftoken";
|
|
71
|
-
var sessionIdKey = "crm-sessionid";
|
|
72
|
-
|
|
73
|
-
var KUISettings = /** @class */ (function () {
|
|
74
|
-
function KUISettings() {
|
|
75
|
-
var _this = this;
|
|
76
|
-
this.getSettings = function () { return (__assign({}, _this.settings)); };
|
|
77
|
-
this.setSettings = function (newSettings) {
|
|
78
|
-
_this.settings = __assign(__assign({}, _this.settings), newSettings);
|
|
79
|
-
setSettings(newSettings);
|
|
80
|
-
_this.observers.forEach(function (observer) { return observer(_this.settings); });
|
|
81
|
-
};
|
|
82
|
-
this.subscribeToSettings = function (observer) {
|
|
83
|
-
_this.observers.push(observer);
|
|
84
|
-
};
|
|
85
|
-
this.unsubscribeFromSettings = function (observer) {
|
|
86
|
-
var index = _this.observers.indexOf(observer);
|
|
87
|
-
if (index !== -1)
|
|
88
|
-
_this.observers.splice(index, 1);
|
|
89
|
-
};
|
|
90
|
-
this.settings = { mapKey: "" };
|
|
91
|
-
this.observers = [];
|
|
92
|
-
this.id = Math.random() * 100;
|
|
93
|
-
}
|
|
94
|
-
return KUISettings;
|
|
95
|
-
}());
|
|
96
|
-
var kuiSettings = new KUISettings();
|
|
97
|
-
|
|
98
|
-
var CatalogsAgent = {
|
|
99
|
-
getCountries: function (offset, limit, params) {
|
|
100
|
-
var appUrl = kuiSettings.getSettings().apiBaseUrl;
|
|
101
|
-
return requests.get("/catalogs/countries?limit=".concat(limit, "&offset=").concat(offset).concat(params), appUrl);
|
|
102
|
-
},
|
|
103
|
-
getRegions: function (offset, limit, params) {
|
|
104
|
-
var appUrl = kuiSettings.getSettings().apiBaseUrl;
|
|
105
|
-
return requests.get("/catalogs/regions?limit=".concat(limit, "&offset=").concat(offset).concat(params), appUrl);
|
|
106
|
-
},
|
|
107
|
-
getCities: function (offset, limit, params) {
|
|
108
|
-
var appUrl = kuiSettings.getSettings().apiBaseUrl;
|
|
109
|
-
return requests.get("/catalogs/cities?limit=".concat(limit, "&offset=").concat(offset).concat(params), appUrl);
|
|
110
|
-
},
|
|
111
|
-
getDistricts: function (offset, limit, params) {
|
|
112
|
-
var appUrl = kuiSettings.getSettings().apiBaseUrl;
|
|
113
|
-
return requests.get("/catalogs/districts?limit=".concat(limit, "&offset=").concat(offset).concat(params), appUrl);
|
|
114
|
-
},
|
|
115
|
-
getCounties: function (offset, limit, params) {
|
|
116
|
-
var appUrl = kuiSettings.getSettings().apiBaseUrl;
|
|
117
|
-
return requests.get("/catalogs/counties?limit=".concat(limit, "&offset=").concat(offset).concat(params), appUrl);
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
var CompaniesAgent = {
|
|
122
|
-
all: function (offset, limit, params) {
|
|
123
|
-
return requests.get("/companies?limit=".concat(limit, "&offset=").concat(offset).concat(params));
|
|
124
|
-
},
|
|
125
|
-
create: function (data) {
|
|
126
|
-
return requests.post("/companies", data);
|
|
127
|
-
},
|
|
128
|
-
createLogo: function (companyId, logo) {
|
|
129
|
-
return requests.put("/companies/".concat(companyId, "/logo"), logo);
|
|
130
|
-
},
|
|
131
|
-
findCompanyByINN: function (body) {
|
|
132
|
-
return requests.post("/companies/info-by-new-tin", body);
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
var UploadAgent = {
|
|
137
|
-
uploadImage: function (data, url) {
|
|
138
|
-
return requests.post(url ? "" : "/upload/image", data, url);
|
|
139
|
-
},
|
|
140
|
-
uploadDocument: function (data, url) {
|
|
141
|
-
return requests.post(url ? "" : "/upload/document", data, url);
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
var FillingTagsAgent = {
|
|
146
|
-
getAll: function (type) {
|
|
147
|
-
var appUrl = kuiSettings.getSettings().catalogsUrl;
|
|
148
|
-
return requests.get("/features?feature_type=".concat(type), appUrl);
|
|
149
|
-
},
|
|
150
|
-
create: function (data) { return requests.post("/features", data); },
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
var TariffsAgent = {
|
|
154
|
-
all: function (tariff, offset, limit, params) {
|
|
155
|
-
return requests.get("/tariffs/".concat(tariff, "?ordering=region&offset=").concat(offset, "&limit=").concat(limit).concat(params));
|
|
156
|
-
},
|
|
157
|
-
createTariff: function (data, tariff) {
|
|
158
|
-
return requests.post("/tariffs/".concat(tariff), data);
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var AuthAgent = {
|
|
163
|
-
signIn: function (data) {
|
|
164
|
-
var baseUrl = kuiSettings.getSettings().appUrl;
|
|
165
|
-
return requests.post("/api/api-token-auth/", data, baseUrl);
|
|
166
|
-
},
|
|
167
|
-
logout: function () {
|
|
168
|
-
var baseUrl = kuiSettings.getSettings().appUrl;
|
|
169
|
-
return requests.get("/api/auth/logout", baseUrl);
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
var ApartmentsAgent = {
|
|
174
|
-
getAll: function (offset, limit, params) {
|
|
175
|
-
return requests.get("/apartments?limit=".concat(limit, "&offset=").concat(offset).concat(params));
|
|
176
|
-
},
|
|
177
|
-
getFillingList: function (apartmentId, fillingType) {
|
|
178
|
-
return requests.get("/apartments/".concat(apartmentId, "/features/list?feature_type=").concat(fillingType));
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
var ApartmentMetersAgent = {
|
|
183
|
-
getMeters: function (apartmentId, resource, year, month, contractId, queryParams) {
|
|
184
|
-
return requests.get("/apartments/".concat(apartmentId, "/expenses/meters/").concat(resource, "?year=").concat(year, "&month=").concat(month).concat(contractId ? "&rental_contract=".concat(contractId) : "").concat(queryParams || ""));
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var axiosInstance = axios.create();
|
|
189
|
-
axiosInstance.defaults.withCredentials = true;
|
|
190
|
-
// axios instance for special handlers
|
|
191
|
-
var axiosWithoutToken = axios.create();
|
|
192
|
-
var errorHandler = function (err) {
|
|
193
|
-
var _a, _b, _c;
|
|
194
|
-
if (err && ((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
195
|
-
var settings = kuiSettings.getSettings();
|
|
196
|
-
deleteCookie(csrfTokenKey);
|
|
197
|
-
deleteCookie(sessionIdKey);
|
|
198
|
-
localStorage.removeItem(authFlag);
|
|
199
|
-
if (settings.errorHandler)
|
|
200
|
-
settings.errorHandler(err);
|
|
201
|
-
}
|
|
202
|
-
return Promise.reject((_c = (_b = err.response) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : err);
|
|
203
|
-
};
|
|
204
|
-
var CSRFPlugin = function (req) {
|
|
205
|
-
var CSRFToken = getCookie(csrfTokenKey);
|
|
206
|
-
if (CSRFToken) {
|
|
207
|
-
req.headers["X-CSRFToken"] = CSRFToken;
|
|
208
|
-
}
|
|
209
|
-
return req;
|
|
210
|
-
};
|
|
211
|
-
axiosInstance.interceptors.request.use(function (config) {
|
|
212
|
-
var reqHandler = kuiSettings.getSettings().reqHandler;
|
|
213
|
-
if (reqHandler)
|
|
214
|
-
return reqHandler(CSRFPlugin(config));
|
|
215
|
-
return CSRFPlugin(config);
|
|
216
|
-
});
|
|
217
|
-
axiosInstance.interceptors.response.use(function (res) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
218
|
-
return [2 /*return*/, res.data];
|
|
219
|
-
}); }); }, function (error) { return errorHandler(error); });
|
|
220
|
-
/*
|
|
221
|
-
* special handlers
|
|
222
|
-
* */
|
|
223
|
-
axiosWithoutToken.interceptors.response.use(function (res) { return res.data; }, function (error) { return errorHandler(error); });
|
|
224
|
-
var requests = {
|
|
225
|
-
get: function (url, base) { return __awaiter(void 0, void 0, void 0, function () {
|
|
226
|
-
var baseUrl;
|
|
227
|
-
return __generator(this, function (_a) {
|
|
228
|
-
baseUrl = base || kuiSettings.getSettings().apiUrl;
|
|
229
|
-
return [2 /*return*/, axiosInstance.get("".concat(baseUrl).concat(url))];
|
|
230
|
-
});
|
|
231
|
-
}); },
|
|
232
|
-
post: function (url, data, base) { return __awaiter(void 0, void 0, void 0, function () {
|
|
233
|
-
var baseUrl;
|
|
234
|
-
return __generator(this, function (_a) {
|
|
235
|
-
baseUrl = base || kuiSettings.getSettings().apiUrl;
|
|
236
|
-
return [2 /*return*/, axiosInstance.post("".concat(baseUrl).concat(url), data)];
|
|
237
|
-
});
|
|
238
|
-
}); },
|
|
239
|
-
put: function (url, data, base) { return __awaiter(void 0, void 0, void 0, function () {
|
|
240
|
-
var baseUrl;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
baseUrl = base || kuiSettings.getSettings().apiUrl;
|
|
243
|
-
return [2 /*return*/, axiosInstance.put("".concat(baseUrl).concat(url), data)];
|
|
244
|
-
});
|
|
245
|
-
}); },
|
|
246
|
-
patch: function (url, data, base) { return __awaiter(void 0, void 0, void 0, function () {
|
|
247
|
-
var baseUrl;
|
|
248
|
-
return __generator(this, function (_a) {
|
|
249
|
-
baseUrl = base || kuiSettings.getSettings().apiUrl;
|
|
250
|
-
return [2 /*return*/, axiosInstance.patch("".concat(baseUrl).concat(url), data)];
|
|
251
|
-
});
|
|
252
|
-
}); },
|
|
253
|
-
delete: function (url, base) { return __awaiter(void 0, void 0, void 0, function () {
|
|
254
|
-
var baseUrl;
|
|
255
|
-
return __generator(this, function (_a) {
|
|
256
|
-
baseUrl = base || kuiSettings.getSettings().apiUrl;
|
|
257
|
-
return [2 /*return*/, axiosInstance.delete("".concat(baseUrl).concat(url))];
|
|
258
|
-
});
|
|
259
|
-
}); },
|
|
260
|
-
getWithoutToken: function (url) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
261
|
-
return [2 /*return*/, axiosWithoutToken.get(url)];
|
|
262
|
-
}); }); },
|
|
263
|
-
postWithoutToken: function (url, data) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
264
|
-
return [2 /*return*/, axiosWithoutToken.post(url, data)];
|
|
265
|
-
}); }); },
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export { ApartmentMetersAgent, ApartmentsAgent, AuthAgent, CatalogsAgent, CompaniesAgent, FillingTagsAgent, TariffsAgent, UploadAgent, requests as default };
|
|
269
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import t from"axios";import{deleteCookie as n,getCookie as e}from"kui-utils";import{setSettings as r}from"kui-complex";var o=function(){return o=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},o.apply(this,arguments)};function i(t,n,e,r){return new(e||(e=Promise))((function(o,i){function c(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(c,a)}u((r=r.apply(t,n||[])).next())}))}function c(t,n){var e,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;c;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=n.call(t,c)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var a="csrftoken",u=new function(){var t=this;this.getSettings=function(){return o({},t.settings)},this.setSettings=function(n){t.settings=o(o({},t.settings),n),r(n),t.observers.forEach((function(n){return n(t.settings)}))},this.subscribeToSettings=function(n){t.observers.push(n)},this.unsubscribeFromSettings=function(n){var e=t.observers.indexOf(n);-1!==e&&t.observers.splice(e,1)},this.settings={mapKey:""},this.observers=[],this.id=100*Math.random()},s={getCountries:function(t,n,e){var r=u.getSettings().apiBaseUrl;return w.get("/catalogs/countries?limit=".concat(n,"&offset=").concat(t).concat(e),r)},getRegions:function(t,n,e){var r=u.getSettings().apiBaseUrl;return w.get("/catalogs/regions?limit=".concat(n,"&offset=").concat(t).concat(e),r)},getCities:function(t,n,e){var r=u.getSettings().apiBaseUrl;return w.get("/catalogs/cities?limit=".concat(n,"&offset=").concat(t).concat(e),r)},getDistricts:function(t,n,e){var r=u.getSettings().apiBaseUrl;return w.get("/catalogs/districts?limit=".concat(n,"&offset=").concat(t).concat(e),r)},getCounties:function(t,n,e){var r=u.getSettings().apiBaseUrl;return w.get("/catalogs/counties?limit=".concat(n,"&offset=").concat(t).concat(e),r)}},f={all:function(t,n,e){return w.get("/companies?limit=".concat(n,"&offset=").concat(t).concat(e))},create:function(t){return w.post("/companies",t)},createLogo:function(t,n){return w.put("/companies/".concat(t,"/logo"),n)},findCompanyByINN:function(t){return w.post("/companies/info-by-new-tin",t)}},l={uploadImage:function(t,n){return w.post(n?"":"/upload/image",t,n)},uploadDocument:function(t,n){return w.post(n?"":"/upload/document",t,n)}},g={getAll:function(t){var n=u.getSettings().catalogsUrl;return w.get("/features?feature_type=".concat(t),n)},create:function(t){return w.post("/features",t)}},p={all:function(t,n,e,r){return w.get("/tariffs/".concat(t,"?ordering=region&offset=").concat(n,"&limit=").concat(e).concat(r))},createTariff:function(t,n){return w.post("/tariffs/".concat(n),t)}},v={signIn:function(t){var n=u.getSettings().appUrl;return w.post("/api/api-token-auth/",t,n)},logout:function(){var t=u.getSettings().appUrl;return w.get("/api/auth/logout",t)}},d={getAll:function(t,n,e){return w.get("/apartments?limit=".concat(n,"&offset=").concat(t).concat(e))},getFillingList:function(t,n){return w.get("/apartments/".concat(t,"/features/list?feature_type=").concat(n))}},h={getMeters:function(t,n,e,r,o,i){return w.get("/apartments/".concat(t,"/expenses/meters/").concat(n,"?year=").concat(e,"&month=").concat(r).concat(o?"&rental_contract=".concat(o):"").concat(i||""))}},m=t.create();m.defaults.withCredentials=!0;var b=t.create(),y=function(t){var e,r,o;if(t&&401===(null===(e=t.response)||void 0===e?void 0:e.status)){var i=u.getSettings();n(a),n("crm-sessionid"),localStorage.removeItem("maroomCRMisAuth"),i.errorHandler&&i.errorHandler(t)}return Promise.reject(null!==(o=null===(r=t.response)||void 0===r?void 0:r.data)&&void 0!==o?o:t)},S=function(t){var n=e(a);return n&&(t.headers["X-CSRFToken"]=n),t};m.interceptors.request.use((function(t){var n=u.getSettings().reqHandler;return n?n(S(t)):S(t)})),m.interceptors.response.use((function(t){return i(void 0,void 0,void 0,(function(){return c(this,(function(n){return[2,t.data]}))}))}),(function(t){return y(t)})),b.interceptors.response.use((function(t){return t.data}),(function(t){return y(t)}));var w={get:function(t,n){return i(void 0,void 0,void 0,(function(){var e;return c(this,(function(r){return e=n||u.getSettings().apiUrl,[2,m.get("".concat(e).concat(t))]}))}))},post:function(t,n,e){return i(void 0,void 0,void 0,(function(){var r;return c(this,(function(o){return r=e||u.getSettings().apiUrl,[2,m.post("".concat(r).concat(t),n)]}))}))},put:function(t,n,e){return i(void 0,void 0,void 0,(function(){var r;return c(this,(function(o){return r=e||u.getSettings().apiUrl,[2,m.put("".concat(r).concat(t),n)]}))}))},patch:function(t,n,e){return i(void 0,void 0,void 0,(function(){var r;return c(this,(function(o){return r=e||u.getSettings().apiUrl,[2,m.patch("".concat(r).concat(t),n)]}))}))},delete:function(t,n){return i(void 0,void 0,void 0,(function(){var e;return c(this,(function(r){return e=n||u.getSettings().apiUrl,[2,m.delete("".concat(e).concat(t))]}))}))},getWithoutToken:function(t){return i(void 0,void 0,void 0,(function(){return c(this,(function(n){return[2,b.get(t)]}))}))},postWithoutToken:function(t,n){return i(void 0,void 0,void 0,(function(){return c(this,(function(e){return[2,b.post(t,n)]}))}))}};export{h as ApartmentMetersAgent,d as ApartmentsAgent,v as AuthAgent,s as CatalogsAgent,f as CompaniesAgent,g as FillingTagsAgent,p as TariffsAgent,l as UploadAgent,w as default};
|
package/agent/package.json
CHANGED
package/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { DependencyList, RefObject } from 'react';
|
|
3
3
|
import { SortingFilter, Paginator } from 'kui-utils';
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ declare type GeolocationParams = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
declare const useMapCards: (location: GeolocationParams, map?: google.maps.Map | undefined) => {
|
|
24
|
-
ref:
|
|
24
|
+
ref: react.RefObject<HTMLDivElement>;
|
|
25
25
|
isOpen: boolean;
|
|
26
26
|
closeCard: () => void;
|
|
27
27
|
toggleCard: () => void;
|
package/hooks/index.js
CHANGED
|
@@ -1,174 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useDebounce } from 'kui-utils';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
var __assign = function() {
|
|
21
|
-
__assign = Object.assign || function __assign(t) {
|
|
22
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
-
s = arguments[i];
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function __spreadArray(to, from, pack) {
|
|
32
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
33
|
-
if (ar || !(i in from)) {
|
|
34
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
35
|
-
ar[i] = from[i];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var useAutocomplete = function (filter, paginator, fetchAll, isOpen, defaultFilter, withoutRequest, deps) {
|
|
42
|
-
useEffect(function () {
|
|
43
|
-
if (defaultFilter)
|
|
44
|
-
filter.updateFilterQuery(defaultFilter);
|
|
45
|
-
filter.updateSearchQuery("");
|
|
46
|
-
paginator.clearOffset();
|
|
47
|
-
paginator.startFetching();
|
|
48
|
-
}, []);
|
|
49
|
-
useEffect(function () {
|
|
50
|
-
if (paginator.isFetching &&
|
|
51
|
-
!paginator.isFinishPage &&
|
|
52
|
-
!withoutRequest &&
|
|
53
|
-
isOpen) {
|
|
54
|
-
fetchAll();
|
|
55
|
-
}
|
|
56
|
-
}, __spreadArray([fetchAll, paginator.isFetching, isOpen], (deps || []), true));
|
|
57
|
-
useDebounce(filter.searchQuery, 500, function () {
|
|
58
|
-
paginator.clearOffset();
|
|
59
|
-
paginator.startFetching();
|
|
60
|
-
});
|
|
61
|
-
useDebounce(filter.filterQuery, 500, function () {
|
|
62
|
-
paginator.clearOffset();
|
|
63
|
-
paginator.startFetching();
|
|
64
|
-
});
|
|
65
|
-
var onSearchItem = function (value) {
|
|
66
|
-
filter.updateSearchQuery(value);
|
|
67
|
-
if (value.length === 0) {
|
|
68
|
-
paginator.clearOffset();
|
|
69
|
-
paginator.startFetching();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var onScrollEnd = function () {
|
|
73
|
-
if (!paginator.isFinishPage) {
|
|
74
|
-
paginator.startFetching();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return { onSearchItem: onSearchItem, onScrollEnd: onScrollEnd };
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
var usePortalPosition = function (portalParentRef) {
|
|
81
|
-
var _a = useState(null), coords = _a[0], setCoords = _a[1];
|
|
82
|
-
useEffect(function () {
|
|
83
|
-
if (!portalParentRef.current) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var updateCoords = function () {
|
|
87
|
-
if (portalParentRef.current) {
|
|
88
|
-
var newCoords = portalParentRef.current.getBoundingClientRect();
|
|
89
|
-
setCoords(__assign(__assign({}, newCoords), { right: document.documentElement.clientWidth - newCoords.right, top: newCoords.top + window.pageYOffset }));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
updateCoords();
|
|
93
|
-
window.addEventListener("calcPortalPosition", updateCoords);
|
|
94
|
-
// eslint-disable-next-line consistent-return
|
|
95
|
-
return function () { return window.removeEventListener("calcPortalPosition", updateCoords); };
|
|
96
|
-
}, [portalParentRef]);
|
|
97
|
-
return coords;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
var useFetchPage = function (paginator, fetchAll, deps, cleanupDeps) {
|
|
101
|
-
useEffect(function () {
|
|
102
|
-
if ((paginator === null || paginator === void 0 ? void 0 : paginator.isFetching) && !(paginator === null || paginator === void 0 ? void 0 : paginator.isFinishPage) && fetchAll) {
|
|
103
|
-
fetchAll();
|
|
104
|
-
}
|
|
105
|
-
if ((paginator === null || paginator === void 0 ? void 0 : paginator.isFetching) && (paginator === null || paginator === void 0 ? void 0 : paginator.isFinishPage)) {
|
|
106
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.stopFetching();
|
|
107
|
-
}
|
|
108
|
-
}, __spreadArray([paginator, paginator === null || paginator === void 0 ? void 0 : paginator.isFetching], (deps || []), true));
|
|
109
|
-
useEffect(function () { return function () {
|
|
110
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.clearOffset();
|
|
111
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.startFetching();
|
|
112
|
-
}; }, __spreadArray(__spreadArray([], (deps || []), true), (cleanupDeps || []), true));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
var useScrollWithBottomSpacing = function (spacingToBottom, delay, callback, element, deps) {
|
|
116
|
-
var handleScroll = function (e) {
|
|
117
|
-
var target = element ? e.target : e.target.documentElement;
|
|
118
|
-
var targetHeight = element ? e.target.clientHeight : window.innerHeight;
|
|
119
|
-
if (target.scrollHeight - (target.scrollTop + targetHeight) <
|
|
120
|
-
spacingToBottom) {
|
|
121
|
-
callback();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
useEffect(function () {
|
|
125
|
-
var throttle = _.throttle(handleScroll, delay);
|
|
126
|
-
var target = (element === null || element === void 0 ? void 0 : element.current) || document;
|
|
127
|
-
target.addEventListener("scroll", throttle);
|
|
128
|
-
return function () {
|
|
129
|
-
target.removeEventListener("scroll", throttle);
|
|
130
|
-
};
|
|
131
|
-
}, __spreadArray([delay], (deps || []), true));
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
var usePaginationPage = function (paginator, fetchAll, filter, deps, cleanupDeps) {
|
|
135
|
-
useFetchPage(paginator, fetchAll, deps, cleanupDeps);
|
|
136
|
-
useDebounce((filter === null || filter === void 0 ? void 0 : filter.searchQuery) || "", 500, function () {
|
|
137
|
-
if (filter) {
|
|
138
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.clearOffset();
|
|
139
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.startFetching();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
useScrollWithBottomSpacing(10, 200, function () {
|
|
143
|
-
paginator === null || paginator === void 0 ? void 0 : paginator.startFetching();
|
|
144
|
-
}, null, deps);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/* global google */
|
|
148
|
-
var useMapCards = function (location, map) {
|
|
149
|
-
var ref = useRef(null);
|
|
150
|
-
var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
151
|
-
var closeCard = function () { return setIsOpen(false); };
|
|
152
|
-
var toggleCard = function () { return setIsOpen(!isOpen); };
|
|
153
|
-
var handleCloseWithEvent = function (e) {
|
|
154
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
155
|
-
closeCard();
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
useEffect(function () {
|
|
159
|
-
if (isOpen && ref.current) {
|
|
160
|
-
var coords = new window.google.maps.LatLng(location);
|
|
161
|
-
map === null || map === void 0 ? void 0 : map.panTo(coords);
|
|
162
|
-
map === null || map === void 0 ? void 0 : map.panBy(48, -150);
|
|
163
|
-
window.google.maps.OverlayView.preventMapHitsAndGesturesFrom(ref.current);
|
|
164
|
-
}
|
|
165
|
-
}, [isOpen]);
|
|
166
|
-
useEffect(function () {
|
|
167
|
-
document.addEventListener("click", handleCloseWithEvent, { passive: true });
|
|
168
|
-
return function () { return document.removeEventListener("click", handleCloseWithEvent); };
|
|
169
|
-
}, []);
|
|
170
|
-
return { ref: ref, isOpen: isOpen, closeCard: closeCard, toggleCard: toggleCard };
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export { useAutocomplete, useFetchPage, useMapCards, usePaginationPage, usePortalPosition, useScrollWithBottomSpacing };
|
|
174
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{useEffect as n,useState as t,useRef as e}from"react";import{useDebounce as r}from"kui-utils";import i from"lodash";var o=function(){return o=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n},o.apply(this,arguments)};function c(n,t,e){if(e||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}var u=function(t,e,i,o,u,l,a){n((function(){u&&t.updateFilterQuery(u),t.updateSearchQuery(""),e.clearOffset(),e.startFetching()}),[]),n((function(){e.isFetching&&!e.isFinishPage&&!l&&o&&i()}),c([i,e.isFetching,o],a||[],!0)),r(t.searchQuery,500,(function(){e.clearOffset(),e.startFetching()})),r(t.filterQuery,500,(function(){e.clearOffset(),e.startFetching()}));return{onSearchItem:function(n){t.updateSearchQuery(n),0===n.length&&(e.clearOffset(),e.startFetching())},onScrollEnd:function(){e.isFinishPage||e.startFetching()}}},l=function(e){var r=t(null),i=r[0],c=r[1];return n((function(){if(e.current){var n=function(){if(e.current){var n=e.current.getBoundingClientRect();c(o(o({},n),{right:document.documentElement.clientWidth-n.right,top:n.top+window.pageYOffset}))}};return n(),window.addEventListener("calcPortalPosition",n),function(){return window.removeEventListener("calcPortalPosition",n)}}}),[e]),i},a=function(t,e,r,i){n((function(){(null==t?void 0:t.isFetching)&&!(null==t?void 0:t.isFinishPage)&&e&&e(),(null==t?void 0:t.isFetching)&&(null==t?void 0:t.isFinishPage)&&(null==t||t.stopFetching())}),c([t,null==t?void 0:t.isFetching],r||[],!0)),n((function(){return function(){null==t||t.clearOffset(),null==t||t.startFetching()}}),c(c([],r||[],!0),i||[],!0))},s=function(t,e,r,o,u){var l=function(n){var e=o?n.target:n.target.documentElement,i=o?n.target.clientHeight:window.innerHeight;e.scrollHeight-(e.scrollTop+i)<t&&r()};n((function(){var n=i.throttle(l,e),t=(null==o?void 0:o.current)||document;return t.addEventListener("scroll",n),function(){t.removeEventListener("scroll",n)}}),c([e],u||[],!0))},f=function(n,t,e,i,o){a(n,t,i,o),r((null==e?void 0:e.searchQuery)||"",500,(function(){e&&(null==n||n.clearOffset(),null==n||n.startFetching())})),s(10,200,(function(){null==n||n.startFetching()}),null,i)},g=function(r,i){var o=e(null),c=t(!1),u=c[0],l=c[1],a=function(){return l(!1)},s=function(n){o.current&&!o.current.contains(n.target)&&a()};return n((function(){if(u&&o.current){var n=new window.google.maps.LatLng(r);null==i||i.panTo(n),null==i||i.panBy(48,-150),window.google.maps.OverlayView.preventMapHitsAndGesturesFrom(o.current)}}),[u]),n((function(){return document.addEventListener("click",s,{passive:!0}),function(){return document.removeEventListener("click",s)}}),[]),{ref:o,isOpen:u,closeCard:a,toggleCard:function(){return l(!u)}}};export{u as useAutocomplete,a as useFetchPage,g as useMapCards,f as usePaginationPage,l as usePortalPosition,s as useScrollWithBottomSpacing};
|