@phpsandbox/sdk 0.0.18 → 0.0.19

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.
@@ -4564,9 +4564,11 @@ var PHPSandbox = (() => {
4564
4564
 
4565
4565
  // src/index.ts
4566
4566
  var NotebookInitError = class extends Error {
4567
- constructor(message) {
4567
+ constructor(message, data = {}) {
4568
4568
  super(message);
4569
4569
  this.message = message;
4570
+ this.data = data;
4571
+ this.name = "NotebookInitError";
4570
4572
  }
4571
4573
  };
4572
4574
  var ApiError = class extends Error {
@@ -4593,6 +4595,10 @@ var PHPSandbox = (() => {
4593
4595
  const response = await this.client.get(`/notebook/${id}`);
4594
4596
  return new NotebookInstance(response.data, this.client);
4595
4597
  }
4598
+ async update(id, input = {}) {
4599
+ const response = await this.client.put(`/notebook/${id}`, input);
4600
+ return new NotebookInstance(response.data, this.client);
4601
+ }
4596
4602
  async delete(id) {
4597
4603
  await this.client.delete(`/notebook/${id}`);
4598
4604
  }
@@ -4636,6 +4642,9 @@ var PHPSandbox = (() => {
4636
4642
  delete(path) {
4637
4643
  return this.makeRequest("DELETE", path);
4638
4644
  }
4645
+ put(path, body) {
4646
+ return this.makeRequest("PUT", path, { body: body ? JSON.stringify(body) : void 0 });
4647
+ }
4639
4648
  async makeRequest(method, path, init) {
4640
4649
  const response = await this.fetch(
4641
4650
  new Request(new URL(`v1/${path.replace(/^\//, "")}`, this.baseUrl), {
@@ -4708,7 +4717,9 @@ var PHPSandbox = (() => {
4708
4717
  return this.invoke("ping");
4709
4718
  }
4710
4719
  listen(event, handler) {
4711
- return this.emitter.listen(event, handler);
4720
+ const disposable = this.emitter.listen(event, handler);
4721
+ this.disposables.push(disposable);
4722
+ return disposable;
4712
4723
  }
4713
4724
  dispose() {
4714
4725
  this.disposables.forEach((d) => d.dispose());
@@ -4766,9 +4777,7 @@ var PHPSandbox = (() => {
4766
4777
  return this.invoke("notebook.update");
4767
4778
  }
4768
4779
  onDidInitialize(handler) {
4769
- const disposable = this.listen("notebook.initialized", handler);
4770
- this.disposables.push(disposable);
4771
- return disposable;
4780
+ return this.listen("notebook.initialized", handler);
4772
4781
  }
4773
4782
  async reconnect() {
4774
4783
  const whenConnected = this.whenConnected();
@@ -4791,7 +4800,7 @@ var PHPSandbox = (() => {
4791
4800
  this.onDidInitialize((result) => {
4792
4801
  this.initialized = result;
4793
4802
  if (result.type === "error") {
4794
- reject(new NotebookInitError(result.message));
4803
+ reject(new NotebookInitError(result.message, result.data));
4795
4804
  }
4796
4805
  resolve(result);
4797
4806
  });