@phpsandbox/sdk 0.0.66 → 0.0.68
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 +5 -4
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +2 -2
- package/dist/browser/phpsandbox-sdk.esm.js +23 -21
- package/dist/browser/phpsandbox-sdk.esm.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.iife.js +23 -21
- package/dist/browser/phpsandbox-sdk.iife.min.js +2 -2
- package/dist/deployments.d.ts +1 -1
- package/dist/deployments.js +6 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -6
- package/dist/runtime/rest.js +10 -10
- package/docs/api-summary.md +3 -3
- package/examples/README.md +5 -5
- package/examples/laravel-load-test.ts +12 -12
- package/examples/notebook-readonly-smoke.ts +20 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ PHPSandbox.realtime('token', 'https://api.phpsandbox.io/v1', {
|
|
|
66
66
|
|
|
67
67
|
// Use explicit request/response runtime actions without a websocket.
|
|
68
68
|
PHPSandbox.rest('token', 'https://api.phpsandbox.io/v1', {
|
|
69
|
-
|
|
69
|
+
runtimeUrlProvider: async (notebookId) => getFreshRuntimeUrl(notebookId),
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -103,6 +103,7 @@ Notes:
|
|
|
103
103
|
- `create()` and `fork()` initialize automatically.
|
|
104
104
|
- `open()` and `get()` return a notebook instance; call `await notebook.ready()` before using tools.
|
|
105
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.
|
|
106
107
|
|
|
107
108
|
## Services At A Glance
|
|
108
109
|
|
|
@@ -124,9 +125,9 @@ Each `NotebookInstance` exposes service clients:
|
|
|
124
125
|
|
|
125
126
|
Notes:
|
|
126
127
|
|
|
127
|
-
- `terminal.spawn()` and `shell.exec()` are part of the current
|
|
128
|
-
- `notebook.repl.eval()` is part of the current
|
|
129
|
-
- `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.
|
|
130
131
|
|
|
131
132
|
## Common Operations
|
|
132
133
|
|
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -5,8 +5,8 @@ export default class Auth {
|
|
|
5
5
|
logout() {
|
|
6
6
|
this.okra.dispose();
|
|
7
7
|
}
|
|
8
|
-
login(
|
|
9
|
-
const runtimeTicket = new URL(
|
|
8
|
+
login(runtimeUrl) {
|
|
9
|
+
const runtimeTicket = new URL(runtimeUrl).searchParams.get('ticket');
|
|
10
10
|
if (runtimeTicket === null || runtimeTicket === '') {
|
|
11
11
|
throw new TypeError('The notebook connection does not contain a runtime ticket.');
|
|
12
12
|
}
|
|
@@ -584,8 +584,8 @@ var Auth = class {
|
|
|
584
584
|
logout() {
|
|
585
585
|
this.okra.dispose();
|
|
586
586
|
}
|
|
587
|
-
login(
|
|
588
|
-
const runtimeTicket = new URL(
|
|
587
|
+
login(runtimeUrl) {
|
|
588
|
+
const runtimeTicket = new URL(runtimeUrl).searchParams.get("ticket");
|
|
589
589
|
if (runtimeTicket === null || runtimeTicket === "") {
|
|
590
590
|
throw new TypeError("The notebook connection does not contain a runtime ticket.");
|
|
591
591
|
}
|
|
@@ -19441,8 +19441,9 @@ var DeploymentRun = class {
|
|
|
19441
19441
|
if (this.started) {
|
|
19442
19442
|
return this;
|
|
19443
19443
|
}
|
|
19444
|
-
|
|
19445
|
-
|
|
19444
|
+
const eventStreamUrl = this.initial.data.eventStreamUrl;
|
|
19445
|
+
if (!eventStreamUrl) {
|
|
19446
|
+
throw new Error(`Deployment ${this.initial.data.id} has no eventStreamUrl for SSE streaming`);
|
|
19446
19447
|
}
|
|
19447
19448
|
this.started = true;
|
|
19448
19449
|
this.resultPromise = new Promise((resolve, reject) => {
|
|
@@ -19450,7 +19451,7 @@ var DeploymentRun = class {
|
|
|
19450
19451
|
this.rejectResult = reject;
|
|
19451
19452
|
});
|
|
19452
19453
|
this.resultPromise.catch(() => void 0);
|
|
19453
|
-
void this.consumeStream(
|
|
19454
|
+
void this.consumeStream(eventStreamUrl);
|
|
19454
19455
|
return this;
|
|
19455
19456
|
}
|
|
19456
19457
|
subscribe() {
|
|
@@ -19467,9 +19468,9 @@ var DeploymentRun = class {
|
|
|
19467
19468
|
}
|
|
19468
19469
|
return queue;
|
|
19469
19470
|
}
|
|
19470
|
-
async consumeStream(
|
|
19471
|
+
async consumeStream(eventStreamUrl) {
|
|
19471
19472
|
try {
|
|
19472
|
-
const stream = await this.client.sse(
|
|
19473
|
+
const stream = await this.client.sse(eventStreamUrl);
|
|
19473
19474
|
for await (const event of readDeployStreamEvents(stream)) {
|
|
19474
19475
|
this.publish(event);
|
|
19475
19476
|
if (event.type === "result") {
|
|
@@ -19868,20 +19869,20 @@ var RestRuntimeInvoker = class {
|
|
|
19868
19869
|
this.refresh = refresh;
|
|
19869
19870
|
this.refreshPromise = null;
|
|
19870
19871
|
this.notebookId = data.id;
|
|
19871
|
-
this.configure(data.
|
|
19872
|
+
this.configure(data.runtimeUrl);
|
|
19872
19873
|
}
|
|
19873
|
-
configure(
|
|
19874
|
-
const
|
|
19875
|
-
const ticket =
|
|
19874
|
+
configure(runtimeUrl) {
|
|
19875
|
+
const actionUrl = new URL(runtimeUrl);
|
|
19876
|
+
const ticket = actionUrl.searchParams.get("ticket") ?? "";
|
|
19876
19877
|
if (ticket === "") {
|
|
19877
19878
|
throw new UnsupportedRuntimeTransportError("The notebook connection does not contain a runtime ticket.");
|
|
19878
19879
|
}
|
|
19879
19880
|
this.ticket = ticket;
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
this.actionUrl =
|
|
19881
|
+
actionUrl.protocol = actionUrl.protocol === "wss:" ? "https:" : "http:";
|
|
19882
|
+
actionUrl.pathname = `/api/v1/notebooks/${encodeURIComponent(this.notebookId)}`;
|
|
19883
|
+
actionUrl.searchParams.delete("ticket");
|
|
19884
|
+
actionUrl.hash = "";
|
|
19885
|
+
this.actionUrl = actionUrl;
|
|
19885
19886
|
}
|
|
19886
19887
|
ready() {
|
|
19887
19888
|
return this.invokeRaw("runtime.ready", {}, {});
|
|
@@ -19939,7 +19940,7 @@ var RestRuntimeInvoker = class {
|
|
|
19939
19940
|
}
|
|
19940
19941
|
async refreshAuthorization() {
|
|
19941
19942
|
if (this.refreshPromise === null) {
|
|
19942
|
-
this.refreshPromise = this.refresh().then((
|
|
19943
|
+
this.refreshPromise = this.refresh().then((runtimeUrl) => this.configure(runtimeUrl));
|
|
19943
19944
|
}
|
|
19944
19945
|
try {
|
|
19945
19946
|
await this.refreshPromise;
|
|
@@ -20335,23 +20336,24 @@ var NotebookInstance2 = class {
|
|
|
20335
20336
|
this.initialized = false;
|
|
20336
20337
|
__privateAdd(this, _initPromise, null);
|
|
20337
20338
|
this.disposables = [];
|
|
20339
|
+
const runtimeUrlProvider = client.options.runtimeUrlProvider;
|
|
20338
20340
|
this.emitter = EventManager.createInstance();
|
|
20339
20341
|
if (client.runtimeTransport === "rest") {
|
|
20340
20342
|
this.socket = null;
|
|
20341
20343
|
this.restInvoker = new RestRuntimeInvoker(
|
|
20342
20344
|
data,
|
|
20343
20345
|
client.options.fetch ?? globalThis.fetch,
|
|
20344
|
-
|
|
20346
|
+
runtimeUrlProvider === void 0 ? void 0 : () => runtimeUrlProvider(data.id)
|
|
20345
20347
|
);
|
|
20346
20348
|
} else {
|
|
20347
20349
|
this.restInvoker = null;
|
|
20348
20350
|
let initialConnection = true;
|
|
20349
|
-
const connectionUrl =
|
|
20351
|
+
const connectionUrl = runtimeUrlProvider === void 0 ? data.runtimeUrl : async () => {
|
|
20350
20352
|
if (initialConnection) {
|
|
20351
20353
|
initialConnection = false;
|
|
20352
|
-
return data.
|
|
20354
|
+
return data.runtimeUrl;
|
|
20353
20355
|
}
|
|
20354
|
-
return
|
|
20356
|
+
return runtimeUrlProvider(data.id);
|
|
20355
20357
|
};
|
|
20356
20358
|
this.socket = new Transport(connectionUrl, this.emitter, {
|
|
20357
20359
|
debug: client.options.debug,
|