@phpsandbox/sdk 0.0.24 → 0.0.27

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.
@@ -4551,6 +4551,15 @@ function isBeaconSupported() {
4551
4551
  }
4552
4552
 
4553
4553
  // src/index.ts
4554
+ function normalizeNotebookSecretInputs(input) {
4555
+ if (Array.isArray(input)) {
4556
+ return input;
4557
+ }
4558
+ return Object.entries(input).map(([name, value]) => ({
4559
+ name,
4560
+ ...typeof value === "string" ? { value } : value
4561
+ }));
4562
+ }
4554
4563
  var NotebookInitError = class extends Error {
4555
4564
  constructor(message, data = {}) {
4556
4565
  super(message);
@@ -4570,6 +4579,7 @@ var ApiError = class extends Error {
4570
4579
  var NotebookApi = class {
4571
4580
  constructor(client) {
4572
4581
  this.client = client;
4582
+ this.secrets = new NotebookSecretApi(client);
4573
4583
  }
4574
4584
  async create(template, input = {}, init = true) {
4575
4585
  const response = await this.client.post("/notebook", { template, ...input });
@@ -4644,11 +4654,38 @@ var Client = class {
4644
4654
  if (!response.ok) {
4645
4655
  throw new ApiError(response, await response.text());
4646
4656
  }
4647
- return { data: await response.json() };
4657
+ if (response.status === 204) {
4658
+ return { data: void 0 };
4659
+ }
4660
+ const body = await response.text();
4661
+ return { data: body === "" ? void 0 : JSON.parse(body) };
4648
4662
  }
4649
4663
  };
4650
4664
  var PHPSandbox = class extends Client {
4651
4665
  };
4666
+ var NotebookSecretApi = class {
4667
+ constructor(client) {
4668
+ this.client = client;
4669
+ }
4670
+ async list(id) {
4671
+ const response = await this.client.get(`/notebook/${id}/secrets`);
4672
+ return response.data;
4673
+ }
4674
+ async set(id, name, input) {
4675
+ const payload = typeof input === "string" ? { name, value: input } : { name, ...input };
4676
+ const response = await this.client.put(`/notebook/${id}/secrets`, payload);
4677
+ return response.data;
4678
+ }
4679
+ async setMany(id, input) {
4680
+ const response = await this.client.put(`/notebook/${id}/secrets`, {
4681
+ secrets: normalizeNotebookSecretInputs(input)
4682
+ });
4683
+ return response.data;
4684
+ }
4685
+ async delete(id, name) {
4686
+ await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}`);
4687
+ }
4688
+ };
4652
4689
  var _initPromise, _NotebookInstance_instances, init_fn;
4653
4690
  var NotebookInstance = class {
4654
4691
  constructor(data, client) {
@@ -4676,6 +4713,7 @@ var NotebookInstance = class {
4676
4713
  this.laravel = new Lravel(this);
4677
4714
  this.shell = new Shell(this);
4678
4715
  this.git = new Git(this);
4716
+ this.secrets = new NotebookSecrets(client, this.data.id);
4679
4717
  }
4680
4718
  async ready() {
4681
4719
  const ready = async () => {
@@ -4797,6 +4835,24 @@ init_fn = function() {
4797
4835
  }));
4798
4836
  return __privateGet(this, _initPromise);
4799
4837
  };
4838
+ var NotebookSecrets = class {
4839
+ constructor(client, notebookId) {
4840
+ this.client = client;
4841
+ this.notebookId = notebookId;
4842
+ }
4843
+ list() {
4844
+ return this.client.notebook.secrets.list(this.notebookId);
4845
+ }
4846
+ set(name, input) {
4847
+ return this.client.notebook.secrets.set(this.notebookId, name, input);
4848
+ }
4849
+ setMany(input) {
4850
+ return this.client.notebook.secrets.setMany(this.notebookId, input);
4851
+ }
4852
+ delete(name) {
4853
+ return this.client.notebook.secrets.delete(this.notebookId, name);
4854
+ }
4855
+ };
4800
4856
  export {
4801
4857
  ApiError,
4802
4858
  Beacon,
@@ -4816,6 +4872,8 @@ export {
4816
4872
  NotebookApi,
4817
4873
  NotebookInitError,
4818
4874
  NotebookInstance,
4875
+ NotebookSecretApi,
4876
+ NotebookSecrets,
4819
4877
  NotebookState,
4820
4878
  PHPSandbox,
4821
4879
  PHPSandboxError,