@phpsandbox/sdk 0.1.4 → 0.1.6

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.
@@ -33,12 +33,17 @@ var PHPSandbox = (() => {
33
33
  CommandError: () => CommandError,
34
34
  ComposerCredentials: () => ComposerCredentials,
35
35
  ErrorEvent: () => ErrorEvent,
36
+ Feedback: () => Feedback,
36
37
  FileChangeFilter: () => FileChangeFilter,
37
38
  FileChangeType: () => FileChangeType,
38
39
  FileType: () => FileType,
39
40
  Filesystem: () => Filesystem,
40
41
  FilesystemError: () => FilesystemError,
41
42
  FilesystemErrorType: () => FilesystemErrorType,
43
+ GitTarget: () => GitTarget,
44
+ GitTargetApi: () => GitTargetApi,
45
+ Integration: () => Integration,
46
+ IntegrationApi: () => IntegrationApi,
42
47
  LspConnection: () => LspConnection,
43
48
  NotebookApi: () => NotebookApi,
44
49
  NotebookComposerCredentialApi: () => NotebookComposerCredentialApi,
@@ -91,14 +96,18 @@ var PHPSandbox = (() => {
91
96
  PublishStreamSseResultEventSchema: () => PublishStreamSseResultEventSchema,
92
97
  RateLimitError: () => RateLimitError,
93
98
  RuntimeTelemetry: () => RuntimeTelemetry,
99
+ SandboxIntegration: () => SandboxIntegration,
100
+ SandboxIntegrationApi: () => SandboxIntegrationApi,
94
101
  SendTimeoutError: () => SendTimeoutError,
95
102
  ServerApi: () => ServerApi,
96
103
  ServerInstance: () => ServerInstance,
97
104
  ShellProcess: () => ShellProcess,
98
105
  UnsupportedRuntimeTransportError: () => UnsupportedRuntimeTransportError,
106
+ integrationId: () => integrationId,
99
107
  notebookBuiltinServices: () => notebookBuiltinServices,
100
108
  notebookKnownServices: () => notebookKnownServices,
101
109
  once: () => once,
110
+ sandboxIntegrationId: () => sandboxIntegrationId,
102
111
  timeout: () => timeout,
103
112
  watchRuntimeTelemetry: () => watchRuntimeTelemetry
104
113
  });
@@ -492,7 +501,7 @@ var PHPSandbox = (() => {
492
501
  return this.okra.invoke("fs.textSearch", { query, options: { ...defaultOptions, ...options } }).finally(() => disposable.dispose());
493
502
  }
494
503
  tail(path, options = {}) {
495
- return this.okra.invoke("fs.tail", { path, lines: options.lines ?? 10 }).catch((e) => this.handleError(e));
504
+ return this.okra.invoke("fs.tail", { path, lines: options.lines ?? 10 }).then(({ content }) => content).catch((e) => this.handleError(e));
496
505
  }
497
506
  stat(path) {
498
507
  return this.okra.invoke("fs.stat", { path }).catch((e) => this.handleError(e));
@@ -4257,6 +4266,7 @@ var PHPSandbox = (() => {
4257
4266
  constructor(okra, client) {
4258
4267
  this.okra = okra;
4259
4268
  this.client = client;
4269
+ this.targets = new GitTargetApi(okra.data.id, client);
4260
4270
  }
4261
4271
  checkpoint(author, message, branch = "main", allowEmpty = false) {
4262
4272
  return this.okra.invoke("git.checkpoint", { author, message, branch, allowEmpty });
@@ -4264,17 +4274,6 @@ var PHPSandbox = (() => {
4264
4274
  checkout(branch, create = true) {
4265
4275
  return this.okra.invoke("git.checkout", { branch, create });
4266
4276
  }
4267
- async sync(input) {
4268
- const response = await this.client.post(
4269
- `/notebook/${this.okra.data.id}/git/sync-targets`,
4270
- this.omitUndefined({ ...input })
4271
- );
4272
- return response.data;
4273
- }
4274
- async syncTargets() {
4275
- const response = await this.client.get(`/notebook/${this.okra.data.id}/git/sync-targets`);
4276
- return response.data;
4277
- }
4278
4277
  log(ref = "main") {
4279
4278
  return this.okra.invoke("git.log", { ref });
4280
4279
  }
@@ -4343,10 +4342,56 @@ var PHPSandbox = (() => {
4343
4342
  url2.hash = "";
4344
4343
  return url2.toString();
4345
4344
  }
4346
- omitUndefined(input) {
4347
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
4345
+ };
4346
+ var GitTargetApi = class {
4347
+ constructor(notebookId, client) {
4348
+ this.notebookId = notebookId;
4349
+ this.client = client;
4350
+ }
4351
+ async create(input) {
4352
+ const response = await this.client.post(
4353
+ `/notebook/${this.notebookId}/git/targets`,
4354
+ omitUndefined({ ...input })
4355
+ );
4356
+ return new GitTarget(response.data, this.notebookId, this.client);
4357
+ }
4358
+ async list() {
4359
+ const response = await this.client.get(`/notebook/${this.notebookId}/git/targets`);
4360
+ return response.data.map((target) => new GitTarget(target, this.notebookId, this.client));
4361
+ }
4362
+ async get(target) {
4363
+ const response = await this.client.get(
4364
+ `/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}`
4365
+ );
4366
+ return new GitTarget(response.data, this.notebookId, this.client);
4367
+ }
4368
+ async sync(target, input = {}) {
4369
+ const response = await this.client.post(
4370
+ `/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}/sync`,
4371
+ omitUndefined({ ...input })
4372
+ );
4373
+ return new GitTarget(response.data, this.notebookId, this.client);
4374
+ }
4375
+ };
4376
+ var GitTarget = class {
4377
+ constructor(data, notebookId, client) {
4378
+ this.data = data;
4379
+ this.notebookId = notebookId;
4380
+ this.client = client;
4381
+ }
4382
+ get id() {
4383
+ return this.data.id;
4384
+ }
4385
+ sync(input = {}) {
4386
+ return new GitTargetApi(this.notebookId, this.client).sync(this, input);
4348
4387
  }
4349
4388
  };
4389
+ function gitTargetId(target) {
4390
+ return typeof target === "string" ? target : target.id;
4391
+ }
4392
+ function omitUndefined(input) {
4393
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
4394
+ }
4350
4395
 
4351
4396
  // node_modules/zod/v4/classic/external.js
4352
4397
  var external_exports = {};
@@ -18915,11 +18960,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18915
18960
  var PublicationProtectionModeSchema = external_exports.enum(["none", "password"]);
18916
18961
  var PublicationLogStreamSchema = external_exports.enum(["build", "runtime"]);
18917
18962
  var PublishStreamLogStreamSchema = external_exports.enum(["build", "publish", "runtime"]);
18963
+ var PublicationEventPayloadSchema = external_exports.preprocess(
18964
+ (payload) => Array.isArray(payload) && payload.length === 0 ? {} : payload,
18965
+ external_exports.record(external_exports.string(), external_exports.unknown())
18966
+ );
18918
18967
  var PublicationEventDataSchema = external_exports.object({
18919
18968
  id: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
18920
18969
  sequence: external_exports.number(),
18921
18970
  type: external_exports.string(),
18922
- payload: external_exports.record(external_exports.string(), external_exports.unknown()),
18971
+ payload: PublicationEventPayloadSchema,
18923
18972
  createdAt: external_exports.string().nullable()
18924
18973
  }).passthrough();
18925
18974
  var PublicationLogChunkDataSchema = external_exports.object({
@@ -18940,6 +18989,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18940
18989
  var PublishStreamResultSchema = external_exports.object({
18941
18990
  success: external_exports.boolean(),
18942
18991
  publicationId: external_exports.string(),
18992
+ url: external_exports.string().url(),
18943
18993
  buildId: external_exports.string(),
18944
18994
  releaseId: external_exports.string(),
18945
18995
  status: PublicationStatusSchema
@@ -19051,10 +19101,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19051
19101
  const response = await this.client.delete(`/publications/${id}/protection`);
19052
19102
  return new PublicationInstance(response.data, this.client);
19053
19103
  }
19054
- async setFeedback(id, input) {
19055
- const response = await this.client.put(`/publications/${id}/feedback`, input);
19056
- return new PublicationInstance(response.data, this.client);
19057
- }
19058
19104
  async listDomains(id) {
19059
19105
  const response = await this.client.get(
19060
19106
  `/publications/${id}/domains`
@@ -19164,7 +19210,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19164
19210
  if (event.type === "result") {
19165
19211
  const { type: _, ...result } = event;
19166
19212
  this.finalResult = result;
19167
- this.resolveResult?.(result);
19213
+ this.resolveResult?.(this.finalResult);
19168
19214
  }
19169
19215
  }
19170
19216
  if (!this.finalResult) {
@@ -19255,9 +19301,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19255
19301
  disableProtection() {
19256
19302
  return this.client.publications.disableProtection(this.data.id);
19257
19303
  }
19258
- setFeedback(input) {
19259
- return this.client.publications.setFeedback(this.data.id, input);
19260
- }
19261
19304
  domains() {
19262
19305
  return this.client.publications.listDomains(this.data.id);
19263
19306
  }
@@ -19510,18 +19553,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19510
19553
  "container.stats": { method: "GET", path: "/runtime/container/stats" },
19511
19554
  "terminal.list": { method: "GET", path: "/runtime/terminals" },
19512
19555
  "shell.exec": { method: "POST", path: "/runtime/executions" },
19513
- "fs.info": { method: "POST", path: "/runtime/files/info" },
19514
19556
  "fs.readFile": { method: "GET", path: "/runtime/files/content" },
19515
19557
  "fs.writeFile": { method: "PUT", path: "/runtime/files/content" },
19516
- "fs.write": { method: "PUT", path: "/runtime/files/text" },
19517
- "fs.mkdir": { method: "POST", path: "/runtime/directories" },
19518
19558
  "fs.createDirectory": { method: "PUT", path: "/runtime/directories" },
19519
19559
  "fs.readDirectory": { method: "POST", path: "/runtime/directories/read" },
19520
19560
  "fs.stat": { method: "POST", path: "/runtime/files/stat" },
19521
- "fs.move": { method: "POST", path: "/runtime/files/move" },
19522
19561
  "fs.rename": { method: "POST", path: "/runtime/files/rename" },
19523
19562
  "fs.copy": { method: "POST", path: "/runtime/files/copy" },
19524
- "fs.remove": { method: "POST", path: "/runtime/files/remove" },
19525
19563
  "fs.delete": { method: "DELETE", path: "/runtime/files" },
19526
19564
  "fs.tail": { method: "POST", path: "/runtime/files/tail" },
19527
19565
  "fs.find": { method: "POST", path: "/runtime/files/find" },
@@ -19716,6 +19754,164 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19716
19754
  };
19717
19755
  }
19718
19756
 
19757
+ // src/feedback.ts
19758
+ var Feedback = class {
19759
+ constructor(client, notebookId) {
19760
+ this.client = client;
19761
+ this.notebookId = notebookId;
19762
+ }
19763
+ async configure(input) {
19764
+ const response = await this.client.put(this.path("/configuration"), input);
19765
+ return response.data;
19766
+ }
19767
+ async configuration() {
19768
+ const response = await this.client.get(this.path("/configuration"));
19769
+ return response.data;
19770
+ }
19771
+ async submit(input) {
19772
+ const response = await this.client.post(this.path(), input);
19773
+ return response.data;
19774
+ }
19775
+ async list(options = {}) {
19776
+ const query = new URLSearchParams();
19777
+ for (const [name, value] of Object.entries(options)) {
19778
+ if (value !== void 0) query.set(name, String(value));
19779
+ }
19780
+ const response = await this.client.get(
19781
+ `${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`
19782
+ );
19783
+ return response.data;
19784
+ }
19785
+ async get(id) {
19786
+ const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
19787
+ return response.data;
19788
+ }
19789
+ async update(id, input) {
19790
+ const response = await this.client.patch(this.path(`/${encodeURIComponent(id)}`), input);
19791
+ return response.data;
19792
+ }
19793
+ path(suffix = "") {
19794
+ return `/notebook/${this.notebookId}/feedback${suffix}`;
19795
+ }
19796
+ };
19797
+
19798
+ // src/integrations.ts
19799
+ var IntegrationApi = class {
19800
+ constructor(client) {
19801
+ this.client = client;
19802
+ }
19803
+ async link(input) {
19804
+ const response = await this.client.post("/integrations", input);
19805
+ return new Integration(response.data, this.client);
19806
+ }
19807
+ async list() {
19808
+ const response = await this.client.get("/integrations");
19809
+ return response.data.map((integration) => new Integration(integration, this.client));
19810
+ }
19811
+ async get(integration) {
19812
+ const response = await this.client.get(`/integrations/${encodeURIComponent(integrationId(integration))}`);
19813
+ return new Integration(response.data, this.client);
19814
+ }
19815
+ async update(integration, input) {
19816
+ const response = await this.client.patch(
19817
+ `/integrations/${encodeURIComponent(integrationId(integration))}`,
19818
+ input
19819
+ );
19820
+ return new Integration(response.data, this.client);
19821
+ }
19822
+ async unlink(integration) {
19823
+ await this.client.delete(`/integrations/${encodeURIComponent(integrationId(integration))}`);
19824
+ }
19825
+ };
19826
+ var Integration = class {
19827
+ constructor(data, client) {
19828
+ this.data = data;
19829
+ this.client = client;
19830
+ }
19831
+ get id() {
19832
+ return this.data.id;
19833
+ }
19834
+ get provider() {
19835
+ return this.data.provider;
19836
+ }
19837
+ get label() {
19838
+ return this.data.label;
19839
+ }
19840
+ update(input) {
19841
+ return new IntegrationApi(this.client).update(this, input);
19842
+ }
19843
+ unlink() {
19844
+ return new IntegrationApi(this.client).unlink(this);
19845
+ }
19846
+ };
19847
+ function integrationId(integration) {
19848
+ return typeof integration === "string" ? integration : integration.id;
19849
+ }
19850
+
19851
+ // src/sandbox-integrations.ts
19852
+ var SandboxIntegrationApi = class {
19853
+ constructor(notebookId, client) {
19854
+ this.notebookId = notebookId;
19855
+ this.client = client;
19856
+ }
19857
+ async attach(input) {
19858
+ const response = await this.client.post(this.path(), {
19859
+ ...input,
19860
+ integration: integrationId(input.integration)
19861
+ });
19862
+ return new SandboxIntegration(response.data, this.notebookId, this.client);
19863
+ }
19864
+ async list() {
19865
+ const response = await this.client.get(this.path());
19866
+ return response.data.map((integration) => new SandboxIntegration(integration, this.notebookId, this.client));
19867
+ }
19868
+ async get(integration) {
19869
+ const response = await this.client.get(this.bindingPath(integration));
19870
+ return new SandboxIntegration(response.data, this.notebookId, this.client);
19871
+ }
19872
+ async update(integration, input) {
19873
+ const response = await this.client.patch(this.bindingPath(integration), {
19874
+ ...input,
19875
+ integration: input.integration === void 0 ? void 0 : integrationId(input.integration)
19876
+ });
19877
+ return new SandboxIntegration(response.data, this.notebookId, this.client);
19878
+ }
19879
+ async detach(integration) {
19880
+ await this.client.delete(this.bindingPath(integration));
19881
+ }
19882
+ path() {
19883
+ return `/notebook/${this.notebookId}/integrations`;
19884
+ }
19885
+ bindingPath(integration) {
19886
+ return `${this.path()}/${encodeURIComponent(sandboxIntegrationId(integration))}`;
19887
+ }
19888
+ };
19889
+ var SandboxIntegration = class {
19890
+ constructor(data, notebookId, client) {
19891
+ this.data = data;
19892
+ this.notebookId = notebookId;
19893
+ this.client = client;
19894
+ }
19895
+ get id() {
19896
+ return this.data.id;
19897
+ }
19898
+ get integration() {
19899
+ return new Integration(this.data.integration, this.client);
19900
+ }
19901
+ get effects() {
19902
+ return this.data.effects;
19903
+ }
19904
+ update(input) {
19905
+ return new SandboxIntegrationApi(this.notebookId, this.client).update(this, input);
19906
+ }
19907
+ detach() {
19908
+ return new SandboxIntegrationApi(this.notebookId, this.client).detach(this);
19909
+ }
19910
+ };
19911
+ function sandboxIntegrationId(integration) {
19912
+ return typeof integration === "string" ? integration : integration.id;
19913
+ }
19914
+
19719
19915
  // src/index.ts
19720
19916
  function normalizeNotebookSecretInputs(input) {
19721
19917
  if (Array.isArray(input)) {
@@ -19824,6 +20020,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19824
20020
  this.publications = new PublicationApi(this);
19825
20021
  this.notebook = new NotebookApi(this);
19826
20022
  this.servers = new ServerApi(this);
20023
+ this.integrations = new IntegrationApi(this);
19827
20024
  this.options = Object.assign({ startClosed: true }, options);
19828
20025
  this.baseUrl = normalizeApiBaseUrl(url2);
19829
20026
  if (options.fetch) {
@@ -19850,6 +20047,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19850
20047
  put(path, body) {
19851
20048
  return this.makeRequest("PUT", path, { body: body === void 0 ? void 0 : JSON.stringify(body) });
19852
20049
  }
20050
+ patch(path, body) {
20051
+ return this.makeRequest("PATCH", path, { body: body === void 0 ? void 0 : JSON.stringify(body) });
20052
+ }
19853
20053
  async stream(path) {
19854
20054
  const response = await this.fetch(
19855
20055
  new Request(new URL(path.replace(/^\//, ""), this.baseUrl), {
@@ -20063,8 +20263,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20063
20263
  this.services = new Services(this);
20064
20264
  this.config = new Config(this);
20065
20265
  this.secrets = new NotebookSecrets(client, this.data.id);
20266
+ this.integrations = new SandboxIntegrationApi(this.data.id, client);
20066
20267
  this.preview = new NotebookPreview(client, this.data.id);
20067
20268
  this.mail = new NotebookMail(client, this.data.id);
20269
+ this.feedback = new Feedback(client, this.data.id);
20068
20270
  }
20069
20271
  get runtimeTransport() {
20070
20272
  return this.client.runtimeTransport;