MCPcopy Index your code
hub / github.com/simstudioai/sim / requestToStub

Function requestToStub

apps/sim/connectors/jsm/jsm.ts:188–222  ·  view source on GitHub ↗

* Builds a stub ExternalDocument from a request returned by the list endpoint. * Content is deferred — description and comments require a per-request API call * fetched lazily in `getDocument`. The contentHash is metadata-only so it is * identical whether produced here or in `getDocument`.

(request: JsmRequest, domain: string)

Source from the content-addressed store, hash-verified

186 * identical whether produced here or in `getDocument`.
187 */
188function requestToStub(request: JsmRequest, domain: string): ExternalDocument {
189 const issueId = String(request.issueId ?? '')
190 const issueKey = request.issueKey ?? issueId
191 const summary = getFieldText(request, 'summary') || 'Untitled'
192 const status = request.currentStatus?.status
193
194 const bareDomain = domain
195 .trim()
196 .replace(/^https?:\/\//i, '')
197 .replace(/\/+$/, '')
198
199 return {
200 externalId: issueId,
201 title: `${issueKey}: ${summary}`,
202 content: '',
203 contentDeferred: true,
204 mimeType: 'text/plain',
205 sourceUrl: request._links?.web || `https://${bareDomain}/browse/${issueKey}`,
206 contentHash: `jsm:${issueId}:${getChangeIndicator(request)}`,
207 metadata: {
208 issueKey,
209 requestTypeId: request.requestTypeId,
210 serviceDeskId: request.serviceDeskId,
211 status,
212 reporter: request.reporter?.displayName,
213 created: request.createdDate?.iso8601,
214 /**
215 * The list endpoint has no true "last updated" field; `statusDate` is the
216 * closest available signal (time of last status change). Mapped to the
217 * `updated` tag and documented as such.
218 */
219 statusDate: request.currentStatus?.statusDate?.iso8601,
220 },
221 }
222}
223
224/**
225 * Renders a readable plain-text document from a fully-fetched request and its

Callers 1

jsm.tsFile · 0.85

Calls 3

getFieldTextFunction · 0.85
getChangeIndicatorFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected