@krainovsd/js-helpers 0.15.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lib/cjs/index.cjs +658 -560
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/esm/{lib/api/middlewares/console-post-middleware.js → api/after/logger-after-handler.js} +5 -5
  4. package/lib/esm/api/after/logger-after-handler.js.map +1 -0
  5. package/lib/esm/api/api.constants.js +23 -0
  6. package/lib/esm/api/api.constants.js.map +1 -0
  7. package/lib/esm/api/api.js +343 -0
  8. package/lib/esm/api/api.js.map +1 -0
  9. package/lib/esm/{lib/api/middlewares/console-middleware.js → api/before/logger-before-handler.js} +4 -4
  10. package/lib/esm/api/before/logger-before-handler.js.map +1 -0
  11. package/lib/esm/{lib/api/middlewares/oauth-middleware.js → api/before/oauth-before-handler.js} +15 -15
  12. package/lib/esm/api/before/oauth-before-handler.js.map +1 -0
  13. package/lib/esm/{lib/api/oauth/token.js → api/oauth.js} +33 -27
  14. package/lib/esm/api/oauth.js.map +1 -0
  15. package/lib/esm/constants/errors.js +16 -0
  16. package/lib/esm/constants/errors.js.map +1 -0
  17. package/lib/esm/constants/index.js +27 -0
  18. package/lib/esm/constants/index.js.map +1 -0
  19. package/lib/esm/index.js +9 -8
  20. package/lib/esm/index.js.map +1 -1
  21. package/lib/esm/lib/colors/get-color-format.js +1 -2
  22. package/lib/esm/lib/colors/get-color-format.js.map +1 -1
  23. package/lib/esm/lib/colors/take-opacity-colors.js +1 -2
  24. package/lib/esm/lib/colors/take-opacity-colors.js.map +1 -1
  25. package/lib/esm/lib/colors/transform-to-color.js +1 -2
  26. package/lib/esm/lib/colors/transform-to-color.js.map +1 -1
  27. package/lib/esm/lib/date/get-date-by-rules.js +1 -2
  28. package/lib/esm/lib/date/get-date-by-rules.js.map +1 -1
  29. package/lib/esm/lib/date/is-yesterday.js +0 -1
  30. package/lib/esm/lib/date/is-yesterday.js.map +1 -1
  31. package/lib/esm/lib/utils/build-query-string.js.map +1 -1
  32. package/lib/esm/lib/utils/{create-url-with-params.js → create-url-with-queries.js} +3 -3
  33. package/lib/esm/lib/utils/create-url-with-queries.js.map +1 -0
  34. package/lib/esm/lib/utils/field-view-format.js +1 -2
  35. package/lib/esm/lib/utils/field-view-format.js.map +1 -1
  36. package/lib/index.d.ts +226 -171
  37. package/package.json +4 -2
  38. package/lib/esm/constants/api.js +0 -10
  39. package/lib/esm/constants/api.js.map +0 -1
  40. package/lib/esm/constants/colors.js +0 -9
  41. package/lib/esm/constants/colors.js.map +0 -1
  42. package/lib/esm/constants/date.js +0 -11
  43. package/lib/esm/constants/date.js.map +0 -1
  44. package/lib/esm/constants/fields.js +0 -11
  45. package/lib/esm/constants/fields.js.map +0 -1
  46. package/lib/esm/lib/api/constants.js +0 -4
  47. package/lib/esm/lib/api/constants.js.map +0 -1
  48. package/lib/esm/lib/api/core.js +0 -187
  49. package/lib/esm/lib/api/core.js.map +0 -1
  50. package/lib/esm/lib/api/middlewares/console-middleware.js.map +0 -1
  51. package/lib/esm/lib/api/middlewares/console-post-middleware.js.map +0 -1
  52. package/lib/esm/lib/api/middlewares/index.js +0 -64
  53. package/lib/esm/lib/api/middlewares/index.js.map +0 -1
  54. package/lib/esm/lib/api/middlewares/oauth-middleware.js.map +0 -1
  55. package/lib/esm/lib/api/oauth/token.js.map +0 -1
  56. package/lib/esm/lib/api/oauth/user.js +0 -35
  57. package/lib/esm/lib/api/oauth/user.js.map +0 -1
  58. package/lib/esm/lib/utils/create-url-with-params.js.map +0 -1
@@ -1,22 +1,18 @@
1
- import '../../../constants/environment.js';
2
- import { waitUntil } from '../../utils/wait-until.js';
1
+ import '../constants/environment.js';
2
+ import { waitUntil } from '../lib/utils/wait-until.js';
3
3
  import 'dayjs';
4
- import '../../date/is-today.js';
5
- import '../../date/is-tomorrow.js';
6
- import '../../date/is-yesterday.js';
7
- import { isArray } from '../../typings/is-array.js';
8
- import { isString } from '../../typings/is-string.js';
4
+ import '../lib/date/is-today.js';
5
+ import '../lib/date/is-tomorrow.js';
6
+ import '../lib/date/is-yesterday.js';
7
+ import { isArray } from '../lib/typings/is-array.js';
8
+ import { isString } from '../lib/typings/is-string.js';
9
9
  import 'lodash/get';
10
10
  import 'lodash/set';
11
- import { getQueryValues } from '../../browser/get-query-values.js';
11
+ import { getQueryValues } from '../lib/browser/get-query-values.js';
12
+ import { OAUTH_STATE } from './api.constants.js';
12
13
 
13
- let waiting = false;
14
14
  async function getOauthTokenFromOtherWindow(options) {
15
- await waitUntil(() => waiting);
16
- const expires = localStorage.getItem(options.expiresTokenStorageName);
17
- if (expires != undefined && !Number.isNaN(+expires) && Date.now() < +expires)
18
- return;
19
- waiting = true;
15
+ let waiting = true;
20
16
  const url = new URL(typeof options.refreshTokenWindowUrl === "function"
21
17
  ? options.refreshTokenWindowUrl()
22
18
  : (options.refreshTokenWindowUrl ?? window.origin));
@@ -60,10 +56,26 @@ async function getOauthTokenFromOtherWindow(options) {
60
56
  }
61
57
  await waitUntil(() => waiting);
62
58
  }
