@cedarjs/web 7.0.0-canary.3137 → 7.0.0-canary.3138
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/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.js +5 -1
- package/dist/apollo/links.d.ts +2 -0
- package/dist/apollo/links.d.ts.map +1 -1
- package/dist/apollo/links.js +7 -2
- package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
- package/dist/components/DevFatalErrorPage.js +64 -47
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAchF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAQ5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAchF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAQ5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAqC7B,UAAU,KAAK;IACb,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG;QAC/D,KAAK,EAAE,WAAW,CAAA;KACnB,CAAA;IACD;;;;OAIG;IACH,WAAW,EAAE,MAAM,WAAW,CAAA;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,MAAM,EACN,WAAW,EACX,QAAQ,EACR,OAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,qBAsMP"}
|
|
@@ -16,6 +16,7 @@ import { UploadHttpLink } from "../bundled/apollo-upload-client.js";
|
|
|
16
16
|
import { useFetchConfig } from "../components/FetchConfigProvider.js";
|
|
17
17
|
import { ApolloClientFactoryContext } from "./ApolloClientFactoryContext.js";
|
|
18
18
|
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
19
|
+
import { getOperationKind } from "./links.js";
|
|
19
20
|
import * as SSELinkExports from "./sseLink.js";
|
|
20
21
|
const { SSELink, isSubscription, isLiveQuery } = SSELinkExports;
|
|
21
22
|
function ApolloProviderWithFetchConfig({
|
|
@@ -35,7 +36,10 @@ function ApolloProviderWithFetchConfig({
|
|
|
35
36
|
const { operationName, query, variables } = operation;
|
|
36
37
|
data.mostRecentRequest = {};
|
|
37
38
|
data.mostRecentRequest.operationName = operationName;
|
|
38
|
-
data.mostRecentRequest.operationKind =
|
|
39
|
+
data.mostRecentRequest.operationKind = getOperationKind(
|
|
40
|
+
query,
|
|
41
|
+
operationName
|
|
42
|
+
);
|
|
39
43
|
data.mostRecentRequest.variables = variables;
|
|
40
44
|
data.mostRecentRequest.query = query && print(operation.query);
|
|
41
45
|
return forward(operation).pipe(
|
package/dist/apollo/links.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ApolloLink, HttpLink } from '@apollo/client';
|
|
2
2
|
import { SetContextLink } from '@apollo/client/link/context';
|
|
3
|
+
import type { DocumentNode, OperationTypeNode } from 'graphql';
|
|
4
|
+
export declare function getOperationKind(query: DocumentNode, operationName?: string): OperationTypeNode | undefined;
|
|
3
5
|
export declare function createHttpLink(uri: string, httpLinkConfig: HttpLink.Options | undefined, cookieHeader?: string | null): HttpLink;
|
|
4
6
|
export declare function createUpdateDataLink(): ApolloLink;
|
|
5
7
|
export declare function createAuthApolloLink(authProviderType: string, headersFromFetchProvider: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/apollo/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/apollo/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAK9D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,YAAY,EACnB,aAAa,CAAC,EAAE,MAAM,GACrB,iBAAiB,GAAG,SAAS,CAE/B;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,QAAQ,CAAC,OAAO,GAAG,SAAS,EAC5C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,YAc7B;AAeD,wBAAgB,oBAAoB,eAqBnC;AACD,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EACpB;IACE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,GACD,SAAS,cA6Bd;AACD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,kBAMrE;AAED,wBAAgB,eAAe,CAAC,EAC9B,kBAAkB,EAClB,YAAY,GACb,EAAE;IACD,kBAAkB,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;IAC1D,YAAY,EAAE,kBAAkB,CAAA;CACjC,GAAG,UAAU,CAUb;AAID,MAAM,MAAM,iBAAiB,CAC3B,IAAI,SAAS,qBAAqB,EAClC,IAAI,SAAS,UAAU,GAAG,UAAU,IAClC;IACF,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC7B,iBAAiB,CAAC,WAAW,CAAC,GAC9B,iBAAiB,CAAC,gBAAgB,CAAC,GACnC,iBAAiB,CAAC,kBAAkB,CAAC,GACrC,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAC1C,EAAE,CAAA;AAMH,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAA;AAC9C,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,CAAA;AAC3E,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;AAExE,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,UAAU,CAAA"}
|
package/dist/apollo/links.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ApolloLink, HttpLink } from "@apollo/client";
|
|
2
2
|
import { SetContextLink } from "@apollo/client/link/context";
|
|
3
|
+
import { getOperationAST } from "graphql";
|
|
3
4
|
import { print } from "graphql/language/printer.js";
|
|
4
5
|
import { Observable } from "rxjs";
|
|
6
|
+
function getOperationKind(query, operationName) {
|
|
7
|
+
return getOperationAST(query, operationName)?.operation;
|
|
8
|
+
}
|
|
5
9
|
function createHttpLink(uri, httpLinkConfig, cookieHeader) {
|
|
6
10
|
const headers = {};
|
|
7
11
|
if (cookieHeader) {
|
|
@@ -18,7 +22,7 @@ function enhanceError(operation, error) {
|
|
|
18
22
|
const { operationName, query, variables } = operation;
|
|
19
23
|
error.__RedwoodEnhancedError = {
|
|
20
24
|
operationName,
|
|
21
|
-
operationKind: query
|
|
25
|
+
operationKind: getOperationKind(query, operationName),
|
|
22
26
|
variables,
|
|
23
27
|
query: query && print(query)
|
|
24
28
|
};
|
|
@@ -90,5 +94,6 @@ export {
|
|
|
90
94
|
createFinalLink,
|
|
91
95
|
createHttpLink,
|
|
92
96
|
createTokenLink,
|
|
93
|
-
createUpdateDataLink
|
|
97
|
+
createUpdateDataLink,
|
|
98
|
+
getOperationKind
|
|
94
99
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevFatalErrorPage.d.ts","sourceRoot":"","sources":["../../src/components/DevFatalErrorPage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAmBpD,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,GAAG,CAAA;CACf,CAAA;AAED,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,sBAAsB,EAAE,cAAc,CAAA;CACvC;AAID,KAAK,oBAAoB,GAAG,KAAK,GAAG;IAClC,iBAAiB,CAAC,EAAE,cAAc,CAAA;IAClC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC3B,kBAAkB,CAAC,EAAE,GAAG,CAAA;CACzB,CAAA;
|
|
1
|
+
{"version":3,"file":"DevFatalErrorPage.d.ts","sourceRoot":"","sources":["../../src/components/DevFatalErrorPage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAmBpD,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,GAAG,CAAA;CACf,CAAA;AAED,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,sBAAsB,EAAE,cAAc,CAAA;CACvC;AAID,KAAK,oBAAoB,GAAG,KAAK,GAAG;IAClC,iBAAiB,CAAC,EAAE,cAAc,CAAA;IAClC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC3B,kBAAkB,CAAC,EAAE,GAAG,CAAA;CACzB,CAAA;AA+GD,eAAO,MAAM,iBAAiB,GAAI,OAAO;IAAE,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAAE,sBA4FxE,CAAA"}
|
|
@@ -10,73 +10,90 @@ if (/^[A-Z]:\\/.test(srcRoot)) {
|
|
|
10
10
|
} else {
|
|
11
11
|
appRoot = srcRoot.substring(1);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
function formatMarkdownCode(value) {
|
|
14
|
+
const fence = "`".repeat(longestBacktickRun(value) + 1);
|
|
15
|
+
const padding = value.startsWith("`") || value.endsWith("`") ? " " : "";
|
|
16
|
+
return `${fence}${padding}${value}${padding}${fence}`;
|
|
17
|
+
}
|
|
18
|
+
function formatMarkdownCodeBlock(value, language) {
|
|
19
|
+
const fence = "`".repeat(Math.max(3, longestBacktickRun(value) + 1));
|
|
20
|
+
return `${fence}${language}
|
|
21
|
+
${value}
|
|
22
|
+
${fence}`;
|
|
23
|
+
}
|
|
24
|
+
function longestBacktickRun(value) {
|
|
25
|
+
return Array.from(value.matchAll(/`+/g)).reduce(
|
|
26
|
+
(longest, [run]) => Math.max(longest, run.length),
|
|
27
|
+
0
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
function formatErrorForClipboard(stack, typeName, msg, errorWithMeta) {
|
|
31
|
+
const sections = [
|
|
32
|
+
`## Error
|
|
33
|
+
|
|
34
|
+
${formatMarkdownCode(typeName)}: ${formatMarkdownCode(msg)}`
|
|
35
|
+
];
|
|
22
36
|
const mostRecentRequest = errorWithMeta.mostRecentRequest || errorWithMeta.errors?.find((gqlErr) => gqlErr.__RedwoodEnhancedError)?.__RedwoodEnhancedError;
|
|
23
37
|
if (mostRecentRequest) {
|
|
24
|
-
|
|
25
|
-
lines.push("REQUEST CONTEXT");
|
|
26
|
-
lines.push("-".repeat(80));
|
|
27
|
-
lines.push(`Operation: ${mostRecentRequest.operationName}`);
|
|
28
|
-
lines.push(`Kind: ${mostRecentRequest.operationKind}`);
|
|
29
|
-
lines.push("");
|
|
30
|
-
lines.push("Variables:");
|
|
38
|
+
let variables;
|
|
31
39
|
try {
|
|
32
|
-
|
|
40
|
+
variables = JSON.stringify(mostRecentRequest.variables, null, 2) ?? "undefined";
|
|
33
41
|
} catch {
|
|
34
|
-
|
|
42
|
+
variables = "Unable to stringify variables";
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
sections.push(
|
|
45
|
+
[
|
|
46
|
+
"## Request",
|
|
47
|
+
"",
|
|
48
|
+
`${mostRecentRequest.operationKind} ${mostRecentRequest.operationName}`,
|
|
49
|
+
"",
|
|
50
|
+
"### Variables",
|
|
51
|
+
"",
|
|
52
|
+
formatMarkdownCodeBlock(variables, "json"),
|
|
53
|
+
"",
|
|
54
|
+
"### Query",
|
|
55
|
+
"",
|
|
56
|
+
formatMarkdownCodeBlock(mostRecentRequest.query, "graphql")
|
|
57
|
+
].join("\n")
|
|
58
|
+
);
|
|
40
59
|
}
|
|
41
60
|
if (errorWithMeta.mostRecentResponse) {
|
|
42
|
-
|
|
43
|
-
lines.push("RESPONSE CONTEXT");
|
|
44
|
-
lines.push("-".repeat(80));
|
|
61
|
+
let response;
|
|
45
62
|
try {
|
|
46
|
-
|
|
63
|
+
response = JSON.stringify(errorWithMeta.mostRecentResponse, null, 2) ?? "undefined";
|
|
47
64
|
} catch {
|
|
48
|
-
|
|
65
|
+
response = "Unable to stringify response";
|
|
49
66
|
}
|
|
50
|
-
|
|
67
|
+
sections.push(`## Response
|
|
68
|
+
|
|
69
|
+
${formatMarkdownCodeBlock(response, "json")}`);
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
lines.push("-".repeat(80));
|
|
55
|
-
stack.items.forEach((entry, i) => {
|
|
56
|
-
const fileShort = entry.fileShort || "[Unknown]";
|
|
71
|
+
const stackEntries = stack.items.map((entry, i) => {
|
|
72
|
+
const file = entry.fileShort || "[Unknown]";
|
|
57
73
|
const callee = entry.callee || "[Anonymous]";
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
lines.push(`[${i}] ${fileShort}:${line}:${column} in ${callee}`);
|
|
74
|
+
const location = `${file}:${entry.line || "?"}:${entry.column || "?"}`;
|
|
75
|
+
const lines = [`${i + 1}. \`${location}\` in \`${callee}\``];
|
|
61
76
|
const sourceFile = entry.sourceFile;
|
|
62
|
-
if (sourceFile?.lines && sourceFile.lines.length
|
|
63
|
-
const lineIndex =
|
|
77
|
+
if (sourceFile?.lines.length && entry.line && entry.line <= sourceFile.lines.length && !entry.thirdParty) {
|
|
78
|
+
const lineIndex = entry.line - 1;
|
|
64
79
|
const window = 2;
|
|
65
80
|
const start = Math.max(0, lineIndex - window);
|
|
66
81
|
const end = Math.min(sourceFile.lines.length, lineIndex + window + 1);
|
|
67
|
-
|
|
82
|
+
const sourceLines = [];
|
|
68
83
|
for (let idx = start; idx < end; idx++) {
|
|
69
|
-
const marker = idx === lineIndex ? ">
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
const marker = idx === lineIndex ? ">" : " ";
|
|
85
|
+
sourceLines.push(
|
|
86
|
+
`${marker} ${(idx + 1).toString().padStart(4)} | ${sourceFile.lines[idx]}`
|
|
72
87
|
);
|
|
73
88
|
}
|
|
74
|
-
lines.push("");
|
|
89
|
+
lines.push("", formatMarkdownCodeBlock(sourceLines.join("\n"), "text"));
|
|
75
90
|
}
|
|
91
|
+
return lines.join("\n");
|
|
76
92
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
sections.push(`## Stack trace
|
|
94
|
+
|
|
95
|
+
${stackEntries.join("\n\n")}`);
|
|
96
|
+
return sections.join("\n\n");
|
|
80
97
|
}
|
|
81
98
|
const DevFatalErrorPage = (props) => {
|
|
82
99
|
const [copyFeedback, setCopyFeedback] = useState("");
|
|
@@ -99,7 +116,7 @@ const DevFatalErrorPage = (props) => {
|
|
|
99
116
|
const msg = String(err?.message);
|
|
100
117
|
const FileRef = stack.items[0] ? /* @__PURE__ */ React.createElement("a", { href: toVSCodeURL(stack.items[0]) }, stack.items[0].fileName) : null;
|
|
101
118
|
const handleCopyAll = async () => {
|
|
102
|
-
const errorText = formatErrorForClipboard(
|
|
119
|
+
const errorText = formatErrorForClipboard(stack, typeName, msg, err);
|
|
103
120
|
try {
|
|
104
121
|
await navigator.clipboard.writeText(errorText);
|
|
105
122
|
setCopyFeedback("\u2713 Copied to clipboard");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/web",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.3138",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@apollo/client": "4.2.12",
|
|
82
|
-
"@cedarjs/server-store": "7.0.0-canary.
|
|
82
|
+
"@cedarjs/server-store": "7.0.0-canary.3138",
|
|
83
83
|
"@dr.pogodin/react-helmet": "2.0.4",
|
|
84
84
|
"@whatwg-node/fetch": "0.10.13",
|
|
85
85
|
"apollo-upload-client": "19.0.0",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@apollo/client-react-streaming": "0.14.5",
|
|
97
97
|
"@arethetypeswrong/cli": "0.18.5",
|
|
98
|
-
"@cedarjs/auth": "7.0.0-canary.
|
|
99
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
100
|
-
"@cedarjs/internal": "7.0.0-canary.
|
|
98
|
+
"@cedarjs/auth": "7.0.0-canary.3138",
|
|
99
|
+
"@cedarjs/framework-tools": "7.0.0-canary.3138",
|
|
100
|
+
"@cedarjs/internal": "7.0.0-canary.3138",
|
|
101
101
|
"@testing-library/dom": "10.4.1",
|
|
102
102
|
"@testing-library/jest-dom": "6.9.1",
|
|
103
103
|
"@testing-library/react": "16.3.3",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"vitest": "4.1.11"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
|
-
"@cedarjs/auth": "7.0.0-canary.
|
|
117
|
+
"@cedarjs/auth": "7.0.0-canary.3138",
|
|
118
118
|
"react": "19.2.8",
|
|
119
119
|
"react-dom": "19.2.8"
|
|
120
120
|
},
|