@phpsandbox/sdk 0.1.13 → 0.1.15

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.
Files changed (40) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -18
  3. package/dist/browser/phpsandbox-sdk.esm.js +25 -14
  4. package/dist/browser/phpsandbox-sdk.esm.min.js +9 -9
  5. package/dist/browser/phpsandbox-sdk.iife.js +25 -14
  6. package/dist/browser/phpsandbox-sdk.iife.min.js +9 -9
  7. package/dist/errors/index.d.ts +7 -1
  8. package/dist/errors/index.js +2 -1
  9. package/dist/index.d.ts +27 -6
  10. package/dist/index.js +16 -12
  11. package/dist/{integrations.d.ts → integrations/account.d.ts} +1 -1
  12. package/dist/integrations/index.d.ts +2 -0
  13. package/dist/integrations/index.js +2 -0
  14. package/dist/{sandbox-integrations.d.ts → integrations/sandbox.d.ts} +2 -2
  15. package/dist/{sandbox-integrations.js → integrations/sandbox.js} +1 -1
  16. package/dist/log.d.ts +1 -1
  17. package/dist/log.js +1 -1
  18. package/dist/metrics.d.ts +1 -1
  19. package/dist/metrics.js +1 -1
  20. package/dist/ports.d.ts +1 -1
  21. package/dist/ports.js +1 -1
  22. package/dist/runtime.d.ts +1 -1
  23. package/dist/runtime.js +1 -1
  24. package/package.json +5 -9
  25. package/docs/api-summary.md +0 -181
  26. package/docs/cdn-usage.md +0 -68
  27. package/docs/getting-started.md +0 -169
  28. package/examples/README.md +0 -203
  29. package/examples/basic.ts +0 -15
  30. package/examples/get.ts +0 -22
  31. package/examples/git-merge-smoke.ts +0 -395
  32. package/examples/laravel-load-test.ts +0 -2800
  33. package/examples/notebook-readonly-smoke.ts +0 -806
  34. package/examples/publication-provider-label.ts +0 -11
  35. package/examples/publish-cloudflare-container.ts +0 -65
  36. package/examples/publish-laravel-cloud.ts +0 -123
  37. package/examples/publish-ssh-agent.ts +0 -211
  38. /package/dist/{integrations.js → integrations/account.js} +0 -0
  39. /package/dist/{runtime-telemetry.d.ts → telemetry.d.ts} +0 -0
  40. /package/dist/{runtime-telemetry.js → telemetry.js} +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) PHPSandbox
3
+ Copyright (c) Xeviant LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -22,14 +22,10 @@ if (!token) throw new Error('Missing PHPSANDBOX_TOKEN');
22
22
 
23
23
  const client = PHPSandbox.realtime(token);
24
24
  const notebook = await client.notebook.create('standard');
25
-
26
25
  await notebook.files.write('hello.php', '<?php echo "Hello from PHPSandbox";');
27
26
  const result = await notebook.exec('php', ['hello.php']);
28
- if (result.exitCode !== 0) throw new Error(result.stderr || result.output);
29
27
  console.log(result.stdout.trim());
30
-
31
28
  await notebook.destroy();
32
- notebook.dispose();
33
29
  ```
34
30
 
35
31
  ## Authentication
@@ -97,6 +93,9 @@ Each `NotebookInstance` exposes service clients:
97
93
  - `notebook.files` (`Filesystem`)
98
94
  - `notebook.terminals` (`Terminals`)
99
95
  - `notebook.runtime` (lifecycle, configuration, logs, metrics, and ports)
96
+ - `notebook.config` (`Config`)
97
+ - `notebook.secrets` (runtime secrets)
98
+ - `notebook.preview` (preview access and sessions)
100
99
  - `notebook.composer` (`Composer`)
101
100
  - `notebook.git` (`Git`)
102
101
  - `notebook.integrations` (`SandboxIntegrationApi`)
@@ -301,21 +300,21 @@ await notebook.mail.disable();
301
300
  ### Feedback
302
301
 
303
302
  ```ts
304
- await sandbox.feedback.configure({
303
+ await notebook.feedback.configure({
305
304
  widget: {
306
305
  targets: ['preview', 'publication'],
307
306
  types: ['bug', 'suggestion', 'question'],
308
307
  },
309
308
  });
310
309
 
311
- const feedback = await sandbox.feedback.submit({
310
+ const feedback = await notebook.feedback.submit({
312
311
  type: 'bug',
313
312
  message: 'Saving the profile failed.',
314
313
  author: { externalId: 'customer-42', email: 'ada@example.com' },
315
314
  context: { url: 'https://app.example.com/profile', path: '/profile' },
316
315
  });
317
316
 
318
- await sandbox.feedback.update(feedback.id, { status: 'resolved' });
317
+ await notebook.feedback.update(feedback.id, { status: 'resolved' });
319
318
  ```
320
319
 
321
320
  The server-side SDK uses the same PHPSandbox API token as the rest of the sandbox. Set `widget: null` to remove the optional popout without disabling API ingestion.
@@ -362,20 +361,10 @@ try {
362
361
  }
363
362
  ```
364
363
 
365
- ## Browser/CDN Usage
366
-
367
- See [Browser usage](docs/cdn-usage.md) for ESM and script-tag examples.
368
-
369
- ## More Docs
370
-
371
- - Getting started walkthrough: [Getting started](docs/getting-started.md)
372
- - API overview: [API overview](docs/api-summary.md)
373
- - Examples: [Examples](examples/README.md)
374
-
375
364
  ## Support
376
365
 
377
366
  - Issues: https://github.com/phpsandbox/sdk/issues
378
- - Product docs: https://docs.phpsandbox.io
367
+ - Product docs: https://phpsandbox.io/docs
379
368
 
380
369
  ## License
381
370
 
@@ -71,9 +71,10 @@ var RemoteError = class _RemoteError extends PHPSandboxError {
71
71
  }
72
72
  };
73
73
  var TransportError = class _TransportError extends PHPSandboxError {
74
- constructor(message, code, cause) {
74
+ constructor(message, code, cause, response) {
75
75
  super(message, cause);
76
76
  this.code = code;
77
+ this.response = response;
77
78
  }
78
79
  static is(error51, code) {
79
80
  return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
@@ -1038,7 +1039,7 @@ var Composer = class {
1038
1039
  }
1039
1040
  };
1040
1041
 
1041
- // src/runtime-telemetry.ts
1042
+ // src/telemetry.ts
1042
1043
  var RuntimeTelemetry = class {
1043
1044
  constructor(okra) {
1044
1045
  this.okra = okra;
@@ -19733,7 +19734,7 @@ var Feedback = class {
19733
19734
  }
19734
19735
  };
19735
19736
 
19736
- // src/integrations.ts
19737
+ // src/integrations/account.ts
19737
19738
  var IntegrationApi = class {
19738
19739
  constructor(client) {
19739
19740
  this.client = client;
@@ -19780,7 +19781,7 @@ function integrationId(integration) {
19780
19781
  return typeof integration === "string" ? integration : integration.id;
19781
19782
  }
19782
19783
 
19783
- // src/sandbox-integrations.ts
19784
+ // src/integrations/sandbox.ts
19784
19785
  var SandboxIntegrationApi = class {
19785
19786
  constructor(notebookId, client) {
19786
19787
  this.notebookId = notebookId;
@@ -19855,6 +19856,10 @@ var NotebookApi = class {
19855
19856
  constructor(client) {
19856
19857
  this.client = client;
19857
19858
  }
19859
+ async inspectImport(input) {
19860
+ const response = await this.client.post("/notebook/imports/inspect", input);
19861
+ return response.data;
19862
+ }
19858
19863
  async create(template, input = {}) {
19859
19864
  const response = await this.client.post("/notebook", { template, ...input });
19860
19865
  return new NotebookInstance(response.data, this.client);
@@ -19920,7 +19925,7 @@ var ClientImplementation = class {
19920
19925
  })
19921
19926
  );
19922
19927
  if (!response.ok) {
19923
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19928
+ throw await responseError(response);
19924
19929
  }
19925
19930
  if (!response.body) {
19926
19931
  throw new TransportError("PHPSandbox API response body is not readable.", "InvalidResponse", response);
@@ -19938,7 +19943,7 @@ var ClientImplementation = class {
19938
19943
  })
19939
19944
  );
19940
19945
  if (!response.ok) {
19941
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19946
+ throw await responseError(response);
19942
19947
  }
19943
19948
  if (!response.body) {
19944
19949
  throw new TransportError("PHPSandbox API SSE response body is not readable.", "InvalidResponse", response);
@@ -19954,7 +19959,7 @@ var ClientImplementation = class {
19954
19959
  })
19955
19960
  );
19956
19961
  if (!response.ok) {
19957
- throw remoteError("core", errorPayload(await responsePayload(response)), response);
19962
+ throw await responseError(response);
19958
19963
  }
19959
19964
  if (response.status === 204) {
19960
19965
  return { data: void 0 };
@@ -19987,15 +19992,21 @@ var ClientImplementation = class {
19987
19992
  }
19988
19993
  }
19989
19994
  };
19990
- async function responsePayload(response) {
19995
+ async function responseError(response) {
19991
19996
  const body = await response.text();
19992
- if (body === "") {
19993
- return void 0;
19994
- }
19995
19997
  try {
19996
- return JSON.parse(body);
19997
- } catch (error51) {
19998
- throw new TransportError("PHPSandbox API returned an invalid JSON response.", "InvalidResponse", error51);
19998
+ return remoteError("core", errorPayload(body === "" ? void 0 : JSON.parse(body)), response);
19999
+ } catch {
20000
+ return new TransportError(
20001
+ `PHPSandbox API returned an invalid error response (HTTP ${response.status}).`,
20002
+ "InvalidResponse",
20003
+ response,
20004
+ {
20005
+ status: response.status,
20006
+ statusText: response.statusText,
20007
+ body
20008
+ }
20009
+ );
19999
20010
  }
20000
20011
  }
20001
20012
  function errorPayload(payload) {