@cyberskill/shared 2.28.0 → 3.0.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 (91) hide show
  1. package/dist/config/config.util.cjs +1 -1
  2. package/dist/config/config.util.js +24 -33
  3. package/dist/config/eslint/index.cjs +1 -1
  4. package/dist/config/eslint/index.d.ts +4 -0
  5. package/dist/config/eslint/index.js +4 -12
  6. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
  7. package/dist/config/graphql-codegen/graphql-codegen.util.js +28 -33
  8. package/dist/config/storybook/storybook.preview.cjs +1 -1
  9. package/dist/config/storybook/storybook.preview.js +10 -13
  10. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  11. package/dist/config/vitest/vitest.e2e.js +1 -1
  12. package/dist/config/vitest/vitest.unit.cjs +1 -1
  13. package/dist/config/vitest/vitest.unit.js +19 -8
  14. package/dist/constant/common.cjs +1 -1
  15. package/dist/constant/common.js +1 -1
  16. package/dist/node/apollo-server/apollo-server.util.cjs +1 -1
  17. package/dist/node/apollo-server/apollo-server.util.js +21 -48
  18. package/dist/node/cli/index.cjs +2 -2
  19. package/dist/node/cli/index.js +109 -165
  20. package/dist/node/command/command.util.cjs +2 -2
  21. package/dist/node/command/command.util.js +135 -170
  22. package/dist/node/express/express.util.cjs +1 -1
  23. package/dist/node/express/express.util.js +39 -72
  24. package/dist/node/fs/fs.util.cjs +3 -3
  25. package/dist/node/fs/fs.util.js +45 -60
  26. package/dist/node/log/log.util.cjs +1 -1
  27. package/dist/node/log/log.util.js +29 -30
  28. package/dist/node/mongo/mongo.controller.cjs +1 -1
  29. package/dist/node/mongo/mongo.controller.js +531 -629
  30. package/dist/node/mongo/mongo.util.cjs +2 -2
  31. package/dist/node/mongo/mongo.util.js +280 -321
  32. package/dist/node/package/package.util.cjs +1 -1
  33. package/dist/node/package/package.util.js +197 -226
  34. package/dist/node/path/index.cjs +1 -1
  35. package/dist/node/path/index.js +26 -25
  36. package/dist/node/path/path.constant.cjs +1 -1
  37. package/dist/node/path/path.constant.d.ts +2 -0
  38. package/dist/node/path/path.constant.js +130 -150
  39. package/dist/node/storage/storage.util.cjs +1 -1
  40. package/dist/node/storage/storage.util.js +110 -158
  41. package/dist/node/upload/upload.util.cjs +1 -1
  42. package/dist/node/upload/upload.util.js +119 -150
  43. package/dist/node/ws/ts.util.cjs +1 -1
  44. package/dist/node/ws/ts.util.js +31 -54
  45. package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
  46. package/dist/react/apollo-client/apollo-client.component.js +4 -4
  47. package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
  48. package/dist/react/apollo-client/apollo-client.util.js +51 -58
  49. package/dist/react/apollo-client/links/upload.cjs +1 -1
  50. package/dist/react/apollo-client/links/upload.js +71 -74
  51. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
  52. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -18
  53. package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
  54. package/dist/react/apollo-error/apollo-error.component.js +61 -23
  55. package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -1
  56. package/dist/react/apollo-error/apollo-error.module.scss.js +6 -6
  57. package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
  58. package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
  59. package/dist/react/apollo-error/apollo-error.util.js +6 -6
  60. package/dist/react/loading/loading.component.cjs +2 -2
  61. package/dist/react/loading/loading.component.js +30 -46
  62. package/dist/react/log/log.util.cjs +1 -1
  63. package/dist/react/log/log.util.js +4 -4
  64. package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
  65. package/dist/react/next-intl/next-intl.hoc.js +13 -22
  66. package/dist/react/next-intl/next-intl.provider.cjs +1 -1
  67. package/dist/react/next-intl/next-intl.provider.js +7 -7
  68. package/dist/react/storage/storage.hook.cjs +1 -1
  69. package/dist/react/storage/storage.hook.js +43 -59
  70. package/dist/react/storage/storage.util.cjs +1 -1
  71. package/dist/react/storage/storage.util.js +28 -53
  72. package/dist/react/userback/userback.component.cjs +1 -1
  73. package/dist/react/userback/userback.component.js +18 -42
  74. package/dist/style.css +1 -1
  75. package/dist/util/common/common.util.cjs +1 -1
  76. package/dist/util/common/common.util.d.ts +2 -0
  77. package/dist/util/common/common.util.js +29 -37
  78. package/dist/util/index.cjs +1 -1
  79. package/dist/util/index.js +10 -9
  80. package/dist/util/object/object.util.cjs +1 -1
  81. package/dist/util/object/object.util.js +72 -76
  82. package/dist/util/string/index.cjs +1 -1
  83. package/dist/util/string/index.js +4 -3
  84. package/dist/util/string/string.util.cjs +1 -1
  85. package/dist/util/string/string.util.d.ts +12 -0
  86. package/dist/util/string/string.util.js +63 -44
  87. package/package.json +25 -16
  88. package/public/tsconfig.base.json +7 -3
  89. package/README.md +0 -470
  90. /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_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.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}/node_modules/vitest/dist/config.cjs +0 -0
  91. /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_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.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}/node_modules/vitest/dist/config.js +0 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("graphql-ws/use/ws"),i=require("ws");var S=Object.defineProperty,p=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,v=(t,r,e)=>r in t?S(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,_=(t,r)=>{for(var e in r||(r={}))d.call(r,e)&&v(t,e,r[e]);if(p)for(var e of p(r))h.call(r,e)&&v(t,e,r[e]);return t},f=(t,r,e)=>new Promise((s,o)=>{var n=c=>{try{u(e.next(c))}catch(l){o(l)}},a=c=>{try{u(e.throw(c))}catch(l){o(l)}},u=c=>c.done?s(c.value):Promise.resolve(c.value).then(n,a);u((e=e.apply(t,r)).next())});function m(t){const{server:r,path:e,sessionParser:s}=t;if(s){const o=new i.WebSocketServer({noServer:!0});return r.on("upgrade",(n,a,u)=>{try{if(new URL(n.url||"","http://localhost").pathname!==e)return;s(n,{},()=>{o.handleUpgrade(n,a,u,l=>{o.emit("connection",l,n)})})}catch(c){a.destroy()}}),o}return new i.WebSocketServer({server:r,path:e})}function w(t){const{schema:r,server:e,context:s,onConnect:o}=t;return y.useServer({schema:r,context:n=>f(null,null,function*(){const a=n.extra.request,u=s?yield s(a):{};return _({req:a},u)}),onConnect:n=>f(null,null,function*(){if(o){const a=n.extra.request;yield o(a)}})},e)}exports.createWSServer=m;exports.initGraphQLWS=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("graphql-ws/use/ws"),u=require("ws");function h(c){const{server:o,path:a,sessionParser:n}=c;if(n){const t=new u.WebSocketServer({noServer:!0});return o.on("upgrade",(e,r,s)=>{try{if(new URL(e.url||"","http://localhost").pathname!==a)return;n(e,{},()=>{t.handleUpgrade(e,r,s,i=>{t.emit("connection",i,e)})})}catch{r.destroy()}}),t}return new u.WebSocketServer({server:o,path:a})}function l(c){const{schema:o,server:a,context:n,onConnect:t}=c;return S.useServer({schema:o,context:async e=>{const r=e.extra.request,s=n?await n(r):{};return{req:r,...s}},onConnect:async e=>{if(t){const r=e.extra.request;await t(r)}}},a)}exports.createWSServer=h;exports.initGraphQLWS=l;
@@ -1,68 +1,45 @@
1
- import { useServer as m } from "graphql-ws/use/ws";
2
- import { WebSocketServer as i } from "ws";
3
- var h = Object.defineProperty, p = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable, f = (t, r, e) => r in t ? h(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, d = (t, r) => {
4
- for (var e in r || (r = {}))
5
- y.call(r, e) && f(t, e, r[e]);
6
- if (p)
7
- for (var e of p(r))
8
- _.call(r, e) && f(t, e, r[e]);
9
- return t;
10
- }, v = (t, r, e) => new Promise((l, o) => {
11
- var n = (c) => {
12
- try {
13
- s(e.next(c));
14
- } catch (u) {
15
- o(u);
16
- }
17
- }, a = (c) => {
18
- try {
19
- s(e.throw(c));
20
- } catch (u) {
21
- o(u);
22
- }
23
- }, s = (c) => c.done ? l(c.value) : Promise.resolve(c.value).then(n, a);
24
- s((e = e.apply(t, r)).next());
25
- });
26
- function S(t) {
27
- const { server: r, path: e, sessionParser: l } = t;
28
- if (l) {
29
- const o = new i({ noServer: !0 });
30
- return r.on("upgrade", (n, a, s) => {
1
+ import { useServer as p } from "graphql-ws/use/ws";
2
+ import { WebSocketServer as u } from "ws";
3
+ function f(c) {
4
+ const { server: o, path: a, sessionParser: n } = c;
5
+ if (n) {
6
+ const r = new u({ noServer: !0 });
7
+ return o.on("upgrade", (e, t, s) => {
31
8
  try {
32
- if (new URL(n.url || "", "http://localhost").pathname !== e)
9
+ if (new URL(e.url || "", "http://localhost").pathname !== a)
33
10
  return;
34
- l(n, {}, () => {
35
- o.handleUpgrade(n, a, s, (u) => {
36
- o.emit("connection", u, n);
11
+ n(e, {}, () => {
12
+ r.handleUpgrade(e, t, s, (i) => {
13
+ r.emit("connection", i, e);
37
14
  });
38
15
  });
39
- } catch (c) {
40
- a.destroy();
16
+ } catch {
17
+ t.destroy();
41
18
  }
42
- }), o;
19
+ }), r;
43
20
  }
44
- return new i({ server: r, path: e });
21
+ return new u({ server: o, path: a });
45
22
  }
46
- function x(t) {
47
- const { schema: r, server: e, context: l, onConnect: o } = t;
48
- return m(
23
+ function S(c) {
24
+ const { schema: o, server: a, context: n, onConnect: r } = c;
25
+ return p(
49
26
  {
50
- schema: r,
51
- context: (n) => v(null, null, function* () {
52
- const a = n.extra.request, s = l ? yield l(a) : {};
53
- return d({ req: a }, s);
54
- }),
55
- onConnect: (n) => v(null, null, function* () {
56
- if (o) {
57
- const a = n.extra.request;
58
- yield o(a);
27
+ schema: o,
28
+ context: async (e) => {
29
+ const t = e.extra.request, s = n ? await n(t) : {};
30
+ return { req: t, ...s };
31
+ },
32
+ onConnect: async (e) => {
33
+ if (r) {
34
+ const t = e.extra.request;
35
+ await r(t);
59
36
  }
60
- })
37
+ }
61
38
  },
62
- e
39
+ a
63
40
  );
64
41
  }
65
42
  export {
66
- S as createWSServer,
67
- x as initGraphQLWS
43
+ f as createWSServer,
44
+ S as initGraphQLWS
68
45
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@apollo/client/react"),n=require("react"),c=require("./apollo-client.context.cjs"),a=require("./apollo-client.util.cjs"),u=require("../apollo-error/apollo-error.provider.cjs"),p=require("../apollo-error/apollo-error.component.cjs"),m=require("react-hot-toast");function d(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const t=d(n);function s({options:e,children:o,onError:r}){const l=n.useMemo(()=>a.getClient(e!=null?e:{}),[e]);return t.createElement(t.Fragment,null,t.createElement(u.ApolloErrorProvider,{onError:r},t.createElement(c.ApolloClientProvider,{client:l},t.createElement(i.ApolloProvider,{client:l},o)),!r&&t.createElement(p.ApolloErrorComponent,null)),t.createElement(m.Toaster,{position:"top-right"}))}exports.ApolloProvider=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@apollo/client/react"),n=require("react"),c=require("./apollo-client.context.cjs"),a=require("./apollo-client.util.cjs"),u=require("../apollo-error/apollo-error.provider.cjs"),p=require("../apollo-error/apollo-error.component.cjs"),m=require("react-hot-toast");function s(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,l.get?l:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const t=s(n);function d({options:e,children:o,onError:r}){const l=n.useMemo(()=>a.getClient(e??{}),[e]);return t.createElement(t.Fragment,null,t.createElement(u.ApolloErrorProvider,{onError:r},t.createElement(c.ApolloClientProvider,{client:l},t.createElement(i.ApolloProvider,{client:l},o)),!r&&t.createElement(p.ApolloErrorComponent,null)),t.createElement(m.Toaster,{position:"top-right"}))}exports.ApolloProvider=d;
@@ -6,12 +6,12 @@ import { getClient as p } from "./apollo-client.util.js";
6
6
  import { ApolloErrorProvider as a } from "../apollo-error/apollo-error.provider.js";
7
7
  import { ApolloErrorComponent as c } from "../apollo-error/apollo-error.component.js";
8
8
  import { Toaster as f } from "react-hot-toast";
9
- function g({ options: r, children: l, onError: o }) {
9
+ function g({ options: o, children: l, onError: r }) {
10
10
  const t = i(
11
- () => p(r != null ? r : {}),
12
- [r]
11
+ () => p(o ?? {}),
12
+ [o]
13
13
  );
14
- return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError: o }, /* @__PURE__ */ e.createElement(n, { client: t }, /* @__PURE__ */ e.createElement(m, { client: t }, l)), !o && /* @__PURE__ */ e.createElement(c, null)), /* @__PURE__ */ e.createElement(f, { position: "top-right" }));
14
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(a, { onError: r }, /* @__PURE__ */ e.createElement(n, { client: t }, /* @__PURE__ */ e.createElement(m, { client: t }, l)), !r && /* @__PURE__ */ e.createElement(c, null)), /* @__PURE__ */ e.createElement(f, { position: "top-right" }));
15
15
  }
16
16
  export {
17
17
  g as ApolloProvider
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@apollo/client/core"),c=require("@apollo/client/link"),b=require("@apollo/client/link/error"),y=require("@apollo/client/link/remove-typename"),h=require("@apollo/client/link/subscriptions"),O=require("graphql"),q=require("graphql-ws"),E=require("react"),v=require("rxjs"),f=require("./apollo-client.constant.cjs"),m=require("./apollo-client.module.scss.cjs"),P=require("./links/upload.cjs"),p=require("../apollo-error/apollo-error.util.cjs"),i=require("../log/log.util.cjs"),d=require("react-hot-toast");function A(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const g=A(E);var C=Object.defineProperty,L=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable,k=(e,r,o)=>r in e?C(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,S=(e,r)=>{for(var o in r||(r={}))T.call(r,o)&&k(e,o,r[o]);if(L)for(var o of L(r))N.call(r,o)&&k(e,o,r[o]);return e};const $=new c.ApolloLink((e,r)=>(e.setContext({start:new Date}),r(e).pipe(v.tap(()=>{const o=new Date().getTime()-e.getContext().start;i.log.info(`Operation ${e.operationName} took ${o}ms to complete`)})))),R=new b.ErrorLink(({error:e,operation:r})=>{const o=(r==null?void 0:r.operationName)||"Unknown";let t="";s.CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:n,locations:l,path:a},u)=>{u===0&&(t=n),i.log.error(`[GraphQL error] ${o}: ${n}, Location: ${JSON.stringify(l,null,4)}, Path: ${a}`)}):s.CombinedProtocolErrors.is(e)?e.errors.forEach(({message:n,extensions:l},a)=>{a===0&&(t=n),i.log.error(`[Protocol error]: ${n}, Extensions: ${JSON.stringify(l,null,4)}`)}):s.ServerError.is(e)?(t=e.message,i.log.error(`[Server error]: ${e.message}`)):(t=e.message,i.log.error(`[Network error]: ${e.message}`)),e&&t&&typeof window!="undefined"&&(p.hasCustomApolloErrorHandler()?p.showGlobalApolloError(e):d.toast.error(n=>g.createElement("div",{className:m.default["error-container"]},t,g.createElement("button",{type:"button",className:m.default["error-details-button"],onClick:()=>{p.showGlobalApolloError(e),d.toast.dismiss(n.id)}},"Error Details"))))});function w(e){const{uri:r,wsUrl:o,customLinks:t}=e,n=new y.RemoveTypenameFromVariablesLink;r||i.log.warn(`[Apollo] No GraphQL URI provided — using "${f.GRAPHQL_URI_DEFAULT}" as default`);const l=P.createUploadLink({uri:r!=null?r:f.GRAPHQL_URI_DEFAULT,credentials:"include",headers:{"apollo-require-preflight":"true"}}),a=o?new h.GraphQLWsLink(q.createClient({url:o})):c.ApolloLink.empty(),u=o?c.ApolloLink.split(({operationType:_})=>_===O.OperationTypeNode.SUBSCRIPTION,a,l):l;return o&&u===l&&i.log.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[$,R,n,...t!=null?t:[],u]}function U(e){const r=c.ApolloLink.from(w(e));return new s.ApolloClient(S({link:r,cache:new s.InMemoryCache},e))}exports.createApolloLinks=w;exports.getClient=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@apollo/client/core"),c=require("@apollo/client/link"),b=require("@apollo/client/link/error"),w=require("@apollo/client/link/remove-typename"),q=require("@apollo/client/link/subscriptions"),h=require("graphql"),y=require("graphql-ws"),A=require("react"),E=require("rxjs"),f=require("./apollo-client.constant.cjs"),m=require("./apollo-client.module.scss.cjs"),C=require("./links/upload.cjs"),p=require("../apollo-error/apollo-error.util.cjs"),l=require("../log/log.util.cjs"),d=require("react-hot-toast");function T(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:()=>e[r]})}}return o.default=e,Object.freeze(o)}const g=T(A),N=new c.ApolloLink((e,o)=>(e.setContext({start:new Date}),o(e).pipe(E.tap(()=>{const r=new Date().getTime()-e.getContext().start;l.log.info(`Operation ${e.operationName} took ${r}ms to complete`)})))),$=new b.ErrorLink(({error:e,operation:o})=>{const r=o?.operationName||"Unknown";let t="";a.CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:n,locations:i,path:s},u)=>{u===0&&(t=n),l.log.error(`[GraphQL error] ${r}: ${n}, Location: ${JSON.stringify(i,null,4)}, Path: ${s}`)}):a.CombinedProtocolErrors.is(e)?e.errors.forEach(({message:n,extensions:i},s)=>{s===0&&(t=n),l.log.error(`[Protocol error]: ${n}, Extensions: ${JSON.stringify(i,null,4)}`)}):a.ServerError.is(e)?(t=e.message,l.log.error(`[Server error]: ${e.message}`)):(t=e.message,l.log.error(`[Network error]: ${e.message}`)),e&&t&&typeof window<"u"&&(p.hasCustomApolloErrorHandler()?p.showGlobalApolloError(e):d.toast.error(n=>g.createElement("div",{className:m.default["error-container"]},t,g.createElement("button",{type:"button",className:m.default["error-details-button"],onClick:()=>{p.showGlobalApolloError(e),d.toast.dismiss(n.id)}},"Error Details"))))});function k(e){const{uri:o,wsUrl:r,customLinks:t}=e,n=new w.RemoveTypenameFromVariablesLink;o||l.log.warn(`[Apollo] No GraphQL URI provided — using "${f.GRAPHQL_URI_DEFAULT}" as default`);const i=C.createUploadLink({uri:o??f.GRAPHQL_URI_DEFAULT,credentials:"include",headers:{"apollo-require-preflight":"true"}}),s=r?new q.GraphQLWsLink(y.createClient({url:r})):c.ApolloLink.empty(),u=r?c.ApolloLink.split(({operationType:L})=>L===h.OperationTypeNode.SUBSCRIPTION,s,i):i;return r&&u===i&&l.log.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[N,$,n,...t??[],u]}function O(e){const o=c.ApolloLink.from(k(e));return new a.ApolloClient({link:o,cache:new a.InMemoryCache,...e})}exports.createApolloLinks=k;exports.getClient=O;
@@ -1,84 +1,77 @@
1
- import { ApolloClient as y, InMemoryCache as h, CombinedGraphQLErrors as g, CombinedProtocolErrors as E, ServerError as v } from "@apollo/client/core";
2
- import { ApolloLink as m } from "@apollo/client/link";
3
- import { ErrorLink as _ } from "@apollo/client/link/error";
4
- import { RemoveTypenameFromVariablesLink as O } from "@apollo/client/link/remove-typename";
5
- import { GraphQLWsLink as P } from "@apollo/client/link/subscriptions";
6
- import { OperationTypeNode as b } from "graphql";
7
- import { createClient as C } from "graphql-ws";
1
+ import { ApolloClient as d, InMemoryCache as w, CombinedGraphQLErrors as h, CombinedProtocolErrors as E, ServerError as g } from "@apollo/client/core";
2
+ import { ApolloLink as a } from "@apollo/client/link";
3
+ import { ErrorLink as C } from "@apollo/client/link/error";
4
+ import { RemoveTypenameFromVariablesLink as y } from "@apollo/client/link/remove-typename";
5
+ import { GraphQLWsLink as N } from "@apollo/client/link/subscriptions";
6
+ import { OperationTypeNode as $ } from "graphql";
7
+ import { createClient as b } from "graphql-ws";
8
8
  import * as p from "react";
9
- import { tap as N } from "rxjs";
10
- import { GRAPHQL_URI_DEFAULT as f } from "./apollo-client.constant.js";
11
- import c from "./apollo-client.module.scss.js";
12
- import { createUploadLink as $ } from "./links/upload.js";
13
- import { hasCustomApolloErrorHandler as A, showGlobalApolloError as u } from "../apollo-error/apollo-error.util.js";
9
+ import { tap as A } from "rxjs";
10
+ import { GRAPHQL_URI_DEFAULT as c } from "./apollo-client.constant.js";
11
+ import f from "./apollo-client.module.scss.js";
12
+ import { createUploadLink as T } from "./links/upload.js";
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
- import { toast as d } from "react-hot-toast";
16
- var S = Object.defineProperty, w = Object.getOwnPropertySymbols, T = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, L = (r, e, o) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o, I = (r, e) => {
17
- for (var o in e || (e = {}))
18
- T.call(e, o) && L(r, o, e[o]);
19
- if (w)
20
- for (var o of w(e))
21
- U.call(e, o) && L(r, o, e[o]);
22
- return r;
23
- };
24
- const R = new m((r, e) => (r.setContext({ start: /* @__PURE__ */ new Date() }), e(r).pipe(
25
- N(() => {
26
- const o = (/* @__PURE__ */ new Date()).getTime() - r.getContext().start;
27
- s.info(`Operation ${r.operationName} took ${o}ms to complete`);
15
+ import { toast as L } from "react-hot-toast";
16
+ const R = new a((o, e) => (o.setContext({ start: /* @__PURE__ */ new Date() }), e(o).pipe(
17
+ A(() => {
18
+ const t = (/* @__PURE__ */ new Date()).getTime() - o.getContext().start;
19
+ s.info(`Operation ${o.operationName} took ${t}ms to complete`);
28
20
  })
29
- ))), G = new _(({ error: r, operation: e }) => {
30
- const o = (e == null ? void 0 : e.operationName) || "Unknown";
31
- let t = "";
32
- g.is(r) ? r.errors.forEach(({ message: n, locations: i, path: l }, a) => {
33
- a === 0 && (t = n), s.error(
34
- `[GraphQL error] ${o}: ${n}, Location: ${JSON.stringify(i, null, 4)}, Path: ${l}`
21
+ ))), S = new C(({ error: o, operation: e }) => {
22
+ const t = e?.operationName || "Unknown";
23
+ let i = "";
24
+ h.is(o) ? o.errors.forEach(({ message: r, locations: n, path: l }, m) => {
25
+ m === 0 && (i = r), s.error(
26
+ `[GraphQL error] ${t}: ${r}, Location: ${JSON.stringify(n, null, 4)}, Path: ${l}`
35
27
  );
36
- }) : E.is(r) ? r.errors.forEach(({ message: n, extensions: i }, l) => {
37
- l === 0 && (t = n), s.error(
38
- `[Protocol error]: ${n}, Extensions: ${JSON.stringify(i, null, 4)}`
28
+ }) : E.is(o) ? o.errors.forEach(({ message: r, extensions: n }, l) => {
29
+ l === 0 && (i = r), s.error(
30
+ `[Protocol error]: ${r}, Extensions: ${JSON.stringify(n, null, 4)}`
39
31
  );
40
- }) : v.is(r) ? (t = r.message, s.error(`[Server error]: ${r.message}`)) : (t = r.message, s.error(`[Network error]: ${r.message}`)), r && t && typeof window != "undefined" && (A() ? u(r) : d.error((n) => /* @__PURE__ */ p.createElement("div", { className: c["error-container"] }, t, /* @__PURE__ */ p.createElement(
32
+ }) : g.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(
41
33
  "button",
42
34
  {
43
35
  type: "button",
44
- className: c["error-details-button"],
36
+ className: f["error-details-button"],
45
37
  onClick: () => {
46
- u(r), d.dismiss(n.id);
38
+ u(o), L.dismiss(r.id);
47
39
  }
48
40
  },
49
41
  "Error Details"
50
42
  ))));
51
43
  });
52
- function Q(r) {
53
- const { uri: e, wsUrl: o, customLinks: t } = r, n = new O();
54
- e || s.warn(`[Apollo] No GraphQL URI provided — using "${f}" as default`);
55
- const i = $({
56
- uri: e != null ? e : f,
44
+ function v(o) {
45
+ const { uri: e, wsUrl: t, customLinks: i } = o, r = new y();
46
+ e || s.warn(`[Apollo] No GraphQL URI provided — using "${c}" as default`);
47
+ const n = T({
48
+ uri: e ?? c,
57
49
  credentials: "include",
58
50
  headers: {
59
51
  "apollo-require-preflight": "true"
60
52
  }
61
- }), l = o ? new P(C({ url: o })) : m.empty(), a = o ? m.split(
62
- ({ operationType: k }) => k === b.SUBSCRIPTION,
53
+ }), l = t ? new N(b({ url: t })) : a.empty(), m = t ? a.split(
54
+ ({ operationType: k }) => k === $.SUBSCRIPTION,
63
55
  l,
64
- i
65
- ) : i;
66
- return o && a === i && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
56
+ n
57
+ ) : n;
58
+ return t && m === n && s.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
67
59
  R,
68
- G,
69
- n,
70
- ...t != null ? t : [],
71
- a
60
+ S,
61
+ r,
62
+ ...i ?? [],
63
+ m
72
64
  ];
73
65
  }
74
- function Y(r) {
75
- const e = m.from(Q(r));
76
- return new y(I({
66
+ function B(o) {
67
+ const e = a.from(v(o));
68
+ return new d({
77
69
  link: e,
78
- cache: new h()
79
- }, r));
70
+ cache: new w(),
71
+ ...o
72
+ });
80
73
  }
81
74
  export {
82
- Q as createApolloLinks,
83
- Y as getClient
75
+ v as createApolloLinks,
76
+ B as getClient
84
77
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@apollo/client/link"),c=require("@apollo/client/link/http"),w=require("@apollo/client/utilities"),T=require("extract-files/extractFiles.mjs"),j=require("extract-files/isExtractableFile.mjs");var G=Object.defineProperty,_=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,E=(n,e,t)=>e in n?G(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&E(n,t,e[t]);if(_)for(var t of _(e))J.call(e,t)&&E(n,t,e[t]);return n};function N(){if(typeof AbortController=="undefined")return{controller:!1,signal:!1};const n=new AbortController,e=n.signal;return{controller:n,signal:e}}function z(n,e,t){"name"in t?n.append(e,t,t.name):n.append(e,t)}function B({uri:n="/graphql",useGETForQueries:e,isExtractableFile:t=j,FormData:v,formDataAppendFile:F=z,print:S=c.defaultPrinter,fetch:q,fetchOptions:x,credentials:P,headers:A,includeExtensions:C}={}){const I={http:{includeExtensions:C},options:x,credentials:P,headers:A};return new L.ApolloLink(l=>{const p=l.getContext(),{clientAwareness:{name:g,version:m}={},headers:k}=p,U={http:p.http,options:p.fetchOptions,credentials:p.credentials,headers:h(h(h({},g&&{"apollographql-client-name":g}),m&&{"apollographql-client-version":m}),k)},{options:o,body:b}=c.selectHttpOptionsAndBodyInternal(l,S,c.fallbackHttpConfig,I,U),{clone:y,files:f}=T(b,t,"");let u=c.selectURI(l,n);if(f.size){o.headers&&delete o.headers["content-type"];const a=v||FormData,i=new a;i.append("operations",JSON.stringify(y));const r={};let d=0;f.forEach(O=>{r[++d]=O}),i.append("map",JSON.stringify(r)),d=0,f.forEach((O,R)=>{F(i,String(++d),R)}),o.body=i}else if(e&&!l.query.definitions.some(a=>a.kind==="OperationDefinition"&&a.operation==="mutation")&&(o.method="GET"),o.method==="GET"){const{newURI:a,parseError:i}=c.rewriteURIForGET(u,b);if(i)return new w.Observable(r=>{r.error(i)});u=a}else o.body=JSON.stringify(y);const{controller:s}=N();typeof s!="boolean"&&(o.signal&&(o.signal.aborted?s.abort():o.signal.addEventListener("abort",()=>{s.abort()},{once:!0})),o.signal=s.signal);const D=q||fetch;return new w.Observable(a=>{let i;return D(u,o).then(r=>(l.setContext({response:r}),r)).then(c.parseAndCheckHttpResponse(l)).then(r=>{a.next(r),a.complete()}).catch(r=>{i||(r.result&&r.result.errors&&r.result.data&&a.next(r.result),a.error(r))}),()=>{i=!0,typeof s!="boolean"&&s.abort()}})})}exports.createUploadLink=B;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@apollo/client/link"),c=require("@apollo/client/link/http"),F=require("@apollo/client/utilities"),T=require("extract-files/extractFiles.mjs"),v=require("extract-files/isExtractableFile.mjs");function G(){if(typeof AbortController>"u")return{controller:!1,signal:!1};const o=new AbortController,i=o.signal;return{controller:o,signal:i}}function H(o,i,a){"name"in a?o.append(i,a,a.name):o.append(i,a)}function J({uri:o="/graphql",useGETForQueries:i,isExtractableFile:a=v,FormData:q,formDataAppendFile:x=H,print:E=c.defaultPrinter,fetch:O,fetchOptions:k,credentials:w,headers:A,includeExtensions:C}={}){const S={http:{includeExtensions:C},options:k,credentials:w,headers:A};return new L.ApolloLink(l=>{const p=l.getContext(),{clientAwareness:{name:h,version:g}={},headers:U}=p,D={http:p.http,options:p.fetchOptions,credentials:p.credentials,headers:{...h&&{"apollographql-client-name":h},...g&&{"apollographql-client-version":g},...U}},{options:t,body:b}=c.selectHttpOptionsAndBodyInternal(l,E,c.fallbackHttpConfig,S,D),{clone:m,files:f}=T(b,a,"");let d=c.selectURI(l,o);if(f.size){t.headers&&delete t.headers["content-type"];const n=q||FormData,r=new n;r.append("operations",JSON.stringify(m));const e={};let u=0;f.forEach(y=>{e[++u]=y}),r.append("map",JSON.stringify(e)),u=0,f.forEach((y,R)=>{x(r,String(++u),R)}),t.body=r}else if(i&&!l.query.definitions.some(n=>n.kind==="OperationDefinition"&&n.operation==="mutation")&&(t.method="GET"),t.method==="GET"){const{newURI:n,parseError:r}=c.rewriteURIForGET(d,b);if(r)return new F.Observable(e=>{e.error(r)});d=n}else t.body=JSON.stringify(m);const{controller:s}=G();typeof s!="boolean"&&(t.signal&&(t.signal.aborted?s.abort():t.signal.addEventListener("abort",()=>{s.abort()},{once:!0})),t.signal=s.signal);const I=O||fetch;return new F.Observable(n=>{let r;return I(d,t).then(e=>(l.setContext({response:e}),e)).then(c.parseAndCheckHttpResponse(l)).then(e=>{n.next(e),n.complete()}).catch(e=>{r||(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))}),()=>{r=!0,typeof s!="boolean"&&s.abort()}})})}exports.createUploadLink=J;
@@ -1,88 +1,85 @@
1
1
  import { ApolloLink as q } from "@apollo/client/link";
2
- import { selectHttpOptionsAndBodyInternal as G, defaultPrinter as H, fallbackHttpConfig as J, selectURI as L, rewriteURIForGET as N, parseAndCheckHttpResponse as T } from "@apollo/client/link/http";
3
- import { Observable as O } from "@apollo/client/utilities";
4
- import j from "extract-files/extractFiles.mjs";
2
+ import { selectHttpOptionsAndBodyInternal as G, defaultPrinter as H, fallbackHttpConfig as J, selectURI as L, rewriteURIForGET as T, parseAndCheckHttpResponse as N } from "@apollo/client/link/http";
3
+ import { Observable as y } from "@apollo/client/utilities";
4
+ import v from "extract-files/extractFiles.mjs";
5
5
  import z from "extract-files/isExtractableFile.mjs";
6
- var B = Object.defineProperty, w = Object.getOwnPropertySymbols, V = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable, _ = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, m = (n, t) => {
7
- for (var e in t || (t = {}))
8
- V.call(t, e) && _(n, e, t[e]);
9
- if (w)
10
- for (var e of w(t))
11
- K.call(t, e) && _(n, e, t[e]);
12
- return n;
13
- };
14
- function M() {
15
- if (typeof AbortController == "undefined")
6
+ function B() {
7
+ if (typeof AbortController > "u")
16
8
  return { controller: !1, signal: !1 };
17
- const n = new AbortController(), t = n.signal;
18
- return { controller: n, signal: t };
9
+ const r = new AbortController(), i = r.signal;
10
+ return { controller: r, signal: i };
19
11
  }
20
- function Q(n, t, e) {
21
- "name" in e ? n.append(t, e, e.name) : n.append(t, e);
12
+ function P(r, i, a) {
13
+ "name" in a ? r.append(i, a, a.name) : r.append(i, a);
22
14
  }
23
- function tt({
24
- uri: n = "/graphql",
25
- useGETForQueries: t,
26
- isExtractableFile: e = z,
27
- FormData: E,
28
- formDataAppendFile: x = Q,
29
- print: F = H,
30
- fetch: v,
15
+ function V({
16
+ uri: r = "/graphql",
17
+ useGETForQueries: i,
18
+ isExtractableFile: a = z,
19
+ FormData: x,
20
+ formDataAppendFile: F = P,
21
+ print: E = H,
22
+ fetch: w,
31
23
  fetchOptions: A,
32
24
  credentials: C,
33
- headers: P,
34
- includeExtensions: S
25
+ headers: O,
26
+ includeExtensions: k
35
27
  } = {}) {
36
- const I = {
37
- http: { includeExtensions: S },
28
+ const S = {
29
+ http: { includeExtensions: k },
38
30
  options: A,
39
31
  credentials: C,
40
- headers: P
32
+ headers: O
41
33
  };
42
34
  return new q((l) => {
43
- const p = l.getContext(), {
35
+ const c = l.getContext(), {
44
36
  // Apollo Studio client awareness `name` and `version` can be configured
45
37
  // via `ApolloClient` constructor options:
46
38
  // https://www.apollographql.com/docs/graphos/metrics/client-awareness/#setup
47
- clientAwareness: { name: u, version: h } = {},
39
+ clientAwareness: { name: m, version: h } = {},
48
40
  headers: D
49
- } = p, R = {
50
- http: p.http,
51
- options: p.fetchOptions,
52
- credentials: p.credentials,
53
- headers: m(m(m({}, u && { "apollographql-client-name": u }), h && { "apollographql-client-version": h }), D)
54
- }, { options: o, body: g } = G(
41
+ } = c, I = {
42
+ http: c.http,
43
+ options: c.fetchOptions,
44
+ credentials: c.credentials,
45
+ headers: {
46
+ // Client awareness headers can be overridden by context `headers`.
47
+ ...m && { "apollographql-client-name": m },
48
+ ...h && { "apollographql-client-version": h },
49
+ ...D
50
+ }
51
+ }, { options: e, body: u } = G(
55
52
  l,
56
- F,
53
+ E,
57
54
  J,
58
- I,
59
- R
60
- ), { clone: y, files: c } = j(g, e, "");
61
- let f = L(l, n);
62
- if (c.size) {
63
- o.headers && delete o.headers["content-type"];
64
- const a = E || FormData, i = new a();
65
- i.append("operations", JSON.stringify(y));
66
- const r = {};
55
+ S,
56
+ I
57
+ ), { clone: g, files: p } = v(u, a, "");
58
+ let f = L(l, r);
59
+ if (p.size) {
60
+ e.headers && delete e.headers["content-type"];
61
+ const n = x || FormData, o = new n();
62
+ o.append("operations", JSON.stringify(g));
63
+ const t = {};
67
64
  let d = 0;
68
- c.forEach((b) => {
69
- r[++d] = b;
70
- }), i.append("map", JSON.stringify(r)), d = 0, c.forEach((b, k) => {
71
- x(i, String(++d), k);
72
- }), o.body = i;
73
- } else if (t && !l.query.definitions.some(
74
- (a) => a.kind === "OperationDefinition" && a.operation === "mutation"
75
- ) && (o.method = "GET"), o.method === "GET") {
76
- const { newURI: a, parseError: i } = N(f, g);
77
- if (i)
78
- return new O((r) => {
79
- r.error(i);
65
+ p.forEach((b) => {
66
+ t[++d] = b;
67
+ }), o.append("map", JSON.stringify(t)), d = 0, p.forEach((b, U) => {
68
+ F(o, String(++d), U);
69
+ }), e.body = o;
70
+ } else if (i && !l.query.definitions.some(
71
+ (n) => n.kind === "OperationDefinition" && n.operation === "mutation"
72
+ ) && (e.method = "GET"), e.method === "GET") {
73
+ const { newURI: n, parseError: o } = T(f, u);
74
+ if (o)
75
+ return new y((t) => {
76
+ t.error(o);
80
77
  });
81
- f = a;
78
+ f = n;
82
79
  } else
83
- o.body = JSON.stringify(y);
84
- const { controller: s } = M();
85
- typeof s != "boolean" && (o.signal && (o.signal.aborted ? s.abort() : o.signal.addEventListener(
80
+ e.body = JSON.stringify(g);
81
+ const { controller: s } = B();
82
+ typeof s != "boolean" && (e.signal && (e.signal.aborted ? s.abort() : e.signal.addEventListener(
86
83
  "abort",
87
84
  () => {
88
85
  s.abort();
@@ -92,20 +89,20 @@ function tt({
92
89
  // is long lasting, or controls multiple things.
93
90
  once: !0
94
91
  }
95
- )), o.signal = s.signal);
96
- const U = v || fetch;
97
- return new O((a) => {
98
- let i;
99
- return U(f, o).then((r) => (l.setContext({ response: r }), r)).then(T(l)).then((r) => {
100
- a.next(r), a.complete();
101
- }).catch((r) => {
102
- i || (r.result && r.result.errors && r.result.data && a.next(r.result), a.error(r));
92
+ )), e.signal = s.signal);
93
+ const R = w || fetch;
94
+ return new y((n) => {
95
+ let o;
96
+ return R(f, e).then((t) => (l.setContext({ response: t }), t)).then(N(l)).then((t) => {
97
+ n.next(t), n.complete();
98
+ }).catch((t) => {
99
+ o || (t.result && t.result.errors && t.result.data && n.next(t.result), n.error(t));
103
100
  }), () => {
104
- i = !0, typeof s != "boolean" && s.abort();
101
+ o = !0, typeof s != "boolean" && s.abort();
105
102
  };
106
103
  });
107
104
  });
108
105
  }
109
106
  export {
110
- tt as createUploadLink
107
+ V as createUploadLink
111
108
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@apollo/client-integration-nextjs"),i=require("@apollo/client/link"),a=require("../apollo-client/apollo-client.util.cjs");var p=Object.defineProperty,o=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,l=(r,e,t)=>e in r?p(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))c.call(e,t)&&l(r,t,e[t]);if(o)for(var t of o(e))u.call(e,t)&&l(r,t,e[t]);return r};function s(r={}){const e=i.ApolloLink.from(a.createApolloLinks(r));return new n.ApolloClient(f({link:e,cache:new n.InMemoryCache},r))}exports.getClient=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@apollo/client-integration-nextjs"),l=require("@apollo/client/link"),i=require("../apollo-client/apollo-client.util.cjs");function o(e={}){const t=l.ApolloLink.from(i.createApolloLinks(e));return new n.ApolloClient({link:t,cache:new n.InMemoryCache,...e})}exports.getClient=o;
@@ -1,21 +1,14 @@
1
- import { ApolloClient as l, InMemoryCache as p } from "@apollo/client-integration-nextjs";
2
- import { ApolloLink as a } from "@apollo/client/link";
3
- import { createApolloLinks as i } from "../apollo-client/apollo-client.util.js";
4
- var f = Object.defineProperty, t = Object.getOwnPropertySymbols, m = Object.prototype.hasOwnProperty, c = Object.prototype.propertyIsEnumerable, n = (e, r, o) => r in e ? f(e, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[r] = o, _ = (e, r) => {
5
- for (var o in r || (r = {}))
6
- m.call(r, o) && n(e, o, r[o]);
7
- if (t)
8
- for (var o of t(r))
9
- c.call(r, o) && n(e, o, r[o]);
10
- return e;
11
- };
12
- function v(e = {}) {
13
- const r = a.from(i(e));
14
- return new l(_({
15
- link: r,
16
- cache: new p()
17
- }, e));
1
+ import { ApolloClient as r, InMemoryCache as n } from "@apollo/client-integration-nextjs";
2
+ import { ApolloLink as t } from "@apollo/client/link";
3
+ import { createApolloLinks as l } from "../apollo-client/apollo-client.util.js";
4
+ function p(o = {}) {
5
+ const e = t.from(l(o));
6
+ return new r({
7
+ link: e,
8
+ cache: new n(),
9
+ ...o
10
+ });
18
11
  }
19
12
  export {
20
- v as getClient
13
+ p as getClient
21
14
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),a=require("../../util/validate/validate.util.cjs"),i=require("./apollo-error.context.cjs"),o=require("./apollo-error.module.scss.cjs");function c(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,l.get?l:{enumerable:!0,get:()=>r[n]})}}return e.default=r,Object.freeze(e)}const t=c(s);function u(){const r=s.use(i.ApolloErrorContext),e=r==null?void 0:r.error;if(!e)return null;const n="locations"in e||"path"in e||"extensions"in e,l="message"in e?e.message:"Unknown error occurred";return t.createElement("div",{className:o.default["modal-backdrop"]},t.createElement("div",{className:o.default["modal-content"]},t.createElement("button",{type:"button",className:o.default["btn-close"],onClick:r.hideError},"✕"),t.createElement("div",{className:o.default["error-title"]},t.createElement("button",{type:"button",className:o.default["btn-retry"],onClick:()=>window.location.reload()},"Reload")," ",!a.validate.isEmpty(e)&&l),t.createElement("div",{className:o.default["error-details"]},n&&"locations"in e&&e.locations&&t.createElement("pre",{className:"locations"},t.createElement("strong",null,"Locations:")," ",JSON.stringify(e.locations,null,4)),n&&"path"in e&&e.path&&t.createElement("pre",{className:"path"},t.createElement("strong",null,"Path:")," ",JSON.stringify(e.path,null,4)),n&&"extensions"in e&&e.extensions&&t.createElement("pre",{className:"extensions"},t.createElement("strong",null,"Extensions:")," ",JSON.stringify(e.extensions,null,4)),!n&&t.createElement("pre",{className:"error-details"},t.createElement("strong",null,"Error Details:")," ",a.validate.isEmpty(e)?l:JSON.stringify(e,null,4)))))}exports.ApolloErrorComponent=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),E=require("../../util/validate/validate.util.cjs"),y=require("./apollo-error.context.cjs"),s=require("./apollo-error.module.scss.cjs");function g(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const r in l)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(l,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>l[r]})}}return e.default=l,Object.freeze(e)}const t=g(i),h='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function v(){const l=i.use(y.ApolloErrorContext),{error:e,hideError:r}=l??{},n=i.useRef(null),c=i.useRef(null);i.useEffect(()=>{if(!e||!r)return;const o=a=>{a.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[e,r]),i.useEffect(()=>{e&&n.current?(c.current=document.activeElement,n.current.focus()):!e&&c.current&&(c.current.focus(),c.current=null)},[e]);const p=o=>{if(o.key!=="Tab"||!n.current)return;const a=Array.from(n.current.querySelectorAll(h)).filter(b=>!b.hasAttribute("disabled"));if(a.length===0)return;const d=a[0],f=a[a.length-1];!d||!f||(o.shiftKey?document.activeElement===d&&(o.preventDefault(),f.focus()):document.activeElement===f&&(o.preventDefault(),d.focus()))};if(!e)return null;const u="locations"in e||"path"in e||"extensions"in e,m="message"in e?e.message:"Unknown error occurred";return t.createElement("div",{className:s.default["modal-backdrop"]},t.createElement("div",{ref:n,className:s.default["modal-content"],role:"dialog","aria-modal":"true","aria-labelledby":"apollo-error-title",tabIndex:-1,onKeyDown:p},t.createElement("button",{type:"button",className:s.default["btn-close"],onClick:r,"aria-label":"Close error details",title:"Close error details"},"✕"),t.createElement("div",{id:"apollo-error-title",className:s.default["error-title"]},t.createElement("button",{type:"button",className:s.default["btn-retry"],onClick:()=>window.location.reload(),"aria-label":"Reload page"},"Reload")," ",!E.validate.isEmpty(e)&&m),t.createElement("div",{className:s.default["error-details"]},u&&"locations"in e&&e.locations&&t.createElement("pre",{className:"locations"},t.createElement("strong",null,"Locations:")," ",JSON.stringify(e.locations,null,4)),u&&"path"in e&&e.path&&t.createElement("pre",{className:"path"},t.createElement("strong",null,"Path:")," ",JSON.stringify(e.path,null,4)),u&&"extensions"in e&&e.extensions&&t.createElement("pre",{className:"extensions"},t.createElement("strong",null,"Extensions:")," ",JSON.stringify(e.extensions,null,4)),!u&&t.createElement("pre",{className:"error-details"},t.createElement("strong",null,"Error Details:")," ",E.validate.isEmpty(e)?m:JSON.stringify(e,null,4)))))}exports.ApolloErrorComponent=v;