@phpsandbox/sdk 0.0.68 → 0.1.2
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 +66 -32
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -3
- package/dist/beacon/index.d.ts +2 -0
- package/dist/beacon/index.js +5 -0
- package/dist/browser/phpsandbox-sdk.esm.js +842 -1320
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +842 -1320
- package/dist/browser/phpsandbox-sdk.iife.min.js +23 -23
- package/dist/composer.d.ts +36 -23
- package/dist/composer.js +61 -11
- package/dist/container.d.ts +2 -6
- package/dist/container.js +0 -28
- package/dist/filesystem.d.ts +58 -17
- package/dist/filesystem.js +169 -51
- package/dist/index.d.ts +30 -26
- package/dist/index.js +37 -32
- package/dist/log.d.ts +11 -5
- package/dist/log.js +10 -7
- package/dist/metrics.d.ts +10 -0
- package/dist/metrics.js +13 -0
- package/dist/ports.d.ts +10 -0
- package/dist/ports.js +13 -0
- package/dist/publications.d.ts +222 -0
- package/dist/{deployments.js → publications.js} +64 -69
- package/dist/repl.d.ts +0 -2
- package/dist/repl.js +0 -3
- package/dist/runtime/rest.js +1 -4
- package/dist/runtime-telemetry.d.ts +15 -0
- package/dist/runtime-telemetry.js +111 -0
- package/dist/schemas/{deployments.d.ts → publications.d.ts} +76 -76
- package/dist/schemas/publications.js +133 -0
- package/dist/services.d.ts +2 -9
- package/dist/services.js +3 -10
- package/dist/shell.d.ts +52 -22
- package/dist/shell.js +103 -75
- package/dist/terminal.d.ts +18 -14
- package/dist/terminal.js +29 -49
- package/docs/api-summary.md +37 -29
- package/docs/cdn-usage.md +4 -4
- package/docs/getting-started.md +17 -17
- package/examples/README.md +8 -9
- package/examples/basic.ts +2 -2
- package/examples/git-merge-smoke.ts +3 -6
- package/examples/laravel-load-test.ts +80 -98
- package/examples/notebook-readonly-smoke.ts +38 -41
- package/examples/publication-provider-label.ts +11 -0
- package/examples/{deploy-cloudflare-container.ts → publish-cloudflare-container.ts} +11 -11
- package/examples/{deploy-laravel-cloud.ts → publish-laravel-cloud.ts} +11 -11
- package/examples/{deploy-ssh-agent.ts → publish-ssh-agent.ts} +15 -16
- package/package.json +7 -2
- package/dist/deployments.d.ts +0 -251
- package/dist/laravel.d.ts +0 -22
- package/dist/laravel.js +0 -11
- package/dist/schemas/deployments.js +0 -133
- package/examples/deployment-provider-label.ts +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import { Filesystem, FilesystemActions, FilesystemEvents } from './filesystem.js';
|
|
2
|
-
import
|
|
3
|
-
import Container, { ContainerActions, ContainerEvents, PortInfo
|
|
2
|
+
import Terminals, { TerminalEvents, TerminalActions, type SpawnOptions } from './terminal.js';
|
|
3
|
+
import Container, { ContainerActions, ContainerEvents, PortInfo } from './container.js';
|
|
4
4
|
import Auth, { AuthActions } from './auth.js';
|
|
5
5
|
import Lsp, { LspActions, LspEvents } from './lsp.js';
|
|
6
6
|
import Composer, { ComposerActions, ComposerEvents } from './composer.js';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import Logs, { LogActions, LogEvents } from './log.js';
|
|
8
|
+
import Metrics from './metrics.js';
|
|
9
|
+
import Ports from './ports.js';
|
|
9
10
|
import Repl, { ReplActions, ReplEvents } from './repl.js';
|
|
10
|
-
import
|
|
11
|
+
import { ShellEvents, ShellActions, type ProcessResult, type ShellProcess } from './shell.js';
|
|
11
12
|
import Services, { ServiceActions, ServiceEvents } from './services.js';
|
|
12
13
|
import Config, { ConfigActions } from './config.js';
|
|
13
14
|
import { EventDispatcher } from './events/index.js';
|
|
14
15
|
import Git, { GitActions, GitCredentials, GitEvents } from './git.js';
|
|
15
16
|
import { Disposable } from './types.js';
|
|
16
|
-
import { Beacon, BeaconOptions } from './beacon/index.js';
|
|
17
17
|
import { NotebookUnavailableError } from './errors/index.js';
|
|
18
|
-
import {
|
|
18
|
+
import { PublicationApi, NotebookPublicationApi, type PublicationInstance, type PublicationRun, type PublishInput } from './publications.js';
|
|
19
19
|
import { ServerApi } from './servers.js';
|
|
20
20
|
export * from './types.js';
|
|
21
|
-
export { Transport } from './socket/index.js';
|
|
22
21
|
export * from './lsp.js';
|
|
23
22
|
export * from './filesystem.js';
|
|
24
23
|
export * from './container.js';
|
|
24
|
+
export * from './log.js';
|
|
25
|
+
export * from './metrics.js';
|
|
26
|
+
export * from './ports.js';
|
|
27
|
+
export * from './runtime-telemetry.js';
|
|
25
28
|
export * from './shell.js';
|
|
26
29
|
export * from './terminal.js';
|
|
27
30
|
export * from './git.js';
|
|
28
31
|
export * from './services.js';
|
|
29
32
|
export * from './config.js';
|
|
30
33
|
export * from './utils/promise.js';
|
|
31
|
-
export * from './beacon/index.js';
|
|
32
34
|
export * from './errors/index.js';
|
|
33
|
-
export * from './
|
|
35
|
+
export * from './publications.js';
|
|
34
36
|
export * from './servers.js';
|
|
35
37
|
interface Result<TType extends 'success' | 'error' | 'running', TData extends object> {
|
|
36
38
|
type: TType;
|
|
@@ -100,11 +102,11 @@ export interface Action<Args = object, Response = void> {
|
|
|
100
102
|
args: Args;
|
|
101
103
|
response: Response;
|
|
102
104
|
}
|
|
103
|
-
export type Events = TerminalEvents & ContainerEvents & LspEvents & ComposerEvents & LogEvents & ServiceEvents &
|
|
105
|
+
export type Events = TerminalEvents & ContainerEvents & LspEvents & ComposerEvents & LogEvents & ServiceEvents & NotebookEvents & ReplEvents & ShellEvents & FilesystemEvents & GitEvents;
|
|
104
106
|
interface SystemActions {
|
|
105
107
|
ping: Action<object, 'pong'>;
|
|
106
108
|
}
|
|
107
|
-
export type Invokable = SystemActions & TerminalActions & ContainerActions & FilesystemActions & AuthActions & LspActions &
|
|
109
|
+
export type Invokable = SystemActions & TerminalActions & ContainerActions & FilesystemActions & AuthActions & LspActions & ComposerActions & LogActions & ServiceActions & ConfigActions & NotebookActions & ReplActions & ShellActions & GitActions;
|
|
108
110
|
export interface CreateNotebookImportAuthInput {
|
|
109
111
|
access_token: string;
|
|
110
112
|
}
|
|
@@ -289,22 +291,20 @@ export declare class NotebookApi {
|
|
|
289
291
|
readonly composerCredentials: NotebookComposerCredentialApi;
|
|
290
292
|
readonly preview: NotebookPreviewApi;
|
|
291
293
|
readonly mail: NotebookMailApi;
|
|
292
|
-
readonly
|
|
294
|
+
readonly publication: NotebookPublicationApi;
|
|
293
295
|
constructor(client: Client);
|
|
294
296
|
create(template: string, input?: Partial<CreateNotebookInput>, init?: boolean): Promise<NotebookInstance>;
|
|
295
297
|
get(id: string): Promise<NotebookInstance>;
|
|
296
298
|
update(id: string, input?: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
|
|
297
|
-
|
|
299
|
+
destroy(id: string): Promise<void>;
|
|
298
300
|
fork(id: string, input?: Partial<ForkNotebookInput>): Promise<NotebookInstance>;
|
|
299
301
|
gitCredentials(id: string): Promise<GitCredentials>;
|
|
300
|
-
open(id: string): Promise<NotebookInstance>;
|
|
301
302
|
openFromData(data: NotebookData): Promise<NotebookInstance>;
|
|
302
303
|
private init;
|
|
303
304
|
}
|
|
304
305
|
export interface PHPSandboxClientOptions {
|
|
305
306
|
debug?: boolean;
|
|
306
307
|
startClosed?: boolean;
|
|
307
|
-
telemetry?: Set<TelemetryFeature>;
|
|
308
308
|
fetch?: typeof globalThis.fetch;
|
|
309
309
|
webSocket?: unknown;
|
|
310
310
|
runtimeUrlProvider?: (notebookId: string) => Promise<string>;
|
|
@@ -312,7 +312,7 @@ export interface PHPSandboxClientOptions {
|
|
|
312
312
|
export type RuntimeTransport = 'realtime' | 'rest';
|
|
313
313
|
export declare class Client {
|
|
314
314
|
readonly notebook: NotebookApi;
|
|
315
|
-
readonly
|
|
315
|
+
readonly publications: PublicationApi;
|
|
316
316
|
readonly servers: ServerApi;
|
|
317
317
|
readonly options: PHPSandboxClientOptions;
|
|
318
318
|
protected runtimeTransportValue: RuntimeTransport;
|
|
@@ -389,16 +389,17 @@ export declare class NotebookInstance {
|
|
|
389
389
|
#private;
|
|
390
390
|
readonly data: NotebookData;
|
|
391
391
|
protected client: Client;
|
|
392
|
-
readonly
|
|
393
|
-
readonly
|
|
392
|
+
readonly files: Filesystem;
|
|
393
|
+
readonly terminals: Terminals;
|
|
394
394
|
readonly auth: Auth;
|
|
395
395
|
readonly lsp: Lsp;
|
|
396
396
|
readonly composer: Composer;
|
|
397
|
-
readonly
|
|
397
|
+
readonly logs: Logs;
|
|
398
|
+
readonly metrics: Metrics;
|
|
399
|
+
readonly ports: Ports;
|
|
398
400
|
readonly repl: Repl;
|
|
399
401
|
readonly container: Container;
|
|
400
|
-
readonly
|
|
401
|
-
readonly shell: Shell;
|
|
402
|
+
private readonly shell;
|
|
402
403
|
readonly git: Git;
|
|
403
404
|
readonly services: Services;
|
|
404
405
|
readonly config: Config;
|
|
@@ -414,10 +415,14 @@ export declare class NotebookInstance {
|
|
|
414
415
|
constructor(data: NotebookData, client: Client);
|
|
415
416
|
ready(): Promise<NotebookInitSuccessResult>;
|
|
416
417
|
fork(input?: Partial<ForkNotebookInput>): Promise<NotebookInstance>;
|
|
417
|
-
|
|
418
|
-
publish(input
|
|
418
|
+
publication(): Promise<PublicationInstance | null>;
|
|
419
|
+
publish(input: PublishInput): Promise<PublicationRun>;
|
|
420
|
+
run(command: string | string[], opts?: SpawnOptions): ShellProcess;
|
|
421
|
+
run(command: string, args: string[], opts?: SpawnOptions): ShellProcess;
|
|
422
|
+
exec(command: string | string[], opts?: SpawnOptions): Promise<ProcessResult>;
|
|
423
|
+
exec(command: string, args: string[], opts?: SpawnOptions): Promise<ProcessResult>;
|
|
419
424
|
gitCredentials(): Promise<GitCredentials>;
|
|
420
|
-
|
|
425
|
+
destroy(): Promise<void>;
|
|
421
426
|
stop(): Promise<void>;
|
|
422
427
|
restart(): Promise<void>;
|
|
423
428
|
invoke<T extends keyof Invokable>(action: T, data?: Invokable[T]['args'], options?: CallOption): Promise<Invokable[T]['response']>;
|
|
@@ -437,7 +442,6 @@ export declare class NotebookInstance {
|
|
|
437
442
|
update(input: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
|
|
438
443
|
onDidInitialize(handler: (result: NotebookInitResult) => void): Disposable;
|
|
439
444
|
reconnect(): Promise<NotebookInstance>;
|
|
440
|
-
beacon(iframe: HTMLIFrameElement, options?: BeaconOptions): Promise<Beacon>;
|
|
441
445
|
private realtimeSocket;
|
|
442
446
|
}
|
|
443
447
|
export declare class NotebookSecrets {
|
package/dist/index.js
CHANGED
|
@@ -11,13 +11,15 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _NotebookInstance_instances, _NotebookInstance_initPromise, _NotebookInstance_init;
|
|
13
13
|
import { Filesystem } from './filesystem.js';
|
|
14
|
-
import
|
|
14
|
+
import Terminals from './terminal.js';
|
|
15
15
|
import Container from './container.js';
|
|
16
16
|
import Auth from './auth.js';
|
|
17
17
|
import Lsp from './lsp.js';
|
|
18
18
|
import Composer from './composer.js';
|
|
19
|
-
import
|
|
20
|
-
import
|
|
19
|
+
import Logs from './log.js';
|
|
20
|
+
import Metrics from './metrics.js';
|
|
21
|
+
import Ports from './ports.js';
|
|
22
|
+
import { RuntimeTelemetry } from './runtime-telemetry.js';
|
|
21
23
|
import Repl from './repl.js';
|
|
22
24
|
import Shell from './shell.js';
|
|
23
25
|
import Services from './services.js';
|
|
@@ -25,25 +27,26 @@ import Config from './config.js';
|
|
|
25
27
|
import { Transport } from './socket/index.js';
|
|
26
28
|
import EventManager from './events/index.js';
|
|
27
29
|
import Git from './git.js';
|
|
28
|
-
import { createBeacon } from './beacon/index.js';
|
|
29
30
|
import { NotebookUnavailableError, UnsupportedRuntimeTransportError } from './errors/index.js';
|
|
30
|
-
import {
|
|
31
|
+
import { PublicationApi, NotebookPublicationApi } from './publications.js';
|
|
31
32
|
import { ServerApi } from './servers.js';
|
|
32
33
|
import { RestRuntimeInvoker } from './runtime/rest.js';
|
|
33
34
|
export * from './types.js';
|
|
34
|
-
export { Transport } from './socket/index.js';
|
|
35
35
|
export * from './lsp.js';
|
|
36
36
|
export * from './filesystem.js';
|
|
37
37
|
export * from './container.js';
|
|
38
|
+
export * from './log.js';
|
|
39
|
+
export * from './metrics.js';
|
|
40
|
+
export * from './ports.js';
|
|
41
|
+
export * from './runtime-telemetry.js';
|
|
38
42
|
export * from './shell.js';
|
|
39
43
|
export * from './terminal.js';
|
|
40
44
|
export * from './git.js';
|
|
41
45
|
export * from './services.js';
|
|
42
46
|
export * from './config.js';
|
|
43
47
|
export * from './utils/promise.js';
|
|
44
|
-
export * from './beacon/index.js';
|
|
45
48
|
export * from './errors/index.js';
|
|
46
|
-
export * from './
|
|
49
|
+
export * from './publications.js';
|
|
47
50
|
export * from './servers.js';
|
|
48
51
|
function normalizeNotebookSecretInputs(input) {
|
|
49
52
|
if (Array.isArray(input)) {
|
|
@@ -101,7 +104,7 @@ export class NotebookApi {
|
|
|
101
104
|
this.composerCredentials = new NotebookComposerCredentialApi(client);
|
|
102
105
|
this.preview = new NotebookPreviewApi(client);
|
|
103
106
|
this.mail = new NotebookMailApi(client);
|
|
104
|
-
this.
|
|
107
|
+
this.publication = new NotebookPublicationApi(client);
|
|
105
108
|
}
|
|
106
109
|
async create(template, input = {}, init = true) {
|
|
107
110
|
const response = await this.client.post('/notebook', { template, ...input });
|
|
@@ -119,7 +122,7 @@ export class NotebookApi {
|
|
|
119
122
|
const response = await this.client.put(`/notebook/${id}`, input);
|
|
120
123
|
return new NotebookInstance(response.data, this.client);
|
|
121
124
|
}
|
|
122
|
-
async
|
|
125
|
+
async destroy(id) {
|
|
123
126
|
await this.client.delete(`/notebook/${id}`);
|
|
124
127
|
}
|
|
125
128
|
async fork(id, input = {}) {
|
|
@@ -130,10 +133,6 @@ export class NotebookApi {
|
|
|
130
133
|
const response = await this.client.post(`/notebook/${id}/git/credentials`);
|
|
131
134
|
return response.data;
|
|
132
135
|
}
|
|
133
|
-
async open(id) {
|
|
134
|
-
const response = await this.client.get(`/notebook/${id}`);
|
|
135
|
-
return new NotebookInstance(response.data, this.client);
|
|
136
|
-
}
|
|
137
136
|
openFromData(data) {
|
|
138
137
|
return this.init(new NotebookInstance(data, this.client));
|
|
139
138
|
}
|
|
@@ -157,7 +156,7 @@ export class Client {
|
|
|
157
156
|
constructor(token, url = 'https://api.phpsandbox.io/v1', options = {}) {
|
|
158
157
|
this.runtimeTransportValue = 'realtime';
|
|
159
158
|
this.fetch = globalThis.fetch;
|
|
160
|
-
this.
|
|
159
|
+
this.publications = new PublicationApi(this);
|
|
161
160
|
this.notebook = new NotebookApi(this);
|
|
162
161
|
this.servers = new ServerApi(this);
|
|
163
162
|
this.options = Object.assign({ startClosed: true }, options);
|
|
@@ -375,15 +374,17 @@ export class NotebookInstance {
|
|
|
375
374
|
this.watchConnection();
|
|
376
375
|
__classPrivateFieldSet(this, _NotebookInstance_initPromise, __classPrivateFieldGet(this, _NotebookInstance_instances, "m", _NotebookInstance_init).call(this), "f");
|
|
377
376
|
}
|
|
378
|
-
this.
|
|
379
|
-
this.
|
|
377
|
+
this.files = new Filesystem(this, this.socket === null ? null : (handler) => this.onDidConnect(handler));
|
|
378
|
+
this.terminals = new Terminals(this);
|
|
380
379
|
this.auth = new Auth(this);
|
|
381
380
|
this.lsp = new Lsp(this);
|
|
382
381
|
this.composer = new Composer(this, client);
|
|
383
|
-
|
|
382
|
+
const telemetry = new RuntimeTelemetry(this);
|
|
383
|
+
this.logs = new Logs(this, telemetry);
|
|
384
|
+
this.metrics = new Metrics(this, telemetry);
|
|
385
|
+
this.ports = new Ports(this, telemetry);
|
|
384
386
|
this.repl = new Repl(this);
|
|
385
387
|
this.container = new Container(this);
|
|
386
|
-
this.laravel = new Laravel(this);
|
|
387
388
|
this.shell = new Shell(this);
|
|
388
389
|
this.git = new Git(this, client);
|
|
389
390
|
this.services = new Services(this);
|
|
@@ -418,17 +419,29 @@ export class NotebookInstance {
|
|
|
418
419
|
fork(input = {}) {
|
|
419
420
|
return this.client.notebook.fork(this.data.id, input);
|
|
420
421
|
}
|
|
421
|
-
|
|
422
|
-
return this.client.notebook.
|
|
422
|
+
publication() {
|
|
423
|
+
return this.client.notebook.publication.current(this.data.id);
|
|
423
424
|
}
|
|
424
425
|
publish(input) {
|
|
425
|
-
return this.client.notebook.
|
|
426
|
+
return this.client.notebook.publication.publish(this.data.id, input);
|
|
427
|
+
}
|
|
428
|
+
run(command, argsOrOpts = [], opts) {
|
|
429
|
+
if (Array.isArray(argsOrOpts)) {
|
|
430
|
+
return this.shell.run(command, argsOrOpts, opts);
|
|
431
|
+
}
|
|
432
|
+
return this.shell.run(command, argsOrOpts);
|
|
433
|
+
}
|
|
434
|
+
exec(command, argsOrOpts = [], opts) {
|
|
435
|
+
if (Array.isArray(argsOrOpts)) {
|
|
436
|
+
return this.run(command, argsOrOpts, opts).wait();
|
|
437
|
+
}
|
|
438
|
+
return this.run(command, argsOrOpts).wait();
|
|
426
439
|
}
|
|
427
440
|
gitCredentials() {
|
|
428
441
|
return this.client.notebook.gitCredentials(this.data.id);
|
|
429
442
|
}
|
|
430
|
-
|
|
431
|
-
return this.client.notebook.
|
|
443
|
+
destroy() {
|
|
444
|
+
return this.client.notebook.destroy(this.data.id).then(() => {
|
|
432
445
|
this.socket?.terminate(new NotebookUnavailableError('Notebook has been deleted.', { id: this.data.id }));
|
|
433
446
|
});
|
|
434
447
|
}
|
|
@@ -515,9 +528,6 @@ export class NotebookInstance {
|
|
|
515
528
|
const socket = this.realtimeSocket();
|
|
516
529
|
socket.onDidConnect(() => {
|
|
517
530
|
socket.emit('okra.connected');
|
|
518
|
-
if (this.client.options.telemetry) {
|
|
519
|
-
this.container.enableTelemetry(this.client.options.telemetry);
|
|
520
|
-
}
|
|
521
531
|
});
|
|
522
532
|
socket.onDidClose(() => {
|
|
523
533
|
socket.emit('okra.disconnected');
|
|
@@ -581,11 +591,6 @@ export class NotebookInstance {
|
|
|
581
591
|
// Wait for initialization to complete
|
|
582
592
|
return this.ready().then(() => this);
|
|
583
593
|
}
|
|
584
|
-
async beacon(iframe, options) {
|
|
585
|
-
const result = await this.ready();
|
|
586
|
-
iframe.src = result.data.previewUrl;
|
|
587
|
-
return createBeacon(iframe, options);
|
|
588
|
-
}
|
|
589
594
|
realtimeSocket() {
|
|
590
595
|
if (this.socket === null) {
|
|
591
596
|
throw new UnsupportedRuntimeTransportError('This operation requires the realtime transport.');
|
package/dist/log.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NotebookInstance } from './index.js';
|
|
2
|
+
import { RuntimeTelemetry, type RuntimeWatchOptions } from './runtime-telemetry.js';
|
|
2
3
|
export interface LogEvents {
|
|
3
4
|
'notebook.log': string;
|
|
4
5
|
}
|
|
5
6
|
export interface LogActions {
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
+
export interface RuntimeLogEntry {
|
|
9
|
+
timestamp: string;
|
|
10
|
+
source: 'runtime';
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export default class Logs {
|
|
8
14
|
protected okra: NotebookInstance;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
private readonly telemetry;
|
|
16
|
+
constructor(okra: NotebookInstance, telemetry: RuntimeTelemetry);
|
|
17
|
+
follow(options?: RuntimeWatchOptions): ReadableStream<RuntimeLogEntry>;
|
|
12
18
|
}
|
package/dist/log.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { watchRuntimeTelemetry } from './runtime-telemetry.js';
|
|
2
|
+
export default class Logs {
|
|
3
|
+
constructor(okra, telemetry) {
|
|
3
4
|
this.okra = okra;
|
|
5
|
+
this.telemetry = telemetry;
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
return this.okra.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
follow(options = {}) {
|
|
8
|
+
return watchRuntimeTelemetry(this.okra, this.telemetry, 'logs', 'notebook.log', (message) => ({
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
source: 'runtime',
|
|
11
|
+
message,
|
|
12
|
+
}), options);
|
|
10
13
|
}
|
|
11
14
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NotebookInstance } from './index.js';
|
|
2
|
+
import type { ContainerStats } from './container.js';
|
|
3
|
+
import { RuntimeTelemetry, type RuntimeWatchOptions } from './runtime-telemetry.js';
|
|
4
|
+
export default class Metrics {
|
|
5
|
+
private readonly okra;
|
|
6
|
+
private readonly telemetry;
|
|
7
|
+
constructor(okra: NotebookInstance, telemetry: RuntimeTelemetry);
|
|
8
|
+
current(): Promise<ContainerStats | null>;
|
|
9
|
+
watch(options?: RuntimeWatchOptions): ReadableStream<ContainerStats>;
|
|
10
|
+
}
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { watchRuntimeTelemetry } from './runtime-telemetry.js';
|
|
2
|
+
export default class Metrics {
|
|
3
|
+
constructor(okra, telemetry) {
|
|
4
|
+
this.okra = okra;
|
|
5
|
+
this.telemetry = telemetry;
|
|
6
|
+
}
|
|
7
|
+
current() {
|
|
8
|
+
return this.okra.invoke('container.stats');
|
|
9
|
+
}
|
|
10
|
+
watch(options = {}) {
|
|
11
|
+
return watchRuntimeTelemetry(this.okra, this.telemetry, 'stats', 'container.stats', (stats) => stats, options);
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/ports.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NotebookInstance } from './index.js';
|
|
2
|
+
import type { PortInfo } from './container.js';
|
|
3
|
+
import { RuntimeTelemetry, type RuntimeWatchOptions } from './runtime-telemetry.js';
|
|
4
|
+
export default class Ports {
|
|
5
|
+
private readonly okra;
|
|
6
|
+
private readonly telemetry;
|
|
7
|
+
constructor(okra: NotebookInstance, telemetry: RuntimeTelemetry);
|
|
8
|
+
list(): Promise<PortInfo[]>;
|
|
9
|
+
watch(options?: RuntimeWatchOptions): ReadableStream<PortInfo[]>;
|
|
10
|
+
}
|
package/dist/ports.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { watchRuntimeTelemetry } from './runtime-telemetry.js';
|
|
2
|
+
export default class Ports {
|
|
3
|
+
constructor(okra, telemetry) {
|
|
4
|
+
this.okra = okra;
|
|
5
|
+
this.telemetry = telemetry;
|
|
6
|
+
}
|
|
7
|
+
list() {
|
|
8
|
+
return this.okra.invoke('container.opened-ports');
|
|
9
|
+
}
|
|
10
|
+
watch(options = {}) {
|
|
11
|
+
return watchRuntimeTelemetry(this.okra, this.telemetry, 'ports', 'container.ports', (ports) => ports, options);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { type Client, type SecretRef } from './index.js';
|
|
2
|
+
import type { PublicationBuildStatus, PublicationDomainDnsRecordType, PublicationEventData, PublicationJurisdiction, PublicationLogChunkData, PublicationProtectionMode, PublicationRegion, PublicationReleaseStatus, PublicationSize, PublicationStatus, PublishStreamEvent, PublishStreamResult } from './schemas/publications.js';
|
|
3
|
+
export * from './schemas/publications.js';
|
|
4
|
+
export interface PublicationPlacement {
|
|
5
|
+
regions?: PublicationRegion[];
|
|
6
|
+
jurisdiction?: PublicationJurisdiction;
|
|
7
|
+
}
|
|
8
|
+
export type LaravelCloudRegion = 'us-east-2' | 'us-east-1' | 'ca-central-1' | 'eu-central-1' | 'eu-west-1' | 'eu-west-2' | 'me-central-1' | 'ap-southeast-1' | 'ap-southeast-2' | 'ap-northeast-1';
|
|
9
|
+
export interface PublicationProtectionData {
|
|
10
|
+
mode: PublicationProtectionMode;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
token?: string;
|
|
13
|
+
expiresAt?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PublicationFeedbackData {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
config: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export type PublicationProtectionInput = {
|
|
21
|
+
mode: 'none';
|
|
22
|
+
password?: never;
|
|
23
|
+
} | {
|
|
24
|
+
mode: 'password';
|
|
25
|
+
password: string;
|
|
26
|
+
};
|
|
27
|
+
export interface PublicationFeedbackInput {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
config?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface CloudflareContainersProviderOptions {
|
|
32
|
+
size?: PublicationSize;
|
|
33
|
+
sleepAfter?: string;
|
|
34
|
+
placement?: PublicationPlacement;
|
|
35
|
+
instances?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface SshServerProviderOptions {
|
|
38
|
+
serverId: string;
|
|
39
|
+
}
|
|
40
|
+
export interface LaravelCloudProviderData {
|
|
41
|
+
region?: LaravelCloudRegion;
|
|
42
|
+
repository?: string;
|
|
43
|
+
branch?: string;
|
|
44
|
+
sourceControlProviderType?: 'github' | 'gitlab' | 'bitbucket';
|
|
45
|
+
apiKeyConfigured?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface LaravelCloudProviderInput {
|
|
48
|
+
apiKey: SecretRef;
|
|
49
|
+
region?: LaravelCloudRegion;
|
|
50
|
+
}
|
|
51
|
+
export interface PublicationProviderInputs {
|
|
52
|
+
'cloudflare-containers': CloudflareContainersProviderOptions;
|
|
53
|
+
'ssh-server': SshServerProviderOptions;
|
|
54
|
+
'laravel-cloud': LaravelCloudProviderInput;
|
|
55
|
+
}
|
|
56
|
+
export interface PublicationProviderData {
|
|
57
|
+
'cloudflare-containers': CloudflareContainersProviderOptions;
|
|
58
|
+
'ssh-server': SshServerProviderOptions;
|
|
59
|
+
'laravel-cloud': LaravelCloudProviderData;
|
|
60
|
+
}
|
|
61
|
+
export type PublicationProviderName = Extract<keyof PublicationProviderInputs, string>;
|
|
62
|
+
export type PublicationProviderInput<TName extends PublicationProviderName = PublicationProviderName> = {
|
|
63
|
+
[Name in TName]: {
|
|
64
|
+
name: Name;
|
|
65
|
+
} & PublicationProviderInputs[Name];
|
|
66
|
+
}[TName];
|
|
67
|
+
export type PublicationProvider<TName extends PublicationProviderName = PublicationProviderName> = {
|
|
68
|
+
[Name in TName]: {
|
|
69
|
+
name: Name;
|
|
70
|
+
} & PublicationProviderData[Name];
|
|
71
|
+
}[TName];
|
|
72
|
+
export interface PublishInput<TName extends PublicationProviderName = PublicationProviderName> {
|
|
73
|
+
slug: string;
|
|
74
|
+
provider: PublicationProviderInput<TName>;
|
|
75
|
+
protection?: PublicationProtectionInput;
|
|
76
|
+
feedback?: PublicationFeedbackInput;
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
export interface PublicationBuildData<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
80
|
+
id: string;
|
|
81
|
+
status: PublicationBuildStatus;
|
|
82
|
+
strategy: string;
|
|
83
|
+
provider: PublicationProvider<TProvider>;
|
|
84
|
+
errorMessage: string | null;
|
|
85
|
+
startedAt: string | null;
|
|
86
|
+
finishedAt: string | null;
|
|
87
|
+
}
|
|
88
|
+
export interface PublicationReleaseData {
|
|
89
|
+
id: string;
|
|
90
|
+
status: PublicationReleaseStatus;
|
|
91
|
+
manifest: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface PublicationDomainDnsData {
|
|
94
|
+
type: PublicationDomainDnsRecordType;
|
|
95
|
+
name: string;
|
|
96
|
+
value: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PublicationDomainData {
|
|
99
|
+
id: string;
|
|
100
|
+
publicationId: string | null;
|
|
101
|
+
hostname: string;
|
|
102
|
+
status: string;
|
|
103
|
+
provider: string;
|
|
104
|
+
providerHostnameId: string | null;
|
|
105
|
+
dns: PublicationDomainDnsData;
|
|
106
|
+
ssl: {
|
|
107
|
+
status: string | null;
|
|
108
|
+
};
|
|
109
|
+
validationErrors: unknown[];
|
|
110
|
+
validationRecords: unknown[];
|
|
111
|
+
metadata: Record<string, unknown>;
|
|
112
|
+
verifiedAt: string | null;
|
|
113
|
+
createdAt: string | null;
|
|
114
|
+
updatedAt: string | null;
|
|
115
|
+
}
|
|
116
|
+
export interface CreatePublicationDomainInput {
|
|
117
|
+
hostname: string;
|
|
118
|
+
}
|
|
119
|
+
export interface PublicationData<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
120
|
+
id: string;
|
|
121
|
+
slug: string;
|
|
122
|
+
url: string;
|
|
123
|
+
status: PublicationStatus;
|
|
124
|
+
strategy: string;
|
|
125
|
+
provider: PublicationProvider<TProvider>;
|
|
126
|
+
protection: PublicationProtectionData;
|
|
127
|
+
feedback: PublicationFeedbackData;
|
|
128
|
+
eventStreamUrl: string | null;
|
|
129
|
+
originUrl: string | null;
|
|
130
|
+
currentRelease?: PublicationReleaseData | null;
|
|
131
|
+
domains?: PublicationDomainData[];
|
|
132
|
+
latestBuild?: PublicationBuildData<TProvider> | null;
|
|
133
|
+
deployedAt: string | null;
|
|
134
|
+
createdAt: string | null;
|
|
135
|
+
updatedAt: string | null;
|
|
136
|
+
}
|
|
137
|
+
export interface UpdatePublicationProtectionInput {
|
|
138
|
+
mode: PublicationProtectionMode;
|
|
139
|
+
password?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface PublicationProtectionSessionData {
|
|
142
|
+
previewSessionId: string;
|
|
143
|
+
token: string;
|
|
144
|
+
expiresAt: string;
|
|
145
|
+
url: string;
|
|
146
|
+
}
|
|
147
|
+
export interface UpdatePublicationFeedbackInput {
|
|
148
|
+
enabled: boolean;
|
|
149
|
+
config?: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
export declare class NotebookPublicationApi {
|
|
152
|
+
private readonly client;
|
|
153
|
+
constructor(client: Client);
|
|
154
|
+
current<TProvider extends PublicationProviderName = PublicationProviderName>(notebookId: string): Promise<PublicationInstance<TProvider> | null>;
|
|
155
|
+
publish<TProvider extends PublicationProviderName = PublicationProviderName>(notebookId: string, input?: PublishInput): Promise<PublicationRun<TProvider>>;
|
|
156
|
+
}
|
|
157
|
+
export declare class PublicationApi {
|
|
158
|
+
private readonly client;
|
|
159
|
+
constructor(client: Client);
|
|
160
|
+
get<TProvider extends PublicationProviderName = PublicationProviderName>(id: string): Promise<PublicationInstance<TProvider>>;
|
|
161
|
+
destroy(id: string): Promise<void>;
|
|
162
|
+
setProtection<TProvider extends PublicationProviderName = PublicationProviderName>(id: string, input: UpdatePublicationProtectionInput): Promise<PublicationInstance<TProvider>>;
|
|
163
|
+
protection(id: string): Promise<PublicationProtectionData>;
|
|
164
|
+
createProtectionSession(id: string): Promise<PublicationProtectionSessionData>;
|
|
165
|
+
disableProtection<TProvider extends PublicationProviderName = PublicationProviderName>(id: string): Promise<PublicationInstance<TProvider>>;
|
|
166
|
+
setFeedback<TProvider extends PublicationProviderName = PublicationProviderName>(id: string, input: UpdatePublicationFeedbackInput): Promise<PublicationInstance<TProvider>>;
|
|
167
|
+
listDomains(id: string): Promise<PublicationDomainData[]>;
|
|
168
|
+
createDomain(id: string, input: CreatePublicationDomainInput): Promise<PublicationDomainData>;
|
|
169
|
+
refreshDomain(id: string, domainId: string): Promise<PublicationDomainData>;
|
|
170
|
+
deleteDomain(id: string, domainId: string): Promise<void>;
|
|
171
|
+
events(id: string): Promise<ReadableStream<PublicationEventData>>;
|
|
172
|
+
buildLogs(id: string, buildId: string): Promise<ReadableStream<PublicationLogChunkData>>;
|
|
173
|
+
logs(id: string): Promise<ReadableStream<PublicationLogChunkData>>;
|
|
174
|
+
}
|
|
175
|
+
export declare class PublicationRun<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
176
|
+
readonly initial: PublicationInstance<TProvider>;
|
|
177
|
+
private readonly client;
|
|
178
|
+
private started;
|
|
179
|
+
private completed;
|
|
180
|
+
private finalError;
|
|
181
|
+
private finalResult;
|
|
182
|
+
private resultPromise;
|
|
183
|
+
private resolveResult;
|
|
184
|
+
private rejectResult;
|
|
185
|
+
private readonly bufferedEvents;
|
|
186
|
+
private readonly subscribers;
|
|
187
|
+
constructor(initial: PublicationInstance<TProvider>, client: Client);
|
|
188
|
+
events(): AsyncIterable<PublishStreamEvent>;
|
|
189
|
+
result(): Promise<PublishStreamResult>;
|
|
190
|
+
publication(): Promise<PublicationInstance<TProvider>>;
|
|
191
|
+
start(): this;
|
|
192
|
+
private subscribe;
|
|
193
|
+
private consumeStream;
|
|
194
|
+
private publish;
|
|
195
|
+
private closeSubscribers;
|
|
196
|
+
private fail;
|
|
197
|
+
}
|
|
198
|
+
export declare class PublicationInstance<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
199
|
+
readonly data: PublicationData<TProvider>;
|
|
200
|
+
private readonly client;
|
|
201
|
+
private readonly notebookId?;
|
|
202
|
+
constructor(data: PublicationData<TProvider>, client: Client, notebookId?: string);
|
|
203
|
+
refresh(): Promise<PublicationInstance<TProvider>>;
|
|
204
|
+
publish(): Promise<PublicationRun<TProvider>>;
|
|
205
|
+
destroy(): Promise<void>;
|
|
206
|
+
wait(options?: {
|
|
207
|
+
intervalMs?: number;
|
|
208
|
+
timeoutMs?: number;
|
|
209
|
+
}): Promise<PublicationInstance<TProvider>>;
|
|
210
|
+
events(): Promise<ReadableStream<PublicationEventData>>;
|
|
211
|
+
buildLogs(buildId?: string): Promise<ReadableStream<PublicationLogChunkData>>;
|
|
212
|
+
logs(): Promise<ReadableStream<PublicationLogChunkData>>;
|
|
213
|
+
setProtection(input: UpdatePublicationProtectionInput): Promise<PublicationInstance<TProvider>>;
|
|
214
|
+
protection(): Promise<PublicationProtectionData>;
|
|
215
|
+
createProtectionSession(): Promise<PublicationProtectionSessionData>;
|
|
216
|
+
disableProtection(): Promise<PublicationInstance<TProvider>>;
|
|
217
|
+
setFeedback(input: UpdatePublicationFeedbackInput): Promise<PublicationInstance<TProvider>>;
|
|
218
|
+
domains(): Promise<PublicationDomainData[]>;
|
|
219
|
+
addDomain(input: CreatePublicationDomainInput): Promise<PublicationDomainData>;
|
|
220
|
+
refreshDomain(domainId: string): Promise<PublicationDomainData>;
|
|
221
|
+
deleteDomain(domainId: string): Promise<void>;
|
|
222
|
+
}
|