@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 +14 -8
- package/dist/auth.d.ts +3 -4
- package/dist/auth.js +7 -3
- package/dist/browser/phpsandbox-sdk.esm.js +374 -49
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +374 -49
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/deployments.d.ts +2 -0
- package/dist/deployments.js +6 -5
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +6 -0
- package/dist/filesystem.d.ts +2 -2
- package/dist/filesystem.js +7 -4
- package/dist/index.d.ts +14 -0
- package/dist/index.js +110 -34
- package/dist/runtime/rest.d.ts +20 -0
- package/dist/runtime/rest.js +226 -0
- package/dist/socket/index.d.ts +2 -1
- package/dist/socket/index.js +12 -3
- package/dist/types.d.ts +1 -1
- package/docs/api-summary.md +9 -3
- package/examples/README.md +5 -5
- package/examples/laravel-load-test.ts +20 -20
- package/examples/notebook-readonly-smoke.ts +20 -20
- package/package.json +1 -1
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 =
|
|
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 =
|
|
56
|
+
const client = PHPSandbox.realtime(process.env.PHPSANDBOX_TOKEN!);
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Explicit realtime and REST clients:
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
|
-
|
|
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 =
|
|
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
|
|
123
|
-
- `notebook.repl.eval()` is part of the current
|
|
124
|
-
- `notebook.laravel` is exposed by the SDK, but the current
|
|
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
|
-
|
|
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():
|
|
12
|
-
login(
|
|
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
|
-
|
|
6
|
+
this.okra.dispose();
|
|
7
7
|
}
|
|
8
|
-
login(
|
|
9
|
-
|
|
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
|
}
|