Skip to content

Commit 016fcc2

Browse files
committed
chore(blueprints): Add convenience build_context API that takes a StorageObject directly.
1 parent 9edd07f commit 016fcc2

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/sdk.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@ export class DevboxOps {
283283
* });
284284
* const devbox = await sdk.devbox.createFromBlueprintId(blueprint.id, { name: 'my-devbox' });
285285
* ```
286+
*
287+
* To use a local directory as a build context, use an object.
288+
*
289+
* @example
290+
* ```typescript
291+
* const sdk = new RunloopSDK();
292+
* const obj = await sdk.storageObject.uploadFromDir(
293+
* './',
294+
* {
295+
* name: 'build-context',
296+
* ttl_ms: 3600000, // 1 hour
297+
* }
298+
* );
299+
* const blueprint = await sdk.blueprint.create({
300+
* name: 'my-blueprint-with-context',
301+
* dockerfile: `FROM ubuntu:22.04
302+
* COPY . .`,
303+
* build_context: obj,
304+
* });
305+
* ```
286306
*/
287307
export class BlueprintOps {
288308
/**
@@ -297,12 +317,18 @@ export class BlueprintOps {
297317
* @returns {Promise<Blueprint>} A {@link Blueprint} instance.
298318
*/
299319
async create(
300-
params: BlueprintCreateParams,
320+
params: Omit<BlueprintCreateParams, 'build_context'> & {
321+
build_context?: StorageObject | BlueprintCreateParams.BuildContext | null;
322+
},
301323
options?: Core.RequestOptions & {
302324
polling?: Partial<PollingOptions<RunloopAPI.Blueprints.BlueprintView>>;
303325
},
304326
): Promise<Blueprint> {
305-
return Blueprint.create(this.client, params, options);
327+
let rawParams = { ...params };
328+
if (params.build_context instanceof StorageObject) {
329+
rawParams.build_context = { type: 'object', object_id: params.build_context.id };
330+
}
331+
return Blueprint.create(this.client, rawParams as BlueprintCreateParams, options);
306332
}
307333

308334
/**

0 commit comments

Comments
 (0)