TypeScript SDK
Client configuration
Configure the @dsplane/core Fetch client with a landscape URL, JWT authentication, headers, and request options.
DSPlaneCore accepts a Fetch client created by createClient() from @dsplane/core/client.
Configure a landscape client
import { DSPlaneCore } from '@dsplane/core';
import { createClient } from '@dsplane/core/client';
const client = createClient({
auth: () => `Bearer ${jwt}`,
baseUrl: 'https://example.applicationstudio.cloud.sap/',
headers: {
Accept: 'application/json, text/plain, */*',
},
});
const dsplane = new DSPlaneCore({ client });
The generated ClientOptions model requires baseUrl to contain a URL scheme.
Configure authentication
The generated workspace operations declare the x-approuter-authorization security scheme. Provide the JWT through the client’s auth option:
const client = createClient({
auth: () => (jwt.startsWith('Bearer ') ? jwt : `Bearer ${jwt}`),
baseUrl: landscapeUrl,
});
The /key operation does not declare the same OpenAPI security scheme. DS Plane CLI creates a client for the Dev Space startup URL and sets the header explicitly:
const startupClient = createClient({
baseUrl: startupUrl,
headers: {
Authorization: `Bearer ${jwt}`,
},
});
const dsplane = new DSPlaneCore({ client: startupClient });
const privateKey = await dsplane.wsManager.fetchKey();
Override one operation
Each generated method accepts an options object after its flat parameters. Use it to override supported client request options:
const environment = await dsplane.wsManager.fetchEnvironment(
{ wsID: 'workspace-id' },
{
headers: {
'X-Request-ID': crypto.randomUUID(),
},
},
);
You can also pass another generated client through the operation’s client option.
Use multiple clients
Each DSPlaneCore instance retains the client passed to its constructor:
const production = new DSPlaneCore({
client: createClient({
auth: () => productionJwt,
baseUrl: productionLandscape,
}),
});
const development = new DSPlaneCore({
client: createClient({
auth: () => developmentJwt,
baseUrl: developmentLandscape,
}),
});
Use separate instances when credentials or landscape origins differ.
Handle errors
Generated methods accept the Fetch client’s standard options, including throwOnError. The generated signatures default their ThrowOnError generic to false.
const environment = await dsplane.wsManager.fetchEnvironment(
{ wsID: 'workspace-id' },
{ throwOnError: true },
);
When throwOnError is enabled, handle failures at the boundary appropriate for your application.