kurtosis-sdk 0.57.5 → 0.57.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ import { ServiceContext } from "../services/service_context";
7
7
  import type { PartitionConnection } from "./partition_connection";
8
8
  import { TemplateAndData } from "./template_and_data";
9
9
  import { Readable } from "stream";
10
+ import { StarlarkRunResult } from "./starlark_run_blocking";
10
11
  export declare type EnclaveID = string;
11
12
  export declare type PartitionID = string;
12
13
  export declare const KURTOSIS_YAML_FILENAME = "kurtosis.yml";
@@ -22,8 +23,11 @@ export declare class EnclaveContext {
22
23
  unloadModule(moduleId: ModuleID): Promise<Result<null, Error>>;
23
24
  getModuleContext(moduleId: ModuleID): Promise<Result<ModuleContext, Error>>;
24
25
  runStarlarkScript(serializedStartosisScript: string, serializedParams: string, dryRun: boolean): Promise<Result<Readable, Error>>;
26
+ runStarlarkScriptBlocking(serializedStartosisScript: string, serializedParams: string, dryRun: boolean): Promise<Result<StarlarkRunResult, Error>>;
25
27
  runStarlarkPackage(packageRootPath: string, serializedParams: string, dryRun: boolean): Promise<Result<Readable, Error>>;
28
+ runStarlarkPackageBlocking(packageRootPath: string, serializedParams: string, dryRun: boolean): Promise<Result<StarlarkRunResult, Error>>;
26
29
  runStarlarkRemotePackage(moduleId: string, serializedParams: string, dryRun: boolean): Promise<Result<Readable, Error>>;
30
+ runStarlarkRemotePackageBlocking(moduleId: string, serializedParams: string, dryRun: boolean): Promise<Result<StarlarkRunResult, Error>>;
27
31
  addService(serviceId: ServiceID, containerConfig: ContainerConfig): Promise<Result<ServiceContext, Error>>;
28
32
  addServices(containerConfigs: Map<ServiceID, ContainerConfig>): Promise<Result<[Map<ServiceID, ServiceContext>, Map<ServiceID, Error>], Error>>;
29
33
  addServiceToPartition(serviceId: ServiceID, partitionId: PartitionID, containerConfig: ContainerConfig): Promise<Result<ServiceContext, Error>>;
@@ -26,6 +26,7 @@ const port_spec_1 = require("../services/port_spec");
26
26
  const api_container_service_pb_1 = require("../../kurtosis_core_rpc_api_bindings/api_container_service_pb");
27
27
  const path = require("path");
28
28
  const kurtosis_yaml_1 = require("./kurtosis_yaml");
29
+ const starlark_run_blocking_1 = require("./starlark_run_blocking");
29
30
  // This will always resolve to the default partition ID (regardless of whether such a partition exists in the enclave,
30
31
  // or it was repartitioned away)
31
32
  const DEFAULT_PARTITION_ID = "";
@@ -153,6 +154,17 @@ class EnclaveContext {
153
154
  return (0, neverthrow_1.ok)(scriptRunResult.value);
154
155
  });
155
156
  }
157
+ // Docs available at https://docs.kurtosis.com/sdk/#runstarlarkscriptblockingstring-serializedstarlarkscript-boolean-dryrun---starlarkrunresult-runresult-error-error
158
+ runStarlarkScriptBlocking(serializedStartosisScript, serializedParams, dryRun) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ const runAsyncResponse = yield this.runStarlarkScript(serializedStartosisScript, serializedParams, dryRun);
161
+ if (runAsyncResponse.isErr()) {
162
+ return (0, neverthrow_1.err)(runAsyncResponse.error);
163
+ }
164
+ const fullRunResult = yield (0, starlark_run_blocking_1.readStreamContentUntilClosed)(runAsyncResponse.value);
165
+ return (0, neverthrow_1.ok)(fullRunResult);
166
+ });
167
+ }
156
168
  // Docs available at https://docs.kurtosis.com/sdk/#runstarlarkpackagestring-packagerootpath-string-serializedparams-boolean-dryrun---streamstarlarkrunresponseline-responselines-error-error
