@cyberskill/shared 3.1.0 → 3.2.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.
- package/dist/config/config.util.js +3 -2
- package/dist/config/config.util.js.map +1 -1
- package/dist/config/storybook/storybook.preview.d.ts +1 -1
- package/dist/config/storybook/storybook.preview.js +5 -4
- package/dist/config/storybook/storybook.preview.js.map +1 -1
- package/dist/config/vitest/vitest.e2e.d.ts +2 -0
- package/dist/config/vitest/vitest.e2e.js +11 -18
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.d.ts +2 -0
- package/dist/config/vitest/vitest.unit.js +7 -5
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/node/cli/index.js +55 -45
- package/dist/node/cli/index.js.map +1 -1
- package/dist/node/command/command.util.js +75 -75
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/express/express.util.js +16 -16
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/mongo/mongo.controller.d.ts +1 -1
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/node/mongo/mongo.dynamic-populate.js +64 -64
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
- package/dist/node/mongo/mongo.populate.js.map +1 -1
- package/dist/node/mongo/mongo.util.d.ts +16 -16
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/path/path.constant.js +9 -9
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/ws/index.d.ts +1 -1
- package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +13 -13
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.component.js +22 -21
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/util/common/common.util.js +26 -25
- package/dist/util/common/common.util.js.map +1 -1
- package/dist/util/object/object.util.js +49 -49
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/serializer.util.js +12 -12
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/string/string.util.js +29 -28
- package/dist/util/string/string.util.js.map +1 -1
- package/dist/util/validate/validate.util.d.ts +0 -4
- package/dist/util/validate/validate.util.js +3 -3
- package/dist/util/validate/validate.util.js.map +1 -1
- package/package.json +31 -29
- package/public/tsconfig.base.json +1 -1
- package/dist/config/config.test.unit.d.ts +0 -1
- package/dist/config/config.type.test.unit.d.ts +0 -1
- package/dist/constant/constant.test.unit.d.ts +0 -1
- package/dist/node/command/command.test.unit.d.ts +0 -1
- package/dist/node/fs/fs.test.unit.d.ts +0 -1
- package/dist/node/log/log.test.unit.d.ts +0 -1
- package/dist/node/mongo/mongo.controller.test.unit.d.ts +0 -1
- package/dist/node/mongo/mongo.util.test.unit.d.ts +0 -1
- package/dist/node/package/package.test.unit.d.ts +0 -1
- package/dist/node/path/path.test.unit.d.ts +0 -1
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +0 -1
- package/dist/react/loading/loading.test.unit.d.ts +0 -1
- package/dist/react/storage/storage.test.unit.d.ts +0 -1
- package/dist/typescript/typescript.test.unit.d.ts +0 -1
- package/dist/util/common/common.test.unit.d.ts +0 -1
- package/dist/util/object/object.test.unit.d.ts +0 -1
- package/dist/util/serializer/serializer.test.unit.d.ts +0 -1
- package/dist/util/string/string.test.unit.d.ts +0 -1
- package/dist/util/validate/validate.test.unit.d.ts +0 -1
- /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ApolloClient as d, InMemoryCache as w, CombinedGraphQLErrors as h, CombinedProtocolErrors as E, ServerError as
|
|
2
|
-
import { ApolloLink as
|
|
3
|
-
import { ErrorLink as
|
|
1
|
+
import { ApolloClient as d, InMemoryCache as w, CombinedGraphQLErrors as h, CombinedProtocolErrors as E, ServerError as C } from "@apollo/client/core";
|
|
2
|
+
import { ApolloLink as m } from "@apollo/client/link";
|
|
3
|
+
import { ErrorLink as g } from "@apollo/client/link/error";
|
|
4
4
|
import { RemoveTypenameFromVariablesLink as y } from "@apollo/client/link/remove-typename";
|
|
5
5
|
import { GraphQLWsLink as N } from "@apollo/client/link/subscriptions";
|
|
6
6
|
import { OperationTypeNode as $ } from "graphql";
|
|
@@ -13,23 +13,23 @@ import { createUploadLink as T } from "./links/upload.js";
|
|
|
13
13
|
import { hasCustomApolloErrorHandler as U, showGlobalApolloError as u } from "../apollo-error/apollo-error.util.js";
|
|
14
14
|
import { log as s } from "../log/log.util.js";
|
|
15
15
|
import { toast as L } from "react-hot-toast";
|
|
16
|
-
const R = new
|
|
16
|
+
const R = new m((o, e) => (o.setContext({ start: /* @__PURE__ */ new Date() }), e(o).pipe(
|
|
17
17
|
A(() => {
|
|
18
|
-
const t =
|
|
18
|
+
const t = Date.now() - o.getContext().start;
|
|
19
19
|
s.info(`Operation ${o.operationName} took ${t}ms to complete`);
|
|
20
20
|
})
|
|
21
|
-
))), S = new
|
|
21
|
+
))), S = new g(({ error: o, operation: e }) => {
|
|
22
22
|
const t = e?.operationName || "Unknown";
|
|
23
23
|
let i = "";
|
|
24
|
-
h.is(o) ? o.errors.forEach(({ message: r, locations: n, path: l },
|
|
25
|
-
|
|
24
|
+
h.is(o) ? o.errors.forEach(({ message: r, locations: n, path: l }, a) => {
|
|
25
|
+
a === 0 && (i = r), s.error(
|
|
26
26
|
`[GraphQL error] ${t}: ${r}, Location: ${JSON.stringify(n, null, 4)}, Path: ${l}`
|
|
27
27
|
);
|
|
28
28
|
}) : E.is(o) ? o.errors.forEach(({ message: r, extensions: n }, l) => {
|
|
29
29
|
l === 0 && (i = r), s.error(
|
|
30
30
|
`[Protocol error]: ${r}, Extensions: ${JSON.stringify(n, null, 4)}`
|
|
31
31
|
);
|
|
32
|
-
}) :
|
|
32
|
+
}) : C.is(o) ? (i = o.message, s.error(`[Server error]: ${o.message}`)) : (i = o.message, s.error(`[Network error]: ${o.message}`)), o && i && typeof window < "u" && (U() ? u(o) : L.error((r) => /* @__PURE__ */ p.createElement("div", { className: f["error-container"] }, i, /* @__PURE__ */ p.createElement(
|
|
33
33
|
"button",
|
|
34
34
|
{
|
|
35
35
|
type: "button",
|
|
@@ -50,21 +50,21 @@ function v(o) {
|
|
|
50
50
|
headers: {
|
|
51
51
|
"apollo-require-preflight": "true"
|
|
52
52
|
}
|
|
53
|
-
}), l = t ? new N(b({ url: t })) :
|
|
53
|
+
}), l = t ? new N(b({ url: t })) : m.empty(), a = t ? m.split(
|
|
54
54
|
({ operationType: k }) => k === $.SUBSCRIPTION,
|
|
55
55
|
l,
|
|
56
56
|
n
|
|
57
57
|
) : n;
|
|
58
|
-
return t &&
|
|
58
|
+
return t && a === n && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
|
|
59
59
|
R,
|
|
60
60
|
S,
|
|
61
61
|
r,
|
|
62
62
|
...i ?? [],
|
|
63
|
-
|
|
63
|
+
a
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
66
|
function B(o) {
|
|
67
|
-
const e =
|
|
67
|
+
const e = m.from(v(o));
|
|
68
68
|
return new d({
|
|
69
69
|
link: e,
|
|
70
70
|
cache: new w(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-client.util.js","sources":["../../../src/react/apollo-client/apollo-client.util.tsx"],"sourcesContent":["import { ApolloClient, CombinedGraphQLErrors, CombinedProtocolErrors, InMemoryCache, ServerError } from '@apollo/client/core';\nimport { ApolloLink } from '@apollo/client/link';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { RemoveTypenameFromVariablesLink } from '@apollo/client/link/remove-typename';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { OperationTypeNode } from 'graphql';\nimport { createClient } from 'graphql-ws';\nimport * as React from 'react';\nimport { tap } from 'rxjs';\n\nimport type { I_ApolloOptions } from './apollo-client.type.js';\n\nimport { hasCustomApolloErrorHandler, showGlobalApolloError } from '../apollo-error/index.js';\nimport { log } from '../log/index.js';\nimport { toast } from '../toast/index.js';\nimport { GRAPHQL_URI_DEFAULT } from './apollo-client.constant.js';\nimport styles from './apollo-client.module.scss';\nimport { createUploadLink } from './links/index.js';\n\nconst roundTripLink = new ApolloLink((operation, forward) => {\n operation.setContext({ start: new Date() });\n\n return forward(operation).pipe(\n tap(() => {\n const time =
|
|
1
|
+
{"version":3,"file":"apollo-client.util.js","sources":["../../../src/react/apollo-client/apollo-client.util.tsx"],"sourcesContent":["import { ApolloClient, CombinedGraphQLErrors, CombinedProtocolErrors, InMemoryCache, ServerError } from '@apollo/client/core';\nimport { ApolloLink } from '@apollo/client/link';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { RemoveTypenameFromVariablesLink } from '@apollo/client/link/remove-typename';\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions';\nimport { OperationTypeNode } from 'graphql';\nimport { createClient } from 'graphql-ws';\nimport * as React from 'react';\nimport { tap } from 'rxjs';\n\nimport type { I_ApolloOptions } from './apollo-client.type.js';\n\nimport { hasCustomApolloErrorHandler, showGlobalApolloError } from '../apollo-error/index.js';\nimport { log } from '../log/index.js';\nimport { toast } from '../toast/index.js';\nimport { GRAPHQL_URI_DEFAULT } from './apollo-client.constant.js';\nimport styles from './apollo-client.module.scss';\nimport { createUploadLink } from './links/index.js';\n\nconst roundTripLink = new ApolloLink((operation, forward) => {\n operation.setContext({ start: new Date() });\n\n return forward(operation).pipe(\n tap(() => {\n const time = Date.now() - operation.getContext()['start'];\n\n log.info(`Operation ${operation.operationName} took ${time}ms to complete`);\n }),\n );\n});\n\nconst errorLink = new ErrorLink(({ error, operation }) => {\n const opName = operation?.operationName || 'Unknown';\n let errorMessage = '';\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[GraphQL error] ${opName}: ${message}, Location: ${JSON.stringify(locations, null, 4)}, Path: ${path}`,\n );\n });\n }\n else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }, index) => {\n if (index === 0) {\n errorMessage = message;\n }\n\n log.error(\n `[Protocol error]: ${message}, Extensions: ${JSON.stringify(extensions, null, 4)}`,\n );\n });\n }\n else if (ServerError.is(error)) {\n errorMessage = error.message;\n\n log.error(`[Server error]: ${error.message}`);\n }\n else {\n errorMessage = error.message;\n\n log.error(`[Network error]: ${error.message}`);\n }\n\n if (error && errorMessage && typeof window !== 'undefined') {\n if (hasCustomApolloErrorHandler()) {\n showGlobalApolloError(error);\n }\n else {\n toast.error((t: { id: string }) => (\n <div className={styles['error-container']}>\n {errorMessage}\n <button\n type=\"button\"\n className={styles['error-details-button']}\n onClick={() => {\n showGlobalApolloError(error);\n\n toast.dismiss(t.id);\n }}\n >\n Error Details\n </button>\n </div>\n ));\n }\n }\n});\n\n/**\n * Creates a comprehensive Apollo Link chain with all necessary middleware.\n * This function sets up a complete Apollo Link chain including error handling,\n * logging, file uploads, WebSocket subscriptions, and custom links. The chain\n * is configured to handle both HTTP and WebSocket operations with proper routing.\n *\n * The link chain includes:\n * - Development logging for operation tracking\n * - Error handling with user-friendly notifications\n * - Type name removal for cleaner requests\n * - File upload support\n * - WebSocket subscription support\n * - Custom link integration\n *\n * @param options - Configuration options for the Apollo Client including URI, WebSocket URL, and custom links.\n * @returns An array of Apollo Links configured for the specified options.\n */\nexport function createApolloLinks(options: I_ApolloOptions): ApolloLink[] {\n const { uri, wsUrl, customLinks } = options;\n\n const removeTypenameLink = new RemoveTypenameFromVariablesLink();\n\n if (!uri) {\n log.warn(`[Apollo] No GraphQL URI provided — using \"${GRAPHQL_URI_DEFAULT}\" as default`);\n }\n\n const uploadLink = createUploadLink({\n uri: uri ?? GRAPHQL_URI_DEFAULT,\n credentials: 'include',\n headers: {\n 'apollo-require-preflight': 'true',\n },\n });\n\n const wsLink = wsUrl\n ? new GraphQLWsLink(createClient({ url: wsUrl }))\n : ApolloLink.empty();\n\n const splitLink = wsUrl\n ? ApolloLink.split(\n ({ operationType }) => {\n return operationType === OperationTypeNode.SUBSCRIPTION;\n },\n wsLink,\n uploadLink as unknown as ApolloLink,\n )\n : uploadLink;\n\n if (wsUrl && splitLink === uploadLink) {\n log.warn('[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config.');\n }\n\n return [\n roundTripLink,\n errorLink,\n removeTypenameLink,\n ...(customLinks ?? []),\n splitLink as unknown as ApolloLink,\n ];\n}\n\n/**\n * Creates a fully configured Apollo Client instance.\n * This function creates an Apollo Client with all necessary configuration including\n * the link chain, cache, and any additional options provided. The client is ready\n * for immediate use in React applications with comprehensive error handling and\n * development tooling.\n *\n * @param options - Configuration options for the Apollo Client including links, cache, and other settings.\n * @returns A fully configured Apollo Client instance ready for use.\n */\nexport function getClient(options: I_ApolloOptions) {\n const link = ApolloLink.from(createApolloLinks(options));\n\n return new ApolloClient({\n link,\n cache: new InMemoryCache(),\n ...options,\n });\n}\n"],"names":["roundTripLink","ApolloLink","operation","forward","tap","time","log","errorLink","ErrorLink","error","opName","errorMessage","CombinedGraphQLErrors","message","locations","path","index","CombinedProtocolErrors","extensions","ServerError","hasCustomApolloErrorHandler","showGlobalApolloError","toast","t","React","styles","createApolloLinks","options","uri","wsUrl","customLinks","removeTypenameLink","RemoveTypenameFromVariablesLink","GRAPHQL_URI_DEFAULT","uploadLink","createUploadLink","wsLink","GraphQLWsLink","createClient","splitLink","operationType","OperationTypeNode","getClient","link","ApolloClient","InMemoryCache"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,IAAgB,IAAIC,EAAW,CAACC,GAAWC,OAC7CD,EAAU,WAAW,EAAE,OAAO,oBAAI,KAAA,GAAQ,GAEnCC,EAAQD,CAAS,EAAE;AAAA,EACtBE,EAAI,MAAM;AACN,UAAMC,IAAO,KAAK,IAAA,IAAQH,EAAU,WAAA,EAAa;AAEjD,IAAAI,EAAI,KAAK,aAAaJ,EAAU,aAAa,SAASG,CAAI,gBAAgB;AAAA,EAC9E,CAAC;AAAA,EAER,GAEKE,IAAY,IAAIC,EAAU,CAAC,EAAE,OAAAC,GAAO,WAAAP,QAAgB;AACtD,QAAMQ,IAASR,GAAW,iBAAiB;AAC3C,MAAIS,IAAe;AAEnB,EAAIC,EAAsB,GAAGH,CAAK,IAC9BA,EAAM,OAAO,QAAQ,CAAC,EAAE,SAAAI,GAAS,WAAAC,GAAW,MAAAC,EAAA,GAAQC,MAAU;AAC1D,IAAIA,MAAU,MACVL,IAAeE,IAGnBP,EAAI;AAAA,MACA,mBAAmBI,CAAM,KAAKG,CAAO,eAAe,KAAK,UAAUC,GAAW,MAAM,CAAC,CAAC,WAAWC,CAAI;AAAA,IAAA;AAAA,EAE7G,CAAC,IAEIE,EAAuB,GAAGR,CAAK,IACpCA,EAAM,OAAO,QAAQ,CAAC,EAAE,SAAAI,GAAS,YAAAK,EAAA,GAAcF,MAAU;AACrD,IAAIA,MAAU,MACVL,IAAeE,IAGnBP,EAAI;AAAA,MACA,qBAAqBO,CAAO,iBAAiB,KAAK,UAAUK,GAAY,MAAM,CAAC,CAAC;AAAA,IAAA;AAAA,EAExF,CAAC,IAEIC,EAAY,GAAGV,CAAK,KACzBE,IAAeF,EAAM,SAErBH,EAAI,MAAM,mBAAmBG,EAAM,OAA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AAO1C,EAAW,KAAKyB,EAAkBC,CAAO,CAAC;AAEvD,SAAO,IAAIiB,EAAa;AAAA,IACpB,MAAAD;AAAA,IACA,OAAO,IAAIE,EAAA;AAAA,IACX,GAAGlB;AAAA,EAAA,CACN;AACL;"}
|
|
@@ -2,66 +2,67 @@ import * as t from "react";
|
|
|
2
2
|
import { use as g, useRef as d, useEffect as f } from "react";
|
|
3
3
|
import { validate as E } from "../../util/validate/validate.util.js";
|
|
4
4
|
import { ApolloErrorContext as h } from "./apollo-error.context.js";
|
|
5
|
-
import
|
|
5
|
+
import n from "./apollo-error.module.scss.js";
|
|
6
6
|
const N = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
7
7
|
function C() {
|
|
8
|
-
const p = g(h), { error: e, hideError: a } = p ?? {},
|
|
8
|
+
const p = g(h), { error: e, hideError: a } = p ?? {}, o = d(null), s = d(null);
|
|
9
9
|
f(() => {
|
|
10
|
-
if (!e || !a)
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (!e || !a)
|
|
11
|
+
return;
|
|
12
|
+
const r = (l) => {
|
|
13
|
+
l.key === "Escape" && a();
|
|
13
14
|
};
|
|
14
15
|
return window.addEventListener("keydown", r), () => {
|
|
15
16
|
window.removeEventListener("keydown", r);
|
|
16
17
|
};
|
|
17
18
|
}, [e, a]), f(() => {
|
|
18
|
-
e &&
|
|
19
|
+
e && o.current ? (s.current = document.activeElement, o.current.focus()) : !e && s.current && (s.current.focus(), s.current = null);
|
|
19
20
|
}, [e]);
|
|
20
|
-
const
|
|
21
|
-
if (r.key !== "Tab" || !
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const c =
|
|
21
|
+
const b = (r) => {
|
|
22
|
+
if (r.key !== "Tab" || !o.current)
|
|
23
|
+
return;
|
|
24
|
+
const l = [...o.current.querySelectorAll(N)].filter((y) => !y.hasAttribute("disabled"));
|
|
25
|
+
if (l.length === 0)
|
|
26
|
+
return;
|
|
27
|
+
const c = l[0], u = l.at(-1);
|
|
27
28
|
!c || !u || (r.shiftKey ? document.activeElement === c && (r.preventDefault(), u.focus()) : document.activeElement === u && (r.preventDefault(), c.focus()));
|
|
28
29
|
};
|
|
29
30
|
if (!e)
|
|
30
31
|
return null;
|
|
31
32
|
const i = "locations" in e || "path" in e || "extensions" in e, m = "message" in e ? e.message : "Unknown error occurred";
|
|
32
|
-
return /* @__PURE__ */ t.createElement("div", { className:
|
|
33
|
+
return /* @__PURE__ */ t.createElement("div", { className: n["modal-backdrop"] }, /* @__PURE__ */ t.createElement(
|
|
33
34
|
"div",
|
|
34
35
|
{
|
|
35
|
-
ref:
|
|
36
|
-
className:
|
|
36
|
+
ref: o,
|
|
37
|
+
className: n["modal-content"],
|
|
37
38
|
role: "dialog",
|
|
38
39
|
"aria-modal": "true",
|
|
39
40
|
"aria-labelledby": "apollo-error-title",
|
|
40
41
|
tabIndex: -1,
|
|
41
|
-
onKeyDown:
|
|
42
|
+
onKeyDown: b
|
|
42
43
|
},
|
|
43
44
|
/* @__PURE__ */ t.createElement(
|
|
44
45
|
"button",
|
|
45
46
|
{
|
|
46
47
|
type: "button",
|
|
47
|
-
className:
|
|
48
|
+
className: n["btn-close"],
|
|
48
49
|
onClick: a,
|
|
49
50
|
"aria-label": "Close error details",
|
|
50
51
|
title: "Close error details"
|
|
51
52
|
},
|
|
52
53
|
"✕"
|
|
53
54
|
),
|
|
54
|
-
/* @__PURE__ */ t.createElement("div", { id: "apollo-error-title", className:
|
|
55
|
+
/* @__PURE__ */ t.createElement("div", { id: "apollo-error-title", className: n["error-title"] }, /* @__PURE__ */ t.createElement(
|
|
55
56
|
"button",
|
|
56
57
|
{
|
|
57
58
|
type: "button",
|
|
58
|
-
className:
|
|
59
|
+
className: n["btn-retry"],
|
|
59
60
|
onClick: () => window.location.reload(),
|
|
60
61
|
"aria-label": "Reload page"
|
|
61
62
|
},
|
|
62
63
|
"Reload"
|
|
63
64
|
), " ", !E.isEmpty(e) && m),
|
|
64
|
-
/* @__PURE__ */ t.createElement("div", { className:
|
|
65
|
+
/* @__PURE__ */ t.createElement("div", { className: n["error-details"] }, i && "locations" in e && e.locations && /* @__PURE__ */ t.createElement("pre", { className: "locations" }, /* @__PURE__ */ t.createElement("strong", null, "Locations:"), " ", JSON.stringify(e.locations, null, 4)), i && "path" in e && e.path && /* @__PURE__ */ t.createElement("pre", { className: "path" }, /* @__PURE__ */ t.createElement("strong", null, "Path:"), " ", JSON.stringify(e.path, null, 4)), i && "extensions" in e && e.extensions && /* @__PURE__ */ t.createElement("pre", { className: "extensions" }, /* @__PURE__ */ t.createElement("strong", null, "Extensions:"), " ", JSON.stringify(e.extensions, null, 4)), !i && /* @__PURE__ */ t.createElement("pre", { className: "error-details" }, /* @__PURE__ */ t.createElement("strong", null, "Error Details:"), " ", E.isEmpty(e) ? m : JSON.stringify(e, null, 4)))
|
|
65
66
|
));
|
|
66
67
|
}
|
|
67
68
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-error.component.js","sources":["../../../src/react/apollo-error/apollo-error.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport { use, useEffect, useRef } from 'react';\n\nimport { validate } from '#util/validate/validate.util.js';\n\nimport { ApolloErrorContext } from './apollo-error.context.js';\nimport style from './apollo-error.module.scss';\n\nconst FOCUSABLE_SELECTORS = 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Apollo Error Component that displays detailed error information in a modal.\n * This component provides a comprehensive error display interface that shows\n * GraphQL errors and other error types with detailed information for debugging purposes.\n *\n * Features:\n * - Modal overlay with backdrop for focus\n * - Detailed error categorization and display\n * - Reload functionality for error recovery\n * - Close button to dismiss the error modal\n * - Structured display of different error types\n * - Extra information display for debugging\n *\n * @returns A modal component displaying Apollo error details, or null if no error is present.\n */\nexport function ApolloErrorComponent() {\n const context = use(ApolloErrorContext);\n const { error, hideError } = context ?? {};\n const dialogRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!error || !hideError)
|
|
1
|
+
{"version":3,"file":"apollo-error.component.js","sources":["../../../src/react/apollo-error/apollo-error.component.tsx"],"sourcesContent":["import * as React from 'react';\nimport { use, useEffect, useRef } from 'react';\n\nimport { validate } from '#util/validate/validate.util.js';\n\nimport { ApolloErrorContext } from './apollo-error.context.js';\nimport style from './apollo-error.module.scss';\n\nconst FOCUSABLE_SELECTORS = 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Apollo Error Component that displays detailed error information in a modal.\n * This component provides a comprehensive error display interface that shows\n * GraphQL errors and other error types with detailed information for debugging purposes.\n *\n * Features:\n * - Modal overlay with backdrop for focus\n * - Detailed error categorization and display\n * - Reload functionality for error recovery\n * - Close button to dismiss the error modal\n * - Structured display of different error types\n * - Extra information display for debugging\n *\n * @returns A modal component displaying Apollo error details, or null if no error is present.\n */\nexport function ApolloErrorComponent() {\n const context = use(ApolloErrorContext);\n const { error, hideError } = context ?? {};\n const dialogRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!error || !hideError)\n return;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n hideError();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n };\n }, [error, hideError]);\n\n useEffect(() => {\n if (error && dialogRef.current) {\n previousFocusRef.current = document.activeElement as HTMLElement;\n dialogRef.current.focus();\n }\n else if (!error && previousFocusRef.current) {\n previousFocusRef.current.focus();\n previousFocusRef.current = null;\n }\n }, [error]);\n\n const handleFocusTrap = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Tab' || !dialogRef.current)\n return;\n\n const focusableElements = [...dialogRef.current.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS)].filter(el => !el.hasAttribute('disabled'));\n\n if (focusableElements.length === 0)\n return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements.at(-1);\n\n if (!firstElement || !lastElement)\n return;\n\n if (event.shiftKey) {\n if (document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n }\n }\n else if (document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n };\n\n if (!error) {\n return null;\n }\n\n const isGraphQLError = 'locations' in error || 'path' in error || 'extensions' in error;\n const errorMessage = 'message' in error ? error.message : 'Unknown error occurred';\n\n return (\n <div className={style['modal-backdrop']}>\n <div\n ref={dialogRef}\n className={style['modal-content']}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"apollo-error-title\"\n tabIndex={-1}\n onKeyDown={handleFocusTrap}\n >\n <button\n type=\"button\"\n className={style['btn-close']}\n onClick={hideError}\n aria-label=\"Close error details\"\n title=\"Close error details\"\n >\n ✕\n </button>\n <div id=\"apollo-error-title\" className={style['error-title']}>\n <button\n type=\"button\"\n className={style['btn-retry']}\n onClick={() => window.location.reload()}\n aria-label=\"Reload page\"\n >\n Reload\n </button>\n {' '}\n {!validate.isEmpty(error) && errorMessage}\n </div>\n <div className={style['error-details']}>\n {isGraphQLError && 'locations' in error && error.locations && (\n <pre className=\"locations\">\n <strong>Locations:</strong>\n {' '}\n {JSON.stringify(error.locations, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'path' in error && error.path && (\n <pre className=\"path\">\n <strong>Path:</strong>\n {' '}\n {JSON.stringify(error.path, null, 4)}\n </pre>\n )}\n {isGraphQLError && 'extensions' in error && error.extensions && (\n <pre className=\"extensions\">\n <strong>Extensions:</strong>\n {' '}\n {JSON.stringify(error.extensions, null, 4)}\n </pre>\n )}\n {!isGraphQLError && (\n <pre className=\"error-details\">\n <strong>Error Details:</strong>\n {' '}\n {validate.isEmpty(error) ? errorMessage : JSON.stringify(error, null, 4)}\n </pre>\n )}\n </div>\n </div>\n </div>\n );\n}\n"],"names":["FOCUSABLE_SELECTORS","ApolloErrorComponent","context","use","ApolloErrorContext","error","hideError","dialogRef","useRef","previousFocusRef","useEffect","handleKeyDown","event","handleFocusTrap","focusableElements","el","firstElement","lastElement","isGraphQLError","errorMessage","React","style","validate"],"mappings":";;;;;AAQA,MAAMA,IAAsB;AAiBrB,SAASC,IAAuB;AACnC,QAAMC,IAAUC,EAAIC,CAAkB,GAChC,EAAE,OAAAC,GAAO,WAAAC,EAAA,IAAcJ,KAAW,CAAA,GAClCK,IAAYC,EAAuB,IAAI,GACvCC,IAAmBD,EAA2B,IAAI;AAExD,EAAAE,EAAU,MAAM;AACZ,QAAI,CAACL,KAAS,CAACC;AACX;AAEJ,UAAMK,IAAgB,CAACC,MAAyB;AAC5C,MAAIA,EAAM,QAAQ,YACdN,EAAA;AAAA,IAER;AAEA,kBAAO,iBAAiB,WAAWK,CAAa,GAEzC,MAAM;AACT,aAAO,oBAAoB,WAAWA,CAAa;AAAA,IACvD;AAAA,EACJ,GAAG,CAACN,GAAOC,CAAS,CAAC,GAErBI,EAAU,MAAM;AACZ,IAAIL,KAASE,EAAU,WACnBE,EAAiB,UAAU,SAAS,eACpCF,EAAU,QAAQ,MAAA,KAEb,CAACF,KAASI,EAAiB,YAChCA,EAAiB,QAAQ,MAAA,GACzBA,EAAiB,UAAU;AAAA,EAEnC,GAAG,CAACJ,CAAK,CAAC;AAEV,QAAMQ,IAAkB,CAACD,MAA+C;AACpE,QAAIA,EAAM,QAAQ,SAAS,CAACL,EAAU;AAClC;AAEJ,UAAMO,IAAoB,CAAC,GAAGP,EAAU,QAAQ,iBAA8BP,CAAmB,CAAC,EAAE,OAAO,CAAAe,MAAM,CAACA,EAAG,aAAa,UAAU,CAAC;AAE7I,QAAID,EAAkB,WAAW;AAC7B;AAEJ,UAAME,IAAeF,EAAkB,CAAC,GAClCG,IAAcH,EAAkB,GAAG,EAAE;AAE3C,IAAI,CAACE,KAAgB,CAACC,MAGlBL,EAAM,WACF,SAAS,kBAAkBI,MAC3BJ,EAAM,eAAA,GACN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EAAM,QACxC,gBAAAe,EAAA,cAAC,SAAI,WAAU,OAAA,mCACV,UAAA,MAAO,OAAK,GACZ,KACA,KAAK,UAAUf,EAAM,MAAM,MAAM,CAAC,CACvC,GAEHa,KAAkB,gBAAgBb,KAASA,EAAM,cAC9C,gBAAAe,EAAA,cAAC,SAAI,WAAU,gDACV,UAAA,MAAO,aAAW,GAClB,KACA,KAAK,UAAUf,EAAM,YAAY,MAAM,CAAC,CAC7C,GAEH,CAACa,qCACG,OAAA,EAAI,WAAU,mBACX,gBAAAE,EAAA,cAAC,UAAA,MAAO,gBAAc,GACrB,KACAE,EAAS,QAAQjB,CAAK,IAAIc,IAAe,KAAK,UAAUd,GAAO,MAAM,CAAC,CAC3E,CAER;AAAA,EAAA,CAER;AAER;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E_Environment as
|
|
1
|
+
import { E_Environment as o } from "../../typescript/common.type.js";
|
|
2
2
|
const p = {
|
|
3
3
|
a: ["à", "á", "ạ", "ả", "ã", "â", "ầ", "ấ", "ậ", "ẩ", "ẫ", "ă", "ằ", "ắ", "ặ", "ẳ", "ẵ"],
|
|
4
4
|
e: ["è", "é", "ẹ", "ẻ", "ẽ", "ê", "ề", "ế", "ệ", "ể", "ễ"],
|
|
@@ -7,47 +7,48 @@ const p = {
|
|
|
7
7
|
u: ["ù", "ú", "ụ", "ủ", "ũ", "ư", "ừ", "ứ", "ự", "ử", "ữ"],
|
|
8
8
|
y: ["ỳ", "ý", "ỵ", "ỷ", "ỹ"],
|
|
9
9
|
d: ["đ"]
|
|
10
|
-
},
|
|
11
|
-
(e, [n, t]) => (e[n.toUpperCase()] = t.map((
|
|
10
|
+
}, a = Object.entries(p).reduce(
|
|
11
|
+
(e, [n, t]) => (e[n.toUpperCase()] = t.map((r) => r.toUpperCase()), e),
|
|
12
12
|
{}
|
|
13
|
-
), u = { ...p, ...
|
|
13
|
+
), u = { ...p, ...a }, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
14
14
|
Object.entries(u).forEach(([e, n]) => {
|
|
15
15
|
const t = `(${[e, ...n].join("|")})`;
|
|
16
|
-
[e, ...n].forEach((
|
|
17
|
-
|
|
16
|
+
[e, ...n].forEach((r) => {
|
|
17
|
+
s.set(r, t), i.add(r);
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
const O =
|
|
21
|
-
function
|
|
22
|
-
return e.replace(
|
|
20
|
+
const O = [...i].join(""), D = new RegExp(`[${O}]`, "g"), N = /[.*+?^${}()|[\]\\]/g;
|
|
21
|
+
function M(e) {
|
|
22
|
+
return e.replace(N, "\\$&");
|
|
23
23
|
}
|
|
24
24
|
function m(e) {
|
|
25
|
-
return e =
|
|
25
|
+
return e = M(e), e.replace(D, (n) => s.get(n) || n);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const f = /\p{Diacritic}/gu;
|
|
28
|
+
function P(e) {
|
|
29
|
+
return e.normalize("NFD").replace(f, "");
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function R(e, n) {
|
|
31
32
|
if (!n)
|
|
32
|
-
return
|
|
33
|
-
const t = /* @__PURE__ */ new Set(),
|
|
33
|
+
return [...new Set(e)];
|
|
34
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
34
35
|
for (const c of e) {
|
|
35
36
|
const E = n(c);
|
|
36
|
-
t.has(E) || (t.add(E),
|
|
37
|
+
t.has(E) || (t.add(E), r.push(c));
|
|
37
38
|
}
|
|
38
|
-
return
|
|
39
|
+
return r;
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
-
const { NODE_ENV: n =
|
|
42
|
-
if (n ===
|
|
41
|
+
function _(e) {
|
|
42
|
+
const { NODE_ENV: n = o.DEVELOPMENT, NODE_ENV_MODE: t = o.DEVELOPMENT } = e, r = n === o.DEVELOPMENT && t === o.DEVELOPMENT, c = n === o.PRODUCTION && t === o.STAGING, E = n === o.PRODUCTION && t === o.PRODUCTION;
|
|
43
|
+
if (n === o.PRODUCTION && t === o.DEVELOPMENT)
|
|
43
44
|
throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");
|
|
44
|
-
return { IS_DEV:
|
|
45
|
+
return { IS_DEV: r, IS_STAG: c, IS_PROD: E };
|
|
45
46
|
}
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
M as escapeRegExp,
|
|
49
|
+
_ as mapEnvironment,
|
|
49
50
|
m as regexSearchMapper,
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
P as removeAccent,
|
|
52
|
+
R as uniqueArray
|
|
52
53
|
};
|
|
53
54
|
//# sourceMappingURL=common.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.util.js","sources":["../../../src/util/common/common.util.ts"],"sourcesContent":["import { E_Environment } from '#typescript/index.js';\n\nimport type { I_EnvFlags, I_NodeEnvInput } from './common.type.js';\n\nconst charMap: Record<string, string[]> = {\n a: ['à', 'á', 'ạ', 'ả', 'ã', 'â', 'ầ', 'ấ', 'ậ', 'ẩ', 'ẫ', 'ă', 'ằ', 'ắ', 'ặ', 'ẳ', 'ẵ'],\n e: ['è', 'é', 'ẹ', 'ẻ', 'ẽ', 'ê', 'ề', 'ế', 'ệ', 'ể', 'ễ'],\n i: ['ì', 'í', 'ị', 'ỉ', 'ĩ'],\n o: ['ò', 'ó', 'ọ', 'ỏ', 'õ', 'ô', 'ồ', 'ố', 'ộ', 'ổ', 'ỗ', 'ơ', 'ờ', 'ớ', 'ợ', 'ở', 'ỡ'],\n u: ['ù', 'ú', 'ụ', 'ủ', 'ũ', 'ư', 'ừ', 'ứ', 'ự', 'ử', 'ữ'],\n y: ['ỳ', 'ý', 'ỵ', 'ỷ', 'ỹ'],\n d: ['đ'],\n};\n\nconst upperCharMap: Record<string, string[]> = Object.entries(charMap).reduce(\n (map, [key, value]) => {\n map[key.toUpperCase()] = value.map(char => char.toUpperCase());\n return map;\n },\n {} as Record<string, string[]>,\n);\n\nconst combinedMap = { ...charMap, ...upperCharMap };\n\n// Pre-compute replacement map and search regex for better performance\n// This avoids rebuilding regexes and maps on every function call\nconst replacementMap = new Map<string, string>();\nconst charsToMatch = new Set<string>();\n\nObject.entries(combinedMap).forEach(([baseChar, variations]) => {\n // The replacement pattern is the same for the base char and all its variations\n // Example: 'a', 'à', 'á'... all map to '(a|à|á...)'\n const replacement = `(${[baseChar, ...variations].join('|')})`;\n\n [baseChar, ...variations].forEach((char) => {\n replacementMap.set(char, replacement);\n charsToMatch.add(char);\n });\n});\n\n// Construct a single regex that matches any character in our map\nconst patternString =
|
|
1
|
+
{"version":3,"file":"common.util.js","sources":["../../../src/util/common/common.util.ts"],"sourcesContent":["import { E_Environment } from '#typescript/index.js';\n\nimport type { I_EnvFlags, I_NodeEnvInput } from './common.type.js';\n\nconst charMap: Record<string, string[]> = {\n a: ['à', 'á', 'ạ', 'ả', 'ã', 'â', 'ầ', 'ấ', 'ậ', 'ẩ', 'ẫ', 'ă', 'ằ', 'ắ', 'ặ', 'ẳ', 'ẵ'],\n e: ['è', 'é', 'ẹ', 'ẻ', 'ẽ', 'ê', 'ề', 'ế', 'ệ', 'ể', 'ễ'],\n i: ['ì', 'í', 'ị', 'ỉ', 'ĩ'],\n o: ['ò', 'ó', 'ọ', 'ỏ', 'õ', 'ô', 'ồ', 'ố', 'ộ', 'ổ', 'ỗ', 'ơ', 'ờ', 'ớ', 'ợ', 'ở', 'ỡ'],\n u: ['ù', 'ú', 'ụ', 'ủ', 'ũ', 'ư', 'ừ', 'ứ', 'ự', 'ử', 'ữ'],\n y: ['ỳ', 'ý', 'ỵ', 'ỷ', 'ỹ'],\n d: ['đ'],\n};\n\nconst upperCharMap: Record<string, string[]> = Object.entries(charMap).reduce(\n (map, [key, value]) => {\n map[key.toUpperCase()] = value.map(char => char.toUpperCase());\n return map;\n },\n {} as Record<string, string[]>,\n);\n\nconst combinedMap = { ...charMap, ...upperCharMap };\n\n// Pre-compute replacement map and search regex for better performance\n// This avoids rebuilding regexes and maps on every function call\nconst replacementMap = new Map<string, string>();\nconst charsToMatch = new Set<string>();\n\nObject.entries(combinedMap).forEach(([baseChar, variations]) => {\n // The replacement pattern is the same for the base char and all its variations\n // Example: 'a', 'à', 'á'... all map to '(a|à|á...)'\n const replacement = `(${[baseChar, ...variations].join('|')})`;\n\n [baseChar, ...variations].forEach((char) => {\n replacementMap.set(char, replacement);\n charsToMatch.add(char);\n });\n});\n\n// Construct a single regex that matches any character in our map\nconst patternString = [...charsToMatch].join('');\n// We use a character class regex: [abc...]\n// eslint-disable-next-line regexp/no-empty-character-class -- regex is built dynamically from precomputed charMap\nconst searchRegex = new RegExp(`[${patternString}]`, 'g');\n\nconst RE_ESCAPE_REGEXP = /[.*+?^${}()|[\\]\\\\]/g;\n\n/**\n * Escapes special characters in a string for use in a regular expression.\n * This function escapes characters that have special meaning in regex (e.g., ., *, +, ?, etc.)\n * so they are treated as literal characters.\n *\n * @param str - The string to escape.\n * @returns The escaped string safe for use in a RegExp.\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(RE_ESCAPE_REGEXP, '\\\\$&');\n}\n\n/**\n * Convert a string to a regex pattern that matches the string and its accented variations.\n * This function normalizes the input string and creates a regex pattern that can match\n * both the original characters and their accented equivalents.\n *\n * Optimization: Uses pre-computed regex and map to perform replacement in a single pass (O(N)),\n * instead of iterating through all character groups (O(K*N)).\n * Removed unnecessary NFD normalization which improves performance and fixes\n * matching against NFC target strings.\n *\n * @param str - The string to convert to a regex pattern.\n * @returns The regex pattern as a string that matches the original string and its accented variations.\n */\nexport function regexSearchMapper(str: string) {\n str = escapeRegExp(str);\n return str.replace(searchRegex, match => replacementMap.get(match) || match);\n}\n\nconst RE_DIACRITIC = /\\p{Diacritic}/gu;\n\n/**\n * Remove accents from a string.\n * This function normalizes the string using NFD normalization and removes all diacritical marks.\n *\n * @param str - The string to remove accents from.\n * @returns The string without any accents or diacritical marks.\n */\nexport function removeAccent(str: string) {\n return str.normalize('NFD').replace(RE_DIACRITIC, '');\n}\n\n/**\n * Remove duplicates from an array based on a key function.\n * This function can remove duplicates either by comparing values directly (when no keyFn is provided)\n * or by using a custom key function to determine uniqueness.\n *\n * @param arr - The array to remove duplicates from.\n * @param keyFn - Optional function that returns a unique key for each item in the array.\n * @returns A new array with duplicates removed, maintaining the original order.\n */\nexport function uniqueArray<T>(\n arr: T[],\n keyFn?: (item: T) => string | number,\n): T[] {\n if (!keyFn) {\n return [...new Set(arr)];\n }\n\n const seen = new Set<string | number>();\n const result: T[] = [];\n\n for (const item of arr) {\n const key = keyFn(item);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(item);\n }\n }\n\n return result;\n}\n\n/**\n * Map environment variables to boolean flags indicating the current environment.\n * This function takes NODE_ENV and NODE_ENV_MODE variables and returns flags\n * indicating whether the current environment is development, staging, or production.\n *\n * @param env - The environment variables object containing NODE_ENV and NODE_ENV_MODE.\n * @returns An object containing boolean flags for the environment (IS_DEV, IS_STAG, IS_PROD).\n * @throws {Error} When NODE_ENV is production but NODE_ENV_MODE is development.\n */\nexport function mapEnvironment(env: I_NodeEnvInput): I_EnvFlags {\n const { NODE_ENV = E_Environment.DEVELOPMENT, NODE_ENV_MODE = E_Environment.DEVELOPMENT } = env;\n\n const IS_DEV = NODE_ENV === E_Environment.DEVELOPMENT && NODE_ENV_MODE === E_Environment.DEVELOPMENT;\n const IS_STAG = NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.STAGING;\n const IS_PROD = NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.PRODUCTION;\n\n if (NODE_ENV === E_Environment.PRODUCTION && NODE_ENV_MODE === E_Environment.DEVELOPMENT) {\n throw new Error('NODE_ENV_MODE must be set to staging or production in production environment');\n }\n\n return { IS_DEV, IS_STAG, IS_PROD };\n}\n"],"names":["E_Environment","charMap","upperCharMap","map","key","value","char","combinedMap","replacementMap","charsToMatch","baseChar","variations","replacement","patternString","searchRegex","RE_ESCAPE_REGEXP","escapeRegExp","str","regexSearchMapper","match","RE_DIACRITIC","removeAccent","uniqueArray","arr","keyFn","seen","result","item","mapEnvironment","env","NODE_ENV","NODE_ENV_MODE","IS_DEV","IS_STAG","IS_PROD"],"mappings":"AAIA,SAAA,iBAAAA,SAAA;AAAA,MAAMC,IAAoC;AAAA,EACtC,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EACvF,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EACzD,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EAC3B,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EACvF,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EACzD,GAAG,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,EAC3B,GAAG,CAAC,GAAG;AACX,GAEMC,IAAyC,OAAO,QAAQD,CAAO,EAAE;AAAA,EACnE,CAACE,GAAK,CAACC,GAAKC,CAAK,OACbF,EAAIC,EAAI,aAAa,IAAIC,EAAM,IAAI,CAAAC,MAAQA,EAAK,aAAa,GACtDH;AAAA,EAEX,CAAA;AACJ,GAEMI,IAAc,EAAE,GAAGN,GAAS,GAAGC,EAAA,GAI/BM,wBAAqB,IAAA,GACrBC,wBAAmB,IAAA;AAEzB,OAAO,QAAQF,CAAW,EAAE,QAAQ,CAAC,CAACG,GAAUC,CAAU,MAAM;AAG5D,QAAMC,IAAc,IAAI,CAACF,GAAU,GAAGC,CAAU,EAAE,KAAK,GAAG,CAAC;AAE3D,GAACD,GAAU,GAAGC,CAAU,EAAE,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AA8E;AAGlG,SAAO,EAAE,QAAAgC,GAAQ,SAAAC,GAAS,SAAAC,EAAA;AAC9B;"}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
function
|
|
1
|
+
function A(e) {
|
|
2
2
|
try {
|
|
3
3
|
return JSON.parse(e), !0;
|
|
4
4
|
} catch {
|
|
5
5
|
return !1;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function p(e, t) {
|
|
9
9
|
let n = e;
|
|
10
|
-
const
|
|
11
|
-
for (let r = 0; r <
|
|
10
|
+
const s = t.length;
|
|
11
|
+
for (let r = 0; r < s; r++) {
|
|
12
12
|
if (n == null || typeof n != "object")
|
|
13
13
|
return;
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
n = n[
|
|
14
|
+
const o = t[r];
|
|
15
|
+
if (o !== void 0 && o in n)
|
|
16
|
+
n = n[o];
|
|
17
17
|
else
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
return n;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
if (
|
|
22
|
+
function c(e, t, n, s) {
|
|
23
|
+
if (s >= t.length)
|
|
24
24
|
return e;
|
|
25
|
-
const r = t[
|
|
26
|
-
if (
|
|
25
|
+
const r = t[s];
|
|
26
|
+
if (s === t.length - 1)
|
|
27
27
|
return {
|
|
28
28
|
...e,
|
|
29
29
|
[r]: n
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const o = e[r];
|
|
32
32
|
return {
|
|
33
33
|
...e,
|
|
34
|
-
[r]:
|
|
35
|
-
typeof
|
|
34
|
+
[r]: c(
|
|
35
|
+
typeof o == "object" && o !== null ? o : {},
|
|
36
36
|
t,
|
|
37
37
|
n,
|
|
38
|
-
|
|
38
|
+
s + 1
|
|
39
39
|
)
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
function g(e, t, n) {
|
|
43
|
-
return t.length === 0 ? e :
|
|
43
|
+
return t.length === 0 ? e : c(e, t, n, 0);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function f(e) {
|
|
46
46
|
if (e === null || typeof e != "object")
|
|
47
47
|
return e;
|
|
48
48
|
if (Array.isArray(e))
|
|
49
|
-
return e.map((
|
|
49
|
+
return e.map((s) => f(s));
|
|
50
50
|
if (e instanceof Date)
|
|
51
51
|
return new Date(e.getTime());
|
|
52
52
|
if (e instanceof RegExp)
|
|
@@ -55,8 +55,8 @@ function u(e) {
|
|
|
55
55
|
if (t !== Object.prototype && t !== null)
|
|
56
56
|
return e;
|
|
57
57
|
const n = {};
|
|
58
|
-
for (const
|
|
59
|
-
Object.
|
|
58
|
+
for (const s in e)
|
|
59
|
+
Object.hasOwn(e, s) && (n[s] = f(e[s]));
|
|
60
60
|
return n;
|
|
61
61
|
}
|
|
62
62
|
function y(...e) {
|
|
@@ -68,22 +68,22 @@ function y(...e) {
|
|
|
68
68
|
if (t.length === 1)
|
|
69
69
|
return t[0];
|
|
70
70
|
if (t.every(Array.isArray))
|
|
71
|
-
return
|
|
71
|
+
return t.flat();
|
|
72
72
|
if (t.every((r) => typeof r == "object" && r !== null && !Array.isArray(r))) {
|
|
73
73
|
const r = {};
|
|
74
|
-
for (const
|
|
75
|
-
const
|
|
76
|
-
for (const
|
|
77
|
-
if (Object.
|
|
78
|
-
const
|
|
79
|
-
if (Object.
|
|
80
|
-
const
|
|
81
|
-
typeof
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
) : r[
|
|
74
|
+
for (const o of t) {
|
|
75
|
+
const l = o;
|
|
76
|
+
for (const i in l)
|
|
77
|
+
if (Object.hasOwn(l, i)) {
|
|
78
|
+
const u = l[i];
|
|
79
|
+
if (Object.hasOwn(r, i)) {
|
|
80
|
+
const a = r[i];
|
|
81
|
+
typeof u == "object" && u !== null && typeof a == "object" && a !== null ? Array.isArray(u) && Array.isArray(a) ? r[i] = [...a, ...u] : !Array.isArray(u) && !Array.isArray(a) ? r[i] = y(
|
|
82
|
+
a,
|
|
83
|
+
u
|
|
84
|
+
) : r[i] = u : r[i] = u;
|
|
85
85
|
} else
|
|
86
|
-
r[
|
|
86
|
+
r[i] = u;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return r;
|
|
@@ -92,10 +92,10 @@ function y(...e) {
|
|
|
92
92
|
throw new Error(
|
|
93
93
|
"deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
|
|
94
94
|
);
|
|
95
|
-
const n = t.some(Array.isArray),
|
|
95
|
+
const n = t.some(Array.isArray), s = t.some(
|
|
96
96
|
(r) => typeof r == "object" && r !== null && !Array.isArray(r)
|
|
97
97
|
);
|
|
98
|
-
throw n &&
|
|
98
|
+
throw n && s ? new Error(
|
|
99
99
|
"deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
|
|
100
100
|
) : new Error(
|
|
101
101
|
"deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
|
|
@@ -105,30 +105,30 @@ function h(e) {
|
|
|
105
105
|
if (!e || typeof e != "object")
|
|
106
106
|
return e;
|
|
107
107
|
const t = {};
|
|
108
|
-
function n(
|
|
109
|
-
for (const
|
|
110
|
-
if (!Object.
|
|
108
|
+
function n(s, r) {
|
|
109
|
+
for (const o in s) {
|
|
110
|
+
if (!Object.hasOwn(s, o))
|
|
111
111
|
continue;
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
let
|
|
115
|
-
for (const
|
|
116
|
-
if (Object.
|
|
117
|
-
|
|
112
|
+
const l = s[o], i = r ? `${r}.${o}` : o;
|
|
113
|
+
if (l && typeof l == "object" && !Array.isArray(l)) {
|
|
114
|
+
let u = !1;
|
|
115
|
+
for (const a in l)
|
|
116
|
+
if (Object.hasOwn(l, a) && a.startsWith("$")) {
|
|
117
|
+
u = !0;
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
u ? t[i] = l : n(l, i);
|
|
121
121
|
} else
|
|
122
|
-
t[
|
|
122
|
+
t[i] = l;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
return n(e, ""), t;
|
|
126
126
|
}
|
|
127
127
|
export {
|
|
128
|
-
|
|
128
|
+
f as deepClone,
|
|
129
129
|
y as deepMerge,
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
p as getNestedValue,
|
|
131
|
+
A as isJSON,
|
|
132
132
|
h as normalizeMongoFilter,
|
|
133
133
|
g as setNestedValue
|
|
134
134
|
};
|