@phpsandbox/sdk 0.1.4 → 0.1.6
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 +31 -6
- package/dist/browser/phpsandbox-sdk.esm.js +230 -28
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +230 -28
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/feedback.d.ts +73 -0
- package/dist/feedback.js +38 -0
- package/dist/filesystem.d.ts +3 -24
- package/dist/filesystem.js +3 -1
- package/dist/git.d.ts +28 -11
- package/dist/git.js +41 -10
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/integrations.d.ts +43 -0
- package/dist/integrations.js +48 -0
- package/dist/publications.d.ts +5 -21
- package/dist/publications.js +1 -8
- package/dist/runtime/rest.js +0 -5
- package/dist/sandbox-integrations.d.ts +44 -0
- package/dist/sandbox-integrations.js +63 -0
- package/dist/schemas/publications.d.ts +11 -1
- package/dist/schemas/publications.js +3 -1
- package/dist/terminal.d.ts +0 -7
- package/docs/api-summary.md +33 -3
- package/examples/README.md +1 -1
- package/examples/publish-cloudflare-container.ts +15 -0
- package/examples/publish-laravel-cloud.ts +33 -22
- package/package.json +12 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Client, PaginatedApiResponse } from './index.js';
|
|
2
|
+
export type FeedbackType = 'bug' | 'suggestion' | 'question' | 'other';
|
|
3
|
+
export type FeedbackStatus = 'open' | 'resolved' | 'archived';
|
|
4
|
+
export type FeedbackSource = 'sdk' | 'widget';
|
|
5
|
+
export type FeedbackWidgetTarget = 'preview' | 'publication';
|
|
6
|
+
export interface FeedbackWidgetConfig {
|
|
7
|
+
targets: FeedbackWidgetTarget[];
|
|
8
|
+
label?: string;
|
|
9
|
+
types?: FeedbackType[];
|
|
10
|
+
}
|
|
11
|
+
export interface ConfigureFeedbackInput {
|
|
12
|
+
widget: FeedbackWidgetConfig | null;
|
|
13
|
+
}
|
|
14
|
+
export interface SubmitFeedbackInput {
|
|
15
|
+
type: FeedbackType;
|
|
16
|
+
message: string;
|
|
17
|
+
author?: {
|
|
18
|
+
externalId?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
};
|
|
22
|
+
context?: {
|
|
23
|
+
url?: string;
|
|
24
|
+
path?: string;
|
|
25
|
+
};
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface FeedbackData {
|
|
29
|
+
id: string;
|
|
30
|
+
type: FeedbackType;
|
|
31
|
+
message: string;
|
|
32
|
+
status: FeedbackStatus;
|
|
33
|
+
source: FeedbackSource;
|
|
34
|
+
author: {
|
|
35
|
+
source: 'external' | 'phpsandbox';
|
|
36
|
+
externalId: string | null;
|
|
37
|
+
phpsandboxUserId: number | null;
|
|
38
|
+
name: string | null;
|
|
39
|
+
email: string | null;
|
|
40
|
+
};
|
|
41
|
+
context: {
|
|
42
|
+
url: string | null;
|
|
43
|
+
path: string | null;
|
|
44
|
+
publication: {
|
|
45
|
+
id: string;
|
|
46
|
+
releaseId: string | null;
|
|
47
|
+
} | null;
|
|
48
|
+
};
|
|
49
|
+
metadata: Record<string, unknown>;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
}
|
|
53
|
+
export interface FeedbackListOptions {
|
|
54
|
+
type?: FeedbackType;
|
|
55
|
+
status?: FeedbackStatus;
|
|
56
|
+
source?: FeedbackSource;
|
|
57
|
+
page?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface UpdateFeedbackInput {
|
|
60
|
+
status: FeedbackStatus;
|
|
61
|
+
}
|
|
62
|
+
export declare class Feedback {
|
|
63
|
+
private readonly client;
|
|
64
|
+
private readonly notebookId;
|
|
65
|
+
constructor(client: Client, notebookId: string);
|
|
66
|
+
configure(input: ConfigureFeedbackInput): Promise<ConfigureFeedbackInput>;
|
|
67
|
+
configuration(): Promise<ConfigureFeedbackInput>;
|
|
68
|
+
submit(input: SubmitFeedbackInput): Promise<FeedbackData>;
|
|
69
|
+
list(options?: FeedbackListOptions): Promise<PaginatedApiResponse<FeedbackData>>;
|
|
70
|
+
get(id: string): Promise<FeedbackData>;
|
|
71
|
+
update(id: string, input: UpdateFeedbackInput): Promise<FeedbackData>;
|
|
72
|
+
private path;
|
|
73
|
+
}
|
package/dist/feedback.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class Feedback {
|
|
2
|
+
constructor(client, notebookId) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.notebookId = notebookId;
|
|
5
|
+
}
|
|
6
|
+
async configure(input) {
|
|
7
|
+
const response = await this.client.put(this.path('/configuration'), input);
|
|
8
|
+
return response.data;
|
|
9
|
+
}
|
|
10
|
+
async configuration() {
|
|
11
|
+
const response = await this.client.get(this.path('/configuration'));
|
|
12
|
+
return response.data;
|
|
13
|
+
}
|
|
14
|
+
async submit(input) {
|
|
15
|
+
const response = await this.client.post(this.path(), input);
|
|
16
|
+
return response.data;
|
|
17
|
+
}
|
|
18
|
+
async list(options = {}) {
|
|
19
|
+
const query = new URLSearchParams();
|
|
20
|
+
for (const [name, value] of Object.entries(options)) {
|
|
21
|
+
if (value !== undefined)
|
|
22
|
+
query.set(name, String(value));
|
|
23
|
+
}
|
|
24
|
+
const response = await this.client.get(`${this.path()}${query.size === 0 ? '' : `?${query.toString()}`}`);
|
|
25
|
+
return response.data;
|
|
26
|
+
}
|
|
27
|
+
async get(id) {
|
|
28
|
+
const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
|
|
29
|
+
return response.data;
|
|
30
|
+
}
|
|
31
|
+
async update(id, input) {
|
|
32
|
+
const response = await this.client.patch(this.path(`/${encodeURIComponent(id)}`), input);
|
|
33
|
+
return response.data;
|
|
34
|
+
}
|
|
35
|
+
path(suffix = '') {
|
|
36
|
+
return `/notebook/${this.notebookId}/feedback${suffix}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/dist/filesystem.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Action, Disposable, NotebookInstance } from './index.js';
|
|
2
2
|
import { ErrorEvent } from './types.js';
|
|
3
|
-
export interface FileInfo {
|
|
4
|
-
binary: boolean;
|
|
5
|
-
contents: string | null;
|
|
6
|
-
language: string;
|
|
7
|
-
}
|
|
8
3
|
export interface FileResult {
|
|
9
4
|
name: string;
|
|
10
5
|
directory: string;
|
|
@@ -361,24 +356,6 @@ export interface ReadFileRangeResult {
|
|
|
361
356
|
error: string | null;
|
|
362
357
|
}
|
|
363
358
|
export interface FilesystemActions {
|
|
364
|
-
'fs.info': Action<{
|
|
365
|
-
path: string;
|
|
366
|
-
}, FileInfo>;
|
|
367
|
-
'fs.write': Action<{
|
|
368
|
-
path: string;
|
|
369
|
-
contents: string;
|
|
370
|
-
}, boolean>;
|
|
371
|
-
'fs.mkdir': Action<{
|
|
372
|
-
path: string;
|
|
373
|
-
}, boolean>;
|
|
374
|
-
'fs.remove': Action<{
|
|
375
|
-
path: string;
|
|
376
|
-
type: 'file' | 'directory';
|
|
377
|
-
}, boolean>;
|
|
378
|
-
'fs.move': Action<{
|
|
379
|
-
from: string;
|
|
380
|
-
to: string;
|
|
381
|
-
}, boolean>;
|
|
382
359
|
'fs.find': Action<{
|
|
383
360
|
query: string;
|
|
384
361
|
options: FileSearchOptions;
|
|
@@ -472,7 +449,9 @@ export interface FilesystemActions {
|
|
|
472
449
|
'fs.tail': Action<{
|
|
473
450
|
path: string;
|
|
474
451
|
lines: number;
|
|
475
|
-
},
|
|
452
|
+
}, {
|
|
453
|
+
content: string;
|
|
454
|
+
}>;
|
|
476
455
|
}
|
|
477
456
|
interface FilesystemEventData {
|
|
478
457
|
'fs.watch': FileChange;
|
package/dist/filesystem.js
CHANGED
|
@@ -356,7 +356,9 @@ export class Filesystem {
|
|
|
356
356
|
.finally(() => disposable.dispose());
|
|
357
357
|
}
|
|
358
358
|
tail(path, options = {}) {
|
|
359
|
-
return this.okra.invoke('fs.tail', { path, lines: options.lines ?? 10 })
|
|
359
|
+
return this.okra.invoke('fs.tail', { path, lines: options.lines ?? 10 })
|
|
360
|
+
.then(({ content }) => content)
|
|
361
|
+
.catch((e) => this.handleError(e));
|
|
360
362
|
}
|
|
361
363
|
stat(path) {
|
|
362
364
|
return this.okra.invoke('fs.stat', { path }).catch((e) => this.handleError(e));
|
package/dist/git.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client
|
|
1
|
+
import type { Client } from './index.js';
|
|
2
2
|
import { Action, NotebookInstance } from './index.js';
|
|
3
3
|
export interface GitLog {
|
|
4
4
|
hash: string;
|
|
@@ -50,35 +50,37 @@ export interface GitCredentials {
|
|
|
50
50
|
expiresAt: string;
|
|
51
51
|
}
|
|
52
52
|
export type GitProvider = 'github' | (string & {});
|
|
53
|
-
export type GitRepositoryVisibility = 'private' | 'public';
|
|
54
53
|
export type GitSyncDirection = 'pull' | 'push' | 'both';
|
|
55
54
|
export interface GitSyncAuthor {
|
|
56
55
|
name: string;
|
|
57
56
|
email: string;
|
|
58
57
|
}
|
|
59
|
-
export interface
|
|
58
|
+
export interface GitTargetConfiguration {
|
|
60
59
|
provider: GitProvider;
|
|
61
60
|
repository: string;
|
|
62
61
|
author: GitSyncAuthor;
|
|
63
62
|
branch?: string;
|
|
64
|
-
credential: SecretRef;
|
|
65
|
-
direction?: GitSyncDirection;
|
|
66
|
-
visibility?: GitRepositoryVisibility;
|
|
67
63
|
setDefault?: boolean;
|
|
68
64
|
}
|
|
69
|
-
export
|
|
65
|
+
export type CreateGitTargetInput = GitTargetConfiguration;
|
|
66
|
+
export interface GitSyncExistingTargetInput {
|
|
67
|
+
direction?: GitSyncDirection;
|
|
68
|
+
author?: GitSyncAuthor;
|
|
69
|
+
force?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface GitTargetData {
|
|
70
72
|
id: string;
|
|
71
73
|
provider: GitProvider;
|
|
72
74
|
repository: string;
|
|
73
75
|
url: string | null;
|
|
74
76
|
branch: string;
|
|
75
|
-
credentialConfigured: boolean;
|
|
76
77
|
default: boolean;
|
|
77
78
|
lastCommitSha: string | null;
|
|
78
79
|
lastSyncedAt: string | null;
|
|
79
80
|
createdAt: string | null;
|
|
80
81
|
updatedAt: string | null;
|
|
81
82
|
}
|
|
83
|
+
export type GitTargetReference = string | GitTarget;
|
|
82
84
|
export interface GitCheckoutResult extends GitRef {
|
|
83
85
|
branch: string;
|
|
84
86
|
created: boolean;
|
|
@@ -213,11 +215,10 @@ export interface GitActions {
|
|
|
213
215
|
export default class Git {
|
|
214
216
|
protected okra: NotebookInstance;
|
|
215
217
|
private readonly client;
|
|
218
|
+
readonly targets: GitTargetApi;
|
|
216
219
|
constructor(okra: NotebookInstance, client: Client);
|
|
217
220
|
checkpoint(author: string, message: string, branch?: string, allowEmpty?: boolean): Promise<GitRef>;
|
|
218
221
|
checkout(branch: string, create?: boolean): Promise<GitCheckoutResult>;
|
|
219
|
-
sync(input: GitSyncTargetInput): Promise<GitSyncTargetData>;
|
|
220
|
-
syncTargets(): Promise<GitSyncTargetData[]>;
|
|
221
222
|
log(ref?: string): Promise<GitLog[]>;
|
|
222
223
|
diff(input: GitDiffInput): Promise<GitDiffPreview>;
|
|
223
224
|
merge(input: GitMergeInput): Promise<GitMergeResult>;
|
|
@@ -233,6 +234,22 @@ export default class Git {
|
|
|
233
234
|
status(): Promise<GitStatus>;
|
|
234
235
|
private normalizeRemoteInput;
|
|
235
236
|
private gitUrlForNotebook;
|
|
236
|
-
|
|
237
|
+
}
|
|
238
|
+
export declare class GitTargetApi {
|
|
239
|
+
private readonly notebookId;
|
|
240
|
+
private readonly client;
|
|
241
|
+
constructor(notebookId: string, client: Client);
|
|
242
|
+
create(input: CreateGitTargetInput): Promise<GitTarget>;
|
|
243
|
+
list(): Promise<GitTarget[]>;
|
|
244
|
+
get(target: GitTargetReference): Promise<GitTarget>;
|
|
245
|
+
sync(target: GitTargetReference, input?: GitSyncExistingTargetInput): Promise<GitTarget>;
|
|
246
|
+
}
|
|
247
|
+
export declare class GitTarget {
|
|
248
|
+
readonly data: GitTargetData;
|
|
249
|
+
private readonly notebookId;
|
|
250
|
+
private readonly client;
|
|
251
|
+
constructor(data: GitTargetData, notebookId: string, client: Client);
|
|
252
|
+
get id(): string;
|
|
253
|
+
sync(input?: GitSyncExistingTargetInput): Promise<GitTarget>;
|
|
237
254
|
}
|
|
238
255
|
export {};
|
package/dist/git.js
CHANGED
|
@@ -2,6 +2,7 @@ export default class Git {
|
|
|
2
2
|
constructor(okra, client) {
|
|
3
3
|
this.okra = okra;
|
|
4
4
|
this.client = client;
|
|
5
|
+
this.targets = new GitTargetApi(okra.data.id, client);
|
|
5
6
|
}
|
|
6
7
|
checkpoint(author, message, branch = 'main', allowEmpty = false) {
|
|
7
8
|
return this.okra.invoke('git.checkpoint', { author, message, branch, allowEmpty });
|
|
@@ -9,14 +10,6 @@ export default class Git {
|
|
|
9
10
|
checkout(branch, create = true) {
|
|
10
11
|
return this.okra.invoke('git.checkout', { branch, create });
|
|
11
12
|
}
|
|
12
|
-
async sync(input) {
|
|
13
|
-
const response = await this.client.post(`/notebook/${this.okra.data.id}/git/sync-targets`, this.omitUndefined({ ...input }));
|
|
14
|
-
return response.data;
|
|
15
|
-
}
|
|
16
|
-
async syncTargets() {
|
|
17
|
-
const response = await this.client.get(`/notebook/${this.okra.data.id}/git/sync-targets`);
|
|
18
|
-
return response.data;
|
|
19
|
-
}
|
|
20
13
|
log(ref = 'main') {
|
|
21
14
|
return this.okra.invoke('git.log', { ref });
|
|
22
15
|
}
|
|
@@ -85,7 +78,45 @@ export default class Git {
|
|
|
85
78
|
url.hash = '';
|
|
86
79
|
return url.toString();
|
|
87
80
|
}
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
}
|
|
82
|
+
export class GitTargetApi {
|
|
83
|
+
constructor(notebookId, client) {
|
|
84
|
+
this.notebookId = notebookId;
|
|
85
|
+
this.client = client;
|
|
86
|
+
}
|
|
87
|
+
async create(input) {
|
|
88
|
+
const response = await this.client.post(`/notebook/${this.notebookId}/git/targets`, omitUndefined({ ...input }));
|
|
89
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
90
|
+
}
|
|
91
|
+
async list() {
|
|
92
|
+
const response = await this.client.get(`/notebook/${this.notebookId}/git/targets`);
|
|
93
|
+
return response.data.map((target) => new GitTarget(target, this.notebookId, this.client));
|
|
94
|
+
}
|
|
95
|
+
async get(target) {
|
|
96
|
+
const response = await this.client.get(`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}`);
|
|
97
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
98
|
+
}
|
|
99
|
+
async sync(target, input = {}) {
|
|
100
|
+
const response = await this.client.post(`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}/sync`, omitUndefined({ ...input }));
|
|
101
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
90
102
|
}
|
|
91
103
|
}
|
|
104
|
+
export class GitTarget {
|
|
105
|
+
constructor(data, notebookId, client) {
|
|
106
|
+
this.data = data;
|
|
107
|
+
this.notebookId = notebookId;
|
|
108
|
+
this.client = client;
|
|
109
|
+
}
|
|
110
|
+
get id() {
|
|
111
|
+
return this.data.id;
|
|
112
|
+
}
|
|
113
|
+
sync(input = {}) {
|
|
114
|
+
return new GitTargetApi(this.notebookId, this.client).sync(this, input);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function gitTargetId(target) {
|
|
118
|
+
return typeof target === 'string' ? target : target.id;
|
|
119
|
+
}
|
|
120
|
+
function omitUndefined(input) {
|
|
121
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined));
|
|
122
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ import { Disposable } from './types.js';
|
|
|
17
17
|
import { NotebookUnavailableError } from './errors/index.js';
|
|
18
18
|
import { PublicationApi, NotebookPublicationApi, type PublicationInstance, type PublicationRun, type PublishInput } from './publications.js';
|
|
19
19
|
import { ServerApi } from './servers.js';
|
|
20
|
+
import { Feedback } from './feedback.js';
|
|
21
|
+
import { IntegrationApi } from './integrations.js';
|
|
22
|
+
import { SandboxIntegrationApi } from './sandbox-integrations.js';
|
|
20
23
|
export * from './types.js';
|
|
21
24
|
export * from './lsp.js';
|
|
22
25
|
export * from './filesystem.js';
|
|
@@ -34,6 +37,9 @@ export * from './utils/promise.js';
|
|
|
34
37
|
export * from './errors/index.js';
|
|
35
38
|
export * from './publications.js';
|
|
36
39
|
export * from './servers.js';
|
|
40
|
+
export * from './feedback.js';
|
|
41
|
+
export * from './integrations.js';
|
|
42
|
+
export * from './sandbox-integrations.js';
|
|
37
43
|
interface Result<TType extends 'success' | 'error' | 'running', TData extends object> {
|
|
38
44
|
type: TType;
|
|
39
45
|
message: string;
|
|
@@ -314,6 +320,7 @@ export declare class Client {
|
|
|
314
320
|
readonly notebook: NotebookApi;
|
|
315
321
|
readonly publications: PublicationApi;
|
|
316
322
|
readonly servers: ServerApi;
|
|
323
|
+
readonly integrations: IntegrationApi;
|
|
317
324
|
readonly options: PHPSandboxClientOptions;
|
|
318
325
|
protected runtimeTransportValue: RuntimeTransport;
|
|
319
326
|
get runtimeTransport(): RuntimeTransport;
|
|
@@ -333,6 +340,9 @@ export declare class Client {
|
|
|
333
340
|
put<T extends unknown>(path: string, body?: unknown): Promise<{
|
|
334
341
|
data: T;
|
|
335
342
|
}>;
|
|
343
|
+
patch<T extends unknown>(path: string, body?: unknown): Promise<{
|
|
344
|
+
data: T;
|
|
345
|
+
}>;
|
|
336
346
|
stream(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
337
347
|
sse(url: string): Promise<ReadableStream<Uint8Array>>;
|
|
338
348
|
private makeRequest;
|
|
@@ -404,8 +414,10 @@ export declare class NotebookInstance {
|
|
|
404
414
|
readonly services: Services;
|
|
405
415
|
readonly config: Config;
|
|
406
416
|
readonly secrets: NotebookSecrets;
|
|
417
|
+
readonly integrations: SandboxIntegrationApi;
|
|
407
418
|
readonly preview: NotebookPreview;
|
|
408
419
|
readonly mail: NotebookMail;
|
|
420
|
+
readonly feedback: Feedback;
|
|
409
421
|
private readonly socket;
|
|
410
422
|
private readonly restInvoker;
|
|
411
423
|
readonly emitter: EventDispatcher;
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,9 @@ import { NotebookUnavailableError, UnsupportedRuntimeTransportError } from './er
|
|
|
31
31
|
import { PublicationApi, NotebookPublicationApi } from './publications.js';
|
|
32
32
|
import { ServerApi } from './servers.js';
|
|
33
33
|
import { RestRuntimeInvoker } from './runtime/rest.js';
|
|
34
|
+
import { Feedback } from './feedback.js';
|
|
35
|
+
import { IntegrationApi } from './integrations.js';
|
|
36
|
+
import { SandboxIntegrationApi } from './sandbox-integrations.js';
|
|
34
37
|
export * from './types.js';
|
|
35
38
|
export * from './lsp.js';
|
|
36
39
|
export * from './filesystem.js';
|
|
@@ -48,6 +51,9 @@ export * from './utils/promise.js';
|
|
|
48
51
|
export * from './errors/index.js';
|
|
49
52
|
export * from './publications.js';
|
|
50
53
|
export * from './servers.js';
|
|
54
|
+
export * from './feedback.js';
|
|
55
|
+
export * from './integrations.js';
|
|
56
|
+
export * from './sandbox-integrations.js';
|
|
51
57
|
function normalizeNotebookSecretInputs(input) {
|
|
52
58
|
if (Array.isArray(input)) {
|
|
53
59
|
return input;
|
|
@@ -159,6 +165,7 @@ export class Client {
|
|
|
159
165
|
this.publications = new PublicationApi(this);
|
|
160
166
|
this.notebook = new NotebookApi(this);
|
|
161
167
|
this.servers = new ServerApi(this);
|
|
168
|
+
this.integrations = new IntegrationApi(this);
|
|
162
169
|
this.options = Object.assign({ startClosed: true }, options);
|
|
163
170
|
this.baseUrl = normalizeApiBaseUrl(url);
|
|
164
171
|
if (options.fetch) {
|
|
@@ -182,6 +189,9 @@ export class Client {
|
|
|
182
189
|
put(path, body) {
|
|
183
190
|
return this.makeRequest('PUT', path, { body: body === undefined ? undefined : JSON.stringify(body) });
|
|
184
191
|
}
|
|
192
|
+
patch(path, body) {
|
|
193
|
+
return this.makeRequest('PATCH', path, { body: body === undefined ? undefined : JSON.stringify(body) });
|
|
194
|
+
}
|
|
185
195
|
async stream(path) {
|
|
186
196
|
const response = await this.fetch(new Request(new URL(path.replace(/^\//, ''), this.baseUrl), {
|
|
187
197
|
method: 'GET',
|
|
@@ -390,8 +400,10 @@ export class NotebookInstance {
|
|
|
390
400
|
this.services = new Services(this);
|
|
391
401
|
this.config = new Config(this);
|
|
392
402
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
403
|
+
this.integrations = new SandboxIntegrationApi(this.data.id, client);
|
|
393
404
|
this.preview = new NotebookPreview(client, this.data.id);
|
|
394
405
|
this.mail = new NotebookMail(client, this.data.id);
|
|
406
|
+
this.feedback = new Feedback(client, this.data.id);
|
|
395
407
|
}
|
|
396
408
|
async ready() {
|
|
397
409
|
if (this.restInvoker !== null) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Client } from './index.js';
|
|
2
|
+
export type IntegrationProvider = 'cloudflare' | 'github' | 'laravel-cloud';
|
|
3
|
+
export type IntegrationAuthorizationType = 'token';
|
|
4
|
+
export interface IntegrationAuthorization {
|
|
5
|
+
type: IntegrationAuthorizationType;
|
|
6
|
+
token: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LinkIntegrationInput {
|
|
9
|
+
provider: IntegrationProvider;
|
|
10
|
+
label?: string | null;
|
|
11
|
+
authorization: IntegrationAuthorization;
|
|
12
|
+
}
|
|
13
|
+
export interface UpdateIntegrationInput {
|
|
14
|
+
label?: string | null;
|
|
15
|
+
authorization?: IntegrationAuthorization;
|
|
16
|
+
}
|
|
17
|
+
export interface IntegrationData {
|
|
18
|
+
id: string;
|
|
19
|
+
provider: IntegrationProvider;
|
|
20
|
+
label: string | null;
|
|
21
|
+
createdAt: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type IntegrationReference = string | Integration;
|
|
24
|
+
export declare class IntegrationApi {
|
|
25
|
+
private readonly client;
|
|
26
|
+
constructor(client: Client);
|
|
27
|
+
link(input: LinkIntegrationInput): Promise<Integration>;
|
|
28
|
+
list(): Promise<Integration[]>;
|
|
29
|
+
get(integration: IntegrationReference): Promise<Integration>;
|
|
30
|
+
update(integration: IntegrationReference, input: UpdateIntegrationInput): Promise<Integration>;
|
|
31
|
+
unlink(integration: IntegrationReference): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare class Integration {
|
|
34
|
+
readonly data: IntegrationData;
|
|
35
|
+
private readonly client;
|
|
36
|
+
constructor(data: IntegrationData, client: Client);
|
|
37
|
+
get id(): string;
|
|
38
|
+
get provider(): IntegrationProvider;
|
|
39
|
+
get label(): string | null;
|
|
40
|
+
update(input: UpdateIntegrationInput): Promise<Integration>;
|
|
41
|
+
unlink(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export declare function integrationId(integration: IntegrationReference): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export class IntegrationApi {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
async link(input) {
|
|
6
|
+
const response = await this.client.post('/integrations', input);
|
|
7
|
+
return new Integration(response.data, this.client);
|
|
8
|
+
}
|
|
9
|
+
async list() {
|
|
10
|
+
const response = await this.client.get('/integrations');
|
|
11
|
+
return response.data.map((integration) => new Integration(integration, this.client));
|
|
12
|
+
}
|
|
13
|
+
async get(integration) {
|
|
14
|
+
const response = await this.client.get(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
15
|
+
return new Integration(response.data, this.client);
|
|
16
|
+
}
|
|
17
|
+
async update(integration, input) {
|
|
18
|
+
const response = await this.client.patch(`/integrations/${encodeURIComponent(integrationId(integration))}`, input);
|
|
19
|
+
return new Integration(response.data, this.client);
|
|
20
|
+
}
|
|
21
|
+
async unlink(integration) {
|
|
22
|
+
await this.client.delete(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class Integration {
|
|
26
|
+
constructor(data, client) {
|
|
27
|
+
this.data = data;
|
|
28
|
+
this.client = client;
|
|
29
|
+
}
|
|
30
|
+
get id() {
|
|
31
|
+
return this.data.id;
|
|
32
|
+
}
|
|
33
|
+
get provider() {
|
|
34
|
+
return this.data.provider;
|
|
35
|
+
}
|
|
36
|
+
get label() {
|
|
37
|
+
return this.data.label;
|
|
38
|
+
}
|
|
39
|
+
update(input) {
|
|
40
|
+
return new IntegrationApi(this.client).update(this, input);
|
|
41
|
+
}
|
|
42
|
+
unlink() {
|
|
43
|
+
return new IntegrationApi(this.client).unlink(this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function integrationId(integration) {
|
|
47
|
+
return typeof integration === 'string' ? integration : integration.id;
|
|
48
|
+
}
|
package/dist/publications.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Client
|
|
1
|
+
import { type Client } from './index.js';
|
|
2
2
|
import type { PublicationBuildStatus, PublicationDomainDnsRecordType, PublicationEventData, PublicationJurisdiction, PublicationLogChunkData, PublicationProtectionMode, PublicationRegion, PublicationReleaseStatus, PublicationSize, PublicationStatus, PublishStreamEvent, PublishStreamResult } from './schemas/publications.js';
|
|
3
3
|
export * from './schemas/publications.js';
|
|
4
4
|
export interface PublicationPlacement {
|
|
@@ -13,10 +13,6 @@ export interface PublicationProtectionData {
|
|
|
13
13
|
expiresAt?: string;
|
|
14
14
|
url?: string;
|
|
15
15
|
}
|
|
16
|
-
export interface PublicationFeedbackData {
|
|
17
|
-
enabled: boolean;
|
|
18
|
-
config: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
16
|
export type PublicationProtectionInput = {
|
|
21
17
|
mode: 'none';
|
|
22
18
|
password?: never;
|
|
@@ -24,11 +20,8 @@ export type PublicationProtectionInput = {
|
|
|
24
20
|
mode: 'password';
|
|
25
21
|
password: string;
|
|
26
22
|
};
|
|
27
|
-
export interface PublicationFeedbackInput {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
config?: Record<string, unknown>;
|
|
30
|
-
}
|
|
31
23
|
export interface CloudflareContainersProviderOptions {
|
|
24
|
+
accountId: string;
|
|
32
25
|
size?: PublicationSize;
|
|
33
26
|
sleepAfter?: string;
|
|
34
27
|
placement?: PublicationPlacement;
|
|
@@ -42,11 +35,9 @@ export interface LaravelCloudProviderData {
|
|
|
42
35
|
repository?: string;
|
|
43
36
|
branch?: string;
|
|
44
37
|
sourceControlProviderType?: 'github' | 'gitlab' | 'bitbucket';
|
|
45
|
-
apiKeyConfigured?: boolean;
|
|
46
38
|
}
|
|
47
39
|
export interface LaravelCloudProviderInput {
|
|
48
|
-
|
|
49
|
-
region?: LaravelCloudRegion;
|
|
40
|
+
region: LaravelCloudRegion;
|
|
50
41
|
}
|
|
51
42
|
export interface PublicationProviderInputs {
|
|
52
43
|
'cloudflare-containers': CloudflareContainersProviderOptions;
|
|
@@ -73,9 +64,9 @@ export interface PublishInput<TName extends PublicationProviderName = Publicatio
|
|
|
73
64
|
slug: string;
|
|
74
65
|
provider: PublicationProviderInput<TName>;
|
|
75
66
|
protection?: PublicationProtectionInput;
|
|
76
|
-
feedback?: PublicationFeedbackInput;
|
|
77
67
|
metadata?: Record<string, unknown>;
|
|
78
68
|
}
|
|
69
|
+
export type PublicationRunResult = PublishStreamResult;
|
|
79
70
|
export interface PublicationBuildData<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
80
71
|
id: string;
|
|
81
72
|
status: PublicationBuildStatus;
|
|
@@ -124,7 +115,6 @@ export interface PublicationData<TProvider extends PublicationProviderName = Pub
|
|
|
124
115
|
strategy: string;
|
|
125
116
|
provider: PublicationProvider<TProvider>;
|
|
126
117
|
protection: PublicationProtectionData;
|
|
127
|
-
feedback: PublicationFeedbackData;
|
|
128
118
|
eventStreamUrl: string | null;
|
|
129
119
|
originUrl: string | null;
|
|
130
120
|
currentRelease?: PublicationReleaseData | null;
|
|
@@ -144,10 +134,6 @@ export interface PublicationProtectionSessionData {
|
|
|
144
134
|
expiresAt: string;
|
|
145
135
|
url: string;
|
|
146
136
|
}
|
|
147
|
-
export interface UpdatePublicationFeedbackInput {
|
|
148
|
-
enabled: boolean;
|
|
149
|
-
config?: Record<string, unknown>;
|
|
150
|
-
}
|
|
151
137
|
export declare class NotebookPublicationApi {
|
|
152
138
|
private readonly client;
|
|
153
139
|
constructor(client: Client);
|
|
@@ -163,7 +149,6 @@ export declare class PublicationApi {
|
|
|
163
149
|
protection(id: string): Promise<PublicationProtectionData>;
|
|
164
150
|
createProtectionSession(id: string): Promise<PublicationProtectionSessionData>;
|
|
165
151
|
disableProtection<TProvider extends PublicationProviderName = PublicationProviderName>(id: string): Promise<PublicationInstance<TProvider>>;
|
|
166
|
-
setFeedback<TProvider extends PublicationProviderName = PublicationProviderName>(id: string, input: UpdatePublicationFeedbackInput): Promise<PublicationInstance<TProvider>>;
|
|
167
152
|
listDomains(id: string): Promise<PublicationDomainData[]>;
|
|
168
153
|
createDomain(id: string, input: CreatePublicationDomainInput): Promise<PublicationDomainData>;
|
|
169
154
|
refreshDomain(id: string, domainId: string): Promise<PublicationDomainData>;
|
|
@@ -186,7 +171,7 @@ export declare class PublicationRun<TProvider extends PublicationProviderName =
|
|
|
186
171
|
private readonly subscribers;
|
|
187
172
|
constructor(initial: PublicationInstance<TProvider>, client: Client);
|
|
188
173
|
events(): AsyncIterable<PublishStreamEvent>;
|
|
189
|
-
result(): Promise<
|
|
174
|
+
result(): Promise<PublicationRunResult>;
|
|
190
175
|
publication(): Promise<PublicationInstance<TProvider>>;
|
|
191
176
|
start(): this;
|
|
192
177
|
private subscribe;
|
|
@@ -214,7 +199,6 @@ export declare class PublicationInstance<TProvider extends PublicationProviderNa
|
|
|
214
199
|
protection(): Promise<PublicationProtectionData>;
|
|
215
200
|
createProtectionSession(): Promise<PublicationProtectionSessionData>;
|
|
216
201
|
disableProtection(): Promise<PublicationInstance<TProvider>>;
|
|
217
|
-
setFeedback(input: UpdatePublicationFeedbackInput): Promise<PublicationInstance<TProvider>>;
|
|
218
202
|
domains(): Promise<PublicationDomainData[]>;
|
|
219
203
|
addDomain(input: CreatePublicationDomainInput): Promise<PublicationDomainData>;
|
|
220
204
|
refreshDomain(domainId: string): Promise<PublicationDomainData>;
|
package/dist/publications.js
CHANGED
|
@@ -51,10 +51,6 @@ export class PublicationApi {
|
|
|
51
51
|
const response = await this.client.delete(`/publications/${id}/protection`);
|
|
52
52
|
return new PublicationInstance(response.data, this.client);
|
|
53
53
|
}
|
|
54
|
-
async setFeedback(id, input) {
|
|
55
|
-
const response = await this.client.put(`/publications/${id}/feedback`, input);
|
|
56
|
-
return new PublicationInstance(response.data, this.client);
|
|
57
|
-
}
|
|
58
54
|
async listDomains(id) {
|
|
59
55
|
const response = await this.client.get(`/publications/${id}/domains`);
|
|
60
56
|
return unwrapPublicationDomainCollection(response.data);
|
|
@@ -156,7 +152,7 @@ export class PublicationRun {
|
|
|
156
152
|
if (event.type === 'result') {
|
|
157
153
|
const { type: _, ...result } = event;
|
|
158
154
|
this.finalResult = result;
|
|
159
|
-
this.resolveResult?.(
|
|
155
|
+
this.resolveResult?.(this.finalResult);
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
158
|
if (!this.finalResult) {
|
|
@@ -248,9 +244,6 @@ export class PublicationInstance {
|
|
|
248
244
|
disableProtection() {
|
|
249
245
|
return this.client.publications.disableProtection(this.data.id);
|
|
250
246
|
}
|
|
251
|
-
setFeedback(input) {
|
|
252
|
-
return this.client.publications.setFeedback(this.data.id, input);
|
|
253
|
-
}
|
|
254
247
|
domains() {
|
|
255
248
|
return this.client.publications.listDomains(this.data.id);
|
|
256
249
|
}
|
package/dist/runtime/rest.js
CHANGED
|
@@ -15,18 +15,13 @@ const restActionRoutes = {
|
|
|
15
15
|
'container.stats': { method: 'GET', path: '/runtime/container/stats' },
|
|
16
16
|
'terminal.list': { method: 'GET', path: '/runtime/terminals' },
|
|
17
17
|
'shell.exec': { method: 'POST', path: '/runtime/executions' },
|
|
18
|
-
'fs.info': { method: 'POST', path: '/runtime/files/info' },
|
|
19
18
|
'fs.readFile': { method: 'GET', path: '/runtime/files/content' },
|
|
20
19
|
'fs.writeFile': { method: 'PUT', path: '/runtime/files/content' },
|
|
21
|
-
'fs.write': { method: 'PUT', path: '/runtime/files/text' },
|
|
22
|
-
'fs.mkdir': { method: 'POST', path: '/runtime/directories' },
|
|
23
20
|
'fs.createDirectory': { method: 'PUT', path: '/runtime/directories' },
|
|
24
21
|
'fs.readDirectory': { method: 'POST', path: '/runtime/directories/read' },
|
|
25
22
|
'fs.stat': { method: 'POST', path: '/runtime/files/stat' },
|
|
26
|
-
'fs.move': { method: 'POST', path: '/runtime/files/move' },
|
|
27
23
|
'fs.rename': { method: 'POST', path: '/runtime/files/rename' },
|
|
28
24
|
'fs.copy': { method: 'POST', path: '/runtime/files/copy' },
|
|
29
|
-
'fs.remove': { method: 'POST', path: '/runtime/files/remove' },
|
|
30
25
|
'fs.delete': { method: 'DELETE', path: '/runtime/files' },
|
|
31
26
|
'fs.tail': { method: 'POST', path: '/runtime/files/tail' },
|
|
32
27
|
'fs.find': { method: 'POST', path: '/runtime/files/find' },
|