Skip to content

chore: Adds createServiceMethodFactory + transfer.tunnel.next.*#753

Open
jbottigliero wants to merge 15 commits intomainfrom
refactor-method-signatures
Open

chore: Adds createServiceMethodFactory + transfer.tunnel.next.*#753
jbottigliero wants to merge 15 commits intomainfrom
refactor-method-signatures

Conversation

@jbottigliero
Copy link
Member

@jbottigliero jbottigliero commented Feb 13, 2026

This pull request only introduces the new signatures under the next namespace for Tunnels (e.g., transfer.tunnel.next.getAll())

This will allow us to pilot the new signatures (for use in @globus/react-query) before moving forward.


Use a single type for all service methods, enforced by a factory method.

New Call Signature

All service methods now take a single parameter (ServiceMethodPayload); There are no more positional arguments for path segments.

type ServiceMethodPayload = {
  // For methods that require segments, the named path segment will be included in the type.
  // @example: { endpoint_id: string }
  [segment: string]?: string; 
  request?: Omit<BaseServiceMethodOptions, 'payload'> & {
    /**
     * `payload` has been renamed to `data` to better reflect its purpose and avoid confusion with
     * the `ServiceMethodPayload`/object.
     */
    data?: Record<string, unknown>;
  };
  options?: SDKOptions;
};

Method without Segments

// Legacy Signature
await tunnels.getAll({
  query: { filter_name: 'job_name' }
});

// New Signature
await tunnels.next.getAll({
  request: { query: { filter_name: 'job_name' } }
});

Method with Segments

// Legacy Signature
await tunnels.get('example-tunnel-id', {
      query: {
        foo: 'bar',
    },
});

// New Signature
await  tunnels.next.get({
    id: 'example-tunnel-id',
    request: {
      query: {
        foo: 'bar',
      },
    },
});

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.35%. Comparing base (da73698) to head (f8f518e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #753      +/-   ##
==========================================
+ Coverage   95.25%   95.35%   +0.09%     
==========================================
  Files          84       85       +1     
  Lines        1561     1592      +31     
  Branches      248      258      +10     
==========================================
+ Hits         1487     1518      +31     
  Misses         73       73              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbottigliero jbottigliero changed the title wip: createServiceMethodFactory feat: createServiceMethodFactory + tunnel.next.* Feb 13, 2026
@jbottigliero jbottigliero changed the title feat: createServiceMethodFactory + tunnel.next.* feat: Adds createServiceMethodFactory + transfer.tunnel.next.* Feb 13, 2026
@jbottigliero jbottigliero changed the title feat: Adds createServiceMethodFactory + transfer.tunnel.next.* chore: Adds createServiceMethodFactory + transfer.tunnel.next.* Feb 13, 2026
@jbottigliero
Copy link
Member Author

Comment on lines +150 to +158
describe('Typescript Types', () => {
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention */
/**
* Compile-time type equality check.
* If the two type arguments are not identical the assignment will fail to compile.
*/
type Expect<T extends true> = T;
type Equal<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
test('method with segments requires all segments', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wild, I've never seen a "type" test like this. Still trying to parse it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic constraints are just used to see if the two passed in values extend each other (returning true | false) then the wrapped Expect is just looking for true.

It probably won't work for all types, and could very likely be tricked based on type inheritance, but seemed like a decent gut check.

I think we'll eventually move this to Vitest and use https://vitest.dev/guide/testing-types.html (https://github.com/mmkal/expect-type)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants