@bigbinary/neeto-commons-frontend 2.0.3 → 2.0.6
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/README.md +1 -1
- package/initializers.cjs.js +67 -51
- package/initializers.js +67 -51
- package/package.json +3 -3
- package/pure.d.ts +21 -20
- package/react-utils.cjs.js +125 -74
- package/react-utils.d.ts +17 -11
- package/react-utils.js +107 -61
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The commons frontend library for Neeto Applications.
|
|
|
7
7
|
Install from npm:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
yarn add "@bigbinary/neeto-commons-frontend@2.0.
|
|
10
|
+
yarn add "@bigbinary/neeto-commons-frontend@2.0.6"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
This package relies on the host project's tailwind configuration. So add
|
package/initializers.cjs.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ramda = require('ramda');
|
|
6
5
|
var neetoui = require('@bigbinary/neetoui');
|
|
7
6
|
var axios = require('axios');
|
|
8
7
|
var i18next = require('i18next');
|
|
9
|
-
var
|
|
8
|
+
var ramda = require('ramda');
|
|
10
9
|
var reactI18next = require('react-i18next');
|
|
10
|
+
var mixpanel = require('mixpanel-browser');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
13
|
|
|
@@ -25,6 +25,21 @@ function _typeof(obj) {
|
|
|
25
25
|
}, _typeof(obj);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function _defineProperty(obj, key, value) {
|
|
29
|
+
if (key in obj) {
|
|
30
|
+
Object.defineProperty(obj, key, {
|
|
31
|
+
value: value,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
obj[key] = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
function _arrayWithHoles(arr) {
|
|
29
44
|
if (Array.isArray(arr)) return arr;
|
|
30
45
|
}
|
|
@@ -161,28 +176,6 @@ var matches = ramda.curry(function (pattern, object) {
|
|
|
161
176
|
});
|
|
162
177
|
});
|
|
163
178
|
|
|
164
|
-
function initializeGlobalProps() {
|
|
165
|
-
var _document$getElements, _document$getElements2;
|
|
166
|
-
|
|
167
|
-
window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
|
|
168
|
-
deepFreezeObject(window.globalProps);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function _defineProperty(obj, key, value) {
|
|
172
|
-
if (key in obj) {
|
|
173
|
-
Object.defineProperty(obj, key, {
|
|
174
|
-
value: value,
|
|
175
|
-
enumerable: true,
|
|
176
|
-
configurable: true,
|
|
177
|
-
writable: true
|
|
178
|
-
});
|
|
179
|
-
} else {
|
|
180
|
-
obj[key] = value;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return obj;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
179
|
var HEADERS_KEYS = {
|
|
187
180
|
xAuthEmail: "X-Auth-Email",
|
|
188
181
|
xAuthToken: "X-Auth-Token",
|
|
@@ -262,15 +255,28 @@ var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
|
|
|
262
255
|
};
|
|
263
256
|
|
|
264
257
|
var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
|
|
258
|
+
var _error$response;
|
|
259
|
+
|
|
260
|
+
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== 401) return error;
|
|
265
261
|
resetAuthTokens();
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
var _error$config$redirec = error.config.redirectOnError,
|
|
263
|
+
redirectOnError = _error$config$redirec === void 0 ? true : _error$config$redirec;
|
|
264
|
+
|
|
265
|
+
if (redirectOnError) {
|
|
266
|
+
setTimeout(function () {
|
|
267
|
+
var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
|
|
268
|
+
window.location.href = redirectTo;
|
|
269
|
+
}, 300);
|
|
270
|
+
}
|
|
271
|
+
|
|
270
272
|
return error;
|
|
271
273
|
};
|
|
272
274
|
|
|
273
275
|
var showErrorToastr = function showErrorToastr(error) {
|
|
276
|
+
var _error$config$showToa = error.config.showToastr,
|
|
277
|
+
showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
|
|
278
|
+
if (!showToastr) return error;
|
|
279
|
+
|
|
274
280
|
if (axios__default["default"].isCancel(error)) {
|
|
275
281
|
neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.requestCanceled"));
|
|
276
282
|
} else if (error.message === "Network Error") {
|
|
@@ -283,9 +289,12 @@ var showErrorToastr = function showErrorToastr(error) {
|
|
|
283
289
|
};
|
|
284
290
|
|
|
285
291
|
var redirect404 = function redirect404(error) {
|
|
286
|
-
var _error$
|
|
292
|
+
var _error$response2;
|
|
287
293
|
|
|
288
|
-
|
|
294
|
+
var _error$config$redirec2 = error.config.redirectOnError,
|
|
295
|
+
redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
|
|
296
|
+
|
|
297
|
+
if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
|
|
289
298
|
window.location.href = "/page-not-found";
|
|
290
299
|
}
|
|
291
300
|
|
|
@@ -341,26 +350,11 @@ function initializeAxios(skip) {
|
|
|
341
350
|
if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
|
|
342
351
|
}
|
|
343
352
|
|
|
344
|
-
function
|
|
345
|
-
var
|
|
346
|
-
var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
|
|
347
|
-
var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
|
|
353
|
+
function initializeGlobalProps() {
|
|
354
|
+
var _document$getElements, _document$getElements2;
|
|
348
355
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
mixpanel__default["default"].people.set({
|
|
352
|
-
$email: globalProps.user.email,
|
|
353
|
-
$fist_name: globalProps.user.firstName,
|
|
354
|
-
$last_name: globalProps.user.lastName
|
|
355
|
-
});
|
|
356
|
-
mixpanel__default["default"].identify(globalProps.user.email);
|
|
357
|
-
} else {
|
|
358
|
-
/*
|
|
359
|
-
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
360
|
-
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
361
|
-
*/
|
|
362
|
-
mixpanel__default["default"].init("TEST_TOKEN");
|
|
363
|
-
}
|
|
356
|
+
window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
|
|
357
|
+
deepFreezeObject(window.globalProps);
|
|
364
358
|
}
|
|
365
359
|
|
|
366
360
|
var neetoCommons = {
|
|
@@ -374,8 +368,8 @@ var neetoCommons = {
|
|
|
374
368
|
reload: "Reload"
|
|
375
369
|
},
|
|
376
370
|
sidebar: {
|
|
377
|
-
|
|
378
|
-
|
|
371
|
+
myProfile: "My Profile",
|
|
372
|
+
myOrganization: "My Organization",
|
|
379
373
|
logout: "Logout",
|
|
380
374
|
help: "Help"
|
|
381
375
|
},
|
|
@@ -418,6 +412,28 @@ var initializeI18n = function initializeI18n(resources) {
|
|
|
418
412
|
});
|
|
419
413
|
};
|
|
420
414
|
|
|
415
|
+
function initializeMixPanel() {
|
|
416
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
417
|
+
var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
|
|
418
|
+
var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
|
|
419
|
+
|
|
420
|
+
if (isProduction && isTokenPresent && isUserLoggedIn) {
|
|
421
|
+
mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "");
|
|
422
|
+
mixpanel__default["default"].people.set({
|
|
423
|
+
$email: globalProps.user.email,
|
|
424
|
+
$fist_name: globalProps.user.firstName,
|
|
425
|
+
$last_name: globalProps.user.lastName
|
|
426
|
+
});
|
|
427
|
+
mixpanel__default["default"].identify(globalProps.user.email);
|
|
428
|
+
} else {
|
|
429
|
+
/*
|
|
430
|
+
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
431
|
+
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
432
|
+
*/
|
|
433
|
+
mixpanel__default["default"].init("TEST_TOKEN");
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
421
437
|
exports.globalProps = {};
|
|
422
438
|
function initializeApplication(_ref) {
|
|
423
439
|
var translationResources = _ref.translationResources,
|
package/initializers.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { curry, isNil, values, evolve, omit, modify, either, isEmpty, mergeDeepLeft } from 'ramda';
|
|
2
1
|
import { Toastr } from '@bigbinary/neetoui';
|
|
3
2
|
import axios from 'axios';
|
|
4
3
|
import i18next from 'i18next';
|
|
5
|
-
import
|
|
4
|
+
import { curry, isNil, values, evolve, omit, modify, mergeDeepLeft, either, isEmpty } from 'ramda';
|
|
6
5
|
import { initReactI18next } from 'react-i18next';
|
|
6
|
+
import mixpanel from 'mixpanel-browser';
|
|
7
7
|
|
|
8
8
|
function _typeof(obj) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
@@ -15,6 +15,21 @@ function _typeof(obj) {
|
|
|
15
15
|
}, _typeof(obj);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
function _defineProperty(obj, key, value) {
|
|
19
|
+
if (key in obj) {
|
|
20
|
+
Object.defineProperty(obj, key, {
|
|
21
|
+
value: value,
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
obj[key] = value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
function _arrayWithHoles(arr) {
|
|
19
34
|
if (Array.isArray(arr)) return arr;
|
|
20
35
|
}
|
|
@@ -151,28 +166,6 @@ var matches = curry(function (pattern, object) {
|
|
|
151
166
|
});
|
|
152
167
|
});
|
|
153
168
|
|
|
154
|
-
function initializeGlobalProps() {
|
|
155
|
-
var _document$getElements, _document$getElements2;
|
|
156
|
-
|
|
157
|
-
window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
|
|
158
|
-
deepFreezeObject(window.globalProps);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function _defineProperty(obj, key, value) {
|
|
162
|
-
if (key in obj) {
|
|
163
|
-
Object.defineProperty(obj, key, {
|
|
164
|
-
value: value,
|
|
165
|
-
enumerable: true,
|
|
166
|
-
configurable: true,
|
|
167
|
-
writable: true
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
obj[key] = value;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return obj;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
169
|
var HEADERS_KEYS = {
|
|
177
170
|
xAuthEmail: "X-Auth-Email",
|
|
178
171
|
xAuthToken: "X-Auth-Token",
|
|
@@ -252,15 +245,28 @@ var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
|
|
|
252
245
|
};
|
|
253
246
|
|
|
254
247
|
var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
|
|
248
|
+
var _error$response;
|
|
249
|
+
|
|
250
|
+
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== 401) return error;
|
|
255
251
|
resetAuthTokens();
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
var _error$config$redirec = error.config.redirectOnError,
|
|
253
|
+
redirectOnError = _error$config$redirec === void 0 ? true : _error$config$redirec;
|
|
254
|
+
|
|
255
|
+
if (redirectOnError) {
|
|
256
|
+
setTimeout(function () {
|
|
257
|
+
var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
|
|
258
|
+
window.location.href = redirectTo;
|
|
259
|
+
}, 300);
|
|
260
|
+
}
|
|
261
|
+
|
|
260
262
|
return error;
|
|
261
263
|
};
|
|
262
264
|
|
|
263
265
|
var showErrorToastr = function showErrorToastr(error) {
|
|
266
|
+
var _error$config$showToa = error.config.showToastr,
|
|
267
|
+
showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
|
|
268
|
+
if (!showToastr) return error;
|
|
269
|
+
|
|
264
270
|
if (axios.isCancel(error)) {
|
|
265
271
|
Toastr.error(i18next.t("neetoCommons.toastr.error.requestCanceled"));
|
|
266
272
|
} else if (error.message === "Network Error") {
|
|
@@ -273,9 +279,12 @@ var showErrorToastr = function showErrorToastr(error) {
|
|
|
273
279
|
};
|
|
274
280
|
|
|
275
281
|
var redirect404 = function redirect404(error) {
|
|
276
|
-
var _error$
|
|
282
|
+
var _error$response2;
|
|
283
|
+
|
|
284
|
+
var _error$config$redirec2 = error.config.redirectOnError,
|
|
285
|
+
redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
|
|
277
286
|
|
|
278
|
-
if (((_error$
|
|
287
|
+
if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
|
|
279
288
|
window.location.href = "/page-not-found";
|
|
280
289
|
}
|
|
281
290
|
|
|
@@ -331,26 +340,11 @@ function initializeAxios(skip) {
|
|
|
331
340
|
if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
|
|
332
341
|
}
|
|
333
342
|
|
|
334
|
-
function
|
|
335
|
-
var
|
|
336
|
-
var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
|
|
337
|
-
var isUserLoggedIn = !either(isEmpty, isNil)(globalProps.user);
|
|
343
|
+
function initializeGlobalProps() {
|
|
344
|
+
var _document$getElements, _document$getElements2;
|
|
338
345
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
mixpanel.people.set({
|
|
342
|
-
$email: globalProps.user.email,
|
|
343
|
-
$fist_name: globalProps.user.firstName,
|
|
344
|
-
$last_name: globalProps.user.lastName
|
|
345
|
-
});
|
|
346
|
-
mixpanel.identify(globalProps.user.email);
|
|
347
|
-
} else {
|
|
348
|
-
/*
|
|
349
|
-
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
350
|
-
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
351
|
-
*/
|
|
352
|
-
mixpanel.init("TEST_TOKEN");
|
|
353
|
-
}
|
|
346
|
+
window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
|
|
347
|
+
deepFreezeObject(window.globalProps);
|
|
354
348
|
}
|
|
355
349
|
|
|
356
350
|
var neetoCommons = {
|
|
@@ -364,8 +358,8 @@ var neetoCommons = {
|
|
|
364
358
|
reload: "Reload"
|
|
365
359
|
},
|
|
366
360
|
sidebar: {
|
|
367
|
-
|
|
368
|
-
|
|
361
|
+
myProfile: "My Profile",
|
|
362
|
+
myOrganization: "My Organization",
|
|
369
363
|
logout: "Logout",
|
|
370
364
|
help: "Help"
|
|
371
365
|
},
|
|
@@ -408,6 +402,28 @@ var initializeI18n = function initializeI18n(resources) {
|
|
|
408
402
|
});
|
|
409
403
|
};
|
|
410
404
|
|
|
405
|
+
function initializeMixPanel() {
|
|
406
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
407
|
+
var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
|
|
408
|
+
var isUserLoggedIn = !either(isEmpty, isNil)(globalProps.user);
|
|
409
|
+
|
|
410
|
+
if (isProduction && isTokenPresent && isUserLoggedIn) {
|
|
411
|
+
mixpanel.init(process.env.MIXPANEL_TOKEN || "");
|
|
412
|
+
mixpanel.people.set({
|
|
413
|
+
$email: globalProps.user.email,
|
|
414
|
+
$fist_name: globalProps.user.firstName,
|
|
415
|
+
$last_name: globalProps.user.lastName
|
|
416
|
+
});
|
|
417
|
+
mixpanel.identify(globalProps.user.email);
|
|
418
|
+
} else {
|
|
419
|
+
/*
|
|
420
|
+
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
421
|
+
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
422
|
+
*/
|
|
423
|
+
mixpanel.init("TEST_TOKEN");
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
411
427
|
var globalProps$1 = {};
|
|
412
428
|
function initializeApplication(_ref) {
|
|
413
429
|
var translationResources = _ref.translationResources,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@babel/preset-env": "^7.17.10",
|
|
48
48
|
"@babel/preset-react": "^7.16.7",
|
|
49
49
|
"@bigbinary/neeto-icons": "^1.8.35",
|
|
50
|
-
"@bigbinary/neetoui": "^3.5.
|
|
50
|
+
"@bigbinary/neetoui": "^3.5.16",
|
|
51
51
|
"@honeybadger-io/react": "2.0.1",
|
|
52
52
|
"@rollup/plugin-alias": "^3.1.9",
|
|
53
53
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"dependencies": {},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"@bigbinary/neeto-icons": "^1.8.35",
|
|
99
|
-
"@bigbinary/neetoui": "^3.5.
|
|
99
|
+
"@bigbinary/neetoui": "^3.5.16",
|
|
100
100
|
"@honeybadger-io/react": "2.0.1",
|
|
101
101
|
"axios": "^0.27.2",
|
|
102
102
|
"dayjs": "1.11.1",
|
package/pure.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
| boolean
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
10
|
-
type MatchPattern<Obj = any, Parent = Obj> =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export type Primitives = symbol | string | number | boolean | null | undefined;
|
|
2
|
+
export type ObjectAndPrimitives = Primitives | object;
|
|
3
|
+
type KeyType = string | number | symbol;
|
|
4
|
+
|
|
5
|
+
type Matchable<Obj, Parent, key extends keyof Obj> =
|
|
6
|
+
| ((object: Obj[key], parent: Parent) => boolean)
|
|
7
|
+
| MatchPattern<Obj[key], Parent>
|
|
8
|
+
| Primitives;
|
|
9
|
+
|
|
10
|
+
type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[]
|
|
11
|
+
?
|
|
12
|
+
| Matchable<Obj, Parent, number>[]
|
|
13
|
+
| { [key: number]: Matchable<Obj, Parent, number> }
|
|
14
|
+
: Obj extends Primitives
|
|
15
|
+
? Obj
|
|
16
|
+
:
|
|
17
|
+
| {
|
|
18
|
+
[key in keyof Partial<Obj>]: Matchable<Obj, Parent, key>;
|
|
19
|
+
} & {
|
|
20
|
+
[key: KeyType]: Matchable<any, Parent, KeyType>;
|
|
21
|
+
};
|
|
21
22
|
|
|
22
23
|
export function camelToSnakeCase(string: string): string;
|
|
23
24
|
export function capitalize(string: string): string;
|