@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.
@@ -333,6 +333,8 @@ var PHPSandbox = (() => {
333
333
  NotebookApi: () => NotebookApi,
334
334
  NotebookInitError: () => NotebookInitError,
335
335
  NotebookInstance: () => NotebookInstance,
336
+ NotebookSecretApi: () => NotebookSecretApi,
337
+ NotebookSecrets: () => NotebookSecrets,
336
338
  NotebookState: () => NotebookState,
337
339
  PHPSandbox: () => PHPSandbox,
338
340
  PHPSandboxError: () => PHPSandboxError,
@@ -4591,6 +4593,15 @@ var PHPSandbox = (() => {
4591
4593
  }
4592
4594
 
4593
4595
  // src/index.ts
4596
+ function normalizeNotebookSecretInputs(input) {
4597
+ if (Array.isArray(input)) {
4598
+ return input;
4599
+ }
4600
+ return Object.entries(input).map(([name, value]) => ({
4601
+ name,
4602
+ ...typeof value === "string" ? { value } : value
4603
+ }));
4604
+ }
4594
4605
  var NotebookInitError = class extends Error {
4595
4606
  constructor(message, data = {}) {
4596
4607
  super(message);
@@ -4610,6 +4621,7 @@ var PHPSandbox = (() => {
4610
4621
  var NotebookApi = class {
4611
4622
  constructor(client) {
4612
4623
  this.client = client;
4624
+ this.secrets = new NotebookSecretApi(client);
4613
4625
  }
4614
4626
  async create(template, input = {}, init = true) {
4615
4627
  const response = await this.client.post("/notebook", { template, ...input });
@@ -4684,11 +4696,38 @@ var PHPSandbox = (() => {
4684
4696
  if (!response.ok) {
4685
4697
  throw new ApiError(response, await response.text());
4686
4698
  }
4687
- return { data: await response.json() };
4699
+ if (response.status === 204) {
4700
+ return { data: void 0 };
4701
+ }
4702
+ const body = await response.text();
4703
+ return { data: body === "" ? void 0 : JSON.parse(body) };
4688
4704
  }
4689
4705
  };
4690
4706
  var PHPSandbox = class extends Client {
4691
4707
  };
4708
+ var NotebookSecretApi = class {
4709
+ constructor(client) {
4710
+ this.client = client;
4711
+ }
4712
+ async list(id) {
4713
+ const response = await this.client.get(`/notebook/${id}/secrets`);
4714
+ return response.data;
4715
+ }
4716
+ async set(id, name, input) {
4717
+ const payload = typeof input === "string" ? { name, value: input } : { name, ...input };
4718
+ const response = await this.client.put(`/notebook/${id}/secrets`, payload);
4719
+ return response.data;
4720
+ }
4721
+ async setMany(id, input) {
4722
+ const response = await this.client.put(`/notebook/${id}/secrets`, {
4723
+ secrets: normalizeNotebookSecretInputs(input)
4724
+ });
4725
+ return response.data;
4726
+ }
4727
+ async delete(id, name) {
4728
+ await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}`);
4729
+ }
4730
+ };
4692
4731
  var _initPromise, _NotebookInstance_instances, init_fn;
4693
4732
  var NotebookInstance = class {
4694
4733
  constructor(data, client) {
@@ -4716,6 +4755,7 @@ var PHPSandbox = (() => {
4716
4755
  this.laravel = new Lravel(this);
4717
4756
  this.shell = new Shell(this);
4718
4757
  this.git = new Git(this);
4758
+ this.secrets = new NotebookSecrets(client, this.data.id);
4719
4759
  }
4720
4760
  async ready() {
4721
4761
  const ready = async () => {
@@ -4837,6 +4877,24 @@ var PHPSandbox = (() => {
4837
4877
  }));
4838
4878
  return __privateGet(this, _initPromise);
4839
4879
  };
4880
+ var NotebookSecrets = class {
4881
+ constructor(client, notebookId) {
4882
+ this.client = client;
4883
+ this.notebookId = notebookId;
4884
+ }
4885
+ list() {
4886
+ return this.client.notebook.secrets.list(this.notebookId);
4887
+ }
4888
+ set(name, input) {
4889
+ return this.client.notebook.secrets.set(this.notebookId, name, input);
4890
+ }
4891
+ setMany(input) {
4892
+ return this.client.notebook.secrets.setMany(this.notebookId, input);
4893
+ }
4894
+ delete(name) {
4895
+ return this.client.notebook.secrets.delete(this.notebookId, name);
4896
+ }
4897
+ };
4840
4898
  return __toCommonJS(index_exports);
4841
4899
  })();
4842
4900
  /*! Bundled license information: