@phpsandbox/sdk 0.0.65 → 0.0.67

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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ import { PHPSandbox } from '@phpsandbox/sdk';
18
18
  const token = process.env.PHPSANDBOX_TOKEN;
19
19
  if (!token) throw new Error('Missing PHPSANDBOX_TOKEN');
20
20
 
21
- const client = new PHPSandbox(token);
21
+ const client = PHPSandbox.realtime(token);
22
22
 
23
23
  // create() initializes the notebook by default
24
24
  const notebook = await client.notebook.create('php');
@@ -53,22 +53,27 @@ Use an API token:
53
53
  ```ts
54
54
  import { PHPSandbox } from '@phpsandbox/sdk';
55
55
 
56
- const client = new PHPSandbox(process.env.PHPSANDBOX_TOKEN!);
56
+ const client = PHPSandbox.realtime(process.env.PHPSANDBOX_TOKEN!);
57
57
  ```
58
58
 
59
- Optional constructor args:
59
+ Explicit realtime and REST clients:
60
60
 
61
61
  ```ts
62
- new PHPSandbox('token', 'https://api.phpsandbox.io/v1', {
62
+ PHPSandbox.realtime('token', 'https://api.phpsandbox.io/v1', {
63
63
  debug: false,
64
64
  startClosed: true,
65
65
  });
66
+
67
+ // Use explicit request/response runtime actions without a websocket.
68
+ PHPSandbox.rest('token', 'https://api.phpsandbox.io/v1', {
69
+ runtimeUrlProvider: async (notebookId) => getFreshRuntimeUrl(notebookId),
70
+ });
66
71
  ```
67
72
 
68
73
  ## Notebook Lifecycle
69
74
 
70
75
  ```ts
71
- const client = new PHPSandbox(process.env.PHPSANDBOX_TOKEN!);
76
+ const client = PHPSandbox.realtime(process.env.PHPSANDBOX_TOKEN!);
72
77
 
73
78
  const created = await client.notebook.create('laravel');
74
79
  const opened = await client.notebook.open('notebook-id');
@@ -98,6 +103,7 @@ Notes:
98
103
  - `create()` and `fork()` initialize automatically.
99
104
  - `open()` and `get()` return a notebook instance; call `await notebook.ready()` before using tools.
100
105
  - API notebook creates and forks are ephemeral by default. `persistent: true` requires an entitled account.
106
+ - Use `NotebookData.runtimeUrl`, `runtimeUrlProvider`, and `DeploymentData.eventStreamUrl` for runtime access. Their `okraUrl` and `okraUrlProvider` aliases are deprecated compatibility fields.
101
107
 
102
108
  ## Services At A Glance
103
109
 
@@ -119,9 +125,9 @@ Each `NotebookInstance` exposes service clients:
119
125
 
120
126
  Notes:
121
127
 
122
- - `terminal.spawn()` and `shell.exec()` are part of the current okra websocket action set. `terminal.start` currently is not.
123
- - `notebook.repl.eval()` is part of the current okra websocket action set. `repl.start` is currently not.
124
- - `notebook.laravel` is exposed by the SDK, but the current okra websocket action set does not expose Laravel maintenance actions.
128
+ - `terminal.spawn()` and `shell.exec()` are part of the current runtime action set. `terminal.start` currently is not.
129
+ - `notebook.repl.eval()` is part of the current runtime action set. `repl.start` is currently not.
130
+ - `notebook.laravel` is exposed by the SDK, but the current runtime action set does not expose Laravel maintenance actions.
125
131
 
126
132
  ## Common Operations
127
133
 
package/dist/auth.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  import { Action, NotebookInstance } from './index.js';
2
2
  export interface AuthActions {
3
3
  'auth.login': Action<{
4
- newConnectionData: string;
4
+ runtimeTicket: string;
5
5
  }, boolean>;
6
- 'auth.logout': Action<null>;
7
6
  }
8
7
  export default class Auth {
9
8
  protected okra: NotebookInstance;
10
9
  constructor(okra: NotebookInstance);
11
- logout(): Promise<void>;
12
- login(newConnectionData: string): Promise<boolean>;
10
+ logout(): void;
11
+ login(runtimeUrl: string): Promise<boolean>;
13
12
  }
package/dist/auth.js CHANGED
@@ -3,9 +3,13 @@ export default class Auth {
3
3
  this.okra = okra;
4
4
  }
5
5
  logout() {
6
- return this.okra.invoke('auth.logout');
6
+ this.okra.dispose();
7
7
  }
8
- login(newConnectionData) {
9
- return this.okra.invoke('auth.login', { newConnectionData });
8
+ login(runtimeUrl) {
9
+ const runtimeTicket = new URL(runtimeUrl).searchParams.get('ticket');
10
+ if (runtimeTicket === null || runtimeTicket === '') {
11
+ throw new TypeError('The notebook connection does not contain a runtime ticket.');
12
+ }
13
+ return this.okra.invoke('auth.login', { runtimeTicket });
10
14
  }
11
15
  }