@phpsandbox/sdk 0.0.67 → 0.1.1
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 +10 -13
- 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 +311 -1016
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +311 -1016
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/filesystem.d.ts +2 -1
- package/dist/filesystem.js +35 -2
- package/dist/index.d.ts +15 -24
- package/dist/index.js +19 -28
- package/dist/publications.d.ts +222 -0
- package/dist/{deployments.js → publications.js} +65 -70
- package/dist/repl.d.ts +0 -2
- package/dist/repl.js +0 -3
- package/dist/runtime/rest.js +1 -1
- package/dist/schemas/{deployments.d.ts → publications.d.ts} +68 -68
- package/dist/schemas/publications.js +133 -0
- package/dist/shell.d.ts +43 -22
- package/dist/shell.js +103 -75
- package/dist/terminal.d.ts +1 -3
- package/dist/terminal.js +2 -5
- package/docs/api-summary.md +13 -10
- package/docs/cdn-usage.md +4 -4
- package/docs/getting-started.md +6 -6
- package/examples/README.md +8 -9
- package/examples/basic.ts +1 -1
- package/examples/git-merge-smoke.ts +2 -2
- package/examples/laravel-load-test.ts +14 -19
- package/examples/notebook-readonly-smoke.ts +11 -11
- 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 -253
- 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/filesystem.d.ts
CHANGED
|
@@ -454,7 +454,8 @@ export declare class Filesystem {
|
|
|
454
454
|
constructor(okra: NotebookInstance, registerReconnect?: ((handler: () => void) => Disposable) | null);
|
|
455
455
|
private registerReconnectHandler;
|
|
456
456
|
info(path: string): Promise<FileInfo>;
|
|
457
|
-
write(path: string, contents: string): Promise<boolean>;
|
|
457
|
+
write(path: string, contents: string | Uint8Array | ReadableStream<Uint8Array>, options?: FileWriteOptions): Promise<boolean>;
|
|
458
|
+
read(path: string): ReadableStream<Uint8Array>;
|
|
458
459
|
find(query: string, options?: Partial<FileSearchOptions>): Promise<FileResult[]>;
|
|
459
460
|
search(query: TextSearchQuery, options?: Partial<TextSearchOptions>, onMatch?: (result: TextSearchResult | false) => boolean | Promise<boolean> | void | Promise<void>): Promise<[boolean, TextSearchMatch[]]>;
|
|
460
461
|
mkdir(path: string): Promise<boolean>;
|
package/dist/filesystem.js
CHANGED
|
@@ -87,8 +87,26 @@ export class Filesystem {
|
|
|
87
87
|
info(path) {
|
|
88
88
|
return this.okra.invoke('fs.info', { path });
|
|
89
89
|
}
|
|
90
|
-
write(path, contents) {
|
|
91
|
-
|
|
90
|
+
async write(path, contents, options = { overwrite: true, create: true, unlock: false, atomic: false }) {
|
|
91
|
+
if (typeof contents === 'string') {
|
|
92
|
+
return this.okra.invoke('fs.write', { path, contents });
|
|
93
|
+
}
|
|
94
|
+
const bytes = contents instanceof Uint8Array ? contents : await collectBytes(contents);
|
|
95
|
+
await this.writeFile(path, bytes, options);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
read(path) {
|
|
99
|
+
return new ReadableStream({
|
|
100
|
+
start: async (controller) => {
|
|
101
|
+
try {
|
|
102
|
+
controller.enqueue(await this.readFile(path));
|
|
103
|
+
controller.close();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
controller.error(error);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
});
|
|
92
110
|
}
|
|
93
111
|
find(query, options = {
|
|
94
112
|
useIgnoreFiles: false,
|
|
@@ -275,3 +293,18 @@ export class Filesystem {
|
|
|
275
293
|
throw e;
|
|
276
294
|
}
|
|
277
295
|
}
|
|
296
|
+
async function collectBytes(stream) {
|
|
297
|
+
const chunks = [];
|
|
298
|
+
let length = 0;
|
|
299
|
+
for await (const chunk of stream) {
|
|
300
|
+
chunks.push(chunk);
|
|
301
|
+
length += chunk.byteLength;
|
|
302
|
+
}
|
|
303
|
+
const output = new Uint8Array(length);
|
|
304
|
+
let offset = 0;
|
|
305
|
+
for (const chunk of chunks) {
|
|
306
|
+
output.set(chunk, offset);
|
|
307
|
+
offset += chunk.byteLength;
|
|
308
|
+
}
|
|
309
|
+
return output;
|
|
310
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { Filesystem, FilesystemActions, FilesystemEvents } from './filesystem.js';
|
|
2
|
-
import Terminal, { TerminalEvents, TerminalActions } from './terminal.js';
|
|
2
|
+
import Terminal, { TerminalEvents, TerminalActions, type SpawnOptions } from './terminal.js';
|
|
3
3
|
import Container, { ContainerActions, ContainerEvents, PortInfo, TelemetryFeature } 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
7
|
import Log, { LogActions, LogEvents } from './log.js';
|
|
8
|
-
import Laravel, { LaravelActions, LaravelEvents } from './laravel.js';
|
|
9
8
|
import Repl, { ReplActions, ReplEvents } from './repl.js';
|
|
10
|
-
import Shell, { ShellEvents, ShellActions } from './shell.js';
|
|
9
|
+
import Shell, { ShellEvents, ShellActions, type ShellProcess } from './shell.js';
|
|
11
10
|
import Services, { ServiceActions, ServiceEvents } from './services.js';
|
|
12
11
|
import Config, { ConfigActions } from './config.js';
|
|
13
12
|
import { EventDispatcher } from './events/index.js';
|
|
14
13
|
import Git, { GitActions, GitCredentials, GitEvents } from './git.js';
|
|
15
14
|
import { Disposable } from './types.js';
|
|
16
|
-
import { Beacon, BeaconOptions } from './beacon/index.js';
|
|
17
15
|
import { NotebookUnavailableError } from './errors/index.js';
|
|
18
|
-
import {
|
|
16
|
+
import { PublicationApi, NotebookPublicationApi, type PublicationInstance, type PublicationRun, type PublishInput } from './publications.js';
|
|
19
17
|
import { ServerApi } from './servers.js';
|
|
20
18
|
export * from './types.js';
|
|
21
|
-
export { Transport } from './socket/index.js';
|
|
22
19
|
export * from './lsp.js';
|
|
23
20
|
export * from './filesystem.js';
|
|
24
21
|
export * from './container.js';
|
|
@@ -28,9 +25,8 @@ export * from './git.js';
|
|
|
28
25
|
export * from './services.js';
|
|
29
26
|
export * from './config.js';
|
|
30
27
|
export * from './utils/promise.js';
|
|
31
|
-
export * from './beacon/index.js';
|
|
32
28
|
export * from './errors/index.js';
|
|
33
|
-
export * from './
|
|
29
|
+
export * from './publications.js';
|
|
34
30
|
export * from './servers.js';
|
|
35
31
|
interface Result<TType extends 'success' | 'error' | 'running', TData extends object> {
|
|
36
32
|
type: TType;
|
|
@@ -100,11 +96,11 @@ export interface Action<Args = object, Response = void> {
|
|
|
100
96
|
args: Args;
|
|
101
97
|
response: Response;
|
|
102
98
|
}
|
|
103
|
-
export type Events = TerminalEvents & ContainerEvents & LspEvents & ComposerEvents & LogEvents & ServiceEvents &
|
|
99
|
+
export type Events = TerminalEvents & ContainerEvents & LspEvents & ComposerEvents & LogEvents & ServiceEvents & NotebookEvents & ReplEvents & ShellEvents & FilesystemEvents & GitEvents;
|
|
104
100
|
interface SystemActions {
|
|
105
101
|
ping: Action<object, 'pong'>;
|
|
106
102
|
}
|
|
107
|
-
export type Invokable = SystemActions & TerminalActions & ContainerActions & FilesystemActions & AuthActions & LspActions &
|
|
103
|
+
export type Invokable = SystemActions & TerminalActions & ContainerActions & FilesystemActions & AuthActions & LspActions & ComposerActions & LogActions & ServiceActions & ConfigActions & NotebookActions & ReplActions & ShellActions & GitActions;
|
|
108
104
|
export interface CreateNotebookImportAuthInput {
|
|
109
105
|
access_token: string;
|
|
110
106
|
}
|
|
@@ -289,15 +285,14 @@ export declare class NotebookApi {
|
|
|
289
285
|
readonly composerCredentials: NotebookComposerCredentialApi;
|
|
290
286
|
readonly preview: NotebookPreviewApi;
|
|
291
287
|
readonly mail: NotebookMailApi;
|
|
292
|
-
readonly
|
|
288
|
+
readonly publication: NotebookPublicationApi;
|
|
293
289
|
constructor(client: Client);
|
|
294
290
|
create(template: string, input?: Partial<CreateNotebookInput>, init?: boolean): Promise<NotebookInstance>;
|
|
295
291
|
get(id: string): Promise<NotebookInstance>;
|
|
296
292
|
update(id: string, input?: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
|
|
297
|
-
|
|
293
|
+
destroy(id: string): Promise<void>;
|
|
298
294
|
fork(id: string, input?: Partial<ForkNotebookInput>): Promise<NotebookInstance>;
|
|
299
295
|
gitCredentials(id: string): Promise<GitCredentials>;
|
|
300
|
-
open(id: string): Promise<NotebookInstance>;
|
|
301
296
|
openFromData(data: NotebookData): Promise<NotebookInstance>;
|
|
302
297
|
private init;
|
|
303
298
|
}
|
|
@@ -308,13 +303,11 @@ export interface PHPSandboxClientOptions {
|
|
|
308
303
|
fetch?: typeof globalThis.fetch;
|
|
309
304
|
webSocket?: unknown;
|
|
310
305
|
runtimeUrlProvider?: (notebookId: string) => Promise<string>;
|
|
311
|
-
/** @deprecated Use runtimeUrlProvider instead. */
|
|
312
|
-
okraUrlProvider?: (notebookId: string) => Promise<string>;
|
|
313
306
|
}
|
|
314
307
|
export type RuntimeTransport = 'realtime' | 'rest';
|
|
315
308
|
export declare class Client {
|
|
316
309
|
readonly notebook: NotebookApi;
|
|
317
|
-
readonly
|
|
310
|
+
readonly publications: PublicationApi;
|
|
318
311
|
readonly servers: ServerApi;
|
|
319
312
|
readonly options: PHPSandboxClientOptions;
|
|
320
313
|
protected runtimeTransportValue: RuntimeTransport;
|
|
@@ -379,9 +372,7 @@ export declare class NotebookMailApi {
|
|
|
379
372
|
}
|
|
380
373
|
export interface NotebookData {
|
|
381
374
|
id: string;
|
|
382
|
-
runtimeUrl
|
|
383
|
-
/** @deprecated Use runtimeUrl instead. */
|
|
384
|
-
okraUrl: string;
|
|
375
|
+
runtimeUrl: string;
|
|
385
376
|
gitUrl: string;
|
|
386
377
|
type?: string;
|
|
387
378
|
title?: string;
|
|
@@ -401,7 +392,6 @@ export declare class NotebookInstance {
|
|
|
401
392
|
readonly log: Log;
|
|
402
393
|
readonly repl: Repl;
|
|
403
394
|
readonly container: Container;
|
|
404
|
-
readonly laravel: Laravel;
|
|
405
395
|
readonly shell: Shell;
|
|
406
396
|
readonly git: Git;
|
|
407
397
|
readonly services: Services;
|
|
@@ -418,10 +408,12 @@ export declare class NotebookInstance {
|
|
|
418
408
|
constructor(data: NotebookData, client: Client);
|
|
419
409
|
ready(): Promise<NotebookInitSuccessResult>;
|
|
420
410
|
fork(input?: Partial<ForkNotebookInput>): Promise<NotebookInstance>;
|
|
421
|
-
|
|
422
|
-
publish(input
|
|
411
|
+
publication(): Promise<PublicationInstance | null>;
|
|
412
|
+
publish(input: PublishInput): Promise<PublicationRun>;
|
|
413
|
+
run(command: string | string[], opts?: SpawnOptions): ShellProcess;
|
|
414
|
+
run(command: string, args: string[], opts?: SpawnOptions): ShellProcess;
|
|
423
415
|
gitCredentials(): Promise<GitCredentials>;
|
|
424
|
-
|
|
416
|
+
destroy(): Promise<void>;
|
|
425
417
|
stop(): Promise<void>;
|
|
426
418
|
restart(): Promise<void>;
|
|
427
419
|
invoke<T extends keyof Invokable>(action: T, data?: Invokable[T]['args'], options?: CallOption): Promise<Invokable[T]['response']>;
|
|
@@ -441,7 +433,6 @@ export declare class NotebookInstance {
|
|
|
441
433
|
update(input: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
|
|
442
434
|
onDidInitialize(handler: (result: NotebookInitResult) => void): Disposable;
|
|
443
435
|
reconnect(): Promise<NotebookInstance>;
|
|
444
|
-
beacon(iframe: HTMLIFrameElement, options?: BeaconOptions): Promise<Beacon>;
|
|
445
436
|
private realtimeSocket;
|
|
446
437
|
}
|
|
447
438
|
export declare class NotebookSecrets {
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,6 @@ import Auth from './auth.js';
|
|
|
17
17
|
import Lsp from './lsp.js';
|
|
18
18
|
import Composer from './composer.js';
|
|
19
19
|
import Log from './log.js';
|
|
20
|
-
import Laravel from './laravel.js';
|
|
21
20
|
import Repl from './repl.js';
|
|
22
21
|
import Shell from './shell.js';
|
|
23
22
|
import Services from './services.js';
|
|
@@ -25,13 +24,11 @@ import Config from './config.js';
|
|
|
25
24
|
import { Transport } from './socket/index.js';
|
|
26
25
|
import EventManager from './events/index.js';
|
|
27
26
|
import Git from './git.js';
|
|
28
|
-
import { createBeacon } from './beacon/index.js';
|
|
29
27
|
import { NotebookUnavailableError, UnsupportedRuntimeTransportError } from './errors/index.js';
|
|
30
|
-
import {
|
|
28
|
+
import { PublicationApi, NotebookPublicationApi } from './publications.js';
|
|
31
29
|
import { ServerApi } from './servers.js';
|
|
32
30
|
import { RestRuntimeInvoker } from './runtime/rest.js';
|
|
33
31
|
export * from './types.js';
|
|
34
|
-
export { Transport } from './socket/index.js';
|
|
35
32
|
export * from './lsp.js';
|
|
36
33
|
export * from './filesystem.js';
|
|
37
34
|
export * from './container.js';
|
|
@@ -41,9 +38,8 @@ export * from './git.js';
|
|
|
41
38
|
export * from './services.js';
|
|
42
39
|
export * from './config.js';
|
|
43
40
|
export * from './utils/promise.js';
|
|
44
|
-
export * from './beacon/index.js';
|
|
45
41
|
export * from './errors/index.js';
|
|
46
|
-
export * from './
|
|
42
|
+
export * from './publications.js';
|
|
47
43
|
export * from './servers.js';
|
|
48
44
|
function normalizeNotebookSecretInputs(input) {
|
|
49
45
|
if (Array.isArray(input)) {
|
|
@@ -101,7 +97,7 @@ export class NotebookApi {
|
|
|
101
97
|
this.composerCredentials = new NotebookComposerCredentialApi(client);
|
|
102
98
|
this.preview = new NotebookPreviewApi(client);
|
|
103
99
|
this.mail = new NotebookMailApi(client);
|
|
104
|
-
this.
|
|
100
|
+
this.publication = new NotebookPublicationApi(client);
|
|
105
101
|
}
|
|
106
102
|
async create(template, input = {}, init = true) {
|
|
107
103
|
const response = await this.client.post('/notebook', { template, ...input });
|
|
@@ -119,7 +115,7 @@ export class NotebookApi {
|
|
|
119
115
|
const response = await this.client.put(`/notebook/${id}`, input);
|
|
120
116
|
return new NotebookInstance(response.data, this.client);
|
|
121
117
|
}
|
|
122
|
-
async
|
|
118
|
+
async destroy(id) {
|
|
123
119
|
await this.client.delete(`/notebook/${id}`);
|
|
124
120
|
}
|
|
125
121
|
async fork(id, input = {}) {
|
|
@@ -130,10 +126,6 @@ export class NotebookApi {
|
|
|
130
126
|
const response = await this.client.post(`/notebook/${id}/git/credentials`);
|
|
131
127
|
return response.data;
|
|
132
128
|
}
|
|
133
|
-
async open(id) {
|
|
134
|
-
const response = await this.client.get(`/notebook/${id}`);
|
|
135
|
-
return new NotebookInstance(response.data, this.client);
|
|
136
|
-
}
|
|
137
129
|
openFromData(data) {
|
|
138
130
|
return this.init(new NotebookInstance(data, this.client));
|
|
139
131
|
}
|
|
@@ -157,7 +149,7 @@ export class Client {
|
|
|
157
149
|
constructor(token, url = 'https://api.phpsandbox.io/v1', options = {}) {
|
|
158
150
|
this.runtimeTransportValue = 'realtime';
|
|
159
151
|
this.fetch = globalThis.fetch;
|
|
160
|
-
this.
|
|
152
|
+
this.publications = new PublicationApi(this);
|
|
161
153
|
this.notebook = new NotebookApi(this);
|
|
162
154
|
this.servers = new ServerApi(this);
|
|
163
155
|
this.options = Object.assign({ startClosed: true }, options);
|
|
@@ -347,8 +339,7 @@ export class NotebookInstance {
|
|
|
347
339
|
this.initialized = false;
|
|
348
340
|
_NotebookInstance_initPromise.set(this, null);
|
|
349
341
|
this.disposables = [];
|
|
350
|
-
const
|
|
351
|
-
const runtimeUrlProvider = client.options.runtimeUrlProvider ?? client.options.okraUrlProvider;
|
|
342
|
+
const runtimeUrlProvider = client.options.runtimeUrlProvider;
|
|
352
343
|
this.emitter = EventManager.createInstance();
|
|
353
344
|
if (client.runtimeTransport === 'rest') {
|
|
354
345
|
this.socket = null;
|
|
@@ -360,11 +351,11 @@ export class NotebookInstance {
|
|
|
360
351
|
this.restInvoker = null;
|
|
361
352
|
let initialConnection = true;
|
|
362
353
|
const connectionUrl = runtimeUrlProvider === undefined
|
|
363
|
-
? runtimeUrl
|
|
354
|
+
? data.runtimeUrl
|
|
364
355
|
: async () => {
|
|
365
356
|
if (initialConnection) {
|
|
366
357
|
initialConnection = false;
|
|
367
|
-
return runtimeUrl;
|
|
358
|
+
return data.runtimeUrl;
|
|
368
359
|
}
|
|
369
360
|
return runtimeUrlProvider(data.id);
|
|
370
361
|
};
|
|
@@ -384,7 +375,6 @@ export class NotebookInstance {
|
|
|
384
375
|
this.log = new Log(this);
|
|
385
376
|
this.repl = new Repl(this);
|
|
386
377
|
this.container = new Container(this);
|
|
387
|
-
this.laravel = new Laravel(this);
|
|
388
378
|
this.shell = new Shell(this);
|
|
389
379
|
this.git = new Git(this, client);
|
|
390
380
|
this.services = new Services(this);
|
|
@@ -419,17 +409,23 @@ export class NotebookInstance {
|
|
|
419
409
|
fork(input = {}) {
|
|
420
410
|
return this.client.notebook.fork(this.data.id, input);
|
|
421
411
|
}
|
|
422
|
-
|
|
423
|
-
return this.client.notebook.
|
|
412
|
+
publication() {
|
|
413
|
+
return this.client.notebook.publication.current(this.data.id);
|
|
424
414
|
}
|
|
425
415
|
publish(input) {
|
|
426
|
-
return this.client.notebook.
|
|
416
|
+
return this.client.notebook.publication.publish(this.data.id, input);
|
|
417
|
+
}
|
|
418
|
+
run(command, argsOrOpts = [], opts) {
|
|
419
|
+
if (Array.isArray(argsOrOpts)) {
|
|
420
|
+
return this.shell.run(command, argsOrOpts, opts);
|
|
421
|
+
}
|
|
422
|
+
return this.shell.run(command, argsOrOpts);
|
|
427
423
|
}
|
|
428
424
|
gitCredentials() {
|
|
429
425
|
return this.client.notebook.gitCredentials(this.data.id);
|
|
430
426
|
}
|
|
431
|
-
|
|
432
|
-
return this.client.notebook.
|
|
427
|
+
destroy() {
|
|
428
|
+
return this.client.notebook.destroy(this.data.id).then(() => {
|
|
433
429
|
this.socket?.terminate(new NotebookUnavailableError('Notebook has been deleted.', { id: this.data.id }));
|
|
434
430
|
});
|
|
435
431
|
}
|
|
@@ -582,11 +578,6 @@ export class NotebookInstance {
|
|
|
582
578
|
// Wait for initialization to complete
|
|
583
579
|
return this.ready().then(() => this);
|
|
584
580
|
}
|
|
585
|
-
async beacon(iframe, options) {
|
|
586
|
-
const result = await this.ready();
|
|
587
|
-
iframe.src = result.data.previewUrl;
|
|
588
|
-
return createBeacon(iframe, options);
|
|
589
|
-
}
|
|
590
581
|
realtimeSocket() {
|
|
591
582
|
if (this.socket === null) {
|
|
592
583
|
throw new UnsupportedRuntimeTransportError('This operation requires the realtime transport.');
|
|
@@ -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
|
+
}
|