Skip to content

Commit e7054cd

Browse files
committed
feat(jsm): allow overriding the auto-resolved Assets workspace
Atlassian provisions one Assets workspace per site, so workspace discovery uses values[0] by design. For the rare multi-workspace site, expose an advanced "Assets Workspace ID" override on the block that flows through to every Assets operation, and document the single-workspace assumption.
1 parent 5539c1b commit e7054cd

2 files changed

Lines changed: 46 additions & 12 deletions

File tree

apps/sim/blocks/blocks/jira_service_management.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,27 @@ Return ONLY the comment text - no explanations.`,
763763
mode: 'advanced',
764764
condition: { field: 'operation', value: 'search_objects_aql' },
765765
},
766+
{
767+
id: 'assetWorkspaceId',
768+
title: 'Assets Workspace ID',
769+
type: 'short-input',
770+
placeholder: 'Override the auto-resolved Assets workspace',
771+
mode: 'advanced',
772+
condition: {
773+
field: 'operation',
774+
value: [
775+
'list_object_schemas',
776+
'get_object_schema',
777+
'list_object_types',
778+
'get_object_type_attributes',
779+
'search_objects_aql',
780+
'get_object',
781+
'create_object',
782+
'update_object',
783+
'delete_object',
784+
],
785+
},
786+
},
766787
...getTrigger('jsm_request_created').subBlocks,
767788
...getTrigger('jsm_request_updated').subBlocks,
768789
...getTrigger('jsm_request_commented').subBlocks,
@@ -914,6 +935,13 @@ Return ONLY the comment text - no explanations.`,
914935
domain: params.domain,
915936
}
916937

938+
// Assets tools accept an optional workspaceId override; when omitted the
939+
// route resolves the site's single Assets workspace automatically.
940+
const assetBaseParams = {
941+
...baseParams,
942+
workspaceId: params.assetWorkspaceId || undefined,
943+
}
944+
917945
switch (params.operation) {
918946
case 'get_service_desks':
919947
return {
@@ -1337,7 +1365,7 @@ Return ONLY the comment text - no explanations.`,
13371365
}
13381366
case 'list_object_schemas':
13391367
return {
1340-
...baseParams,
1368+
...assetBaseParams,
13411369
startAt: toOptionalInt(params.assetStartAt),
13421370
maxResults: toOptionalInt(params.assetMaxResults),
13431371
includeCounts: params.assetIncludeCounts === 'true' ? true : undefined,
@@ -1346,13 +1374,13 @@ Return ONLY the comment text - no explanations.`,
13461374
if (!params.assetSchemaId) {
13471375
throw new Error('Schema ID is required')
13481376
}
1349-
return { ...baseParams, schemaId: params.assetSchemaId }
1377+
return { ...assetBaseParams, schemaId: params.assetSchemaId }
13501378
case 'list_object_types':
13511379
if (!params.assetSchemaId) {
13521380
throw new Error('Schema ID is required')
13531381
}
13541382
return {
1355-
...baseParams,
1383+
...assetBaseParams,
13561384
schemaId: params.assetSchemaId,
13571385
excludeAbstract: params.assetExcludeAbstract === 'true' ? true : undefined,
13581386
}
@@ -1361,7 +1389,7 @@ Return ONLY the comment text - no explanations.`,
13611389
throw new Error('Object type ID is required')
13621390
}
13631391
return {
1364-
...baseParams,
1392+
...assetBaseParams,
13651393
objectTypeId: params.assetObjectTypeId,
13661394
onlyValueEditable: params.assetOnlyValueEditable === 'true' ? true : undefined,
13671395
query: params.assetAttributeQuery || undefined,
@@ -1371,7 +1399,7 @@ Return ONLY the comment text - no explanations.`,
13711399
throw new Error('AQL query is required')
13721400
}
13731401
return {
1374-
...baseParams,
1402+
...assetBaseParams,
13751403
qlQuery: params.assetQlQuery,
13761404
page: toOptionalInt(params.assetPage),
13771405
resultsPerPage: toOptionalInt(params.assetResultsPerPage),
@@ -1383,13 +1411,13 @@ Return ONLY the comment text - no explanations.`,
13831411
if (!params.assetObjectId) {
13841412
throw new Error('Object ID is required')
13851413
}
1386-
return { ...baseParams, objectId: params.assetObjectId }
1414+
return { ...assetBaseParams, objectId: params.assetObjectId }
13871415
case 'create_object':
13881416
if (!params.assetObjectTypeId) {
13891417
throw new Error('Object type ID is required')
13901418
}
13911419
return {
1392-
...baseParams,
1420+
...assetBaseParams,
13931421
objectTypeId: params.assetObjectTypeId,
13941422
attributes: parseAssetAttributes(params.assetAttributes),
13951423
}
@@ -1398,7 +1426,7 @@ Return ONLY the comment text - no explanations.`,
13981426
throw new Error('Object ID is required')
13991427
}
14001428
return {
1401-
...baseParams,
1429+
...assetBaseParams,
14021430
objectId: params.assetObjectId,
14031431
attributes: parseAssetAttributes(params.assetAttributes),
14041432
objectTypeId: params.assetObjectTypeId || undefined,
@@ -1407,7 +1435,7 @@ Return ONLY the comment text - no explanations.`,
14071435
if (!params.assetObjectId) {
14081436
throw new Error('Object ID is required')
14091437
}
1410-
return { ...baseParams, objectId: params.assetObjectId }
1438+
return { ...assetBaseParams, objectId: params.assetObjectId }
14111439
default:
14121440
return baseParams
14131441
}
@@ -1481,6 +1509,10 @@ Return ONLY the comment text - no explanations.`,
14811509
assetResultsPerPage: { type: 'string', description: 'AQL search results per page' },
14821510
assetIncludeAttributes: { type: 'string', description: 'Include attribute values in results' },
14831511
assetObjectSchemaId: { type: 'string', description: 'Scope AQL search to a schema ID' },
1512+
assetWorkspaceId: {
1513+
type: 'string',
1514+
description: 'Override the auto-resolved Assets workspace ID',
1515+
},
14841516
},
14851517
outputs: {
14861518
ts: { type: 'string', description: 'Timestamp of the operation' },

apps/sim/tools/jsm/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ export function getAssetsApiBaseUrl(cloudId: string, workspaceId: string): strin
103103
/**
104104
* Resolve the Assets `workspaceId` for a Jira site.
105105
*
106-
* Calls the Service Desk discovery endpoint, which returns one workspace per
107-
* site. Requires the `read:servicedesk-request` scope (already granted by the
108-
* `jira` provider).
106+
* Calls the Service Desk discovery endpoint and uses the first workspace.
107+
* Atlassian provisions a single Assets workspace per site, so this is the
108+
* canonical workspace; callers on a multi-workspace site can pass an explicit
109+
* `workspaceId` to {@link resolveAssetsContext} to override it. Requires the
110+
* `read:servicedesk-request` scope (already granted by the `jira` provider).
109111
* @param cloudId - The Jira Cloud ID
110112
* @param accessToken - The OAuth access token
111113
* @returns The Assets workspace ID for the site

0 commit comments

Comments
 (0)