@bigbinary/neeto-commons-frontend 0.0.1 → 0.0.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/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@0.0.1"
10
+ yarn add "@bigbinary/neeto-commons-frontend@0.0.2"
11
11
  ```
12
12
 
13
13
  This package relies on the host project's tailwind configuration. So add
@@ -32,7 +32,39 @@ them to read more:
32
32
 
33
33
  1. [Initializers](./docs/initializers/README.md)
34
34
  2. [React utilities](./docs/react/README.md)
35
- 3. [General utility functions](./docs/utils/README.md)
35
+ 3. [Pure utility functions](./docs/pure/README.md)
36
+ 4. [Web utility functions](./docs/utils/README.md)
37
+
38
+ ## Migrating from version 1 to 2
39
+
40
+ There is only a single breaking change from version 1 to version 2. The pure
41
+ functions (which has only ramda as its peerDependency) have been moved to a
42
+ separate bundle (named pure). You can import them from
43
+ `@bigbinary/neeto-commons-frontend/pure` instead of
44
+ `@bigbinary/neeto-commons-frontend/utils`.
45
+
46
+ Here is a list of functions that have been moved:
47
+
48
+ `removeById`, `findById`, `replaceById`, `modifyById`, `findBy`, `removeBy`,
49
+ `replaceBy`,`modifyBy`, `existsById`, `existsBy`, `findLastBy`, `findIndexById`,
50
+ `findIndexBy`,`findLastIndexBy`, `filterBy`, `countBy`, `copyKeys`,
51
+ `renameKeys`, `copyKeysDeep`
52
+
53
+ `noop`, `toLabelAndValue`, `getRandomInt`, `randomPick`, `dynamicArray`,
54
+ `isNotNil`, `isNotEmpty`, `notEquals`, `isNot`, `notEqualsDeep`,
55
+ `isNotEqualDeep`
56
+
57
+ `transformObjectDeep`, `keysToCamelCase`, `keysToSnakeCase`, `deepFreezeObject`,
58
+ `matches`, `filterNonNull`
59
+
60
+ `slugify`, `humanize`, `snakeToCamelCase`, `camelToSnakeCase`, `capitalize`,
61
+ `truncate`
62
+
63
+ When you are migrating from version 1 to version 2, do the following:
64
+
65
+ 1. Search for all imports from `@bigbinary/neeto-commons-frontend/utils` and
66
+ delete the above mentioned functions from those imports.
67
+ 2. Import these functions from `@bigbinary/neeto-commons-frontend/pure` instead.
36
68
 
37
69
  ## Development instructions
38
70
 
@@ -46,7 +78,7 @@ them to read more:
46
78
  neeto-commons-frontend to the local yalc store.
47
79
  6. Run `yalc install` to install the neeto-commons-frontend to the host
48
80
  application.
49
- 7. After making all changes to `neeto-commons-frontend`, run `yal push` to push
81
+ 7. After making all changes to `neeto-commons-frontend`, run `yalc push` to push
50
82
  the changes to the host application.
51
83
  8. Video explanation on how to use yalc: https://vimeo.com/722958162/9e931b640c
52
84
 
@@ -62,7 +94,7 @@ This is how releases are managed in this repo.
62
94
  [package.json](https://github.com/bigbinary/neeto-commons-frontend/blob/master/package.json#L3)
63
95
  will be updated to the current branch name.
64
96
  - From now on, we can install the package to neeto-applications using the
65
- version `1.X.Y`.
97
+ version `2.X.Y`.
66
98
  - We will create a draft PR of this branch targeting master. This keeps the
67
99
  branch in sync with master branch (bot-bigbinary will auto-merge the changes).
68
100
  - When all features have been built, we will deploy it to all neeto-applications
@@ -75,19 +107,19 @@ This is how releases are managed in this repo.
75
107
  the latest changes.
76
108
  - Once everything is fine and the verification is complete, we will create a
77
109
  [new github release](https://github.com/bigbinary/neeto-commons-frontend/releases/new)
78
- from `1.X.Y` branch with the exact same name for the tag (`1.X.Y`). The target
79
- branch will be kept as `1.X.Y`. This will create a tag from the latest `1.X.Y`
110
+ from `2.X.Y` branch with the exact same name for the tag (`2.X.Y`). The target
111
+ branch will be kept as `2.X.Y`. This will create a tag from the latest `2.X.Y`
80
112
  branch and this ensures that the latest commit on that branch will remain
81
113
  intact even if that branch gets deleted.
82
114
  - Whenever a new release is created with a new version number, the github
83
115
  actions will automatically publish the built package to npm.
84
- - Now we will squash and merge the PR `1.X.Y` to master and delete its source
116
+ - Now we will squash and merge the PR `2.X.Y` to master and delete its source
85
117
  branch. This will delete all commits except the top one (since we have created
86
118
  a tag with it).
87
- - Immediately, we will open another branch with the next version (`1.X.Y`) and
119
+ - Immediately, we will open another branch with the next version (`2.X.Y`) and
88
120
  the cycle will continue.
89
121
  - Now we can run `yalc remove neeto-commons-frontend` to remove yalc based
90
- package and run `yarn add neeto-commons-frontend@1.X.Y` to fetch the latest
122
+ package and run `yarn add neeto-commons-frontend@2.X.Y` to fetch the latest
91
123
  changes from npm in all repos and raise PR. You might be able to slightly
92
124
  tweak this script to get the job done:
93
125
  https://gist.github.com/jagannathBhat/42a584748d97fe134f0abadb191ef29a
@@ -0,0 +1,438 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var neetoui = require('@bigbinary/neetoui');
6
+ var axios = require('axios');
7
+ var i18next = require('i18next');
8
+ var ramda = require('ramda');
9
+ var reactI18next = require('react-i18next');
10
+ var mixpanel = require('mixpanel-browser');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
15
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
16
+ var mixpanel__default = /*#__PURE__*/_interopDefaultLegacy(mixpanel);
17
+
18
+ function _typeof(obj) {
19
+ "@babel/helpers - typeof";
20
+
21
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
22
+ return typeof obj;
23
+ } : function (obj) {
24
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
25
+ }, _typeof(obj);
26
+ }
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
+
43
+ function _arrayWithHoles(arr) {
44
+ if (Array.isArray(arr)) return arr;
45
+ }
46
+
47
+ function _iterableToArrayLimit(arr, i) {
48
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
49
+
50
+ if (_i == null) return;
51
+ var _arr = [];
52
+ var _n = true;
53
+ var _d = false;
54
+
55
+ var _s, _e;
56
+
57
+ try {
58
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
59
+ _arr.push(_s.value);
60
+
61
+ if (i && _arr.length === i) break;
62
+ }
63
+ } catch (err) {
64
+ _d = true;
65
+ _e = err;
66
+ } finally {
67
+ try {
68
+ if (!_n && _i["return"] != null) _i["return"]();
69
+ } finally {
70
+ if (_d) throw _e;
71
+ }
72
+ }
73
+
74
+ return _arr;
75
+ }
76
+
77
+ function _arrayLikeToArray(arr, len) {
78
+ if (len == null || len > arr.length) len = arr.length;
79
+
80
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
81
+ arr2[i] = arr[i];
82
+ }
83
+
84
+ return arr2;
85
+ }
86
+
87
+ function _unsupportedIterableToArray(o, minLen) {
88
+ if (!o) return;
89
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
90
+ var n = Object.prototype.toString.call(o).slice(8, -1);
91
+ if (n === "Object" && o.constructor) n = o.constructor.name;
92
+ if (n === "Map" || n === "Set") return Array.from(o);
93
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
94
+ }
95
+
96
+ function _nonIterableRest() {
97
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
+ }
99
+
100
+ function _slicedToArray(arr, i) {
101
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
102
+ }
103
+
104
+ var snakeToCamelCase = function snakeToCamelCase(string) {
105
+ return string.replace(/(_\w)/g, function (letter) {
106
+ return letter[1].toUpperCase();
107
+ });
108
+ };
109
+ var camelToSnakeCase = function camelToSnakeCase(string) {
110
+ return string.replace(/[A-Z]/g, function (letter) {
111
+ return "_".concat(letter.toLowerCase());
112
+ });
113
+ };
114
+
115
+ var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
116
+ var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
117
+
118
+ if (objectPreProcessor && typeof objectPreProcessor === "function") {
119
+ object = objectPreProcessor(object);
120
+ }
121
+
122
+ if (Array.isArray(object)) {
123
+ return object.map(function (obj) {
124
+ return transformObjectDeep(obj, keyValueTransformer, objectPreProcessor);
125
+ });
126
+ } else if (object === null || _typeof(object) !== "object") {
127
+ return object;
128
+ }
129
+
130
+ return Object.fromEntries(Object.entries(object).map(function (_ref3) {
131
+ var _ref4 = _slicedToArray(_ref3, 2),
132
+ key = _ref4[0],
133
+ value = _ref4[1];
134
+
135
+ return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer, objectPreProcessor));
136
+ }));
137
+ };
138
+ var keysToCamelCase = function keysToCamelCase(object) {
139
+ return transformObjectDeep(object, function (key, value) {
140
+ return [snakeToCamelCase(key), value];
141
+ });
142
+ };
143
+ var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
144
+ return transformObjectDeep(object, function (key, value) {
145
+ return [camelToSnakeCase(key), value];
146
+ }, function (object) {
147
+ return typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
148
+ });
149
+ };
150
+ var deepFreezeObject = function deepFreezeObject(object) {
151
+ if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
152
+ Object.keys(object).forEach(function (property) {
153
+ return deepFreezeObject(object[property]);
154
+ });
155
+ Object.freeze(object);
156
+ }
157
+
158
+ return object;
159
+ };
160
+
161
+ var HEADERS_KEYS = {
162
+ xAuthEmail: "X-Auth-Email",
163
+ xAuthToken: "X-Auth-Token",
164
+ xCsrfToken: "X-CSRF-TOKEN"
165
+ };
166
+
167
+ var resetAuthTokens = function resetAuthTokens() {
168
+ ramda.values(HEADERS_KEYS).forEach(function (header) {
169
+ delete axios__default["default"].defaults.headers[header];
170
+ });
171
+ };
172
+
173
+ var shouldNot = function shouldNot(skip) {
174
+ return _typeof(skip) === "object" || !skip;
175
+ };
176
+
177
+ var setAuthHeaders = function setAuthHeaders() {
178
+ var _globalProps$user, _globalProps$user2;
179
+
180
+ axios__default["default"].defaults.headers = _defineProperty({
181
+ Accept: "application/json",
182
+ "Content-Type": "application/json"
183
+ }, HEADERS_KEYS.xCsrfToken, document.querySelector('[name="csrf-token"]').getAttribute("content"));
184
+ var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
185
+ var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
186
+
187
+ if (token && email) {
188
+ axios__default["default"].defaults.headers[HEADERS_KEYS.xAuthEmail] = email;
189
+ axios__default["default"].defaults.headers[HEADERS_KEYS.xAuthToken] = token;
190
+ }
191
+ }; // pipe function from ramda doesn't accept array of functions.
192
+ // We can't use spread operator too. So this is a workaround.
193
+
194
+
195
+ var createPipe = function createPipe(functions) {
196
+ return function (data) {
197
+ return functions.reduce(function (acc, fn) {
198
+ return fn(acc);
199
+ }, data);
200
+ };
201
+ };
202
+
203
+ var transformKeysToCamelCase = function transformKeysToCamelCase(response) {
204
+ var _response$config$tran = response.config.transformResponseCase,
205
+ transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran;
206
+
207
+ if (response.data && transformResponseCase) {
208
+ response.data = keysToCamelCase(response.data);
209
+ }
210
+
211
+ return response;
212
+ };
213
+
214
+ var showSuccessToastr = function showSuccessToastr(response) {
215
+ var _response$config$show = response.config.showToastr,
216
+ showToastr = _response$config$show === void 0 ? true : _response$config$show;
217
+
218
+ if (showToastr && typeof response.data.notice === "string") {
219
+ neetoui.Toastr.success(response.data.notice);
220
+ }
221
+
222
+ return response;
223
+ };
224
+
225
+ var pullDataFromResponse = function pullDataFromResponse(response) {
226
+ var _response$config$incl = response.config.includeMetadataInResponse,
227
+ includeMetadataInResponse = _response$config$incl === void 0 ? false : _response$config$incl;
228
+ return includeMetadataInResponse ? response : response.data;
229
+ };
230
+
231
+ var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
232
+ var interceptors = [];
233
+ if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformKeysToCamelCase);
234
+ if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showSuccessToastr);
235
+ if (!(skip !== null && skip !== void 0 && skip.pullDataFromResponse)) interceptors.push(pullDataFromResponse);
236
+ return createPipe(interceptors);
237
+ };
238
+
239
+ var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
240
+ var _error$response;
241
+
242
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== 401) return error;
243
+ resetAuthTokens();
244
+ var _error$config$redirec = error.config.redirectOnError,
245
+ redirectOnError = _error$config$redirec === void 0 ? true : _error$config$redirec;
246
+
247
+ if (redirectOnError) {
248
+ setTimeout(function () {
249
+ var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
250
+ window.location.href = redirectTo;
251
+ }, 300);
252
+ }
253
+
254
+ return error;
255
+ };
256
+
257
+ var showErrorToastr = function showErrorToastr(error) {
258
+ var _error$config$showToa = error.config.showToastr,
259
+ showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
260
+ if (!showToastr) return error;
261
+
262
+ if (axios__default["default"].isCancel(error)) {
263
+ neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.requestCanceled"));
264
+ } else if (error.message === "Network Error") {
265
+ neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.networkError"));
266
+ } else {
267
+ neetoui.Toastr.error(error);
268
+ }
269
+
270
+ return error;
271
+ };
272
+
273
+ var redirect404 = function redirect404(error) {
274
+ var _error$response2;
275
+
276
+ var _error$config$redirec2 = error.config.redirectOnError,
277
+ redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
278
+
279
+ if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
280
+ window.location.href = "/page-not-found";
281
+ }
282
+
283
+ return error;
284
+ };
285
+
286
+ var buildErrorResponseHandler = function buildErrorResponseHandler(skip) {
287
+ var interceptors = [];
288
+ if (!(skip !== null && skip !== void 0 && skip.redirectOn404)) interceptors.push(redirect404);
289
+ if (!(skip !== null && skip !== void 0 && skip.logoutOn401)) interceptors.push(handleUnauthorizedErrorResponse);
290
+ if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showErrorToastr);
291
+ interceptors.push(Promise.reject.bind(Promise));
292
+ return createPipe(interceptors);
293
+ };
294
+
295
+ var cleanupCredentialsForCrossOrigin = function cleanupCredentialsForCrossOrigin(request) {
296
+ if (!request.url.includes("://")) return request;
297
+ if (request.url.includes(window.location.hostname)) return request;
298
+ return ramda.evolve({
299
+ headers: ramda.omit(ramda.values(HEADERS_KEYS))
300
+ })(request);
301
+ };
302
+
303
+ var transformDataToSnakeCase = function transformDataToSnakeCase(request) {
304
+ var _request$transformReq = request.transformRequestCase,
305
+ transformRequestCase = _request$transformReq === void 0 ? true : _request$transformReq;
306
+ if (!transformRequestCase || !request.data) return request;
307
+ return ramda.modify("data", serializeKeysToSnakeCase, request);
308
+ };
309
+
310
+ var addRequestInterceptors = function addRequestInterceptors(skip) {
311
+ if (!(skip !== null && skip !== void 0 && skip.cleanCredentialsForCrossOrigin)) {
312
+ axios__default["default"].interceptors.request.use(cleanupCredentialsForCrossOrigin);
313
+ }
314
+
315
+ if (!(skip !== null && skip !== void 0 && skip.transformCase)) {
316
+ axios__default["default"].interceptors.request.use(transformDataToSnakeCase);
317
+ }
318
+ };
319
+
320
+ var addResponseInterceptors = function addResponseInterceptors(skip) {
321
+ axios__default["default"].interceptors.response.use(buildSuccessResponseHandler(skip), buildErrorResponseHandler(skip));
322
+ };
323
+
324
+ var registerIntercepts = function registerIntercepts(skip) {
325
+ if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.request)) addRequestInterceptors(skip === null || skip === void 0 ? void 0 : skip.request);
326
+ if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.response)) addResponseInterceptors(skip === null || skip === void 0 ? void 0 : skip.response);
327
+ };
328
+
329
+ function initializeAxios(skip) {
330
+ if (!(skip !== null && skip !== void 0 && skip.baseURL)) axios__default["default"].defaults.baseURL = "/";
331
+ if (!(skip !== null && skip !== void 0 && skip.authHeaders)) setAuthHeaders();
332
+ if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
333
+ }
334
+
335
+ function initializeGlobalProps() {
336
+ var _document$getElements, _document$getElements2;
337
+
338
+ 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) || "{}"));
339
+ deepFreezeObject(window.globalProps);
340
+ }
341
+
342
+ var neetoCommons = {
343
+ errorPage: {
344
+ pageDoesNotExist: "Page does not exist.",
345
+ goToHome: "Go home"
346
+ },
347
+ fallbackComponent: {
348
+ somethingWentWrong: "Sorry, something went wrong.",
349
+ tryReloading: "Please try reloading the page.",
350
+ reload: "Reload"
351
+ },
352
+ sidebar: {
353
+ myProfile: "My Profile",
354
+ myOrganization: "My Organization",
355
+ logout: "Logout",
356
+ help: "Help"
357
+ },
358
+ common: {
359
+ actions: {
360
+ cancel: "Cancel",
361
+ save: "Save"
362
+ }
363
+ },
364
+ toastr: {
365
+ success: {
366
+ copiedToClipboard: "Copied to clipboard!"
367
+ },
368
+ error: {
369
+ requestCanceled: "Request cancelled",
370
+ networkError: "No Internet Connection"
371
+ }
372
+ },
373
+ notice: {
374
+ errorOccurred: "Some error occurred."
375
+ }
376
+ };
377
+ var en = {
378
+ neetoCommons: neetoCommons
379
+ };
380
+
381
+ var initializeI18n = function initializeI18n(resources) {
382
+ i18next__default["default"].use(reactI18next.initReactI18next).init({
383
+ resources: ramda.mergeDeepLeft({
384
+ en: {
385
+ translation: en
386
+ }
387
+ }, resources),
388
+ lng: "en",
389
+ fallbackLng: "en",
390
+ interpolation: {
391
+ escapeValue: false,
392
+ skipOnVariables: false
393
+ }
394
+ });
395
+ };
396
+
397
+ function initializeMixPanel() {
398
+ var isProduction = process.env.NODE_ENV === "production";
399
+ var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
400
+ var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
401
+
402
+ if (isProduction && isTokenPresent && isUserLoggedIn) {
403
+ mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "");
404
+ mixpanel__default["default"].people.set({
405
+ $email: globalProps.user.email,
406
+ $fist_name: globalProps.user.firstName,
407
+ $last_name: globalProps.user.lastName
408
+ });
409
+ mixpanel__default["default"].identify(globalProps.user.email);
410
+ } else {
411
+ /*
412
+ We need to initialize mixpanel with a bogus token in development and test environment to
413
+ prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
414
+ */
415
+ mixpanel__default["default"].init("TEST_TOKEN");
416
+ }
417
+ }
418
+
419
+ exports.globalProps = {};
420
+ function initializeApplication(_ref) {
421
+ var translationResources = _ref.translationResources,
422
+ skip = _ref.skip;
423
+
424
+ if (!(skip !== null && skip !== void 0 && skip.globalProps)) {
425
+ initializeGlobalProps();
426
+ exports.globalProps = window.globalProps;
427
+ }
428
+
429
+ if (!(skip !== null && skip !== void 0 && skip.mixpanel)) initializeMixPanel();
430
+
431
+ if (_typeof(skip === null || skip === void 0 ? void 0 : skip.axios) === "object" || !(skip !== null && skip !== void 0 && skip.axios)) {
432
+ initializeAxios(skip === null || skip === void 0 ? void 0 : skip.axios);
433
+ }
434
+
435
+ if (!(skip !== null && skip !== void 0 && skip.i18n)) initializeI18n(translationResources);
436
+ }
437
+
438
+ exports["default"] = initializeApplication;
@@ -0,0 +1,59 @@
1
+ type Skippable<T> = boolean | Partial<T>;
2
+
3
+ type Configurations = {
4
+ translationResources?: { en: { translation: object } };
5
+ skip?: Partial<{
6
+ globalProps: boolean;
7
+ mixpanel: boolean;
8
+ i18n: boolean;
9
+ axios: Skippable<{
10
+ baseURL: boolean;
11
+ authHeaders: boolean;
12
+ interceptors: Skippable<{
13
+ request: Skippable<{
14
+ cleanCredentialsForCrossOrigin: boolean;
15
+ transformCase: boolean;
16
+ }>;
17
+ response: Skippable<{
18
+ transformCase: boolean;
19
+ showToastr: boolean;
20
+ pullDataFromResponse: boolean;
21
+ redirectOn404: boolean;
22
+ logoutOn401: boolean;
23
+ }>;
24
+ }>;
25
+ }>;
26
+ }>;
27
+ };
28
+
29
+ type GlobalPropsType = {
30
+ nodeEnv: string;
31
+ honeybadgerApiKey: string;
32
+ organization: {
33
+ name: string;
34
+ subdomain: string;
35
+ faviconUrl: string;
36
+ [key: string]: any;
37
+ };
38
+ user?: {
39
+ id: string;
40
+ email: string;
41
+ lastName: string;
42
+ firstName: string;
43
+ profileImageUrl: string;
44
+ active: boolean;
45
+ authenticationToken: string;
46
+ [key: string]: any;
47
+ };
48
+ authenticated: boolean;
49
+ neetoApps: string[];
50
+ isOwner: boolean;
51
+ permissions: string[];
52
+ [key: string]: any;
53
+ };
54
+
55
+ export default function initializeApplication(
56
+ configurations: Configurations
57
+ ): void;
58
+
59
+ export const globalProps: GlobalPropsType;