@trpc/upgrade 11.0.0-rc.824 → 11.0.0-rc.828

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/bin.js CHANGED
@@ -9,7 +9,7 @@ import { exec } from 'node:child_process';
9
9
  import { promisify } from 'node:util';
10
10
  import __node_cjsModule from 'node:module';
11
11
 
12
- var version = "11.0.0-rc.824+b21849468";
12
+ var version = "11.0.0-rc.828+322552736";
13
13
 
14
14
  function getProgram() {
15
15
  const configFile = ts.findConfigFile(process.cwd(), (filepath)=>ts.sys.fileExists(filepath));
@@ -233,7 +233,7 @@ function transform(file, api, options) {
233
233
  root.find(j.Identifier, {
234
234
  name: oldIdentifier.name
235
235
  }).forEach((path)=>{
236
- if (j.MemberExpression.check(path.parent?.parent?.node)) {
236
+ if (j.MemberExpression.check(path.parent?.parent?.node) || j.CallExpression.check(path.parent?.parent?.node)) {
237
237
  const callExprPath = findParentOfType(path.parentPath, j.CallExpression);
238
238
  if (!callExprPath) {
239
239
  console.warn(`Failed to walk up the tree to find utilMethod call expression, on file: ${file.path}`, callExprPath, {
@@ -251,7 +251,7 @@ function transform(file, api, options) {
251
251
  });
252
252
  return;
253
253
  }
254
- if (!(j.MemberExpression.check(memberExpr.object) && j.Identifier.check(memberExpr.property) && memberExpr.property.name in utilMap)) {
254
+ if (!(j.Identifier.check(memberExpr.property) && memberExpr.property.name in utilMap)) {
255
255
  console.warn('Failed to identify utilMethod from proxy call expression', memberExpr);
256
256
  return;
257
257
  }
@@ -333,6 +333,7 @@ function transform(file, api, options) {
333
333
  const tuple = j.ArrayPattern.check(declarator?.id) ? declarator.id : null;
334
334
  const dataName = j.Identifier.check(tuple?.elements?.[0]) ? tuple.elements[0].name : null;
335
335
  const queryName = j.Identifier.check(tuple?.elements?.[1]) ? tuple.elements[1].name : null;
336
+ const deepDestructure = j.ArrayPattern.check(declarator?.id) && j.ObjectPattern.check(tuple?.elements?.[0]) ? tuple?.elements?.[0] : null;
336
337
  if (queryName) {
337
338
  declarator.id = j.identifier(queryName);
338
339
  dirtyFlag = true;
@@ -347,6 +348,12 @@ function transform(file, api, options) {
347
348
  j.property('init', j.identifier('data'), j.identifier(dataName))
348
349
  ]);
349
350
  dirtyFlag = true;
351
+ } else if (deepDestructure) {
352
+ // const [{ dataName }] = ... => const { data: { dataName } } = ...
353
+ declarator.id = j.objectPattern([
354
+ j.property('init', j.identifier('data'), deepDestructure)
355
+ ]);
356
+ dirtyFlag = true;
350
357
  }
351
358
  });
352
359
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/upgrade",
3
- "version": "11.0.0-rc.824+b21849468",
3
+ "version": "11.0.0-rc.828+322552736",
4
4
  "description": "Upgrade scripts for tRPC",
5
5
  "author": "juliusmarminge",
6
6
  "license": "MIT",
@@ -39,10 +39,10 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@tanstack/react-query": "^5.67.1",
42
- "@trpc/client": "11.0.0-rc.824+b21849468",
43
- "@trpc/react-query": "11.0.0-rc.824+b21849468",
44
- "@trpc/server": "11.0.0-rc.824+b21849468",
45
- "@trpc/tanstack-react-query": "11.0.0-rc.824+b21849468",
42
+ "@trpc/client": "11.0.0-rc.828+322552736",
43
+ "@trpc/react-query": "11.0.0-rc.828+322552736",
44
+ "@trpc/server": "11.0.0-rc.828+322552736",
45
+ "@trpc/tanstack-react-query": "11.0.0-rc.828+322552736",
46
46
  "@types/jscodeshift": "0.12.0",
47
47
  "@types/node": "^22.13.5",
48
48
  "bunchee": "6.4.0",
@@ -56,5 +56,5 @@
56
56
  "funding": [
57
57
  "https://trpc.io/sponsor"
58
58
  ],
59
- "gitHead": "b218494681e3e70ce41c8b25785765c9985c08f5"
59
+ "gitHead": "322552736e8e54f7fa07cb532032a86292408119"
60
60
  }
@@ -232,7 +232,10 @@ export default function transform(
232
232
  root
233
233
  .find(j.Identifier, { name: oldIdentifier.name })
234
234
  .forEach((path) => {
235
- if (j.MemberExpression.check(path.parent?.parent?.node)) {
235
+ if (
236
+ j.MemberExpression.check(path.parent?.parent?.node) ||
237
+ j.CallExpression.check(path.parent?.parent?.node)
238
+ ) {
236
239
  const callExprPath = findParentOfType<CallExpression>(
237
240
  path.parentPath,
238
241
  j.CallExpression,
@@ -261,7 +264,6 @@ export default function transform(
261
264
 
262
265
  if (
263
266
  !(
264
- j.MemberExpression.check(memberExpr.object) &&
265
267
  j.Identifier.check(memberExpr.property) &&
266
268
  memberExpr.property.name in utilMap
267
269
  )
@@ -403,6 +405,12 @@ export default function transform(
403
405
  ? tuple.elements[1].name
404
406
  : null;
405
407
 
408
+ const deepDestructure =
409
+ j.ArrayPattern.check(declarator?.id) &&
410
+ j.ObjectPattern.check(tuple?.elements?.[0])
411
+ ? tuple?.elements?.[0]
412
+ : null;
413
+
406
414
  if (queryName) {
407
415
  declarator.id = j.identifier(queryName);
408
416
  dirtyFlag = true;
@@ -423,6 +431,12 @@ export default function transform(
423
431
  j.property('init', j.identifier('data'), j.identifier(dataName)),
424
432
  ]);
425
433
  dirtyFlag = true;
434
+ } else if (deepDestructure) {
435
+ // const [{ dataName }] = ... => const { data: { dataName } } = ...
436
+ declarator.id = j.objectPattern([
437
+ j.property('init', j.identifier('data'), deepDestructure),
438
+ ]);
439
+ dirtyFlag = true;
426
440
  }
427
441
  });
428
442
  }