@cyberskill/shared 2.14.0 → 2.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.
- package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.component.js +4 -4
- package/dist/react/apollo-client/apollo-client.context.d.ts +3 -3
- package/dist/react/apollo-client/apollo-client.hook.d.ts +2 -2
- package/dist/react/apollo-client/apollo-client.type.d.ts +5 -4
- package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.util.d.ts +3 -30
- package/dist/react/apollo-client/apollo-client.util.js +72 -107
- package/dist/react/apollo-client/index.cjs +1 -1
- package/dist/react/apollo-client/index.d.ts +2 -2
- package/dist/react/apollo-client/index.js +18 -19
- package/dist/react/apollo-client/links/index.cjs +1 -0
- package/dist/react/apollo-client/links/index.d.ts +1 -0
- package/dist/react/apollo-client/links/index.js +4 -0
- package/dist/react/apollo-client/links/upload.cjs +1 -0
- package/dist/react/apollo-client/links/upload.d.ts +76 -0
- package/dist/react/apollo-client/links/upload.js +111 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +2 -2
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.d.ts +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +6 -6
- package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.component.d.ts +1 -3
- package/dist/react/apollo-error/apollo-error.component.js +14 -14
- package/dist/react/apollo-error/apollo-error.type.d.ts +4 -4
- package/dist/react/apollo-error/apollo-error.util.d.ts +3 -3
- package/package.json +17 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@apollo/client/react"),e=require("react"),n=require("./apollo-client.context.cjs"),i=require("./apollo-client.util.cjs"),a=require("../apollo-error/apollo-error.provider.cjs"),u=require("../apollo-error/apollo-error.component.cjs"),c=require("react-hot-toast");function p({options:r,children:l}){const o=e.useMemo(()=>i.getClient(r!=null?r:{}),[r]);return e.createElement(e.Fragment,null,e.createElement(a.ApolloErrorProvider,null,e.createElement(n.ApolloClientProvider,{client:o},e.createElement(t.ApolloProvider,{client:o},l)),e.createElement(u.ApolloErrorComponent,null)),e.createElement(c.Toaster,{position:"top-right"}))}exports.ApolloProvider=p;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ApolloProvider as l } from "@apollo/client/react
|
|
1
|
+
import { ApolloProvider as l } from "@apollo/client/react";
|
|
2
2
|
import r, { useMemo as m } from "react";
|
|
3
3
|
import { ApolloClientProvider as n } from "./apollo-client.context.js";
|
|
4
4
|
import { getClient as i } from "./apollo-client.util.js";
|
|
5
5
|
import { ApolloErrorProvider as p } from "../apollo-error/apollo-error.provider.js";
|
|
6
6
|
import { ApolloErrorComponent as a } from "../apollo-error/apollo-error.component.js";
|
|
7
7
|
import { Toaster as c } from "react-hot-toast";
|
|
8
|
-
function
|
|
8
|
+
function g({ options: e, children: t }) {
|
|
9
9
|
const o = m(
|
|
10
|
-
() => i(e
|
|
10
|
+
() => i(e != null ? e : {}),
|
|
11
11
|
[e]
|
|
12
12
|
);
|
|
13
13
|
return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(p, null, /* @__PURE__ */ r.createElement(n, { client: o }, /* @__PURE__ */ r.createElement(l, { client: o }, t)), /* @__PURE__ */ r.createElement(a, null)), /* @__PURE__ */ r.createElement(c, { position: "top-right" }));
|
|
14
14
|
}
|
|
15
15
|
export {
|
|
16
|
-
|
|
16
|
+
g as ApolloProvider
|
|
17
17
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ApolloClient
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* React context for providing Apollo Client instance to child components.
|
|
5
5
|
* This context allows components to access the Apollo Client instance without
|
|
6
6
|
* prop drilling, enabling direct access to client methods and cache operations.
|
|
7
7
|
*/
|
|
8
|
-
declare const ApolloClientContext: React.Context<ApolloClient
|
|
8
|
+
declare const ApolloClientContext: React.Context<ApolloClient | null>;
|
|
9
9
|
/**
|
|
10
10
|
* Provider component that makes Apollo Client available to the component tree.
|
|
11
11
|
* This component wraps the Apollo Client instance in a React context, allowing
|
|
@@ -17,7 +17,7 @@ declare const ApolloClientContext: React.Context<ApolloClient<NormalizedCacheObj
|
|
|
17
17
|
* @returns A React component that provides Apollo Client context to its children.
|
|
18
18
|
*/
|
|
19
19
|
export declare function ApolloClientProvider({ client, children, }: {
|
|
20
|
-
client: ApolloClient
|
|
20
|
+
client: ApolloClient;
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
}): React.JSX.Element;
|
|
23
23
|
export { ApolloClientContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApolloClient
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
2
|
/**
|
|
3
3
|
* React hook that provides access to the Apollo Client instance.
|
|
4
4
|
* This hook retrieves the Apollo Client from the React context and provides
|
|
@@ -11,4 +11,4 @@ import { ApolloClient, NormalizedCacheObject } from '@apollo/client';
|
|
|
11
11
|
* @returns The Apollo Client instance from the nearest ApolloClientProvider context.
|
|
12
12
|
* @throws {Error} When used outside of an ApolloClientProvider context.
|
|
13
13
|
*/
|
|
14
|
-
export declare function useApolloClient(): ApolloClient
|
|
14
|
+
export declare function useApolloClient(): ApolloClient;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
|
+
import { ApolloLink } from '@apollo/client/link';
|
|
2
3
|
import { I_Children } from '../../typescript/index.js';
|
|
3
|
-
export interface I_ApolloOptions extends Omit<
|
|
4
|
-
uri?: string
|
|
4
|
+
export interface I_ApolloOptions extends Omit<ApolloClient.Options, 'link' | 'cache'> {
|
|
5
|
+
uri?: string;
|
|
5
6
|
wsUrl?: string;
|
|
6
7
|
customLinks?: ApolloLink[];
|
|
7
8
|
}
|
|
@@ -9,4 +10,4 @@ export interface I_ApolloProviderProps extends I_Children {
|
|
|
9
10
|
isNextJS?: boolean;
|
|
10
11
|
options?: I_ApolloOptions;
|
|
11
12
|
}
|
|
12
|
-
export type { ApolloCache, ApolloClient
|
|
13
|
+
export type { ApolloCache, ApolloClient } from '@apollo/client';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@apollo/client/core"),p=require("@apollo/client/link"),w=require("@apollo/client/link/error"),h=require("@apollo/client/link/remove-typename"),y=require("@apollo/client/link/subscriptions"),_=require("graphql"),q=require("graphql-ws"),c=require("react"),b=require("rxjs"),m=require("./apollo-client.constant.cjs"),v=require("./links/upload.cjs"),E=require("../apollo-error/apollo-error.util.cjs"),l=require("../log/log.util.cjs"),f=require("react-hot-toast");var P=Object.defineProperty,g=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,L=(e,r,o)=>r in e?P(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,T=(e,r)=>{for(var o in r||(r={}))A.call(r,o)&&L(e,o,r[o]);if(g)for(var o of g(r))O.call(r,o)&&L(e,o,r[o]);return e};const C=new p.ApolloLink((e,r)=>(e.setContext({start:new Date}),r(e).pipe(b.tap(()=>{const o=new Date().getTime()-e.getContext().start;l.log.info(`Operation ${e.operationName} took ${o}ms to complete`)})))),S=new w.ErrorLink(({error:e,operation:r})=>{const o=(r==null?void 0:r.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] ${o}: ${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!="undefined"&&f.toast.error(n=>c.createElement(c.Fragment,null,t," ",c.createElement("button",{type:"button",className:"text-blue-500 hover:text-blue-700",onClick:()=>{setTimeout(()=>{E.showGlobalApolloError(e)},0),f.toast.dismiss(n.id)}},"Show Details")))});function d(e){const{uri:r,wsUrl:o,customLinks:t}=e,n=new h.RemoveTypenameFromVariablesLink;r||l.log.warn(`[Apollo] No GraphQL URI provided — using "${m.GRAPHQL_URI_DEFAULT}" as default`);const i=v.createUploadLink({uri:r!=null?r:m.GRAPHQL_URI_DEFAULT,credentials:"include",headers:{"apollo-require-preflight":"true"}}),s=o?new y.GraphQLWsLink(q.createClient({url:o})):p.ApolloLink.empty(),u=o?p.ApolloLink.split(({operationType:k})=>k===_.OperationTypeNode.SUBSCRIPTION,s,i):i;return o&&u===i&&l.log.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[C,S,n,...t!=null?t:[],u]}function $(e){const r=p.ApolloLink.from(d(e));return new a.ApolloClient(T({link:r,cache:new a.InMemoryCache},e))}exports.createApolloLinks=d;exports.getClient=$;
|
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ApolloClient } from '@apollo/client/core/core.cjs';
|
|
4
|
-
import { ApolloLink } from '@apollo/client/link/core/core.cjs';
|
|
1
|
+
import { ApolloClient } from '@apollo/client/core';
|
|
2
|
+
import { ApolloLink } from '@apollo/client/link';
|
|
5
3
|
import { I_ApolloOptions } from './apollo-client.type.js';
|
|
6
|
-
/**
|
|
7
|
-
* Custom Apollo Link for development logging of GraphQL operations.
|
|
8
|
-
* This link intercepts GraphQL operations and logs detailed information about
|
|
9
|
-
* each request including operation name, duration, and request count for debugging
|
|
10
|
-
* and performance monitoring purposes.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Request counting for tracking operation frequency
|
|
14
|
-
* - Duration measurement for performance analysis
|
|
15
|
-
* - Operation name logging for easy identification
|
|
16
|
-
* - Development-only logging to avoid production noise
|
|
17
|
-
*/
|
|
18
|
-
export declare class DevLoggerLink extends ApolloLink {
|
|
19
|
-
private count;
|
|
20
|
-
/**
|
|
21
|
-
* Intercepts and logs GraphQL operations during development.
|
|
22
|
-
* This method wraps each GraphQL operation with timing and logging functionality,
|
|
23
|
-
* providing insights into operation performance and frequency.
|
|
24
|
-
*
|
|
25
|
-
* @param operation - The GraphQL operation to be logged and executed.
|
|
26
|
-
* @param forward - Function to forward the operation to the next link in the chain.
|
|
27
|
-
* @returns An observable that emits the operation result with logging side effects.
|
|
28
|
-
*/
|
|
29
|
-
request(operation: Operation, forward: (op: Operation) => Observable<FetchResult>): Observable<FetchResult>;
|
|
30
|
-
}
|
|
31
4
|
/**
|
|
32
5
|
* Creates a comprehensive Apollo Link chain with all necessary middleware.
|
|
33
6
|
* This function sets up a complete Apollo Link chain including error handling,
|
|
@@ -56,4 +29,4 @@ export declare function createApolloLinks(options: I_ApolloOptions): ApolloLink[
|
|
|
56
29
|
* @param options - Configuration options for the Apollo Client including links, cache, and other settings.
|
|
57
30
|
* @returns A fully configured Apollo Client instance ready for use.
|
|
58
31
|
*/
|
|
59
|
-
export declare function getClient(options
|
|
32
|
+
export declare function getClient(options: I_ApolloOptions): ApolloClient;
|
|
@@ -1,120 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApolloLink as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { GraphQLWsLink as
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { ApolloClient as L, InMemoryCache as k, CombinedGraphQLErrors as h, CombinedProtocolErrors as g, ServerError as y } from "@apollo/client/core";
|
|
2
|
+
import { ApolloLink as m } from "@apollo/client/link";
|
|
3
|
+
import { ErrorLink as v } from "@apollo/client/link/error";
|
|
4
|
+
import { RemoveTypenameFromVariablesLink as _ } from "@apollo/client/link/remove-typename";
|
|
5
|
+
import { GraphQLWsLink as b } from "@apollo/client/link/subscriptions";
|
|
6
|
+
import { OperationTypeNode as E } from "graphql";
|
|
7
|
+
import { createClient as O } from "graphql-ws";
|
|
8
|
+
import p from "react";
|
|
9
|
+
import { tap as P } from "rxjs";
|
|
10
|
+
import { GRAPHQL_URI_DEFAULT as f } from "./apollo-client.constant.js";
|
|
11
|
+
import { createUploadLink as C } from "./links/upload.js";
|
|
12
|
+
import { showGlobalApolloError as N } from "../apollo-error/apollo-error.util.js";
|
|
13
|
+
import { log as l } from "../log/log.util.js";
|
|
14
|
+
import { toast as c } from "react-hot-toast";
|
|
15
|
+
var $ = Object.defineProperty, u = Object.getOwnPropertySymbols, S = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, w = (r, e, o) => e in r ? $(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o, A = (r, e) => {
|
|
15
16
|
for (var o in e || (e = {}))
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
for (var o of
|
|
19
|
-
|
|
17
|
+
S.call(e, o) && w(r, o, e[o]);
|
|
18
|
+
if (u)
|
|
19
|
+
for (var o of u(e))
|
|
20
|
+
T.call(e, o) && w(r, o, e[o]);
|
|
20
21
|
return r;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
graphQLErrors: t || [],
|
|
58
|
-
protocolErrors: i || [],
|
|
59
|
-
clientErrors: [],
|
|
60
|
-
networkError: n || null,
|
|
61
|
-
errorMessage: l,
|
|
62
|
-
extraInfo: {
|
|
63
|
-
operation: d
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
typeof window != "undefined" && O.error((v) => /* @__PURE__ */ w.createElement(w.Fragment, null, l, " ", /* @__PURE__ */ w.createElement(
|
|
67
|
-
"button",
|
|
68
|
-
{
|
|
69
|
-
type: "button",
|
|
70
|
-
className: "text-blue-500 hover:text-blue-700",
|
|
71
|
-
onClick: () => {
|
|
72
|
-
setTimeout(() => {
|
|
73
|
-
F(a);
|
|
74
|
-
}, 0), O.dismiss(v.id);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"Show Details"
|
|
78
|
-
)));
|
|
79
|
-
}
|
|
80
|
-
}), p = I();
|
|
81
|
-
e || s.warn(`[Apollo] No GraphQL URI provided — using "${k}" as default`);
|
|
82
|
-
const f = G({
|
|
83
|
-
uri: e != null ? e : k,
|
|
22
|
+
};
|
|
23
|
+
const U = new m((r, e) => (r.setContext({ start: /* @__PURE__ */ new Date() }), e(r).pipe(
|
|
24
|
+
P(() => {
|
|
25
|
+
const o = (/* @__PURE__ */ new Date()).getTime() - r.getContext().start;
|
|
26
|
+
l.info(`Operation ${r.operationName} took ${o}ms to complete`);
|
|
27
|
+
})
|
|
28
|
+
))), I = new v(({ error: r, operation: e }) => {
|
|
29
|
+
const o = (e == null ? void 0 : e.operationName) || "Unknown";
|
|
30
|
+
let t = "";
|
|
31
|
+
h.is(r) ? r.errors.forEach(({ message: n, locations: i, path: s }, a) => {
|
|
32
|
+
a === 0 && (t = n), l.error(
|
|
33
|
+
`[GraphQL error] ${o}: ${n}, Location: ${JSON.stringify(i, null, 4)}, Path: ${s}`
|
|
34
|
+
);
|
|
35
|
+
}) : g.is(r) ? r.errors.forEach(({ message: n, extensions: i }, s) => {
|
|
36
|
+
s === 0 && (t = n), l.error(
|
|
37
|
+
`[Protocol error]: ${n}, Extensions: ${JSON.stringify(i, null, 4)}`
|
|
38
|
+
);
|
|
39
|
+
}) : y.is(r) ? (t = r.message, l.error(`[Server error]: ${r.message}`)) : (t = r.message, l.error(`[Network error]: ${r.message}`)), r && t && typeof window != "undefined" && c.error((n) => /* @__PURE__ */ p.createElement(p.Fragment, null, t, " ", /* @__PURE__ */ p.createElement(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
className: "text-blue-500 hover:text-blue-700",
|
|
44
|
+
onClick: () => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
N(r);
|
|
47
|
+
}, 0), c.dismiss(n.id);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"Show Details"
|
|
51
|
+
)));
|
|
52
|
+
});
|
|
53
|
+
function R(r) {
|
|
54
|
+
const { uri: e, wsUrl: o, customLinks: t } = r, n = new _();
|
|
55
|
+
e || l.warn(`[Apollo] No GraphQL URI provided — using "${f}" as default`);
|
|
56
|
+
const i = C({
|
|
57
|
+
uri: e != null ? e : f,
|
|
84
58
|
credentials: "include",
|
|
85
59
|
headers: {
|
|
86
60
|
"apollo-require-preflight": "true"
|
|
87
61
|
}
|
|
88
|
-
}),
|
|
89
|
-
({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
c,
|
|
100
|
-
// ⚠️ Apollo's error handling
|
|
101
|
-
p,
|
|
102
|
-
// 🧼 cleans up __typename
|
|
103
|
-
...m != null ? m : [],
|
|
104
|
-
// 🔗 custom links
|
|
105
|
-
b
|
|
106
|
-
// 📡 HTTP vs WS routing (includes uploadLink)
|
|
62
|
+
}), s = o ? new b(O({ url: o })) : m.empty(), a = o ? m.split(
|
|
63
|
+
({ operationType: d }) => d === E.SUBSCRIPTION,
|
|
64
|
+
s,
|
|
65
|
+
i
|
|
66
|
+
) : i;
|
|
67
|
+
return o && a === i && l.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
|
|
68
|
+
U,
|
|
69
|
+
I,
|
|
70
|
+
n,
|
|
71
|
+
...t != null ? t : [],
|
|
72
|
+
a
|
|
107
73
|
];
|
|
108
74
|
}
|
|
109
|
-
function
|
|
110
|
-
const e =
|
|
111
|
-
return new
|
|
75
|
+
function K(r) {
|
|
76
|
+
const e = m.from(R(r));
|
|
77
|
+
return new L(A({
|
|
112
78
|
link: e,
|
|
113
|
-
cache: new
|
|
79
|
+
cache: new k()
|
|
114
80
|
}, r));
|
|
115
81
|
}
|
|
116
82
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
ie as getClient
|
|
83
|
+
R as createApolloLinks,
|
|
84
|
+
K as getClient
|
|
120
85
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./apollo-client.component.cjs"),n=require("./apollo-client.constant.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./apollo-client.component.cjs"),n=require("./apollo-client.constant.cjs"),r=require("./apollo-client.context.cjs"),t=require("./apollo-client.util.cjs"),o=require("@apollo/client/cache"),e=require("@apollo/client/react");exports.ApolloProvider=u.ApolloProvider;exports.GRAPHQL_URI_DEFAULT=n.GRAPHQL_URI_DEFAULT;exports.ApolloClientContext=r.ApolloClientContext;exports.ApolloClientProvider=r.ApolloClientProvider;exports.createApolloLinks=t.createApolloLinks;exports.getClient=t.getClient;Object.defineProperty(exports,"makeVar",{enumerable:!0,get:()=>o.makeVar});Object.defineProperty(exports,"useApolloClient",{enumerable:!0,get:()=>e.useApolloClient});Object.defineProperty(exports,"useBackgroundQuery",{enumerable:!0,get:()=>e.useBackgroundQuery});Object.defineProperty(exports,"useFragment",{enumerable:!0,get:()=>e.useFragment});Object.defineProperty(exports,"useLazyQuery",{enumerable:!0,get:()=>e.useLazyQuery});Object.defineProperty(exports,"useLoadableQuery",{enumerable:!0,get:()=>e.useLoadableQuery});Object.defineProperty(exports,"useMutation",{enumerable:!0,get:()=>e.useMutation});Object.defineProperty(exports,"useQuery",{enumerable:!0,get:()=>e.useQuery});Object.defineProperty(exports,"useQueryRefHandlers",{enumerable:!0,get:()=>e.useQueryRefHandlers});Object.defineProperty(exports,"useReactiveVar",{enumerable:!0,get:()=>e.useReactiveVar});Object.defineProperty(exports,"useReadQuery",{enumerable:!0,get:()=>e.useReadQuery});Object.defineProperty(exports,"useSubscription",{enumerable:!0,get:()=>e.useSubscription});Object.defineProperty(exports,"useSuspenseFragment",{enumerable:!0,get:()=>e.useSuspenseFragment});Object.defineProperty(exports,"useSuspenseQuery",{enumerable:!0,get:()=>e.useSuspenseQuery});
|
|
@@ -4,5 +4,5 @@ export * from './apollo-client.context.js';
|
|
|
4
4
|
export * from './apollo-client.hook.js';
|
|
5
5
|
export * from './apollo-client.type.js';
|
|
6
6
|
export * from './apollo-client.util.js';
|
|
7
|
-
export { makeVar } from '@apollo/client/cache
|
|
8
|
-
export { useApolloClient, useBackgroundQuery, useFragment, useLazyQuery, useLoadableQuery, useMutation, useQuery, useQueryRefHandlers, useReactiveVar, useReadQuery, useSubscription, useSuspenseFragment, useSuspenseQuery } from '@apollo/client/react
|
|
7
|
+
export { makeVar } from '@apollo/client/cache';
|
|
8
|
+
export { useApolloClient, useBackgroundQuery, useFragment, useLazyQuery, useLoadableQuery, useMutation, useQuery, useQueryRefHandlers, useReactiveVar, useReadQuery, useSubscription, useSuspenseFragment, useSuspenseQuery } from '@apollo/client/react';
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { ApolloProvider as o } from "./apollo-client.component.js";
|
|
2
2
|
import { GRAPHQL_URI_DEFAULT as s } from "./apollo-client.constant.js";
|
|
3
|
-
import { ApolloClientContext as l, ApolloClientProvider as
|
|
4
|
-
import {
|
|
5
|
-
import { makeVar as
|
|
6
|
-
import { useApolloClient as
|
|
3
|
+
import { ApolloClientContext as l, ApolloClientProvider as a } from "./apollo-client.context.js";
|
|
4
|
+
import { createApolloLinks as p, getClient as i } from "./apollo-client.util.js";
|
|
5
|
+
import { makeVar as y } from "@apollo/client/cache";
|
|
6
|
+
import { useApolloClient as f, useBackgroundQuery as x, useFragment as A, useLazyQuery as d, useLoadableQuery as C, useMutation as L, useQuery as R, useQueryRefHandlers as c, useReactiveVar as g, useReadQuery as k, useSubscription as v, useSuspenseFragment as F, useSuspenseQuery as P } from "@apollo/client/react";
|
|
7
7
|
export {
|
|
8
8
|
l as ApolloClientContext,
|
|
9
|
-
|
|
9
|
+
a as ApolloClientProvider,
|
|
10
10
|
o as ApolloProvider,
|
|
11
|
-
p as DevLoggerLink,
|
|
12
11
|
s as GRAPHQL_URI_DEFAULT,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
p as createApolloLinks,
|
|
13
|
+
i as getClient,
|
|
14
|
+
y as makeVar,
|
|
15
|
+
f as useApolloClient,
|
|
16
|
+
x as useBackgroundQuery,
|
|
17
|
+
A as useFragment,
|
|
19
18
|
d as useLazyQuery,
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
C as useLoadableQuery,
|
|
20
|
+
L as useMutation,
|
|
22
21
|
R as useQuery,
|
|
23
22
|
c as useQueryRefHandlers,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
g as useReactiveVar,
|
|
24
|
+
k as useReadQuery,
|
|
25
|
+
v as useSubscription,
|
|
26
|
+
F as useSuspenseFragment,
|
|
27
|
+
P as useSuspenseQuery
|
|
29
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./upload.cjs");exports.createUploadLink=e.createUploadLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './upload.js';
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BaseHttpLink } from '@apollo/client/link/http';
|
|
2
|
+
import { ExtractableFile } from 'extract-files/isExtractableFile.mjs';
|
|
3
|
+
import { ApolloLink } from '@apollo/client/link';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a
|
|
6
|
+
* [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)
|
|
7
|
+
* for [Apollo Client](https://www.apollographql.com/docs/react) that fetches a
|
|
8
|
+
* [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec)
|
|
9
|
+
* if the GraphQL variables contain files (by default
|
|
10
|
+
* [`FileList`](https://developer.mozilla.org/en-US/docs/Web/API/FileList),
|
|
11
|
+
* [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), or
|
|
12
|
+
* [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instances),
|
|
13
|
+
* or else fetches a regular
|
|
14
|
+
* [GraphQL POST or GET request](https://www.apollographql.com/docs/apollo-server/workflow/requests)
|
|
15
|
+
* (depending on the config and GraphQL operation).
|
|
16
|
+
*
|
|
17
|
+
* Some of the options are similar to the
|
|
18
|
+
* [`createHttpLink` options](https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options).
|
|
19
|
+
* @see [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec).
|
|
20
|
+
* @param {object} options Options.
|
|
21
|
+
* @param {Parameters<typeof selectURI>[1]} [options.uri] GraphQL endpoint URI.
|
|
22
|
+
* Defaults to `"/graphql"`.
|
|
23
|
+
* @param {boolean} [options.useGETForQueries] Should GET be used to fetch
|
|
24
|
+
* queries, if there are no files to upload.
|
|
25
|
+
* @param {ExtractableFileMatcher} [options.isExtractableFile] Matches
|
|
26
|
+
* extractable files in the GraphQL operation. Defaults to
|
|
27
|
+
* {@linkcode isExtractableFile}.
|
|
28
|
+
* @param {typeof FormData} [options.FormData]
|
|
29
|
+
* [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
|
30
|
+
* class. Defaults to the {@linkcode FormData} global.
|
|
31
|
+
* @param {FormDataFileAppender} [options.formDataAppendFile]
|
|
32
|
+
* Customizes how extracted files are appended to the
|
|
33
|
+
* [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
|
34
|
+
* instance. Defaults to {@linkcode formDataAppendFile}.
|
|
35
|
+
* @param {import("@apollo/client/link/http/selectHttpOptionsAndBody.js").Printer} [options.print]
|
|
36
|
+
* Prints the GraphQL query or mutation AST to a string for transport.
|
|
37
|
+
* Defaults to {@linkcode defaultPrinter}.
|
|
38
|
+
* @param {typeof fetch} [options.fetch] [`fetch`](https://fetch.spec.whatwg.org)
|
|
39
|
+
* implementation. Defaults to the {@linkcode fetch} global.
|
|
40
|
+
* @param {RequestInit} [options.fetchOptions] `fetch` options; overridden by
|
|
41
|
+
* upload requirements.
|
|
42
|
+
* @param {string} [options.credentials] Overrides
|
|
43
|
+
* {@linkcode RequestInit.credentials credentials} in
|
|
44
|
+
* {@linkcode fetchOptions}.
|
|
45
|
+
* @param {{ [headerName: string]: string }} [options.headers] Merges with and
|
|
46
|
+
* overrides {@linkcode RequestInit.headers headers} in
|
|
47
|
+
* {@linkcode fetchOptions}.
|
|
48
|
+
* @param {boolean} [options.includeExtensions] Toggles sending `extensions`
|
|
49
|
+
* fields to the GraphQL server. Defaults to `false`.
|
|
50
|
+
* @returns A [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link).
|
|
51
|
+
* @example
|
|
52
|
+
* A basic Apollo Client setup:
|
|
53
|
+
*
|
|
54
|
+
* ```js
|
|
55
|
+
* import { ApolloClient, InMemoryCache } from "@apollo/client";
|
|
56
|
+
* import createUploadLink from "apollo-upload-client/createUploadLink.mjs";
|
|
57
|
+
*
|
|
58
|
+
* const client = new ApolloClient({
|
|
59
|
+
* cache: new InMemoryCache(),
|
|
60
|
+
* link: createUploadLink(),
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createUploadLink({ uri: fetchUri, useGETForQueries, isExtractableFile: customIsExtractableFile, FormData: CustomFormData, formDataAppendFile: customFormDataAppendFile, print, fetch: customFetch, fetchOptions, credentials, headers, includeExtensions, }?: {
|
|
65
|
+
uri?: string;
|
|
66
|
+
useGETForQueries?: boolean;
|
|
67
|
+
isExtractableFile?: (value: unknown) => value is ExtractableFile;
|
|
68
|
+
FormData?: typeof FormData;
|
|
69
|
+
formDataAppendFile?: (formData: FormData, fieldName: string, file: ExtractableFile) => void;
|
|
70
|
+
print?: BaseHttpLink.Printer;
|
|
71
|
+
fetch?: typeof fetch;
|
|
72
|
+
fetchOptions?: RequestInit;
|
|
73
|
+
credentials?: RequestCredentials;
|
|
74
|
+
headers?: Record<string, string>;
|
|
75
|
+
includeExtensions?: boolean;
|
|
76
|
+
}): ApolloLink;
|
|
@@ -0,0 +1,111 @@
|
|
|
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";
|
|
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")
|
|
16
|
+
return { controller: !1, signal: !1 };
|
|
17
|
+
const n = new AbortController(), t = n.signal;
|
|
18
|
+
return { controller: n, signal: t };
|
|
19
|
+
}
|
|
20
|
+
function Q(n, t, e) {
|
|
21
|
+
"name" in e ? n.append(t, e, e.name) : n.append(t, e);
|
|
22
|
+
}
|
|
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,
|
|
31
|
+
fetchOptions: A,
|
|
32
|
+
credentials: C,
|
|
33
|
+
headers: P,
|
|
34
|
+
includeExtensions: S
|
|
35
|
+
} = {}) {
|
|
36
|
+
const I = {
|
|
37
|
+
http: { includeExtensions: S },
|
|
38
|
+
options: A,
|
|
39
|
+
credentials: C,
|
|
40
|
+
headers: P
|
|
41
|
+
};
|
|
42
|
+
return new q((l) => {
|
|
43
|
+
const p = l.getContext(), {
|
|
44
|
+
// Apollo Studio client awareness `name` and `version` can be configured
|
|
45
|
+
// via `ApolloClient` constructor options:
|
|
46
|
+
// https://www.apollographql.com/docs/graphos/metrics/client-awareness/#setup
|
|
47
|
+
clientAwareness: { name: u, version: h } = {},
|
|
48
|
+
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(
|
|
55
|
+
l,
|
|
56
|
+
F,
|
|
57
|
+
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 = {};
|
|
67
|
+
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);
|
|
80
|
+
});
|
|
81
|
+
f = a;
|
|
82
|
+
} 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(
|
|
86
|
+
"abort",
|
|
87
|
+
() => {
|
|
88
|
+
s.abort();
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
// Prevent a memory leak if the user configured abort controller
|
|
92
|
+
// is long lasting, or controls multiple things.
|
|
93
|
+
once: !0
|
|
94
|
+
}
|
|
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));
|
|
103
|
+
}), () => {
|
|
104
|
+
i = !0, typeof s != "boolean" && s.abort();
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
tt as createUploadLink
|
|
111
|
+
};
|
|
@@ -10,7 +10,7 @@ import { I_ApolloOptions } from '../apollo-client/index.js';
|
|
|
10
10
|
* @returns A registered Apollo Client factory function that can be used with Next.js server components.
|
|
11
11
|
*/
|
|
12
12
|
export declare const makeClient: (options?: I_ApolloOptions) => {
|
|
13
|
-
getClient: () => import('@apollo/client-integration-nextjs').ApolloClient
|
|
14
|
-
query: <
|
|
13
|
+
getClient: () => import('@apollo/client-integration-nextjs').ApolloClient;
|
|
14
|
+
query: <TData = unknown, TVariables extends import('@apollo/client').OperationVariables = import('@apollo/client').OperationVariables>(options: import("@apollo/client").ApolloClient.QueryOptions<TData, TVariables>) => Promise<import("@apollo/client").ApolloClient.QueryResult<import('@apollo/client').MaybeMasked<TData>>>;
|
|
15
15
|
PreloadQuery: import('@apollo/client-integration-nextjs').PreloadQueryComponent;
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
@@ -10,4 +10,4 @@ import { I_ApolloOptions } from '../apollo-client/index.js';
|
|
|
10
10
|
* @param options - Configuration options for the Apollo Client including URI, WebSocket URL, and custom links.
|
|
11
11
|
* @returns A Next.js optimized Apollo Client instance ready for use in Next.js applications.
|
|
12
12
|
*/
|
|
13
|
-
export declare function getClient(options?: I_ApolloOptions): ApolloClient
|
|
13
|
+
export declare function getClient(options?: I_ApolloOptions): ApolloClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApolloClient as
|
|
2
|
-
import {
|
|
3
|
-
import { createApolloLinks as
|
|
4
|
-
var
|
|
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
5
|
for (var o in r || (r = {}))
|
|
6
6
|
m.call(r, o) && n(e, o, r[o]);
|
|
7
7
|
if (t)
|
|
@@ -10,8 +10,8 @@ var i = Object.defineProperty, t = Object.getOwnPropertySymbols, m = Object.prot
|
|
|
10
10
|
return e;
|
|
11
11
|
};
|
|
12
12
|
function v(e = {}) {
|
|
13
|
-
const r =
|
|
14
|
-
return new
|
|
13
|
+
const r = a.from(i(e));
|
|
14
|
+
return new l(_({
|
|
15
15
|
link: r,
|
|
16
16
|
cache: new p()
|
|
17
17
|
}, e));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),a=require("./apollo-error.context.cjs"),r=require("./apollo-error.module.scss.cjs");function s(){const o=t.use(a.ApolloErrorContext),e=o==null?void 0:o.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:r.default["modal-backdrop"]},t.createElement("div",{className:r.default["modal-content"]},t.createElement("button",{type:"button",className:r.default["btn-close"],onClick:o.hideError},"✕"),t.createElement("div",{className:r.default["error-title"]},t.createElement("button",{type:"button",className:r.default["btn-retry"],onClick:()=>window.location.reload()},"Reload")," ",l),t.createElement("div",{className:r.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:")," ",JSON.stringify(e,null,4)))))}exports.ApolloErrorComponent=s;
|
|
@@ -2,9 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* Apollo Error Component that displays detailed error information in a modal.
|
|
4
4
|
* This component provides a comprehensive error display interface that shows
|
|
5
|
-
*
|
|
6
|
-
* errors, and client errors. It includes a reload button for recovery and
|
|
7
|
-
* detailed error information for debugging purposes.
|
|
5
|
+
* GraphQL errors and other error types with detailed information for debugging purposes.
|
|
8
6
|
*
|
|
9
7
|
* Features:
|
|
10
8
|
* - Modal overlay with backdrop for focus
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ApolloErrorContext as
|
|
3
|
-
import
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
return
|
|
1
|
+
import t, { use as s } from "react";
|
|
2
|
+
import { ApolloErrorContext as a } from "./apollo-error.context.js";
|
|
3
|
+
import n from "./apollo-error.module.scss.js";
|
|
4
|
+
function p() {
|
|
5
|
+
const o = s(a), e = o == null ? void 0 : o.error;
|
|
6
|
+
if (!e)
|
|
7
|
+
return null;
|
|
8
|
+
const r = "locations" in e || "path" in e || "extensions" in e, l = "message" in e ? e.message : "Unknown error occurred";
|
|
9
|
+
return /* @__PURE__ */ t.createElement("div", { className: n["modal-backdrop"] }, /* @__PURE__ */ t.createElement("div", { className: n["modal-content"] }, /* @__PURE__ */ t.createElement(
|
|
10
10
|
"button",
|
|
11
11
|
{
|
|
12
12
|
type: "button",
|
|
13
|
-
className:
|
|
13
|
+
className: n["btn-close"],
|
|
14
14
|
onClick: o.hideError
|
|
15
15
|
},
|
|
16
16
|
"✕"
|
|
17
|
-
), /* @__PURE__ */
|
|
17
|
+
), /* @__PURE__ */ t.createElement("div", { className: n["error-title"] }, /* @__PURE__ */ t.createElement(
|
|
18
18
|
"button",
|
|
19
19
|
{
|
|
20
20
|
type: "button",
|
|
21
|
-
className:
|
|
21
|
+
className: n["btn-retry"],
|
|
22
22
|
onClick: () => window.location.reload()
|
|
23
23
|
},
|
|
24
24
|
"Reload"
|
|
25
|
-
), " ",
|
|
25
|
+
), " ", l), /* @__PURE__ */ t.createElement("div", { className: n["error-details"] }, r && "locations" in e && e.locations && /* @__PURE__ */ t.createElement("pre", { className: "locations" }, /* @__PURE__ */ t.createElement("strong", null, "Locations:"), " ", JSON.stringify(e.locations, null, 4)), r && "path" in e && e.path && /* @__PURE__ */ t.createElement("pre", { className: "path" }, /* @__PURE__ */ t.createElement("strong", null, "Path:"), " ", JSON.stringify(e.path, null, 4)), r && "extensions" in e && e.extensions && /* @__PURE__ */ t.createElement("pre", { className: "extensions" }, /* @__PURE__ */ t.createElement("strong", null, "Extensions:"), " ", JSON.stringify(e.extensions, null, 4)), !r && /* @__PURE__ */ t.createElement("pre", { className: "error-details" }, /* @__PURE__ */ t.createElement("strong", null, "Error Details:"), " ", JSON.stringify(e, null, 4)))));
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
p as ApolloErrorComponent
|
|
29
29
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type {
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export type { GraphQLError } from 'graphql';
|
|
3
3
|
export interface I_ApolloErrorContext {
|
|
4
|
-
error:
|
|
5
|
-
showError: (error:
|
|
4
|
+
error: GraphQLError | Error | null;
|
|
5
|
+
showError: (error: GraphQLError | Error) => void;
|
|
6
6
|
hideError: () => void;
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
2
|
/**
|
|
3
3
|
* Sets the global callback function for Apollo error handling.
|
|
4
4
|
* This function registers a callback that will be called whenever a global
|
|
@@ -8,7 +8,7 @@ import { ApolloError } from '@apollo/client';
|
|
|
8
8
|
*
|
|
9
9
|
* @param callback - The function to be called when a global Apollo error occurs.
|
|
10
10
|
*/
|
|
11
|
-
export declare function setGlobalApolloErrorCallback(callback: (err:
|
|
11
|
+
export declare function setGlobalApolloErrorCallback(callback: (err: GraphQLError | Error) => void): void;
|
|
12
12
|
/**
|
|
13
13
|
* Displays a global Apollo error using the registered callback.
|
|
14
14
|
* This function triggers the global error display system by calling the
|
|
@@ -17,4 +17,4 @@ export declare function setGlobalApolloErrorCallback(callback: (err: ApolloError
|
|
|
17
17
|
*
|
|
18
18
|
* @param error - The Apollo error to display globally.
|
|
19
19
|
*/
|
|
20
|
-
export declare function showGlobalApolloError(error:
|
|
20
|
+
export declare function showGlobalApolloError(error: GraphQLError | Error): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -208,11 +208,11 @@
|
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
210
|
"@antfu/eslint-config": "5.2.1",
|
|
211
|
-
"@apollo/client": "
|
|
212
|
-
"@apollo/client-integration-nextjs": "0.
|
|
211
|
+
"@apollo/client": "4.0.0",
|
|
212
|
+
"@apollo/client-integration-nextjs": "0.13.0",
|
|
213
213
|
"@apollo/server": "5.0.0",
|
|
214
214
|
"@as-integrations/express5": "1.1.2",
|
|
215
|
-
"@dotenvx/dotenvx": "1.
|
|
215
|
+
"@dotenvx/dotenvx": "1.49.0",
|
|
216
216
|
"@eddeee888/gcg-typescript-resolver-files": "0.12.1",
|
|
217
217
|
"@eslint-react/eslint-plugin": "1.52.6",
|
|
218
218
|
"@graphql-codegen/cli": "5.0.7",
|
|
@@ -220,8 +220,7 @@
|
|
|
220
220
|
"@nestjs/common": "11.1.6",
|
|
221
221
|
"@nestjs/core": "11.1.6",
|
|
222
222
|
"@userback/widget": "0.3.11",
|
|
223
|
-
"@vitejs/plugin-react-swc": "4.0.
|
|
224
|
-
"apollo-upload-client": "18.0.1",
|
|
223
|
+
"@vitejs/plugin-react-swc": "4.0.1",
|
|
225
224
|
"body-parser": "2.2.0",
|
|
226
225
|
"chalk": "5.6.0",
|
|
227
226
|
"clsx": "2.1.1",
|
|
@@ -238,32 +237,34 @@
|
|
|
238
237
|
"express": "5.1.0",
|
|
239
238
|
"express-session": "1.18.2",
|
|
240
239
|
"express-useragent": "1.0.15",
|
|
240
|
+
"extract-files": "13.0.0",
|
|
241
241
|
"fs-extra": "11.3.1",
|
|
242
242
|
"globals": "16.3.0",
|
|
243
243
|
"graphql": "16.11.0",
|
|
244
244
|
"graphql-upload": "17.0.0",
|
|
245
245
|
"graphql-ws": "6.0.6",
|
|
246
|
-
"i18next": "25.
|
|
246
|
+
"i18next": "25.4.0",
|
|
247
247
|
"jsdom": "26.1.0",
|
|
248
248
|
"localforage": "1.10.0",
|
|
249
249
|
"lodash-es": "4.17.21",
|
|
250
250
|
"migrate-mongo": "12.1.3",
|
|
251
251
|
"mongodb": "6.18.0",
|
|
252
|
-
"mongoose": "8.17.
|
|
252
|
+
"mongoose": "8.17.2",
|
|
253
253
|
"mongoose-aggregate-paginate-v2": "1.1.4",
|
|
254
254
|
"mongoose-paginate-v2": "1.9.1",
|
|
255
|
-
"next-intl": "4.3.
|
|
255
|
+
"next-intl": "4.3.5",
|
|
256
256
|
"node-fetch": "3.3.2",
|
|
257
257
|
"node-persist": "4.0.4",
|
|
258
258
|
"qs": "6.14.0",
|
|
259
259
|
"react": "19.1.1",
|
|
260
260
|
"react-dom": "19.1.1",
|
|
261
261
|
"react-hot-toast": "2.6.0",
|
|
262
|
-
"react-i18next": "15.
|
|
262
|
+
"react-i18next": "15.7.1",
|
|
263
|
+
"rxjs": "7.8.2",
|
|
263
264
|
"slugify": "1.6.6",
|
|
264
265
|
"unorm": "1.6.0",
|
|
265
266
|
"uuid": "11.1.0",
|
|
266
|
-
"vite": "7.1.
|
|
267
|
+
"vite": "7.1.3",
|
|
267
268
|
"ws": "8.18.3",
|
|
268
269
|
"yargs": "18.0.0"
|
|
269
270
|
},
|
|
@@ -271,10 +272,9 @@
|
|
|
271
272
|
"@commitlint/cli": "19.8.1",
|
|
272
273
|
"@commitlint/config-conventional": "19.8.1",
|
|
273
274
|
"@eslint/config-inspector": "1.2.0",
|
|
274
|
-
"@next/eslint-plugin-next": "15.
|
|
275
|
-
"@testing-library/jest-dom": "6.
|
|
275
|
+
"@next/eslint-plugin-next": "15.5.0",
|
|
276
|
+
"@testing-library/jest-dom": "6.8.0",
|
|
276
277
|
"@testing-library/react": "16.3.0",
|
|
277
|
-
"@types/apollo-upload-client": "18.0.0",
|
|
278
278
|
"@types/body-parser": "1.19.6",
|
|
279
279
|
"@types/compression": "1.8.1",
|
|
280
280
|
"@types/cookie-parser": "1.4.9",
|
|
@@ -283,6 +283,7 @@
|
|
|
283
283
|
"@types/express": "5.0.3",
|
|
284
284
|
"@types/express-session": "1.18.2",
|
|
285
285
|
"@types/express-useragent": "1.0.5",
|
|
286
|
+
"@types/extract-files": "13.0.1",
|
|
286
287
|
"@types/fs-extra": "11.0.4",
|
|
287
288
|
"@types/graphql-upload": "17.0.0",
|
|
288
289
|
"@types/lodash-es": "4.17.12",
|
|
@@ -297,7 +298,7 @@
|
|
|
297
298
|
"@types/yargs": "17.0.33",
|
|
298
299
|
"@vitest/browser": "3.2.4",
|
|
299
300
|
"eslint": "9.33.0",
|
|
300
|
-
"eslint-config-next": "15.
|
|
301
|
+
"eslint-config-next": "15.5.0",
|
|
301
302
|
"glob": "11.0.3",
|
|
302
303
|
"lint-staged": "16.1.5",
|
|
303
304
|
"node-modules-inspector": "1.1.1",
|
|
@@ -306,7 +307,7 @@
|
|
|
306
307
|
"simple-git-hooks": "2.13.1",
|
|
307
308
|
"tsx": "4.20.4",
|
|
308
309
|
"typescript": "5.9.2",
|
|
309
|
-
"vite": "7.1.
|
|
310
|
+
"vite": "7.1.3",
|
|
310
311
|
"vite-plugin-dts": "4.5.4",
|
|
311
312
|
"vitest": "3.2.4"
|
|
312
313
|
},
|