Skip to content

Commit 9e98f85

Browse files
committed
make app_type optional
1 parent 5fff98a commit 9e98f85

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

packages/core/src/awsService/sagemaker/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function deeplinkConnect(
8686
wsUrl: string,
8787
token: string,
8888
domain: string,
89-
appType: string
89+
appType?: string
9090
) {
9191
getLogger().debug(
9292
`sm:deeplinkConnect: connectionIdentifier: ${connectionIdentifier} session: ${session} wsUrl: ${wsUrl} token: ${token}`

packages/core/src/awsService/sagemaker/uriHandlers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ export function register(ctx: ExtContext) {
2828
}
2929

3030
export function parseConnectParams(query: SearchParams) {
31-
const params = query.getFromKeysOrThrow(
31+
const requiredParams = query.getFromKeysOrThrow(
3232
'connection_identifier',
3333
'domain',
3434
'user_profile',
3535
'session',
3636
'ws_url',
3737
'cell-number',
38-
'token',
39-
'app_type'
38+
'token'
4039
)
41-
return params
40+
const optionalParams = query.getFromKeys('app_type')
41+
42+
return { ...requiredParams, ...optionalParams }
4243
}

packages/core/src/test/awsService/sagemaker/uriHandlers.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,29 @@ describe('SageMaker URI handler', function () {
5656
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[3], 'wss://example.com&cell-number=4')
5757
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[4], 'my-token')
5858
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[5], 'my-domain')
59+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[6], 'jupyterlab')
60+
})
61+
62+
it('calls deeplinkConnect with undefined app_type when not provided', async function () {
63+
const params = {
64+
connection_identifier: 'abc123',
65+
domain: 'my-domain',
66+
user_profile: 'me',
67+
session: 'sess-xyz',
68+
ws_url: 'wss://example.com',
69+
'cell-number': '4',
70+
token: 'my-token',
71+
}
72+
73+
const uri = createConnectUri(params)
74+
await handler.handleUri(uri)
75+
76+
assert.ok(deeplinkConnectStub.calledOnce)
77+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[1], 'abc123')
78+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[2], 'sess-xyz')
79+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[3], 'wss://example.com&cell-number=4')
80+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[4], 'my-token')
81+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[5], 'my-domain')
82+
assert.deepStrictEqual(deeplinkConnectStub.firstCall.args[6], undefined)
5983
})
6084
})

0 commit comments

Comments
 (0)