157
169
  runStarlarkPackage(packageRootPath, serializedParams, dryRun) {
158
170
  return __awaiter(this, void 0, void 0, function* () {
@@ -167,6 +179,17 @@ class EnclaveContext {
167
179
  return (0, neverthrow_1.ok)(packageRunResult.value);
168
180
  });
169
181
  }
182
+ // Docs available at https://docs.kurtosis.com/sdk/#runstarlarkpackageblockingstring-packagerootpath-string-serializedparams-boolean-dryrun---starlarkrunresult-runresult-error-error
183
+ runStarlarkPackageBlocking(packageRootPath, serializedParams, dryRun) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ const runAsyncResponse = yield this.runStarlarkPackage(packageRootPath, serializedParams, dryRun);
186
+ if (runAsyncResponse.isErr()) {
187
+ return (0, neverthrow_1.err)(runAsyncResponse.error);
188
+ }
189
+ const fullRunResult = yield (0, starlark_run_blocking_1.readStreamContentUntilClosed)(runAsyncResponse.value);
190
+ return (0, neverthrow_1.ok)(fullRunResult);
191
+ });
192
+ }
170
193
  // Docs available at https://docs.kurtosis.com/sdk/#runremotestarlarkpackagestring-packageid-string-serializedparams-boolean-dryrun---streamstarlarkrunresponseline-responselines-error-error
171
194
  runStarlarkRemotePackage(moduleId, serializedParams, dryRun) {
172
195
  return __awaiter(this, void 0, void 0, function* () {
@@ -182,6 +205,17 @@ class EnclaveContext {
182
205
  return (0, neverthrow_1.ok)(remotePackageRunResult.value);
183
206
  });
184
207
  }
208
+ // Docs available at https://docs.kurtosis.com/sdk/#runstarlarkremotepackageblockingstring-packageid-string-serializedparams-boolean-dryrun---starlarkrunresult-runresult-error-error
209
+ runStarlarkRemotePackageBlocking(moduleId, serializedParams, dryRun) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const runAsyncResponse = yield this.runStarlarkRemotePackage(moduleId, serializedParams, dryRun);
212
+ if (runAsyncResponse.isErr()) {
213
+ return (0, neverthrow_1.err)(runAsyncResponse.error);
214
+ }
215
+ const fullRunResult = yield (0, starlark_run_blocking_1.readStreamContentUntilClosed)(runAsyncResponse.value);
216
+ return (0, neverthrow_1.ok)(fullRunResult);
217
+ });
218
+ }
185
219
  // Docs available at https://docs.kurtosis.com/sdk/#addserviceserviceid-serviceid--containerconfig-containerconfig---servicecontext-servicecontext
186
220
  addService(serviceId, containerConfig) {
187
221
  return __awaiter(this, void 0, void 0, function* () {
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from "stream";
3
+ import { StarlarkExecutionError, StarlarkInstruction, StarlarkInterpretationError, StarlarkValidationError } from "../../kurtosis_core_rpc_api_bindings/api_container_service_pb";
4
+ export declare class StarlarkRunResult {
5
+ readonly runOutput: string;
6
+ readonly instructions: Array<StarlarkInstruction>;
7
+ readonly interpretationError: StarlarkInterpretationError | undefined;
8
+ readonly validationErrors: Array<StarlarkValidationError>;
9
+ readonly executionError: StarlarkExecutionError | undefined;
10
+ constructor(runOutput: string, instructions: Array<StarlarkInstruction>, interpretationError: StarlarkInterpretationError | undefined, validationErrors: Array<StarlarkValidationError>, executionError: StarlarkExecutionError | undefined);
11
+ }
12
+ export declare function readStreamContentUntilClosed(responseLines: Readable): Promise<StarlarkRunResult>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.readStreamContentUntilClosed = exports.StarlarkRunResult = void 0;
13
+ const STARLARK_RUN_OUTPUT_LINE_SPLIT = "\n";
14
+ class StarlarkRunResult {
15
+ constructor(runOutput, instructions, interpretationError, validationErrors, executionError) {
16
+ this.runOutput = runOutput;
17
+ this.instructions = instructions;
18
+ this.interpretationError = interpretationError;
19
+ this.validationErrors = validationErrors;
20
+ this.executionError = executionError;
21
+ }
22
+ }
23
+ exports.StarlarkRunResult = StarlarkRunResult;
24
+ function readStreamContentUntilClosed(responseLines) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ let scriptOutput = "";
27
+ let interpretationError;
28
+ let validationErrors = [];
29
+ let executionError;
30
+ let instructions = [];
31
+ return new Promise((resolve, error) => {
32
+ responseLines.on('data', (responseLine) => {
33
+ var _a, _b, _c, _d, _e, _f;
34
+ if (responseLine.getInstruction() !== undefined) {
35
+ instructions.push(responseLine.getInstruction());
36
+ }
37
+ else if (responseLine.getInstructionResult() !== undefined) {
38
+ scriptOutput += ((_a = responseLine.getInstructionResult()) === null || _a === void 0 ? void 0 : _a.getSerializedInstructionResult()) + STARLARK_RUN_OUTPUT_LINE_SPLIT;
39
+ }
40
+ else if (responseLine.getError() !== undefined) {
41
+ if (((_b = responseLine.getError()) === null || _b === void 0 ? void 0 : _b.getInterpretationError()) !== undefined) {
42
+ interpretationError = (_c = responseLine.getError()) === null || _c === void 0 ? void 0 : _c.getInterpretationError();
43
+ }
44
+ else if (((_d = responseLine.getError()) === null || _d === void 0 ? void 0 : _d.getValidationError()) !== undefined) {
45
+ validationErrors.push(responseLine.getError().getInterpretationError());
46
+ }
47
+ else if (((_e = responseLine.getError()) === null || _e === void 0 ? void 0 : _e.getExecutionError()) !== undefined) {
48
+ executionError = (_f = responseLine.getError()) === null || _f === void 0 ? void 0 : _f.getExecutionError();
49
+ }
50
+ }
51
+ });
52
+ responseLines.on('error', function () {
53
+ if (!responseLines.destroyed) {
54
+ responseLines.destroy();
55
+ error(new Error("Unexpected error"));
56
+ }
57
+ });
58
+ responseLines.on('end', function () {
59
+ if (!responseLines.destroyed) {
60
+ responseLines.destroy();
61
+ resolve(new StarlarkRunResult(scriptOutput, instructions, interpretationError, validationErrors, executionError));
62
+ }
63
+ });
64
+ });
65
+ });
66
+ }
67
+ exports.readStreamContentUntilClosed = readStreamContentUntilClosed;
@@ -4,5 +4,5 @@ exports.KURTOSIS_VERSION = void 0;
4
4
  // !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
5
5
  // This is necessary so that Kurt Core consumers (e.g. modules) will know if they're compatible with the currently-running
6
6
  // API container
7
- exports.KURTOSIS_VERSION = "0.57.5";
7
+ exports.KURTOSIS_VERSION = "0.57.7";
8
8
  // !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kurtosis-sdk",
3
3
  "//": "NOTE: DO NOT UPDATE THIS VERSION MANUALLY - IT WILL BE UPDATED DURING THE RELEASE PROCESS!",
4
- "version": "0.57.5",
4
+ "version": "0.57.7",
5
5
  "main": "./build/index",
6
6
  "description": "This repo contains a Typescript client for communicating with the Kurtosis Engine server, which is responsible for creating, managing and destroying Kurtosis Enclaves.",
7
7
  "types": "./build/index",