59
+ async function refetchAfterOauth(options, refetch) {
60
+ OAUTH_STATE.fetching = true;
61
+ await getOauthTokenFromOtherWindow({
62
+ onlyRefreshTokenWindowQueryName: options.onlyRefreshTokenWindowQueryName,
63
+ onWindowOpenError: options.onWindowOpenError,
64
+ refreshTokenWindowUrl: options.refreshTokenWindowUrl,
65
+ wait: options.wait,
66
+ expiresTokenStorageName: options.expiresTokenStorageName,
67
+ closeObserveInterval: options.closeObserveInterval,
68
+ });
69
+ if (options.tokenRequest) {
70
+ const token = await options.tokenRequest();
71
+ if (token != undefined && options.tokenStorageName) {
72
+ localStorage.setItem(options.tokenStorageName, token);
73
+ }
74
+ }
75
+ OAUTH_STATE.fetching = false;
76
+ return await refetch();
77
+ }
63
78
  function getOauthToken(options) {
64
- let expires = localStorage.getItem(options.expiresTokenStorageName);
65
- if (!expires || Number.isNaN(+expires) || Date.now() > +expires)
66
- expires = null;
67
79
  const queries = getQueryValues([
68
80
  options.expiresTokenQueryName,
69
81
  options.onlyRefreshTokenWindowQueryName,
@@ -77,17 +89,11 @@ function getOauthToken(options) {
77
89
  ? refreshQuery[refreshQuery.length - 1] === "true"
78
90
  : false;
79
91
  /** Expires token */
80
- const expiresFromQuery = isString(expiresQuery)
92
+ const expires = isString(expiresQuery)
81
93
  ? expiresQuery
82
94
  : isArray(expiresQuery)
83
95
  ? expiresQuery[expiresQuery.length - 1]
84
96
  : false;
85
- /** Extract expires from query */
86
- if (!expires && expiresFromQuery) {
87
- expires = expiresFromQuery;
88
- if (!expires || Number.isNaN(+expires) || Date.now() > +expires)
89
- expires = null;
90
- }
91
97
  /** OAuth flow if not expires */
92
98
  if (!expires) {
93
99
  window.location.replace(typeof options.oauthUrl === "function" ? options.oauthUrl() : options.oauthUrl);
@@ -102,7 +108,7 @@ function getOauthToken(options) {
102
108
  window.close();
103
109
  }
104
110
  /** Delete expires query */
105
- if (expiresFromQuery) {
111
+ if (expires) {
106
112
  const url = new URL(window.location.href);
107
113
  url.searchParams.delete(options.expiresTokenQueryName);
108
114
  window.location.replace(url.toString());
@@ -111,5 +117,5 @@ function getOauthToken(options) {
111
117
  return expires;
112
118
  }
113
119
 
114
- export { getOauthToken, getOauthTokenFromOtherWindow };
115
- //# sourceMappingURL=token.js.map
120
+ export { getOauthToken, getOauthTokenFromOtherWindow, refetchAfterOauth };
121
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sources":["../../../src/api/oauth.ts"],"sourcesContent":["import { getQueryValues, isArray, isString, waitUntil } from \"../lib\";\nimport { OAUTH_STATE } from \"./api.constants\";\nimport type {\n GetOauthTokenFromOtherWindowOptions,\n GetOauthTokenOptions,\n OauthOptions,\n} from \"./api.types\";\n\nexport async function getOauthTokenFromOtherWindow(options: GetOauthTokenFromOtherWindowOptions) {\n let waiting = true;\n const url = new URL(\n typeof options.refreshTokenWindowUrl === \"function\"\n ? options.refreshTokenWindowUrl()\n : (options.refreshTokenWindowUrl ?? window.origin),\n );\n url.searchParams.append(options.onlyRefreshTokenWindowQueryName, \"true\");\n\n let windowInstance = window.open(\n url.toString(),\n \"_blank\",\n \"width=800,height=600,left=100,top=100\",\n );\n windowInstance ??= window.open(url.toString(), \"_blank\");\n\n if (windowInstance) {\n const channel = new BroadcastChannel(options.onlyRefreshTokenWindowQueryName);\n const windowCloseObserver = setInterval(() => {\n if (windowInstance.closed) {\n if (waiting) {\n waiting = false;\n channel.close();\n clearInterval(windowCloseObserver);\n }\n }\n }, options.closeObserveInterval ?? 500);\n channel.onmessage = () => {\n if (waiting) {\n waiting = false;\n channel.close();\n clearInterval(windowCloseObserver);\n }\n };\n setTimeout(() => {\n if (waiting) {\n waiting = false;\n channel.close();\n clearInterval(windowCloseObserver);\n }\n if (windowInstance && !windowInstance.closed) {\n windowInstance.close();\n }\n }, options.wait ?? 15000);\n } else {\n if (options.onWindowOpenError) options.onWindowOpenError();\n waiting = false;\n\n return;\n }\n\n await waitUntil(() => waiting);\n}\n\nexport async function refetchAfterOauth<T>(options: OauthOptions, refetch: () => Promise<T>) {\n OAUTH_STATE.fetching = true;\n await getOauthTokenFromOtherWindow({\n onlyRefreshTokenWindowQueryName: options.onlyRefreshTokenWindowQueryName,\n onWindowOpenError: options.onWindowOpenError,\n refreshTokenWindowUrl: options.refreshTokenWindowUrl,\n wait: options.wait,\n expiresTokenStorageName: options.expiresTokenStorageName,\n closeObserveInterval: options.closeObserveInterval,\n });\n if (options.tokenRequest) {\n const token = await options.tokenRequest();\n if (token != undefined && options.tokenStorageName) {\n localStorage.setItem(options.tokenStorageName, token);\n }\n }\n OAUTH_STATE.fetching = false;\n\n return await refetch();\n}\n\nexport function getOauthToken(options: GetOauthTokenOptions) {\n const queries = getQueryValues([\n options.expiresTokenQueryName,\n options.onlyRefreshTokenWindowQueryName,\n ]);\n const refreshQuery = queries?.[options.onlyRefreshTokenWindowQueryName];\n const expiresQuery = queries?.[options.expiresTokenQueryName];\n\n /** Is OnlyRefresh window */\n const isRefresh = isString(refreshQuery)\n ? refreshQuery === \"true\"\n : isArray(refreshQuery)\n ? refreshQuery[refreshQuery.length - 1] === \"true\"\n : false;\n /** Expires token */\n const expires = isString(expiresQuery)\n ? expiresQuery\n : isArray(expiresQuery)\n ? expiresQuery[expiresQuery.length - 1]\n : false;\n\n /** OAuth flow if not expires */\n if (!expires) {\n window.location.replace(\n typeof options.oauthUrl === \"function\" ? options.oauthUrl() : options.oauthUrl,\n );\n\n return null;\n }\n\n localStorage.setItem(options.expiresTokenStorageName, expires);\n\n /** Close if OnlyRefresh window */\n if (isRefresh) {\n const channel = new BroadcastChannel(options.onlyRefreshTokenWindowQueryName);\n channel.postMessage(true);\n channel.close();\n window.close();\n }\n\n /** Delete expires query */\n if (expires) {\n const url = new URL(window.location.href);\n url.searchParams.delete(options.expiresTokenQueryName);\n window.location.replace(url.toString());\n\n return null;\n }\n\n return expires;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAQO,eAAe,4BAA4B,CAAC,OAA4C,EAAA;IAC7F,IAAI,OAAO,GAAG,IAAI;IAClB,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,OAAO,OAAO,CAAC,qBAAqB,KAAK;AACvC,UAAE,OAAO,CAAC,qBAAqB;WAC5B,OAAO,CAAC,qBAAqB,IAAI,MAAM,CAAC,MAAM,CAAC,CACrD;IACD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,+BAA+B,EAAE,MAAM,CAAC;AAExE,IAAA,IAAI,cAAc,GAAG,MAAM,CAAC,IAAI,CAC9B,GAAG,CAAC,QAAQ,EAAE,EACd,QAAQ,EACR,uCAAuC,CACxC;AACD,IAAA,cAAc,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC;IAExD,IAAI,cAAc,EAAE;QAClB,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,+BA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CAAC;;IAG9D,IAAI,SAAS,EAAE;QACb,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,+BAA+B,CAAC;AAC7E,QAAA,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;QACzB,OAAO,CAAC,KAAK,EAAE;QACf,MAAM,CAAC,KAAK,EAAE;;;IAIhB,IAAI,OAAO,EAAE;QACX,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACzC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACtD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAEvC,QAAA,OAAO,IAAI;;AAGb,IAAA,OAAO,OAAO;AAChB;;;;"}
@@ -0,0 +1,16 @@
1
+ class ResponseError extends Error {
2
+ status;
3
+ code;
4
+ description;
5
+ headers;
6
+ constructor({ message, status, description, code, headers }) {
7
+ super(message);
8
+ this.status = status;
9
+ this.description = description;
10
+ this.code = code;
11
+ this.headers = headers;
12
+ }
13
+ }
14
+
15
+ export { ResponseError };
16
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["../../../src/constants/errors.ts"],"sourcesContent":["import type { RequestHeader } from \"../api\";\n\ntype ResponseErrorOptions = {\n message: string;\n status: number;\n code?: number;\n description?: unknown;\n headers?: RequestHeader;\n};\n\nexport class ResponseError extends Error {\n status: number;\n code?: number;\n description?: unknown;\n headers?: RequestHeader;\n\n constructor({ message, status, description, code, headers }: ResponseErrorOptions) {\n super(message);\n this.status = status;\n this.description = description;\n this.code = code;\n this.headers = headers;\n }\n}\n"],"names":[],"mappings":"AAUM,MAAO,aAAc,SAAQ,KAAK,CAAA;AACtC,IAAA,MAAM;AACN,IAAA,IAAI;AACJ,IAAA,WAAW;AACX,IAAA,OAAO;IAEP,WAAY,CAAA,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAwB,EAAA;QAC/E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW;AAC9B,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;;AAEzB;;;;"}
@@ -0,0 +1,27 @@
1
+ export { IS_BROWSER, IS_BUN, IS_DENO, IS_JEST, IS_NODE, IS_WEB_WORKER } from './environment.js';
2
+
3
+ const COLOR_FORMATS = {
4
+ Hex: "HEX",
5
+ Rgb: "RGB",
6
+ Rgba: "RGBA",
7
+ Hsl: "HSL",
8
+ };
9
+ const DATE_TYPES = {
10
+ Days: "days",
11
+ Months: "months",
12
+ Years: "years",
13
+ Seconds: "seconds",
14
+ Minutes: "minutes",
15
+ Hours: "hours",
16
+ };
17
+ const FIELD_TYPES = {
18
+ Date: "date",
19
+ Time: "time",
20
+ DateTime: "dateTime",
21
+ String: "string",
22
+ Number: "number",
23
+ Array: "array",
24
+ };
25
+
26
+ export { COLOR_FORMATS, DATE_TYPES, FIELD_TYPES };
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/constants/index.ts"],"sourcesContent":["export * from \"./errors\";\nexport * from \"./environment\";\n\nexport const COLOR_FORMATS = {\n Hex: \"HEX\",\n Rgb: \"RGB\",\n Rgba: \"RGBA\",\n Hsl: \"HSL\",\n} as const;\n\nexport const DATE_TYPES = {\n Days: \"days\",\n Months: \"months\",\n Years: \"years\",\n Seconds: \"seconds\",\n Minutes: \"minutes\",\n Hours: \"hours\",\n} as const;\n\nexport const FIELD_TYPES = {\n Date: \"date\",\n Time: \"time\",\n DateTime: \"dateTime\",\n String: \"string\",\n Number: \"number\",\n Array: \"array\",\n} as const;\n"],"names":[],"mappings":";;AAGa,MAAA,aAAa,GAAG;AAC3B,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,GAAG,EAAE,KAAK;;AAGC,MAAA,UAAU,GAAG;AACxB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,KAAK,EAAE,OAAO;;AAGH,MAAA,WAAW,GAAG;AACzB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;;;;;"}
package/lib/esm/index.js CHANGED
@@ -1,6 +1,3 @@
1
- export { ResponseError, createRequestClientInstance } from './lib/api/core.js';
2
- export { getOauthToken, getOauthTokenFromOtherWindow } from './lib/api/oauth/token.js';
3
- export { getAuthUser, updateAuthUser } from './lib/api/oauth/user.js';
4
1
  export { downloadFile } from './lib/browser/download-file.js';
5
2
  export { downloadJson } from './lib/browser/download-json.js';
6
3
  export { readFile } from './lib/browser/read-file.js';
@@ -32,7 +29,7 @@ export { jsonParse } from './lib/utils/json-parse.js';
32
29
  export { randomString } from './lib/utils/random-string.js';
33
30
  export { wait } from './lib/utils/wait.js';
34
31
  export { transformToNumber } from './lib/utils/transform-to-number.js';
35
- export { createURLWithParams } from './lib/utils/create-url-with-params.js';
32
+ export { createURLWithQueries } from './lib/utils/create-url-with-queries.js';
36
33
  export { trimUrl } from './lib/utils/trim-url.js';
37
34
  export { arrayToMapByKey } from './lib/utils/array-to-map-by-key.js';
38
35
  export { buildQueryString } from './lib/utils/build-query-string.js';
@@ -70,9 +67,13 @@ export { differenceWith } from './lib/lodash/difference-with.js';
70
67
  export { isEqual } from './lib/lodash/is-equal.js';
71
68
  export { throttle } from './lib/lodash/throttle.js';
72
69
  export { type } from './lib/lodash/type.js';
73
- export { DATE_TYPES } from './constants/date.js';
74
- export { API_MIDDLEWARES, POST_API_MIDDLEWARES } from './constants/api.js';
70
+ export { COLOR_FORMATS, DATE_TYPES, FIELD_TYPES } from './constants/index.js';
71
+ export { createFetchClient } from './api/api.js';
72
+ export { getOauthToken, getOauthTokenFromOtherWindow, refetchAfterOauth } from './api/oauth.js';
73
+ export { loggerAfterHandler } from './api/after/logger-after-handler.js';
74
+ export { loggerBeforeHandler } from './api/before/logger-before-handler.js';
75
+ export { oauthBeforeHandler } from './api/before/oauth-before-handler.js';
76
+ export { OAUTH_STATE, REQUEST_ERROR, RESPONSE_DATA_SYMBOL } from './api/api.constants.js';
77
+ export { ResponseError } from './constants/errors.js';
75
78
  export { IS_BROWSER, IS_BUN, IS_DENO, IS_JEST, IS_NODE, IS_WEB_WORKER } from './constants/environment.js';
76
- export { COLOR_FORMATS } from './constants/colors.js';
77
- export { FIELD_TYPES } from './constants/fields.js';
78
79
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,4 @@
1
- import '../../constants/environment.js';
2
- import { COLOR_FORMATS } from '../../constants/colors.js';
1
+ import { COLOR_FORMATS } from '../../constants/index.js';
3
2
 
4
3
  function getColorFormat(color) {
5
4
  if (color.startsWith("#")) {
@@ -1 +1 @@
1
- {"version":3,"file":"get-color-format.js","sources":["../../../../src/lib/colors/get-color-format.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\n\nexport function getColorFormat(color: string) {\n if (color.startsWith(\"#\")) {\n return COLOR_FORMATS.Hex;\n }\n if (color.startsWith(\"rgba\")) {\n return COLOR_FORMATS.Rgba;\n }\n if (color.startsWith(\"rgb\")) {\n return COLOR_FORMATS.Rgb;\n }\n if (color.startsWith(\"hsl\")) {\n return COLOR_FORMATS.Hsl;\n }\n}\n"],"names":[],"mappings":";;;AAEM,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACzB,OAAO,aAAa,CAAC,GAAG;;AAE1B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,aAAa,CAAC,IAAI;;AAE3B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QAC3B,OAAO,aAAa,CAAC,GAAG;;AAE1B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QAC3B,OAAO,aAAa,CAAC,GAAG;;AAE5B;;;;"}
1
+ {"version":3,"file":"get-color-format.js","sources":["../../../../src/lib/colors/get-color-format.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\n\nexport function getColorFormat(color: string) {\n if (color.startsWith(\"#\")) {\n return COLOR_FORMATS.Hex;\n }\n if (color.startsWith(\"rgba\")) {\n return COLOR_FORMATS.Rgba;\n }\n if (color.startsWith(\"rgb\")) {\n return COLOR_FORMATS.Rgb;\n }\n if (color.startsWith(\"hsl\")) {\n return COLOR_FORMATS.Hsl;\n }\n}\n"],"names":[],"mappings":";;AAEM,SAAU,cAAc,CAAC,KAAa,EAAA;AAC1C,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACzB,OAAO,aAAa,CAAC,GAAG;;AAE1B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,aAAa,CAAC,IAAI;;AAE3B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QAC3B,OAAO,aAAa,CAAC,GAAG;;AAE1B,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QAC3B,OAAO,aAAa,CAAC,GAAG;;AAE5B;;;;"}
@@ -1,5 +1,4 @@
1
- import '../../constants/environment.js';
2
- import { COLOR_FORMATS } from '../../constants/colors.js';
1
+ import { COLOR_FORMATS } from '../../constants/index.js';
3
2
  import { getColorFormat } from './get-color-format.js';
4
3
  import { transformHEXtoRGB } from './transform-hex-to-rgb.js';
5
4
  import { transformRGBtoRGBA } from './transform-rgb-to-rgba.js';
@@ -1 +1 @@
1
- {"version":3,"file":"take-opacity-colors.js","sources":["../../../../src/lib/colors/take-opacity-colors.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\nimport { getColorFormat } from \"./get-color-format\";\nimport { transformHEXtoRGB } from \"./transform-hex-to-rgb\";\nimport { transformRGBtoRGBA } from \"./transform-rgb-to-rgba\";\nimport { transformRGBAtoRGB } from \"./transform-rgba-to-rgb\";\n\nexport function takeOpacityColors(color: string | undefined, opacities: number[]) {\n let rgbColor = color;\n\n if (!rgbColor) return [];\n\n if (getColorFormat(rgbColor) === COLOR_FORMATS.Hex) {\n rgbColor = transformHEXtoRGB(rgbColor);\n } else if (getColorFormat(rgbColor) === COLOR_FORMATS.Rgba) {\n rgbColor = transformRGBAtoRGB(rgbColor);\n }\n\n if (getColorFormat(rgbColor) !== COLOR_FORMATS.Rgb) return [];\n\n return [...opacities.map((opacity) => transformRGBtoRGBA(rgbColor, opacity))];\n}\n"],"names":[],"mappings":";;;;;;;AAMgB,SAAA,iBAAiB,CAAC,KAAyB,EAAE,SAAmB,EAAA;IAC9E,IAAI,QAAQ,GAAG,KAAK;AAEpB,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,EAAE;IAExB,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,GAAG,EAAE;AAClD,QAAA,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC;;SACjC,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,IAAI,EAAE;AAC1D,QAAA,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC;;AAGzC,IAAA,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;AAE7D,IAAA,OAAO,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E;;;;"}
1
+ {"version":3,"file":"take-opacity-colors.js","sources":["../../../../src/lib/colors/take-opacity-colors.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\nimport { getColorFormat } from \"./get-color-format\";\nimport { transformHEXtoRGB } from \"./transform-hex-to-rgb\";\nimport { transformRGBtoRGBA } from \"./transform-rgb-to-rgba\";\nimport { transformRGBAtoRGB } from \"./transform-rgba-to-rgb\";\n\nexport function takeOpacityColors(color: string | undefined, opacities: number[]) {\n let rgbColor = color;\n\n if (!rgbColor) return [];\n\n if (getColorFormat(rgbColor) === COLOR_FORMATS.Hex) {\n rgbColor = transformHEXtoRGB(rgbColor);\n } else if (getColorFormat(rgbColor) === COLOR_FORMATS.Rgba) {\n rgbColor = transformRGBAtoRGB(rgbColor);\n }\n\n if (getColorFormat(rgbColor) !== COLOR_FORMATS.Rgb) return [];\n\n return [...opacities.map((opacity) => transformRGBtoRGBA(rgbColor, opacity))];\n}\n"],"names":[],"mappings":";;;;;;AAMgB,SAAA,iBAAiB,CAAC,KAAyB,EAAE,SAAmB,EAAA;IAC9E,IAAI,QAAQ,GAAG,KAAK;AAEpB,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,EAAE;IAExB,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,GAAG,EAAE;AAClD,QAAA,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC;;SACjC,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,IAAI,EAAE;AAC1D,QAAA,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC;;AAGzC,IAAA,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;AAE7D,IAAA,OAAO,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E;;;;"}
@@ -1,5 +1,4 @@
1
- import '../../constants/environment.js';
2
- import { COLOR_FORMATS } from '../../constants/colors.js';
1
+ import { COLOR_FORMATS } from '../../constants/index.js';
3
2
  import { isString } from '../typings/is-string.js';
4
3
  import { getColorFormat } from './get-color-format.js';
5
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"transform-to-color.js","sources":["../../../../src/lib/colors/transform-to-color.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\nimport type { ColorFormat } from \"../../types\";\nimport { isString } from \"../typings\";\nimport { getColorFormat } from \"./get-color-format\";\n\nexport function transformToColor(\n currentColor: unknown,\n defaultColor: string = \"black\",\n defaultFormat: ColorFormat = COLOR_FORMATS.Hex,\n) {\n if (!isString(currentColor)) return defaultColor;\n\n let correctColor = currentColor;\n\n if (!getColorFormat(correctColor)) {\n switch (defaultFormat) {\n case COLOR_FORMATS.Hex: {\n correctColor = `#${correctColor}`;\n break;\n }\n case COLOR_FORMATS.Rgb: {\n correctColor = `rgb(${correctColor})`;\n break;\n }\n case COLOR_FORMATS.Rgba: {\n correctColor = `rgba(${correctColor})`;\n break;\n }\n case COLOR_FORMATS.Hsl: {\n correctColor = `hsl(${correctColor})`;\n break;\n }\n default: {\n correctColor = `#${correctColor}`;\n break;\n }\n }\n }\n\n return correctColor;\n}\n"],"names":[],"mappings":";;;;;AAKM,SAAU,gBAAgB,CAC9B,YAAqB,EACrB,YAAuB,GAAA,OAAO,EAC9B,aAAA,GAA6B,aAAa,CAAC,GAAG,EAAA;AAE9C,IAAA,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;AAAE,QAAA,OAAO,YAAY;IAEhD,IAAI,YAAY,GAAG,YAAY;AAE/B,IAAA,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;QACjC,QAAQ,aAAa;AACnB,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;gBACjC;;AAEF,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,IAAA,EAAO,YAAY,CAAA,CAAA,CAAG;gBACrC;;AAEF,YAAA,KAAK,aAAa,CAAC,IAAI,EAAE;AACvB,gBAAA,YAAY,GAAG,CAAA,KAAA,EAAQ,YAAY,CAAA,CAAA,CAAG;gBACtC;;AAEF,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,IAAA,EAAO,YAAY,CAAA,CAAA,CAAG;gBACrC;;YAEF,SAAS;AACP,gBAAA,YAAY,GAAG,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;gBACjC;;;;AAKN,IAAA,OAAO,YAAY;AACrB;;;;"}
1
+ {"version":3,"file":"transform-to-color.js","sources":["../../../../src/lib/colors/transform-to-color.ts"],"sourcesContent":["import { COLOR_FORMATS } from \"../../constants\";\nimport type { ColorFormat } from \"../../types\";\nimport { isString } from \"../typings\";\nimport { getColorFormat } from \"./get-color-format\";\n\nexport function transformToColor(\n currentColor: unknown,\n defaultColor: string = \"black\",\n defaultFormat: ColorFormat = COLOR_FORMATS.Hex,\n) {\n if (!isString(currentColor)) return defaultColor;\n\n let correctColor = currentColor;\n\n if (!getColorFormat(correctColor)) {\n switch (defaultFormat) {\n case COLOR_FORMATS.Hex: {\n correctColor = `#${correctColor}`;\n break;\n }\n case COLOR_FORMATS.Rgb: {\n correctColor = `rgb(${correctColor})`;\n break;\n }\n case COLOR_FORMATS.Rgba: {\n correctColor = `rgba(${correctColor})`;\n break;\n }\n case COLOR_FORMATS.Hsl: {\n correctColor = `hsl(${correctColor})`;\n break;\n }\n default: {\n correctColor = `#${correctColor}`;\n break;\n }\n }\n }\n\n return correctColor;\n}\n"],"names":[],"mappings":";;;;AAKM,SAAU,gBAAgB,CAC9B,YAAqB,EACrB,YAAuB,GAAA,OAAO,EAC9B,aAAA,GAA6B,aAAa,CAAC,GAAG,EAAA;AAE9C,IAAA,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;AAAE,QAAA,OAAO,YAAY;IAEhD,IAAI,YAAY,GAAG,YAAY;AAE/B,IAAA,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;QACjC,QAAQ,aAAa;AACnB,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;gBACjC;;AAEF,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,IAAA,EAAO,YAAY,CAAA,CAAA,CAAG;gBACrC;;AAEF,YAAA,KAAK,aAAa,CAAC,IAAI,EAAE;AACvB,gBAAA,YAAY,GAAG,CAAA,KAAA,EAAQ,YAAY,CAAA,CAAA,CAAG;gBACtC;;AAEF,YAAA,KAAK,aAAa,CAAC,GAAG,EAAE;AACtB,gBAAA,YAAY,GAAG,CAAA,IAAA,EAAO,YAAY,CAAA,CAAA,CAAG;gBACrC;;YAEF,SAAS;AACP,gBAAA,YAAY,GAAG,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;gBACjC;;;;AAKN,IAAA,OAAO,YAAY;AACrB;;;;"}
@@ -1,5 +1,4 @@
1
- import { DATE_TYPES } from '../../constants/date.js';
2
- import '../../constants/environment.js';
1
+ import { DATE_TYPES } from '../../constants/index.js';
3
2
 
4
3
  function getDateByRules(rules, date = new Date()) {
5
4
  let result = new Date(date);
@@ -1 +1 @@
1
- {"version":3,"file":"get-date-by-rules.js","sources":["../../../../src/lib/date/get-date-by-rules.ts"],"sourcesContent":["import { DATE_TYPES } from \"../../constants\";\nimport { type DateGetterRule, type DateType } from \"../../types\";\n\nexport function getDateByRules(rules: DateGetterRule[], date: Date = new Date()) {\n let result = new Date(date);\n for (const rule of rules) {\n result = getDate(rule.increment, rule.type, result);\n }\n\n return result;\n}\n\nfunction getDate(increment: number, type: DateType, date: Date = new Date()) {\n const result = new Date(date);\n switch (type) {\n case DATE_TYPES.Days: {\n result.setDate(result.getDate() + increment);\n\n return result;\n }\n case DATE_TYPES.Months: {\n result.setMonth(result.getMonth() + increment);\n\n return result;\n }\n case DATE_TYPES.Years: {\n result.setFullYear(result.getFullYear() + increment);\n\n return result;\n }\n case DATE_TYPES.Seconds: {\n result.setSeconds(result.getSeconds() + increment);\n\n return result;\n }\n case DATE_TYPES.Minutes: {\n result.setMinutes(result.getMinutes() + increment);\n\n return result;\n }\n case DATE_TYPES.Hours: {\n result.setHours(result.getHours() + increment);\n\n return result;\n }\n default:\n return result;\n }\n}\n"],"names":[],"mappings":";;;AAGM,SAAU,cAAc,CAAC,KAAuB,EAAE,IAAa,GAAA,IAAI,IAAI,EAAE,EAAA;AAC7E,IAAA,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;AAC3B,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;;AAGrD,IAAA,OAAO,MAAM;AACf;AAEA,SAAS,OAAO,CAAC,SAAiB,EAAE,IAAc,EAAE,IAAA,GAAa,IAAI,IAAI,EAAE,EAAA;AACzE,IAAA,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IAC7B,QAAQ,IAAI;AACV,QAAA,KAAK,UAAU,CAAC,IAAI,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;AAE5C,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,MAAM,EAAE;YACtB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC;AAE9C,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,KAAK,EAAE;YACrB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC;AAEpD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,OAAO,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC;AAElD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,OAAO,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC;AAElD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,KAAK,EAAE;YACrB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC;AAE9C,YAAA,OAAO,MAAM;;AAEf,QAAA;AACE,YAAA,OAAO,MAAM;;AAEnB;;;;"}
1
+ {"version":3,"file":"get-date-by-rules.js","sources":["../../../../src/lib/date/get-date-by-rules.ts"],"sourcesContent":["import { DATE_TYPES } from \"../../constants\";\nimport { type DateGetterRule, type DateType } from \"../../types\";\n\nexport function getDateByRules(rules: DateGetterRule[], date: Date = new Date()) {\n let result = new Date(date);\n for (const rule of rules) {\n result = getDate(rule.increment, rule.type, result);\n }\n\n return result;\n}\n\nfunction getDate(increment: number, type: DateType, date: Date = new Date()) {\n const result = new Date(date);\n switch (type) {\n case DATE_TYPES.Days: {\n result.setDate(result.getDate() + increment);\n\n return result;\n }\n case DATE_TYPES.Months: {\n result.setMonth(result.getMonth() + increment);\n\n return result;\n }\n case DATE_TYPES.Years: {\n result.setFullYear(result.getFullYear() + increment);\n\n return result;\n }\n case DATE_TYPES.Seconds: {\n result.setSeconds(result.getSeconds() + increment);\n\n return result;\n }\n case DATE_TYPES.Minutes: {\n result.setMinutes(result.getMinutes() + increment);\n\n return result;\n }\n case DATE_TYPES.Hours: {\n result.setHours(result.getHours() + increment);\n\n return result;\n }\n default:\n return result;\n }\n}\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAAC,KAAuB,EAAE,IAAa,GAAA,IAAI,IAAI,EAAE,EAAA;AAC7E,IAAA,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;AAC3B,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;;AAGrD,IAAA,OAAO,MAAM;AACf;AAEA,SAAS,OAAO,CAAC,SAAiB,EAAE,IAAc,EAAE,IAAA,GAAa,IAAI,IAAI,EAAE,EAAA;AACzE,IAAA,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;IAC7B,QAAQ,IAAI;AACV,QAAA,KAAK,UAAU,CAAC,IAAI,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;AAE5C,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,MAAM,EAAE;YACtB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC;AAE9C,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,KAAK,EAAE;YACrB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC;AAEpD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,OAAO,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC;AAElD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,OAAO,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC;AAElD,YAAA,OAAO,MAAM;;AAEf,QAAA,KAAK,UAAU,CAAC,KAAK,EAAE;YACrB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC;AAE9C,YAAA,OAAO,MAAM;;AAEf,QAAA;AACE,YAAA,OAAO,MAAM;;AAEnB;;;;"}
@@ -1,6 +1,5 @@
1
1
  import dayjs from 'dayjs';
2
2
  import yesterdayPlugin from 'dayjs/plugin/isYesterday';
3
- import '../../constants/environment.js';
4
3
 
5
4
  dayjs.extend(yesterdayPlugin);
6
5
  function isYesterday(date) {
@@ -1 +1 @@
1
- {"version":3,"file":"is-yesterday.js","sources":["../../../../src/lib/date/is-yesterday.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport yesterdayPlugin from \"dayjs/plugin/isYesterday\";\nimport { type Maybe } from \"../../types\";\n\ndayjs.extend(yesterdayPlugin);\n\nexport function isYesterday(date: Maybe<string | Date | number>) {\n try {\n return dayjs(date).isYesterday();\n } catch {\n return false;\n }\n}\n"],"names":[],"mappings":";;;;AAIA,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC;AAEvB,SAAU,WAAW,CAAC,IAAmC,EAAA;AAC7D,IAAA,IAAI;AACF,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;;AAChC,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;;AAEhB;;;;"}
1
+ {"version":3,"file":"is-yesterday.js","sources":["../../../../src/lib/date/is-yesterday.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport yesterdayPlugin from \"dayjs/plugin/isYesterday\";\nimport { type Maybe } from \"../../types\";\n\ndayjs.extend(yesterdayPlugin);\n\nexport function isYesterday(date: Maybe<string | Date | number>) {\n try {\n return dayjs(date).isYesterday();\n } catch {\n return false;\n }\n}\n"],"names":[],"mappings":";;;AAIA,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC;AAEvB,SAAU,WAAW,CAAC,IAAmC,EAAA;AAC7D,IAAA,IAAI;AACF,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;;AAChC,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;;AAEhB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"build-query-string.js","sources":["../../../../src/lib/utils/build-query-string.ts"],"sourcesContent":["import type { ParamsType } from \"../../types\";\nimport { isArray, isObject } from \"../typings\";\n\nexport function buildQueryString(params: ParamsType): string {\n const queryString: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n if (isObject(value) || value == undefined) continue;\n\n if (isArray(value)) {\n for (const item of value) {\n if (item != undefined && !isObject(item))\n queryString.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);\n }\n } else {\n queryString.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);\n }\n }\n\n return queryString.join(\"&\");\n}\n"],"names":[],"mappings":";;;AAGM,SAAU,gBAAgB,CAAC,MAAkB,EAAA;IACjD,MAAM,WAAW,GAAa,EAAE;AAEhC,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,SAAS;YAAE;AAE3C,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;AAClB,YAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,IAAI,IAAI,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;AACtC,oBAAA,WAAW,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA,CAAE,CAAC;;;aAEjF;AACL,YAAA,WAAW,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA,CAAE,CAAC;;;AAIvF,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"build-query-string.js","sources":["../../../../src/lib/utils/build-query-string.ts"],"sourcesContent":["import type { RequestQuery } from \"../../api\";\nimport { isArray, isObject } from \"../typings\";\n\nexport function buildQueryString(params: RequestQuery): string {\n const queryString: string[] = [];\n\n for (const [key, value] of Object.entries(params)) {\n if (isObject(value) || value == undefined) continue;\n\n if (isArray(value)) {\n for (const item of value) {\n if (item != undefined && !isObject(item))\n queryString.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);\n }\n } else {\n queryString.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);\n }\n }\n\n return queryString.join(\"&\");\n}\n"],"names":[],"mappings":";;;AAGM,SAAU,gBAAgB,CAAC,MAAoB,EAAA;IACnD,MAAM,WAAW,GAAa,EAAE;AAEhC,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,SAAS;YAAE;AAE3C,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;AAClB,YAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,IAAI,IAAI,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;AACtC,oBAAA,WAAW,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA,CAAE,CAAC;;;aAEjF;AACL,YAAA,WAAW,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA,CAAE,CAAC;;;AAIvF,IAAA,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { buildQueryString } from './build-query-string.js';
2
2
 
3
- function createURLWithParams(options) {
3
+ function createURLWithQueries(options) {
4
4
  const url = options.baseURL;
5
5
  if (!options.params) {
6
6
  return url;
@@ -9,5 +9,5 @@ function createURLWithParams(options) {
9
9
  return `${url}?${queryString}`;
10
10
  }
11
11
 
12
- export { createURLWithParams };
13
- //# sourceMappingURL=create-url-with-params.js.map
12
+ export { createURLWithQueries };
13
+ //# sourceMappingURL=create-url-with-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-url-with-queries.js","sources":["../../../../src/lib/utils/create-url-with-queries.ts"],"sourcesContent":["import type { RequestQuery } from \"../../api\";\nimport { buildQueryString } from \"./build-query-string\";\n\ntype CreateURLOptionsInterface = {\n baseURL: string;\n params?: RequestQuery;\n};\n\nexport function createURLWithQueries(options: CreateURLOptionsInterface): string {\n const url = options.baseURL;\n\n if (!options.params) {\n return url;\n }\n\n const queryString = buildQueryString(options.params);\n\n return `${url}?${queryString}`;\n}\n"],"names":[],"mappings":";;AAQM,SAAU,oBAAoB,CAAC,OAAkC,EAAA;AACrE,IAAA,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO;AAE3B,IAAA,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AACnB,QAAA,OAAO,GAAG;;IAGZ,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;AAEpD,IAAA,OAAO,CAAG,EAAA,GAAG,CAAI,CAAA,EAAA,WAAW,EAAE;AAChC;;;;"}
@@ -1,5 +1,4 @@
1
- import '../../constants/environment.js';
2
- import { FIELD_TYPES } from '../../constants/fields.js';
1
+ import { FIELD_TYPES } from '../../constants/index.js';
3
2
  import 'dayjs';
4
3
  import '../date/is-today.js';
5
4
  import '../date/is-tomorrow.js';
@@ -1 +1 @@
1
- {"version":3,"file":"field-view-format.js","sources":["../../../../src/lib/utils/field-view-format.ts"],"sourcesContent":["import { FIELD_TYPES } from \"../../constants\";\nimport type { FieldType } from \"../../types\";\nimport { dateFormat } from \"../date\";\nimport { isArray, isBoolean, isDate, isNumber, isString } from \"../typings\";\nimport { transformToNumber } from \"./transform-to-number\";\n\nexport function fieldViewFormat(field: unknown, type: FieldType = \"string\") {\n switch (type) {\n case FIELD_TYPES.Array: {\n return isArray(field) ? field.join(\", \") : \"\";\n }\n case FIELD_TYPES.Date: {\n return isString(field) || isNumber(field) || isDate(field)\n ? dateFormat(field, \"DD.MM.YYYY\")\n : \"\";\n }\n case FIELD_TYPES.DateTime: {\n return isString(field) || isNumber(field) || isDate(field)\n ? dateFormat(field, \"DD.MM.YYYY HH:mm\")\n : \"\";\n }\n case FIELD_TYPES.Number: {\n return isString(field) || isNumber(field) || isBoolean(field)\n ? String(transformToNumber(field))\n : \"\";\n }\n case FIELD_TYPES.String: {\n return isString(field) || isNumber(field) || isBoolean(field) ? String(field) : \"\";\n }\n case FIELD_TYPES.Time: {\n return isString(field) || isNumber(field) || isDate(field) ? dateFormat(field, \"HH:mm\") : \"\";\n }\n default: {\n return isString(field) || isNumber(field) || isBoolean(field) ? String(field) : \"\";\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;SAMgB,eAAe,CAAC,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AI,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;;;AAGxF;;;;"}
1
+ {"version":3,"file":"field-view-format.js","sources":["../../../../src/lib/utils/field-view-format.ts"],"sourcesContent":["import { FIELD_TYPES } from \"../../constants\";\nimport type { FieldType } from \"../../types\";\nimport { dateFormat } from \"../date\";\nimport { isArray, isBoolean, isDate, isNumber, isString } from \"../typings\";\nimport { transformToNumber } from \"./transform-to-number\";\n\nexport function fieldViewFormat(field: unknown, type: FieldType = \"string\") {\n switch (type) {\n case FIELD_TYPES.Array: {\n return isArray(field) ? field.join(\", \") : \"\";\n }\n case FIELD_TYPES.Date: {\n return isString(field) || isNumber(field) || isDate(field)\n ? dateFormat(field, \"DD.MM.YYYY\")\n : \"\";\n }\n case FIELD_TYPES.DateTime: {\n return isString(field) || isNumber(field) || isDate(field)\n ? dateFormat(field, \"DD.MM.YYYY HH:mm\")\n : \"\";\n }\n case FIELD_TYPES.Number: {\n return isString(field) || isNumber(field) || isBoolean(field)\n ? String(transformToNumber(field))\n : \"\";\n }\n case FIELD_TYPES.String: {\n return isString(field) || isNumber(field) || isBoolean(field) ? String(field) : \"\";\n }\n case FIELD_TYPES.Time: {\n return isString(field) || isNumber(field) || isDate(field) ? dateFormat(field, \"HH:mm\") : \"\";\n }\n default: {\n return isString(field) || isNumber(field) || isBoolean(field) ? String(field) : \"\";\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;SAMgB,eAAe,CAAC,KAAc,EAAE,OAAkB,QAAQ,EAAA;IACxE,QAAQ,IAAI;AACV,QAAA,KAAK,WAAW,CAAC,KAAK,EAAE;AACtB,YAAA,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;;AAE/C,QAAA,KAAK,WAAW,CAAC,IAAI,EAAE;AACrB,YAAA,OAAO,QAAQ,CAAC,KAAK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