MCPcopy Index your code
hub / github.com/callstack/agent-device / allocate

Method allocate

src/cloud-webdriver/runtime.ts:215–254  ·  view source on GitHub ↗
(
    lease: DeviceLease,
    req?: DaemonRequest,
  )

Source from the content-addressed store, hash-verified

213 }
214
215 private async allocate(
216 lease: DeviceLease,
217 req?: DaemonRequest,
218 ): Promise<Record<string, unknown> | undefined> {
219 if (lease.leaseProvider !== this.provider) return undefined;
220 if (this.sessionsByLeaseId.has(lease.leaseId)) return this.heartbeat(lease);
221 const prepared = await this.prepareSession(lease, req);
222 const client = new WebDriverClient({
223 endpoint: prepared.endpoint,
224 auth: prepared.auth,
225 headers: prepared.headers,
226 requestPolicy: this.options.requestPolicy,
227 });
228 const session = await this.createSessionWithPreparedCleanup(client, prepared);
229 const device = this.deviceForLease(lease, prepared);
230 const providerSessionId = prepared.providerSessionId ?? session.sessionId;
231 const capabilities = this.capabilitiesForPlatform(prepared.platform);
232 this.sessionsByLeaseId.set(lease.leaseId, {
233 lease,
234 device,
235 client,
236 prepared,
237 capabilities,
238 webDriverSessionId: session.sessionId,
239 providerSessionId,
240 interactor: createWebDriverInteractor({
241 client,
242 backend: snapshotBackendForPlatform(prepared.platform),
243 capabilities,
244 }),
245 });
246 return {
247 provider: this.provider,
248 deviceId: device.id,
249 sessionId: session.sessionId,
250 providerSessionId,
251 capabilities,
252 ...prepared.providerData,
253 };
254 }
255
256 private async createSessionWithPreparedCleanup(
257 client: WebDriverClient,

Callers 6

constructorMethod · 0.95
allocateOrReuseLeaseFunction · 0.80
handleLeaseCommandsFunction · 0.80
client.test.tsFile · 0.80

Calls 8

heartbeatMethod · 0.95
prepareSessionMethod · 0.95
deviceForLeaseMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected