@ethlete/query 6.0.0-next.3 → 6.0.0-next.30
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/CHANGELOG.md +447 -0
- package/fesm2022/ethlete-query-testing.mjs +281 -5
- package/fesm2022/ethlete-query-testing.mjs.map +1 -1
- package/fesm2022/ethlete-query.mjs +9926 -5013
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/generators/deprecate-legacy-queries/migration.js +77 -0
- package/generators/deprecate-legacy-queries/schema.json +26 -0
- package/generators/generators.json +15 -0
- package/generators/migrate-query-client-features/migration.js +142 -0
- package/generators/migrate-query-client-features/report.js +136 -0
- package/generators/migrate-query-client-features/schema.json +26 -0
- package/generators/migrate-query-opt-in-features/migration.js +182 -0
- package/generators/migrate-query-opt-in-features/report.js +143 -0
- package/generators/migrate-query-opt-in-features/schema.json +31 -0
- package/generators/migrate-to-query-v3/auth-provider-scaffold.js +131 -0
- package/generators/migrate-to-query-v3/cleanup-migration.js +293 -0
- package/generators/migrate-to-query-v3/http-client-check.js +93 -0
- package/generators/migrate-to-query-v3/legacy-prepare-migration.js +865 -0
- package/generators/migrate-to-query-v3/legacy-query-creator-migration.js +608 -0
- package/generators/migrate-to-query-v3/migration-scope.js +41 -0
- package/generators/migrate-to-query-v3/migration.js +28 -2932
- package/generators/migrate-to-query-v3/module-graph.js +153 -0
- package/generators/migrate-to-query-v3/query-client-migration.js +526 -0
- package/generators/migrate-to-query-v3/rename-symbols.js +193 -0
- package/generators/migrate-to-query-v3/report.js +136 -0
- package/generators/migrate-to-query-v3/schema.json +12 -0
- package/generators/migrate-to-query-v3/shared.js +142 -0
- package/generators/prep-for-query-v3/migration.js +3 -3
- package/package.json +26 -13
- package/types/ethlete-query-testing.d.ts +139 -12
- package/types/ethlete-query.d.ts +6965 -3142
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { getLineNumberFromPosition } from './shared.js';
|
|
2
|
+
const APP_CONFIG_MARKERS = ['bootstrapApplication(', 'ApplicationConfig', 'provideServerRendering('];
|
|
3
|
+
/**
|
|
4
|
+
* Flags the v2 default-header APIs, which the client migration drops on the floor.
|
|
5
|
+
*
|
|
6
|
+
* `setDefaultHeaders` is not cosmetic - an API token or a preview credential lives there, so losing
|
|
7
|
+
* it means every request goes out unauthenticated. v3 has a home for it (`headers` on
|
|
8
|
+
* `createQueryClient`), but the call sites are imperative and scattered, so this is a pointer rather
|
|
9
|
+
* than a rewrite.
|
|
10
|
+
*/
|
|
11
|
+
export const reportDefaultHeaderUsages = (tree, report, scope) => {
|
|
12
|
+
const locations = [];
|
|
13
|
+
scope.visit(tree, (filePath) => {
|
|
14
|
+
if (!filePath.endsWith('.ts')) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const content = tree.read(filePath, 'utf-8');
|
|
18
|
+
if (!content) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const marker of ['setDefaultHeaders', 'globalHeaders']) {
|
|
22
|
+
const index = content.indexOf(marker);
|
|
23
|
+
if (index >= 0) {
|
|
24
|
+
locations.push({ filePath, line: getLineNumberFromPosition(content, index) });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (locations.length === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
report.addWarning({
|
|
32
|
+
title: 'Move default headers onto the query client',
|
|
33
|
+
summary: 'This workspace sets client-wide headers through the v2 `setDefaultHeaders` / `globalHeaders` API, which `createQueryClient` does not have. Left as is, those headers are simply not sent.',
|
|
34
|
+
action: 'Pass `headers` to `createQueryClient` - a function form re-reads on every request, so a signal can drive it. `refreshQueriesInUse: true` becomes `injectMyClient().refreshQueriesInUse()` after the value changes.',
|
|
35
|
+
locations,
|
|
36
|
+
source: 'http-client-check',
|
|
37
|
+
dedupeKey: 'default-headers',
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Flags applications that will build cleanly and then fail on their first request.
|
|
42
|
+
*
|
|
43
|
+
* The v2 client shipped its own transport; v3 does `inject(HttpClient)`. An app that never needed
|
|
44
|
+
* `provideHttpClient()` therefore keeps compiling after the migration and dies at runtime instead -
|
|
45
|
+
* the one failure mode a codemod should never leave behind silently.
|
|
46
|
+
*/
|
|
47
|
+
export const reportMissingHttpClientProviders = (tree, report, scope) => {
|
|
48
|
+
const appConfigFiles = [];
|
|
49
|
+
const filesWithProvider = [];
|
|
50
|
+
const filesWithUploadProgress = [];
|
|
51
|
+
scope.visit(tree, (filePath) => {
|
|
52
|
+
if (!filePath.endsWith('.ts') || filePath.endsWith('.spec.ts')) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const content = tree.read(filePath, 'utf-8');
|
|
56
|
+
if (!content) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (content.includes('provideHttpClient(')) {
|
|
60
|
+
filesWithProvider.push(filePath);
|
|
61
|
+
}
|
|
62
|
+
const markerIndex = APP_CONFIG_MARKERS.map((marker) => content.indexOf(marker)).find((index) => index >= 0);
|
|
63
|
+
if (markerIndex !== undefined) {
|
|
64
|
+
appConfigFiles.push({ filePath, line: getLineNumberFromPosition(content, markerIndex) });
|
|
65
|
+
}
|
|
66
|
+
const progressIndex = content.indexOf('reportProgress');
|
|
67
|
+
if (progressIndex >= 0) {
|
|
68
|
+
filesWithUploadProgress.push({ filePath, line: getLineNumberFromPosition(content, progressIndex) });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (appConfigFiles.length > 0 && filesWithProvider.length === 0) {
|
|
72
|
+
report.addWarning({
|
|
73
|
+
title: 'Add provideHttpClient() to the application providers',
|
|
74
|
+
summary: 'v3 queries run on Angular’s `HttpClient`, but no `provideHttpClient()` was found. The app compiles and then throws on the first request - `@ethlete/query` never provides it, that is the application’s job.',
|
|
75
|
+
action: 'Add `provideHttpClient()` to every app config that uses a query client. If anything relies on upload progress, use `provideHttpClient(withXhr())` - on Angular ≥ 22 the default is fetch, which emits no upload progress events.',
|
|
76
|
+
locations: appConfigFiles,
|
|
77
|
+
source: 'http-client-check',
|
|
78
|
+
dedupeKey: 'missing-provide-http-client',
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (filesWithUploadProgress.length > 0) {
|
|
83
|
+
report.addManualReview({
|
|
84
|
+
title: 'Confirm the HttpClient backend supports upload progress',
|
|
85
|
+
summary: 'Queries in this workspace set `reportProgress`. On Angular ≥ 22 `provideHttpClient()` defaults to the fetch backend, which never emits upload progress events, so those queries would report download progress only.',
|
|
86
|
+
action: 'Switch the affected app to `provideHttpClient(withXhr())`, or drop `reportProgress` where it is unused.',
|
|
87
|
+
locations: filesWithUploadProgress,
|
|
88
|
+
source: 'http-client-check',
|
|
89
|
+
dedupeKey: 'upload-progress-backend',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=http-client-check.js.map
|