Skip to content

Commit 63ac264

Browse files
committed
double-check & check for newer removed exports
1 parent b6d7cb7 commit 63ac264

2 files changed

Lines changed: 33 additions & 64 deletions

File tree

scripts/codemods/ac3-to-ac4/src/__tests__/exports.removed.json

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"ExecutionPatchResult",
2828
"SingleExecutionResult",
2929
"NextLink",
30+
"ClientParseError",
31+
"serializeFetchParameter",
3032
"HttpOptions",
3133
"UriFunction",
3234
"ApolloContextValue",
@@ -136,6 +138,8 @@
136138
"ExecutionPatchResult",
137139
"SingleExecutionResult",
138140
"NextLink",
141+
"ClientParseError",
142+
"serializeFetchParameter",
139143
"HttpOptions",
140144
"UriFunction"
141145
],
@@ -147,28 +151,33 @@
147151
"NetworkError",
148152
"ApolloError"
149153
],
150-
"@apollo/client/link/batch": [],
154+
"@apollo/client/link/batch": [
155+
"BatchableRequest",
156+
"BatchHandler",
157+
"OperationBatcher"
158+
],
151159
"@apollo/client/link/batch-http": [],
152160
"@apollo/client/link/context": ["ContextSetter"],
153-
"@apollo/client/link/core -> @apollo/client/link": [
161+
"@apollo/client/link/core": [
154162
"Path",
155163
"ExecutionPatchInitialResult",
156164
"IncrementalPayload",
157165
"ExecutionPatchIncrementalResult",
158166
"ExecutionPatchResult",
159167
"SingleExecutionResult",
160-
"FetchResult",
161168
"NextLink"
162169
],
163-
"@apollo/client/link/error": ["ErrorResponse"],
170+
"@apollo/client/link/error": ["ErrorResponse", "ErrorHandler"],
164171
"@apollo/client/link/http": [
165172
"ServerParseError",
173+
"ClientParseError",
174+
"serializeFetchParameter",
166175
"HttpOptions",
167176
"UriFunction"
168177
],
169178
"@apollo/client/link/persisted-queries": ["ErrorResponse"],
170179
"@apollo/client/link/retry": [],
171-
"@apollo/client/link/remove-typename": [],
180+
"@apollo/client/link/remove-typename": ["RemoveTypenameFromVariablesOptions"],
172181
"@apollo/client/link/schema": [],
173182
"@apollo/client/link/subscriptions": [],
174183
"@apollo/client/link/utils": [
@@ -180,18 +189,8 @@
180189
"validateOperation",
181190
"transformOperation"
182191
],
183-
"@apollo/client/link/ws": [],
184-
"@apollo/client/masking": [
185-
"DataMasking",
186-
"FragmentType",
187-
"Masked",
188-
"MaskedDocumentNode",
189-
"MaybeMasked",
190-
"Unmasked",
191-
"disableWarningsSlot",
192-
"maskFragment",
193-
"maskOperation"
194-
],
192+
"@apollo/client/link/ws": ["WebSocketParams"],
193+
"@apollo/client/masking": [],
195194
"@apollo/client/react": [
196195
"ApolloConsumer",
197196
"resetApolloContext",
@@ -280,12 +279,7 @@
280279
"UseFragmentOptions",
281280
"UseFragmentResult"
282281
],
283-
"@apollo/client/react/internal": [
284-
"QueryReference",
285-
"getSuspenseCache",
286-
"CacheKey",
287-
"QueryKey"
288-
],
282+
"@apollo/client/react/internal": ["QueryReference"],
289283
"@apollo/client/react/parser": [
290284
"operationName",
291285
"parser",
@@ -342,7 +336,18 @@
342336
"getDirectiveNames",
343337
"getInclusionDirectives",
344338
"getFragmentMaskMode",
345-
"getMainDefinition",
339+
"FragmentMap",
340+
"FragmentMapFunction",
341+
"createFragmentMap",
342+
"getFragmentQueryDocument",
343+
"getFragmentFromSelection",
344+
"isFullyUnmaskedOperation",
345+
"checkDocument",
346+
"getOperationDefinition",
347+
"getOperationName",
348+
"getFragmentDefinitions",
349+
"getQueryDefinition",
350+
"getFragmentDefinition",
346351
"getDefaultValues",
347352
"Directives",
348353
"VariableValue",
@@ -428,6 +433,8 @@
428433
"IsStrictlyAny"
429434
],
430435
"@apollo/client/utilities/globals": [
436+
"maybe",
437+
"global",
431438
"invariant",
432439
"newInvariantError",
433440
"InvariantError",

scripts/codemods/ac3-to-ac4/src/util/getAllExports.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -251,46 +251,6 @@ function analyze(
251251
}
252252
}
253253

254-
function writeTest(exports: ExportInfo[], moduleName: string) {
255-
fs.writeFileSync(
256-
path.join(
257-
import.meta.dirname,
258-
"..",
259-
"__tests__",
260-
`${moduleName.replace(/[@\/]/g, "_")}.generated.ts`
261-
),
262-
`
263-
import { describe, expect, test } from "vitest";
264-
265-
import imports from "../imports.js";
266-
267-
import { createDiff } from "./diffTransform.js";
268-
269-
const diff = createDiff(imports);
270-
describe("@apollo/client", () => {
271-
272-
273-
${exports
274-
.map(
275-
(info) => `
276-
test("${info.name}", () => {
277-
expect(
278-
diff(
279-
\`
280-
import { ${info.name} } from "${info.moduleName}";
281-
${info.usageExamples.join("\n")}
282-
\`.trim()
283-
)
284-
).toMatchSnapshot();
285-
});
286-
`
287-
)
288-
.join("\n")}
289-
});
290-
`
291-
);
292-
}
293-
294254
const entryPoints = [
295255
["src/cache/index.ts", "@apollo/client/cache"],
296256
["src/index.ts", "@apollo/client"],
@@ -348,6 +308,8 @@ for (const [entryPoint, moduleName] of entryPoints) {
348308
collected[moduleName] = exports;
349309
}
350310

311+
// in the end, generated files can be diffed with
312+
// jq --slurpfile new src/__tests__/exports.new.json 'to_entries|map({key, value: ((.value|map(.name))-($new[0][.key]|map(.name)))})|from_entries' < src/__tests__/exports.json >| src/__tests__/exports.removed.json
351313
fs.writeFileSync(
352314
path.join(import.meta.dirname, "..", "__tests__", "exports.json"),
353315
JSON.stringify(collected, null, 2)

0 commit comments

Comments
 (0)