@phpsandbox/sdk 0.1.9 → 0.1.11
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 +42 -50
- package/dist/beacon/index.d.ts +1 -7
- package/dist/beacon/index.js +14 -13
- package/dist/beacon/navigator.d.ts +8 -36
- package/dist/beacon/navigator.js +1 -62
- package/dist/browser/phpsandbox-sdk.esm.js +552 -692
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +552 -692
- package/dist/browser/phpsandbox-sdk.iife.min.js +35 -35
- package/dist/composer.d.ts +10 -8
- package/dist/composer.js +18 -18
- package/dist/errors/index.d.ts +43 -8
- package/dist/errors/index.js +120 -14
- package/dist/feedback.js +1 -2
- package/dist/filesystem.d.ts +0 -17
- package/dist/filesystem.js +2 -21
- package/dist/git.d.ts +1 -5
- package/dist/git.js +6 -8
- package/dist/http.d.ts +6 -0
- package/dist/http.js +11 -0
- package/dist/index.d.ts +54 -144
- package/dist/index.js +170 -289
- package/dist/integrations.d.ts +0 -2
- package/dist/integrations.js +5 -11
- package/dist/log.d.ts +0 -2
- package/dist/lsp.js +1 -1
- package/dist/metrics.d.ts +3 -3
- package/dist/ports.d.ts +1 -1
- package/dist/publications.d.ts +4 -54
- package/dist/publications.js +25 -103
- package/dist/runtime/rest.js +35 -18
- package/dist/runtime.d.ts +68 -0
- package/dist/runtime.js +46 -0
- package/dist/sandbox-integrations.d.ts +1 -2
- package/dist/sandbox-integrations.js +11 -14
- package/dist/schemas/publications.d.ts +0 -6
- package/dist/schemas/publications.js +0 -1
- package/dist/servers.d.ts +4 -2
- package/dist/servers.js +5 -8
- package/dist/shell.d.ts +2 -14
- package/dist/shell.js +1 -21
- package/dist/socket/index.d.ts +6 -7
- package/dist/socket/index.js +39 -25
- package/dist/types.d.ts +0 -12
- package/dist/types.js +1 -15
- package/docs/api-summary.md +28 -28
- package/docs/cdn-usage.md +43 -55
- package/docs/getting-started.md +43 -26
- package/examples/README.md +5 -35
- package/examples/basic.ts +9 -18
- package/examples/get.ts +2 -2
- package/examples/git-merge-smoke.ts +2 -3
- package/examples/laravel-load-test.ts +31 -36
- package/examples/notebook-readonly-smoke.ts +12 -26
- package/examples/publication-provider-label.ts +1 -1
- package/examples/publish-cloudflare-container.ts +2 -2
- package/examples/publish-laravel-cloud.ts +2 -2
- package/examples/publish-ssh-agent.ts +2 -2
- package/package.json +4 -3
- package/dist/container.d.ts +0 -65
- package/dist/container.js +0 -30
|
@@ -13,46 +13,133 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
13
13
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
14
14
|
|
|
15
15
|
// src/errors/index.ts
|
|
16
|
-
var
|
|
17
|
-
|
|
16
|
+
var remoteErrorCodes = [
|
|
17
|
+
"ActionNotFound",
|
|
18
|
+
"AuthenticationRequired",
|
|
19
|
+
"BadGateway",
|
|
20
|
+
"BadRequest",
|
|
21
|
+
"Conflict",
|
|
22
|
+
"FileAlreadyExists",
|
|
23
|
+
"FileIsDirectory",
|
|
24
|
+
"FileNotDirectory",
|
|
25
|
+
"FileNotFound",
|
|
26
|
+
"FilesystemUnavailable",
|
|
27
|
+
"InternalError",
|
|
28
|
+
"InvalidArgument",
|
|
29
|
+
"InvalidConfiguration",
|
|
30
|
+
"InvalidRequest",
|
|
31
|
+
"InvalidResponse",
|
|
32
|
+
"InvalidServiceCommand",
|
|
33
|
+
"MethodNotAllowed",
|
|
34
|
+
"NotebookInitializationFailed",
|
|
35
|
+
"NotebookUnavailable",
|
|
36
|
+
"NotFound",
|
|
37
|
+
"PayloadTooLarge",
|
|
38
|
+
"PermissionDenied",
|
|
39
|
+
"RateLimited",
|
|
40
|
+
"RequestFailed",
|
|
41
|
+
"RuntimeOperationFailed",
|
|
42
|
+
"ServiceNotFound",
|
|
43
|
+
"ServiceUnavailable",
|
|
44
|
+
"UnprocessableEntity",
|
|
45
|
+
"ValidationFailed",
|
|
46
|
+
"WorkspaceUnavailable"
|
|
47
|
+
];
|
|
48
|
+
var PHPSandboxError = class extends Error {
|
|
49
|
+
constructor(message, cause) {
|
|
18
50
|
super(message);
|
|
19
|
-
this.
|
|
51
|
+
this.name = new.target.name;
|
|
52
|
+
this.cause = cause;
|
|
20
53
|
}
|
|
21
54
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
var RemoteError = class _RemoteError extends PHPSandboxError {
|
|
56
|
+
constructor(message, options) {
|
|
57
|
+
super(message, options.cause);
|
|
58
|
+
this.source = options.source;
|
|
59
|
+
this.status = options.status;
|
|
60
|
+
this.code = options.code;
|
|
61
|
+
this.details = options.details;
|
|
25
62
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
constructor(message = "Notebook is no longer available", raw = {}) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.raw = raw;
|
|
31
|
-
this.name = "NotebookUnavailableError";
|
|
63
|
+
static is(error51, code) {
|
|
64
|
+
return error51 instanceof _RemoteError && (code === void 0 || error51.code === code);
|
|
32
65
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
66
|
+
static isValidation(error51) {
|
|
67
|
+
return _RemoteError.is(error51, "ValidationFailed") && validationDetails(error51.details) !== void 0;
|
|
68
|
+
}
|
|
69
|
+
is(code) {
|
|
70
|
+
return this.code === code;
|
|
38
71
|
}
|
|
39
72
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
constructor(code, message, raw = {}) {
|
|
44
|
-
super(message);
|
|
73
|
+
var TransportError = class _TransportError extends PHPSandboxError {
|
|
74
|
+
constructor(message, code, cause) {
|
|
75
|
+
super(message, cause);
|
|
45
76
|
this.code = code;
|
|
46
|
-
|
|
47
|
-
|
|
77
|
+
}
|
|
78
|
+
static is(error51, code) {
|
|
79
|
+
return error51 instanceof _TransportError && (code === void 0 || error51.code === code);
|
|
80
|
+
}
|
|
81
|
+
is(code) {
|
|
82
|
+
return this.code === code;
|
|
48
83
|
}
|
|
49
84
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
85
|
+
function remoteError(source, payload, cause) {
|
|
86
|
+
const error51 = record(payload);
|
|
87
|
+
const status = positiveInteger(error51?.status);
|
|
88
|
+
const code = nonEmptyString(error51?.code);
|
|
89
|
+
const message = nonEmptyString(error51?.message);
|
|
90
|
+
if (status === void 0 || !isRemoteErrorCode(code) || message === void 0) {
|
|
91
|
+
throw new TransportError("PHPSandbox returned an invalid error response.", "InvalidResponse", cause ?? payload);
|
|
92
|
+
}
|
|
93
|
+
return new RemoteError(message, {
|
|
94
|
+
source,
|
|
95
|
+
status,
|
|
96
|
+
code,
|
|
97
|
+
details: error51?.details,
|
|
98
|
+
cause
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function isRemoteErrorCode(value) {
|
|
102
|
+
return typeof value === "string" && remoteErrorCodes.includes(value);
|
|
103
|
+
}
|
|
104
|
+
function positiveInteger(value) {
|
|
105
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
106
|
+
}
|
|
107
|
+
function nonEmptyString(value) {
|
|
108
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
109
|
+
}
|
|
110
|
+
function record(value) {
|
|
111
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
112
|
+
}
|
|
113
|
+
function stringArrayRecord(value) {
|
|
114
|
+
const candidate = record(value);
|
|
115
|
+
if (candidate === void 0) {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
const entries = Object.entries(candidate);
|
|
119
|
+
if (!entries.every(([, messages]) => Array.isArray(messages) && messages.every((message) => typeof message === "string"))) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
return Object.fromEntries(entries);
|
|
123
|
+
}
|
|
124
|
+
function validationDetails(value) {
|
|
125
|
+
const details = record(value);
|
|
126
|
+
const errors = stringArrayRecord(details?.errors);
|
|
127
|
+
return errors === void 0 ? void 0 : { errors };
|
|
128
|
+
}
|
|
129
|
+
var PromiseTimeoutError = class extends Error {
|
|
130
|
+
constructor(message, time3) {
|
|
131
|
+
super(message);
|
|
132
|
+
this.time = time3;
|
|
53
133
|
}
|
|
54
134
|
};
|
|
55
|
-
var
|
|
135
|
+
var SendTimeoutError = class _SendTimeoutError extends TransportError {
|
|
136
|
+
constructor(message, time3, cause) {
|
|
137
|
+
super(message, "SendTimeout", cause);
|
|
138
|
+
this.time = time3;
|
|
139
|
+
}
|
|
140
|
+
static fromPromiseTimeoutError(error51) {
|
|
141
|
+
return new _SendTimeoutError(error51.message, error51.time, error51);
|
|
142
|
+
}
|
|
56
143
|
};
|
|
57
144
|
|
|
58
145
|
// node_modules/nanoid/url-alphabet/index.js
|
|
@@ -88,21 +175,6 @@ var FileChangeType = /* @__PURE__ */ ((FileChangeType2) => {
|
|
|
88
175
|
FileChangeType2[FileChangeType2["DELETED"] = 3] = "DELETED";
|
|
89
176
|
return FileChangeType2;
|
|
90
177
|
})(FileChangeType || {});
|
|
91
|
-
var FilesystemErrorType = /* @__PURE__ */ ((FilesystemErrorType2) => {
|
|
92
|
-
FilesystemErrorType2["Unavailable"] = "Unavailable";
|
|
93
|
-
FilesystemErrorType2["NoPermissions"] = "NoPermissions";
|
|
94
|
-
FilesystemErrorType2["FileExists"] = "FileExists";
|
|
95
|
-
FilesystemErrorType2["FileNotFound"] = "FileNotFound";
|
|
96
|
-
FilesystemErrorType2["FileIsADirectory"] = "FileIsADirectory";
|
|
97
|
-
FilesystemErrorType2["FileNotADirectory"] = "FileNotADirectory";
|
|
98
|
-
return FilesystemErrorType2;
|
|
99
|
-
})(FilesystemErrorType || {});
|
|
100
|
-
var FilesystemError = class extends ErrorEvent {
|
|
101
|
-
constructor(inner, name) {
|
|
102
|
-
super(inner.code, inner.message);
|
|
103
|
-
this.name = name;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
178
|
var FilesystemSubscription = class {
|
|
107
179
|
constructor(disposable, onDispose) {
|
|
108
180
|
this.disposable = disposable;
|
|
@@ -256,7 +328,7 @@ var Filesystem = class {
|
|
|
256
328
|
if (this.okra.runtimeTransport === "rest") {
|
|
257
329
|
return new ReadableStream({
|
|
258
330
|
start(controller) {
|
|
259
|
-
controller.error(new
|
|
331
|
+
controller.error(new PHPSandboxError("Following files requires the realtime transport."));
|
|
260
332
|
}
|
|
261
333
|
});
|
|
262
334
|
}
|
|
@@ -476,9 +548,6 @@ var Filesystem = class {
|
|
|
476
548
|
return this.okra.invoke("fs.tree", { path });
|
|
477
549
|
}
|
|
478
550
|
handleError(e) {
|
|
479
|
-
if (e instanceof ErrorEvent && "name" in e.raw) {
|
|
480
|
-
throw new FilesystemError(e, e.raw.name);
|
|
481
|
-
}
|
|
482
551
|
throw e;
|
|
483
552
|
}
|
|
484
553
|
};
|
|
@@ -683,38 +752,6 @@ var Terminals = class {
|
|
|
683
752
|
}
|
|
684
753
|
};
|
|
685
754
|
|
|
686
|
-
// src/container.ts
|
|
687
|
-
var NotebookState = /* @__PURE__ */ ((NotebookState2) => {
|
|
688
|
-
NotebookState2["RUNNING"] = "running";
|
|
689
|
-
NotebookState2["STOPPED"] = "stopped";
|
|
690
|
-
NotebookState2["STARTING"] = "starting";
|
|
691
|
-
NotebookState2["STOPPING"] = "stopping";
|
|
692
|
-
NotebookState2["KILLED"] = "killed";
|
|
693
|
-
NotebookState2["ERROR"] = "error";
|
|
694
|
-
NotebookState2["PROVISIONING"] = "provisioning";
|
|
695
|
-
return NotebookState2;
|
|
696
|
-
})(NotebookState || {});
|
|
697
|
-
var Container = class {
|
|
698
|
-
constructor(okra) {
|
|
699
|
-
this.okra = okra;
|
|
700
|
-
}
|
|
701
|
-
start() {
|
|
702
|
-
return this.okra.invoke("container.start");
|
|
703
|
-
}
|
|
704
|
-
restart() {
|
|
705
|
-
return this.okra.invoke("container.restart");
|
|
706
|
-
}
|
|
707
|
-
stop() {
|
|
708
|
-
return this.okra.invoke("container.stop");
|
|
709
|
-
}
|
|
710
|
-
state() {
|
|
711
|
-
return this.okra.invoke("container.state");
|
|
712
|
-
}
|
|
713
|
-
setPhp(version2) {
|
|
714
|
-
return this.okra.invoke("container.set-php", { version: version2 });
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
|
|
718
755
|
// src/auth.ts
|
|
719
756
|
var Auth = class {
|
|
720
757
|
constructor(okra) {
|
|
@@ -762,7 +799,7 @@ var Lsp = class {
|
|
|
762
799
|
return LspConnection.create(id, this);
|
|
763
800
|
}
|
|
764
801
|
whenSocketConnected() {
|
|
765
|
-
return this.okra.
|
|
802
|
+
return this.okra.connected();
|
|
766
803
|
}
|
|
767
804
|
};
|
|
768
805
|
var LspConnection = class _LspConnection {
|
|
@@ -808,26 +845,6 @@ function resolveRunInput(command, argsOrOpts = [], opts) {
|
|
|
808
845
|
opts: { tty: false, ...resolvedOpts }
|
|
809
846
|
};
|
|
810
847
|
}
|
|
811
|
-
var CommandError = class extends Error {
|
|
812
|
-
constructor(result) {
|
|
813
|
-
super(result.output);
|
|
814
|
-
this.result = result;
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
var ProcessResult = class {
|
|
818
|
-
constructor(output, stdout, stderr, exitCode) {
|
|
819
|
-
this.output = output;
|
|
820
|
-
this.stdout = stdout;
|
|
821
|
-
this.stderr = stderr;
|
|
822
|
-
this.exitCode = exitCode;
|
|
823
|
-
}
|
|
824
|
-
throw() {
|
|
825
|
-
if (this.exitCode !== 0) {
|
|
826
|
-
throw new CommandError(this);
|
|
827
|
-
}
|
|
828
|
-
return this;
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
848
|
var ProcessReadable = class {
|
|
832
849
|
constructor() {
|
|
833
850
|
this.controller = null;
|
|
@@ -915,7 +932,7 @@ var ShellProcess = class {
|
|
|
915
932
|
{ abortSignal }
|
|
916
933
|
).then((result) => {
|
|
917
934
|
finish();
|
|
918
|
-
return
|
|
935
|
+
return result;
|
|
919
936
|
}).catch((error51) => {
|
|
920
937
|
fail(error51);
|
|
921
938
|
throw error51;
|
|
@@ -940,6 +957,24 @@ var Shell = class {
|
|
|
940
957
|
};
|
|
941
958
|
|
|
942
959
|
// src/composer.ts
|
|
960
|
+
var ComposerCredentials = class {
|
|
961
|
+
constructor(client, notebookId) {
|
|
962
|
+
this.client = client;
|
|
963
|
+
this.notebookId = notebookId;
|
|
964
|
+
}
|
|
965
|
+
async set(input) {
|
|
966
|
+
const response = await this.client.put(
|
|
967
|
+
`/notebook/${this.notebookId}/composer/credentials`,
|
|
968
|
+
input
|
|
969
|
+
);
|
|
970
|
+
return response.data;
|
|
971
|
+
}
|
|
972
|
+
async remove(type, url2) {
|
|
973
|
+
const params = new URLSearchParams({ type });
|
|
974
|
+
if (url2) params.set("url", url2);
|
|
975
|
+
await this.client.delete(`/notebook/${this.notebookId}/composer/credentials?${params.toString()}`);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
943
978
|
var ComposerProcess = class {
|
|
944
979
|
constructor(id, okra, command, args, options) {
|
|
945
980
|
this.id = id;
|
|
@@ -977,7 +1012,7 @@ var ComposerProcess = class {
|
|
|
977
1012
|
};
|
|
978
1013
|
this.completion = this.okra.invoke("composer.invoke", { id, command, args, options }).then((result) => {
|
|
979
1014
|
finish();
|
|
980
|
-
return
|
|
1015
|
+
return result;
|
|
981
1016
|
}).catch((error51) => {
|
|
982
1017
|
fail(error51);
|
|
983
1018
|
throw error51;
|
|
@@ -998,21 +1033,6 @@ var Composer = class {
|
|
|
998
1033
|
run(command, args = {}, options = {}) {
|
|
999
1034
|
return new ComposerProcess(nanoid(), this.okra, command, args, options);
|
|
1000
1035
|
}
|
|
1001
|
-
dumpAutoload(options = {}) {
|
|
1002
|
-
return this.run("dump-autoload", {}, options);
|
|
1003
|
-
}
|
|
1004
|
-
install(options = {}) {
|
|
1005
|
-
return this.run("install", {}, options);
|
|
1006
|
-
}
|
|
1007
|
-
update(args, options = {}) {
|
|
1008
|
-
return this.run("update", args, options);
|
|
1009
|
-
}
|
|
1010
|
-
require(packages, options = {}) {
|
|
1011
|
-
return this.run("require", packages, options);
|
|
1012
|
-
}
|
|
1013
|
-
remove(args, options = {}) {
|
|
1014
|
-
return this.run("remove", args, options);
|
|
1015
|
-
}
|
|
1016
1036
|
packages() {
|
|
1017
1037
|
return this.okra.invoke("composer.packages");
|
|
1018
1038
|
}
|
|
@@ -1172,6 +1192,50 @@ var Ports = class {
|
|
|
1172
1192
|
}
|
|
1173
1193
|
};
|
|
1174
1194
|
|
|
1195
|
+
// src/runtime.ts
|
|
1196
|
+
var RuntimeMetrics = class {
|
|
1197
|
+
constructor(metrics) {
|
|
1198
|
+
this.metrics = metrics;
|
|
1199
|
+
}
|
|
1200
|
+
current() {
|
|
1201
|
+
return this.metrics.current();
|
|
1202
|
+
}
|
|
1203
|
+
watch(options = {}) {
|
|
1204
|
+
return this.metrics.watch(options);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
var RuntimeLogs = class {
|
|
1208
|
+
constructor(logs) {
|
|
1209
|
+
this.logs = logs;
|
|
1210
|
+
}
|
|
1211
|
+
follow(options = {}) {
|
|
1212
|
+
return this.logs.follow(options);
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
var RuntimePorts = class {
|
|
1216
|
+
constructor(ports) {
|
|
1217
|
+
this.ports = ports;
|
|
1218
|
+
}
|
|
1219
|
+
list() {
|
|
1220
|
+
return this.ports.list();
|
|
1221
|
+
}
|
|
1222
|
+
watch(options = {}) {
|
|
1223
|
+
return this.ports.watch(options);
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
var Runtime = class {
|
|
1227
|
+
constructor(notebook) {
|
|
1228
|
+
this.notebook = notebook;
|
|
1229
|
+
const telemetry = new RuntimeTelemetry(notebook);
|
|
1230
|
+
this.metrics = new RuntimeMetrics(new Metrics(notebook, telemetry));
|
|
1231
|
+
this.logs = new RuntimeLogs(new Logs(notebook, telemetry));
|
|
1232
|
+
this.ports = new RuntimePorts(new Ports(notebook, telemetry));
|
|
1233
|
+
}
|
|
1234
|
+
setPhpVersion(version2) {
|
|
1235
|
+
return this.notebook.invoke("container.set-php", { version: version2 });
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1175
1239
|
// src/repl.ts
|
|
1176
1240
|
var Repl = class {
|
|
1177
1241
|
constructor(okra) {
|
|
@@ -2059,24 +2123,24 @@ var CachedKeyDecoder = class {
|
|
|
2059
2123
|
}
|
|
2060
2124
|
find(bytes, inputOffset, byteLength) {
|
|
2061
2125
|
const records = this.caches[byteLength - 1];
|
|
2062
|
-
FIND_CHUNK: for (const
|
|
2063
|
-
const recordBytes =
|
|
2126
|
+
FIND_CHUNK: for (const record3 of records) {
|
|
2127
|
+
const recordBytes = record3.bytes;
|
|
2064
2128
|
for (let j = 0; j < byteLength; j++) {
|
|
2065
2129
|
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
|
2066
2130
|
continue FIND_CHUNK;
|
|
2067
2131
|
}
|
|
2068
2132
|
}
|
|
2069
|
-
return
|
|
2133
|
+
return record3.str;
|
|
2070
2134
|
}
|
|
2071
2135
|
return null;
|
|
2072
2136
|
}
|
|
2073
2137
|
store(bytes, value) {
|
|
2074
2138
|
const records = this.caches[bytes.length - 1];
|
|
2075
|
-
const
|
|
2139
|
+
const record3 = { bytes, str: value };
|
|
2076
2140
|
if (records.length >= this.maxLengthPerKey) {
|
|
2077
|
-
records[Math.random() * records.length | 0] =
|
|
2141
|
+
records[Math.random() * records.length | 0] = record3;
|
|
2078
2142
|
} else {
|
|
2079
|
-
records.push(
|
|
2143
|
+
records.push(record3);
|
|
2080
2144
|
}
|
|
2081
2145
|
}
|
|
2082
2146
|
decode(bytes, inputOffset, byteLength) {
|
|
@@ -2826,17 +2890,17 @@ var Event = (
|
|
|
2826
2890
|
return Event2;
|
|
2827
2891
|
})()
|
|
2828
2892
|
);
|
|
2829
|
-
var
|
|
2893
|
+
var ErrorEvent = (
|
|
2830
2894
|
/** @class */
|
|
2831
2895
|
(function(_super) {
|
|
2832
|
-
__extends(
|
|
2833
|
-
function
|
|
2896
|
+
__extends(ErrorEvent2, _super);
|
|
2897
|
+
function ErrorEvent2(error51, target) {
|
|
2834
2898
|
var _this = _super.call(this, "error", target) || this;
|
|
2835
2899
|
_this.message = error51.message;
|
|
2836
2900
|
_this.error = error51;
|
|
2837
2901
|
return _this;
|
|
2838
2902
|
}
|
|
2839
|
-
return
|
|
2903
|
+
return ErrorEvent2;
|
|
2840
2904
|
})(Event)
|
|
2841
2905
|
);
|
|
2842
2906
|
var CloseEvent = (
|
|
@@ -3261,7 +3325,7 @@ var ReconnectingWebSocket = (
|
|
|
3261
3325
|
};
|
|
3262
3326
|
ReconnectingWebSocket3.prototype._handleTimeout = function() {
|
|
3263
3327
|
this._debug("timeout event");
|
|
3264
|
-
this._handleError(new
|
|
3328
|
+
this._handleError(new ErrorEvent(Error("TIMEOUT"), this));
|
|
3265
3329
|
};
|
|
3266
3330
|
ReconnectingWebSocket3.prototype._disconnect = function(code, reason) {
|
|
3267
3331
|
if (code === void 0) {
|
|
@@ -3348,12 +3412,12 @@ var extractNestedErrorMessage = (value) => {
|
|
|
3348
3412
|
if (!value || typeof value !== "object") {
|
|
3349
3413
|
return void 0;
|
|
3350
3414
|
}
|
|
3351
|
-
const
|
|
3352
|
-
const message = typeof
|
|
3415
|
+
const record3 = value;
|
|
3416
|
+
const message = typeof record3.message === "string" && record3.message ? record3.message : typeof record3.reason === "string" && record3.reason ? record3.reason : void 0;
|
|
3353
3417
|
if (!message) {
|
|
3354
3418
|
return void 0;
|
|
3355
3419
|
}
|
|
3356
|
-
const name = typeof
|
|
3420
|
+
const name = typeof record3.name === "string" && record3.name ? record3.name : void 0;
|
|
3357
3421
|
return name ? `${name}: ${message}` : message;
|
|
3358
3422
|
};
|
|
3359
3423
|
var describeWebSocketEvent = (event) => {
|
|
@@ -3366,29 +3430,29 @@ var describeWebSocketEvent = (event) => {
|
|
|
3366
3430
|
if (!event || typeof event !== "object") {
|
|
3367
3431
|
return String(event);
|
|
3368
3432
|
}
|
|
3369
|
-
const
|
|
3433
|
+
const record3 = event;
|
|
3370
3434
|
const parts = [];
|
|
3371
|
-
const topLevelMessage = extractNestedErrorMessage(
|
|
3435
|
+
const topLevelMessage = extractNestedErrorMessage(record3);
|
|
3372
3436
|
if (topLevelMessage) {
|
|
3373
3437
|
parts.push(topLevelMessage);
|
|
3374
3438
|
}
|
|
3375
|
-
const nestedErrorMessage = extractNestedErrorMessage(
|
|
3439
|
+
const nestedErrorMessage = extractNestedErrorMessage(record3.error);
|
|
3376
3440
|
if (nestedErrorMessage && nestedErrorMessage !== topLevelMessage) {
|
|
3377
3441
|
parts.push(`error=${nestedErrorMessage}`);
|
|
3378
3442
|
}
|
|
3379
|
-
if (typeof
|
|
3380
|
-
parts.push(`type=${
|
|
3443
|
+
if (typeof record3.type === "string" && record3.type) {
|
|
3444
|
+
parts.push(`type=${record3.type}`);
|
|
3381
3445
|
}
|
|
3382
|
-
if (typeof
|
|
3383
|
-
parts.push(`code=${
|
|
3446
|
+
if (typeof record3.code === "number") {
|
|
3447
|
+
parts.push(`code=${record3.code}`);
|
|
3384
3448
|
}
|
|
3385
|
-
if (typeof
|
|
3386
|
-
parts.push(`reason=${
|
|
3449
|
+
if (typeof record3.reason === "string" && record3.reason && record3.reason !== topLevelMessage) {
|
|
3450
|
+
parts.push(`reason=${record3.reason}`);
|
|
3387
3451
|
}
|
|
3388
|
-
if (typeof
|
|
3389
|
-
parts.push(`wasClean=${
|
|
3452
|
+
if (typeof record3.wasClean === "boolean") {
|
|
3453
|
+
parts.push(`wasClean=${record3.wasClean}`);
|
|
3390
3454
|
}
|
|
3391
|
-
const target =
|
|
3455
|
+
const target = record3.target ?? record3.currentTarget;
|
|
3392
3456
|
if (target && typeof target === "object") {
|
|
3393
3457
|
if (typeof target.url === "string" && target.url) {
|
|
3394
3458
|
parts.push(`url=${sanitizeWebSocketUrl(target.url)}`);
|
|
@@ -3438,25 +3502,36 @@ var NamedDisposable = class {
|
|
|
3438
3502
|
};
|
|
3439
3503
|
|
|
3440
3504
|
// src/socket/index.ts
|
|
3505
|
+
var SAFE_DEBUG_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
3506
|
+
"url",
|
|
3507
|
+
"action",
|
|
3508
|
+
"event",
|
|
3509
|
+
"responseEvent",
|
|
3510
|
+
"errorEvent",
|
|
3511
|
+
"hasData",
|
|
3512
|
+
"code",
|
|
3513
|
+
"attempt",
|
|
3514
|
+
"maxRetries",
|
|
3515
|
+
"timeout",
|
|
3516
|
+
"errorCount",
|
|
3517
|
+
"byteLength"
|
|
3518
|
+
]);
|
|
3441
3519
|
var ReconnectingWebSocket2 = reconnecting_websocket_mjs_default ?? reconnecting_websocket_mjs_exports;
|
|
3442
|
-
var ConnectionTimeoutError = class extends
|
|
3520
|
+
var ConnectionTimeoutError = class extends TransportError {
|
|
3443
3521
|
constructor(message = "WebSocket connection timeout") {
|
|
3444
|
-
super(message);
|
|
3445
|
-
this.name = "ConnectionTimeoutError";
|
|
3522
|
+
super(message, "ConnectionTimeout");
|
|
3446
3523
|
}
|
|
3447
3524
|
};
|
|
3448
|
-
var ConnectionFailedError = class extends
|
|
3525
|
+
var ConnectionFailedError = class extends TransportError {
|
|
3449
3526
|
constructor(message, originalError) {
|
|
3450
|
-
super(message);
|
|
3527
|
+
super(message, "ConnectionFailed", originalError);
|
|
3451
3528
|
this.originalError = originalError;
|
|
3452
|
-
this.name = "ConnectionFailedError";
|
|
3453
3529
|
}
|
|
3454
3530
|
};
|
|
3455
|
-
var InvalidMessageError = class extends
|
|
3531
|
+
var InvalidMessageError = class extends TransportError {
|
|
3456
3532
|
constructor(message, data) {
|
|
3457
|
-
super(message);
|
|
3533
|
+
super(message, "InvalidResponse", data);
|
|
3458
3534
|
this.data = data;
|
|
3459
|
-
this.name = "InvalidMessageError";
|
|
3460
3535
|
}
|
|
3461
3536
|
};
|
|
3462
3537
|
var InvalidConfigurationError = class extends Error {
|
|
@@ -3483,7 +3558,6 @@ var Transport = class {
|
|
|
3483
3558
|
const urlProvider = typeof url2 === "string" ? this.url.toString() : async () => new URL(await url2()).toString();
|
|
3484
3559
|
this.PING_INTERVAL = options.pingInterval ?? 3e4;
|
|
3485
3560
|
this.CONNECT_WAIT_TIMEOUT = options.connectWaitTimeout ?? 3e4;
|
|
3486
|
-
const startClosed = options.startClosed !== false;
|
|
3487
3561
|
this.rws = new ReconnectingWebSocket2(urlProvider, [], {
|
|
3488
3562
|
WebSocket: options.webSocket ?? globalThis.WebSocket ?? browser_default,
|
|
3489
3563
|
connectionTimeout: options.connectionTimeout,
|
|
@@ -3491,7 +3565,7 @@ var Transport = class {
|
|
|
3491
3565
|
minReconnectionDelay: 200,
|
|
3492
3566
|
maxEnqueuedMessages: 0,
|
|
3493
3567
|
maxRetries: options.maxRetries ?? 50,
|
|
3494
|
-
startClosed
|
|
3568
|
+
startClosed: true
|
|
3495
3569
|
});
|
|
3496
3570
|
this.log("debug", "Transport initialized", {
|
|
3497
3571
|
url: this.url === null ? "dynamic" : transportLogUrl(this.url),
|
|
@@ -3522,8 +3596,10 @@ var Transport = class {
|
|
|
3522
3596
|
log(level, message, data) {
|
|
3523
3597
|
if (this.options.debug) {
|
|
3524
3598
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3599
|
+
const metadata = safeDebugMetadata(data);
|
|
3600
|
+
const logData = metadata ? `
|
|
3601
|
+
${JSON.stringify(metadata, null, 2)}` : "";
|
|
3602
|
+
console[level](`[Transport ${timestamp}] ${message}${logData}`);
|
|
3527
3603
|
}
|
|
3528
3604
|
}
|
|
3529
3605
|
/**
|
|
@@ -3646,10 +3722,12 @@ var Transport = class {
|
|
|
3646
3722
|
}
|
|
3647
3723
|
if (event === "Events.BootError" /* BootError */) {
|
|
3648
3724
|
const errorData = data;
|
|
3649
|
-
const error51 = new
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3725
|
+
const error51 = new RemoteError(errorData?.message || "Notebook is no longer available", {
|
|
3726
|
+
source: "runtime",
|
|
3727
|
+
status: 503,
|
|
3728
|
+
code: "NotebookUnavailable",
|
|
3729
|
+
details: errorData || {}
|
|
3730
|
+
});
|
|
3653
3731
|
this.log("error", "Boot error received", { data });
|
|
3654
3732
|
this.terminate(error51, 4e3, error51.message);
|
|
3655
3733
|
return;
|
|
@@ -3792,12 +3870,16 @@ var Transport = class {
|
|
|
3792
3870
|
});
|
|
3793
3871
|
this.listenOnce(errorEvent, (e) => {
|
|
3794
3872
|
this.log("error", "Message error received", { action, error: e });
|
|
3795
|
-
|
|
3796
|
-
reject(new ErrorEvent(error51.code, error51.message, error51));
|
|
3873
|
+
reject(remoteError("runtime", e));
|
|
3797
3874
|
});
|
|
3798
3875
|
closeHandler = (_ev) => {
|
|
3799
3876
|
if (_ev.code === 1008 && (_ev.reason || "").includes("rate limit")) {
|
|
3800
|
-
reject(new
|
|
3877
|
+
reject(new RemoteError(_ev.reason || "Rate limit exceeded", {
|
|
3878
|
+
source: "runtime",
|
|
3879
|
+
status: 429,
|
|
3880
|
+
code: "RateLimited",
|
|
3881
|
+
cause: _ev
|
|
3882
|
+
}));
|
|
3801
3883
|
return;
|
|
3802
3884
|
}
|
|
3803
3885
|
const detail = describeWebSocketEvent(_ev);
|
|
@@ -3810,7 +3892,7 @@ var Transport = class {
|
|
|
3810
3892
|
this.log("debug", "Message sent", { action, data });
|
|
3811
3893
|
} catch (error51) {
|
|
3812
3894
|
this.log("error", "Failed to send message", { action, error: error51 });
|
|
3813
|
-
reject(error51);
|
|
3895
|
+
reject(new ConnectionFailedError(`Failed to send runtime action ${action}.`, error51));
|
|
3814
3896
|
}
|
|
3815
3897
|
};
|
|
3816
3898
|
const send = async () => {
|
|
@@ -3863,7 +3945,7 @@ var Transport = class {
|
|
|
3863
3945
|
try {
|
|
3864
3946
|
return await sender();
|
|
3865
3947
|
} catch (e) {
|
|
3866
|
-
if (e instanceof
|
|
3948
|
+
if (e instanceof RemoteError || e instanceof InvalidConfigurationError || e instanceof InvalidMessageError || e instanceof DOMException) {
|
|
3867
3949
|
this.log("debug", "Non-retryable error, bailing", {
|
|
3868
3950
|
error: e.message,
|
|
3869
3951
|
attempt
|
|
@@ -3932,7 +4014,7 @@ var Transport = class {
|
|
|
3932
4014
|
}
|
|
3933
4015
|
terminate(error51, code = 4e3, reason = error51.message) {
|
|
3934
4016
|
this.terminalError = error51;
|
|
3935
|
-
if (error51
|
|
4017
|
+
if (RemoteError.is(error51, "NotebookUnavailable")) {
|
|
3936
4018
|
this.eventEmitter.emit("transport.boot_error", {
|
|
3937
4019
|
error: error51,
|
|
3938
4020
|
timestamp: Date.now()
|
|
@@ -4080,6 +4162,15 @@ startPeriodicPing_fn = function() {
|
|
|
4080
4162
|
};
|
|
4081
4163
|
});
|
|
4082
4164
|
};
|
|
4165
|
+
function safeDebugMetadata(data) {
|
|
4166
|
+
if (data === null || typeof data !== "object") {
|
|
4167
|
+
return null;
|
|
4168
|
+
}
|
|
4169
|
+
const metadata = Object.entries(data).filter(
|
|
4170
|
+
([key, value]) => SAFE_DEBUG_METADATA_KEYS.has(key) && ["string", "number", "boolean"].includes(typeof value)
|
|
4171
|
+
);
|
|
4172
|
+
return metadata.length > 0 ? Object.fromEntries(metadata) : null;
|
|
4173
|
+
}
|
|
4083
4174
|
function transportLogUrl(url2) {
|
|
4084
4175
|
const safeUrl = new URL(url2);
|
|
4085
4176
|
safeUrl.search = "";
|
|
@@ -4204,8 +4295,9 @@ var Git = class {
|
|
|
4204
4295
|
revert(input) {
|
|
4205
4296
|
return this.okra.invoke("git.revert", input);
|
|
4206
4297
|
}
|
|
4207
|
-
credentials() {
|
|
4208
|
-
|
|
4298
|
+
async credentials() {
|
|
4299
|
+
const response = await this.client.post(`/notebook/${this.okra.data.id}/git/credentials`);
|
|
4300
|
+
return response.data;
|
|
4209
4301
|
}
|
|
4210
4302
|
restore(ref) {
|
|
4211
4303
|
return this.okra.invoke("git.restore", { ref });
|
|
@@ -4265,15 +4357,8 @@ var GitTargetApi = class {
|
|
|
4265
4357
|
);
|
|
4266
4358
|
return new GitTarget(response.data, this.notebookId, this.client);
|
|
4267
4359
|
}
|
|
4268
|
-
async sync(target, input = {}) {
|
|
4269
|
-
const response = await this.client.post(
|
|
4270
|
-
`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}/sync`,
|
|
4271
|
-
omitUndefined({ ...input })
|
|
4272
|
-
);
|
|
4273
|
-
return new GitTarget(response.data, this.notebookId, this.client);
|
|
4274
|
-
}
|
|
4275
4360
|
};
|
|
4276
|
-
var GitTarget = class {
|
|
4361
|
+
var GitTarget = class _GitTarget {
|
|
4277
4362
|
constructor(data, notebookId, client) {
|
|
4278
4363
|
this.data = data;
|
|
4279
4364
|
this.notebookId = notebookId;
|
|
@@ -4282,8 +4367,12 @@ var GitTarget = class {
|
|
|
4282
4367
|
get id() {
|
|
4283
4368
|
return this.data.id;
|
|
4284
4369
|
}
|
|
4285
|
-
sync(input = {}) {
|
|
4286
|
-
|
|
4370
|
+
async sync(input = {}) {
|
|
4371
|
+
const response = await this.client.post(
|
|
4372
|
+
`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(this.id)}/sync`,
|
|
4373
|
+
omitUndefined({ ...input })
|
|
4374
|
+
);
|
|
4375
|
+
return new _GitTarget(response.data, this.notebookId, this.client);
|
|
4287
4376
|
}
|
|
4288
4377
|
};
|
|
4289
4378
|
function gitTargetId(target) {
|
|
@@ -4487,7 +4576,7 @@ __export(external_exports, {
|
|
|
4487
4576
|
promise: () => promise,
|
|
4488
4577
|
property: () => _property,
|
|
4489
4578
|
readonly: () => readonly,
|
|
4490
|
-
record: () =>
|
|
4579
|
+
record: () => record2,
|
|
4491
4580
|
refine: () => refine,
|
|
4492
4581
|
regex: () => _regex,
|
|
4493
4582
|
regexes: () => regexes_exports,
|
|
@@ -16825,7 +16914,7 @@ __export(schemas_exports2, {
|
|
|
16825
16914
|
preprocess: () => preprocess,
|
|
16826
16915
|
promise: () => promise,
|
|
16827
16916
|
readonly: () => readonly,
|
|
16828
|
-
record: () =>
|
|
16917
|
+
record: () => record2,
|
|
16829
16918
|
refine: () => refine,
|
|
16830
16919
|
set: () => set,
|
|
16831
16920
|
strictObject: () => strictObject,
|
|
@@ -17794,7 +17883,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
17794
17883
|
inst.keyType = def.keyType;
|
|
17795
17884
|
inst.valueType = def.valueType;
|
|
17796
17885
|
});
|
|
17797
|
-
function
|
|
17886
|
+
function record2(keyType, valueType, params) {
|
|
17798
17887
|
if (!valueType || !valueType._zod) {
|
|
17799
17888
|
return new ZodRecord({
|
|
17800
17889
|
type: "record",
|
|
@@ -18261,7 +18350,7 @@ var stringbool = (...args) => _stringbool({
|
|
|
18261
18350
|
}, ...args);
|
|
18262
18351
|
function json(params) {
|
|
18263
18352
|
const jsonSchema = lazy(() => {
|
|
18264
|
-
return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema),
|
|
18353
|
+
return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record2(string2(), jsonSchema)]);
|
|
18265
18354
|
});
|
|
18266
18355
|
return jsonSchema;
|
|
18267
18356
|
}
|
|
@@ -18856,7 +18945,6 @@ var PublicationRegionSchema = external_exports.enum([
|
|
|
18856
18945
|
"AFR"
|
|
18857
18946
|
]);
|
|
18858
18947
|
var PublicationJurisdictionSchema = external_exports.enum(["eu", "fedramp"]);
|
|
18859
|
-
var PublicationDomainDnsRecordTypeSchema = external_exports.enum(["CNAME", "ALIAS", "ANAME"]);
|
|
18860
18948
|
var PublicationProtectionModeSchema = external_exports.enum(["none", "password"]);
|
|
18861
18949
|
var PublicationLogStreamSchema = external_exports.enum(["build", "runtime"]);
|
|
18862
18950
|
var PublishStreamLogStreamSchema = external_exports.enum(["build", "publish", "runtime"]);
|
|
@@ -18947,33 +19035,6 @@ var PublishStreamSseEventSchema = external_exports.discriminatedUnion("event", [
|
|
|
18947
19035
|
});
|
|
18948
19036
|
|
|
18949
19037
|
// src/publications.ts
|
|
18950
|
-
var NotebookPublicationApi = class {
|
|
18951
|
-
constructor(client) {
|
|
18952
|
-
this.client = client;
|
|
18953
|
-
}
|
|
18954
|
-
async current(notebookId) {
|
|
18955
|
-
try {
|
|
18956
|
-
const response = await this.client.get(
|
|
18957
|
-
`/notebook/${notebookId}/publication`
|
|
18958
|
-
);
|
|
18959
|
-
return new PublicationInstance(response.data, this.client, notebookId);
|
|
18960
|
-
} catch (error51) {
|
|
18961
|
-
if (error51 instanceof ApiError && error51.status === 404) {
|
|
18962
|
-
return null;
|
|
18963
|
-
}
|
|
18964
|
-
throw error51;
|
|
18965
|
-
}
|
|
18966
|
-
}
|
|
18967
|
-
async publish(notebookId, input) {
|
|
18968
|
-
const response = await this.client.post(
|
|
18969
|
-
`/notebook/${notebookId}/publication`,
|
|
18970
|
-
input
|
|
18971
|
-
);
|
|
18972
|
-
const run = new PublicationRun(new PublicationInstance(response.data, this.client, notebookId), this.client);
|
|
18973
|
-
run.start();
|
|
18974
|
-
return run;
|
|
18975
|
-
}
|
|
18976
|
-
};
|
|
18977
19038
|
var PublicationApi = class {
|
|
18978
19039
|
constructor(client) {
|
|
18979
19040
|
this.client = client;
|
|
@@ -18982,60 +19043,6 @@ var PublicationApi = class {
|
|
|
18982
19043
|
const response = await this.client.get(`/publications/${id}`);
|
|
18983
19044
|
return new PublicationInstance(response.data, this.client);
|
|
18984
19045
|
}
|
|
18985
|
-
async destroy(id) {
|
|
18986
|
-
await this.client.delete(`/publications/${id}`);
|
|
18987
|
-
}
|
|
18988
|
-
async setProtection(id, input) {
|
|
18989
|
-
const response = await this.client.put(`/publications/${id}/protection`, input);
|
|
18990
|
-
return new PublicationInstance(response.data, this.client);
|
|
18991
|
-
}
|
|
18992
|
-
async protection(id) {
|
|
18993
|
-
const response = await this.client.get(`/publications/${id}/protection`);
|
|
18994
|
-
return response.data;
|
|
18995
|
-
}
|
|
18996
|
-
async createProtectionSession(id) {
|
|
18997
|
-
const response = await this.client.post(`/publications/${id}/protection/session`);
|
|
18998
|
-
return response.data;
|
|
18999
|
-
}
|
|
19000
|
-
async disableProtection(id) {
|
|
19001
|
-
const response = await this.client.delete(`/publications/${id}/protection`);
|
|
19002
|
-
return new PublicationInstance(response.data, this.client);
|
|
19003
|
-
}
|
|
19004
|
-
async listDomains(id) {
|
|
19005
|
-
const response = await this.client.get(
|
|
19006
|
-
`/publications/${id}/domains`
|
|
19007
|
-
);
|
|
19008
|
-
return unwrapPublicationDomainCollection(response.data);
|
|
19009
|
-
}
|
|
19010
|
-
async createDomain(id, input) {
|
|
19011
|
-
const response = await this.client.post(`/publications/${id}/domains`, input);
|
|
19012
|
-
return response.data;
|
|
19013
|
-
}
|
|
19014
|
-
async refreshDomain(id, domainId) {
|
|
19015
|
-
const response = await this.client.post(`/publications/${id}/domains/${domainId}/refresh`);
|
|
19016
|
-
return response.data;
|
|
19017
|
-
}
|
|
19018
|
-
async deleteDomain(id, domainId) {
|
|
19019
|
-
await this.client.delete(`/publications/${id}/domains/${domainId}`);
|
|
19020
|
-
}
|
|
19021
|
-
async events(id) {
|
|
19022
|
-
return parseNdjsonStream(
|
|
19023
|
-
await this.client.stream(`/publications/${id}/events/stream`),
|
|
19024
|
-
PublicationEventDataSchema
|
|
19025
|
-
);
|
|
19026
|
-
}
|
|
19027
|
-
async buildLogs(id, buildId) {
|
|
19028
|
-
return parseNdjsonStream(
|
|
19029
|
-
await this.client.stream(`/publications/${id}/builds/${buildId}/logs/stream`),
|
|
19030
|
-
PublicationLogChunkDataSchema
|
|
19031
|
-
);
|
|
19032
|
-
}
|
|
19033
|
-
async logs(id) {
|
|
19034
|
-
return parseNdjsonStream(
|
|
19035
|
-
await this.client.stream(`/publications/${id}/logs/stream`),
|
|
19036
|
-
PublicationLogChunkDataSchema
|
|
19037
|
-
);
|
|
19038
|
-
}
|
|
19039
19046
|
};
|
|
19040
19047
|
var PublicationRun = class {
|
|
19041
19048
|
constructor(initial, client) {
|
|
@@ -19154,14 +19161,22 @@ var PublicationInstance = class _PublicationInstance {
|
|
|
19154
19161
|
const response = await this.client.get(`/publications/${this.data.id}`);
|
|
19155
19162
|
return new _PublicationInstance(response.data, this.client, this.notebookId);
|
|
19156
19163
|
}
|
|
19157
|
-
publish() {
|
|
19164
|
+
async publish() {
|
|
19158
19165
|
if (!this.notebookId) {
|
|
19159
19166
|
return Promise.reject(new Error("Publishing requires a notebook-scoped publication instance."));
|
|
19160
19167
|
}
|
|
19161
|
-
|
|
19168
|
+
const response = await this.client.post(
|
|
19169
|
+
`/notebook/${this.notebookId}/publication`
|
|
19170
|
+
);
|
|
19171
|
+
const run = new PublicationRun(
|
|
19172
|
+
new _PublicationInstance(response.data, this.client, this.notebookId),
|
|
19173
|
+
this.client
|
|
19174
|
+
);
|
|
19175
|
+
run.start();
|
|
19176
|
+
return run;
|
|
19162
19177
|
}
|
|
19163
|
-
destroy() {
|
|
19164
|
-
|
|
19178
|
+
async destroy() {
|
|
19179
|
+
await this.client.delete(`/publications/${this.data.id}`);
|
|
19165
19180
|
}
|
|
19166
19181
|
async wait(options = {}) {
|
|
19167
19182
|
const intervalMs = options.intervalMs ?? 1e3;
|
|
@@ -19177,41 +19192,44 @@ var PublicationInstance = class _PublicationInstance {
|
|
|
19177
19192
|
}
|
|
19178
19193
|
return current;
|
|
19179
19194
|
}
|
|
19180
|
-
events() {
|
|
19181
|
-
return
|
|
19195
|
+
async events() {
|
|
19196
|
+
return parseNdjsonStream(
|
|
19197
|
+
await this.client.stream(`/publications/${this.data.id}/events/stream`),
|
|
19198
|
+
PublicationEventDataSchema
|
|
19199
|
+
);
|
|
19182
19200
|
}
|
|
19183
19201
|
buildLogs(buildId = this.data.latestBuild?.id ?? "") {
|
|
19184
19202
|
if (buildId === "") {
|
|
19185
19203
|
return Promise.reject(new Error("Publication has no latest build id"));
|
|
19186
19204
|
}
|
|
19187
|
-
return this.client.publications
|
|
19188
|
-
}
|
|
19189
|
-
logs() {
|
|
19190
|
-
return this.client.publications.logs(this.data.id);
|
|
19191
|
-
}
|
|
19192
|
-
setProtection(input) {
|
|
19193
|
-
return this.client.publications.setProtection(this.data.id, input);
|
|
19205
|
+
return this.client.stream(`/publications/${this.data.id}/builds/${buildId}/logs/stream`).then((stream) => parseNdjsonStream(stream, PublicationLogChunkDataSchema));
|
|
19194
19206
|
}
|
|
19195
|
-
|
|
19196
|
-
return
|
|
19197
|
-
|
|
19198
|
-
|
|
19199
|
-
|
|
19200
|
-
}
|
|
19201
|
-
disableProtection() {
|
|
19202
|
-
return this.client.publications.disableProtection(this.data.id);
|
|
19207
|
+
async logs() {
|
|
19208
|
+
return parseNdjsonStream(
|
|
19209
|
+
await this.client.stream(`/publications/${this.data.id}/logs/stream`),
|
|
19210
|
+
PublicationLogChunkDataSchema
|
|
19211
|
+
);
|
|
19203
19212
|
}
|
|
19204
|
-
|
|
19205
|
-
|
|
19213
|
+
async setProtection(input) {
|
|
19214
|
+
const response = await this.client.put(
|
|
19215
|
+
`/publications/${this.data.id}/protection`,
|
|
19216
|
+
input
|
|
19217
|
+
);
|
|
19218
|
+
return new _PublicationInstance(response.data, this.client, this.notebookId);
|
|
19206
19219
|
}
|
|
19207
|
-
|
|
19208
|
-
|
|
19220
|
+
async protection() {
|
|
19221
|
+
const response = await this.client.get(`/publications/${this.data.id}/protection`);
|
|
19222
|
+
return response.data;
|
|
19209
19223
|
}
|
|
19210
|
-
|
|
19211
|
-
|
|
19224
|
+
async createProtectionSession() {
|
|
19225
|
+
const response = await this.client.post(
|
|
19226
|
+
`/publications/${this.data.id}/protection/session`
|
|
19227
|
+
);
|
|
19228
|
+
return response.data;
|
|
19212
19229
|
}
|
|
19213
|
-
|
|
19214
|
-
|
|
19230
|
+
async disableProtection() {
|
|
19231
|
+
const response = await this.client.delete(`/publications/${this.data.id}/protection`);
|
|
19232
|
+
return new _PublicationInstance(response.data, this.client, this.notebookId);
|
|
19215
19233
|
}
|
|
19216
19234
|
};
|
|
19217
19235
|
function publicationStatusIsTerminal(status) {
|
|
@@ -19220,12 +19238,6 @@ function publicationStatusIsTerminal(status) {
|
|
|
19220
19238
|
function delay(ms) {
|
|
19221
19239
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19222
19240
|
}
|
|
19223
|
-
function unwrapPublicationDomainCollection(input) {
|
|
19224
|
-
if (Array.isArray(input)) {
|
|
19225
|
-
return input;
|
|
19226
|
-
}
|
|
19227
|
-
return Array.isArray(input.data) ? input.data : [];
|
|
19228
|
-
}
|
|
19229
19241
|
var AsyncPublishEventQueue = class {
|
|
19230
19242
|
constructor() {
|
|
19231
19243
|
this.values = [];
|
|
@@ -19392,9 +19404,9 @@ var ServerApi = class {
|
|
|
19392
19404
|
constructor(client) {
|
|
19393
19405
|
this.client = client;
|
|
19394
19406
|
}
|
|
19395
|
-
async list() {
|
|
19396
|
-
const
|
|
19397
|
-
return
|
|
19407
|
+
async list(options = {}) {
|
|
19408
|
+
const query = options.page === void 0 ? "" : `?${new URLSearchParams({ page: String(options.page) }).toString()}`;
|
|
19409
|
+
return this.client.get(`/servers${query}`);
|
|
19398
19410
|
}
|
|
19399
19411
|
async create(input) {
|
|
19400
19412
|
const response = await this.client.post("/servers", input);
|
|
@@ -19404,9 +19416,6 @@ var ServerApi = class {
|
|
|
19404
19416
|
const response = await this.client.get(`/servers/${id}`);
|
|
19405
19417
|
return new ServerInstance(response.data, this.client);
|
|
19406
19418
|
}
|
|
19407
|
-
async delete(id) {
|
|
19408
|
-
await this.client.delete(`/servers/${id}`);
|
|
19409
|
-
}
|
|
19410
19419
|
};
|
|
19411
19420
|
var ServerInstance = class {
|
|
19412
19421
|
constructor(data, client) {
|
|
@@ -19416,8 +19425,8 @@ var ServerInstance = class {
|
|
|
19416
19425
|
refresh() {
|
|
19417
19426
|
return this.client.servers.get(this.data.id);
|
|
19418
19427
|
}
|
|
19419
|
-
delete() {
|
|
19420
|
-
|
|
19428
|
+
async delete() {
|
|
19429
|
+
await this.client.delete(`/servers/${this.data.id}`);
|
|
19421
19430
|
}
|
|
19422
19431
|
async waitReady(options) {
|
|
19423
19432
|
const timeout2 = options?.timeout ?? 3e5;
|
|
@@ -19437,15 +19446,20 @@ var ServerInstance = class {
|
|
|
19437
19446
|
}
|
|
19438
19447
|
};
|
|
19439
19448
|
|
|
19449
|
+
// src/http.ts
|
|
19450
|
+
function authenticatedRequest(input, init) {
|
|
19451
|
+
return new Request(input, {
|
|
19452
|
+
...init,
|
|
19453
|
+
redirect: "manual"
|
|
19454
|
+
});
|
|
19455
|
+
}
|
|
19456
|
+
|
|
19440
19457
|
// src/runtime/rest.ts
|
|
19441
19458
|
var restActionRoutes = {
|
|
19442
19459
|
"runtime.ready": { method: "GET", path: "/runtime" },
|
|
19443
|
-
ping: { method: "GET", path: "/runtime/ping" },
|
|
19444
19460
|
"config.get": { method: "GET", path: "/runtime/config" },
|
|
19445
19461
|
"config.update": { method: "PATCH", path: "/runtime/config" },
|
|
19446
19462
|
"config.set-ports": { method: "PUT", path: "/runtime/config/ports" },
|
|
19447
|
-
"container.state": { method: "GET", path: "/runtime/container" },
|
|
19448
|
-
"container.start": { method: "POST", path: "/runtime/container/start" },
|
|
19449
19463
|
"container.restart": { method: "POST", path: "/runtime/container/restart" },
|
|
19450
19464
|
"container.stop": { method: "POST", path: "/runtime/container/stop" },
|
|
19451
19465
|
"container.set-php": { method: "PUT", path: "/runtime/container/php" },
|
|
@@ -19498,10 +19512,14 @@ var RestRuntimeInvoker = class {
|
|
|
19498
19512
|
const actionUrl = new URL(runtimeUrl);
|
|
19499
19513
|
const ticket = actionUrl.searchParams.get("ticket") ?? "";
|
|
19500
19514
|
if (ticket === "") {
|
|
19501
|
-
throw new
|
|
19515
|
+
throw new PHPSandboxError("The notebook connection does not contain a runtime ticket.");
|
|
19502
19516
|
}
|
|
19503
19517
|
this.ticket = ticket;
|
|
19504
|
-
|
|
19518
|
+
if (actionUrl.protocol === "wss:") {
|
|
19519
|
+
actionUrl.protocol = "https:";
|
|
19520
|
+
} else if (actionUrl.protocol === "ws:") {
|
|
19521
|
+
actionUrl.protocol = "http:";
|
|
19522
|
+
}
|
|
19505
19523
|
actionUrl.pathname = `/api/v1/notebooks/${encodeURIComponent(this.notebookId)}`;
|
|
19506
19524
|
actionUrl.searchParams.delete("ticket");
|
|
19507
19525
|
actionUrl.hash = "";
|
|
@@ -19517,27 +19535,28 @@ var RestRuntimeInvoker = class {
|
|
|
19517
19535
|
return this.invokeRaw(action, data ?? {}, options);
|
|
19518
19536
|
}
|
|
19519
19537
|
send() {
|
|
19520
|
-
throw new
|
|
19538
|
+
throw new PHPSandboxError("Fire-and-forget actions require the realtime transport.");
|
|
19521
19539
|
}
|
|
19522
19540
|
async invokeRaw(action, data, options) {
|
|
19523
19541
|
const abort = runtimeAbort(options);
|
|
19524
19542
|
try {
|
|
19525
19543
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
19526
|
-
const response = await this.fetch
|
|
19544
|
+
const response = await runtimeFetch(this.fetch, this.request(action, data, abort.signal));
|
|
19527
19545
|
if (response.status === 401 && attempt === 0 && this.refresh !== void 0) {
|
|
19528
19546
|
await this.refreshAuthorization();
|
|
19529
19547
|
continue;
|
|
19530
19548
|
}
|
|
19531
19549
|
const payload = await runtimeActionResponse(response);
|
|
19532
19550
|
if (!response.ok || payload.error !== void 0) {
|
|
19533
|
-
|
|
19534
|
-
const message = typeof error51.message === "string" ? error51.message : `Runtime action ${action} failed.`;
|
|
19535
|
-
const code = typeof error51.code === "number" ? error51.code : response.status;
|
|
19536
|
-
throw new ErrorEvent(code, message, error51);
|
|
19551
|
+
throw remoteError("runtime", payload.error, response);
|
|
19537
19552
|
}
|
|
19538
19553
|
return payload.data;
|
|
19539
19554
|
}
|
|
19540
|
-
throw new
|
|
19555
|
+
throw new RemoteError(`Runtime action ${action} could not be authorized.`, {
|
|
19556
|
+
source: "runtime",
|
|
19557
|
+
status: 401,
|
|
19558
|
+
code: "AuthenticationRequired"
|
|
19559
|
+
});
|
|
19541
19560
|
} finally {
|
|
19542
19561
|
abort.dispose();
|
|
19543
19562
|
}
|
|
@@ -19545,7 +19564,7 @@ var RestRuntimeInvoker = class {
|
|
|
19545
19564
|
request(action, data, signal) {
|
|
19546
19565
|
const route = restActionRoutes[action];
|
|
19547
19566
|
if (route === void 0) {
|
|
19548
|
-
throw new
|
|
19567
|
+
throw new PHPSandboxError(`Runtime action ${action} requires the realtime transport.`);
|
|
19549
19568
|
}
|
|
19550
19569
|
const url2 = new URL(this.actionUrl);
|
|
19551
19570
|
url2.pathname += route.path;
|
|
@@ -19554,7 +19573,7 @@ var RestRuntimeInvoker = class {
|
|
|
19554
19573
|
Authorization: `Bearer ${this.ticket}`
|
|
19555
19574
|
};
|
|
19556
19575
|
const body = runtimeActionRequestBody(action, data, url2, headers);
|
|
19557
|
-
return
|
|
19576
|
+
return authenticatedRequest(url2, {
|
|
19558
19577
|
method: route.method,
|
|
19559
19578
|
headers,
|
|
19560
19579
|
body: route.method === "GET" ? void 0 : body,
|
|
@@ -19572,18 +19591,31 @@ var RestRuntimeInvoker = class {
|
|
|
19572
19591
|
}
|
|
19573
19592
|
}
|
|
19574
19593
|
};
|
|
19594
|
+
async function runtimeFetch(fetch, request) {
|
|
19595
|
+
try {
|
|
19596
|
+
return await fetch(request);
|
|
19597
|
+
} catch (error51) {
|
|
19598
|
+
if (error51 instanceof DOMException && error51.name === "AbortError") {
|
|
19599
|
+
throw error51;
|
|
19600
|
+
}
|
|
19601
|
+
throw new TransportError("Unable to reach the PHPSandbox runtime.", "ConnectionFailed", error51);
|
|
19602
|
+
}
|
|
19603
|
+
}
|
|
19575
19604
|
async function runtimeActionResponse(response) {
|
|
19576
19605
|
if (response.ok && response.headers.get("content-type")?.toLowerCase().startsWith("application/octet-stream")) {
|
|
19577
19606
|
return { data: new Uint8Array(await response.arrayBuffer()) };
|
|
19578
19607
|
}
|
|
19579
19608
|
const body = await response.text();
|
|
19580
19609
|
if (body === "") {
|
|
19610
|
+
if (response.ok) {
|
|
19611
|
+
throw new TransportError("PHPSandbox runtime returned an empty response.", "InvalidResponse", response);
|
|
19612
|
+
}
|
|
19581
19613
|
return {};
|
|
19582
19614
|
}
|
|
19583
19615
|
try {
|
|
19584
19616
|
return JSON.parse(body);
|
|
19585
|
-
} catch {
|
|
19586
|
-
|
|
19617
|
+
} catch (error51) {
|
|
19618
|
+
throw new TransportError("PHPSandbox runtime returned an invalid JSON response.", "InvalidResponse", error51);
|
|
19587
19619
|
}
|
|
19588
19620
|
}
|
|
19589
19621
|
function runtimeActionRequestBody(action, data, url2, headers) {
|
|
@@ -19677,10 +19709,9 @@ var Feedback = class {
|
|
|
19677
19709
|
for (const [name, value] of Object.entries(options)) {
|
|
19678
19710
|
if (value !== void 0) query.set(name, String(value));
|
|
19679
19711
|
}
|
|
19680
|
-
|
|
19712
|
+
return this.client.get(
|
|
19681
19713
|
`${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`
|
|
19682
19714
|
);
|
|
19683
|
-
return response.data;
|
|
19684
19715
|
}
|
|
19685
19716
|
async get(id) {
|
|
19686
19717
|
const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
|
|
@@ -19712,18 +19743,8 @@ var IntegrationApi = class {
|
|
|
19712
19743
|
const response = await this.client.get(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
19713
19744
|
return new Integration(response.data, this.client);
|
|
19714
19745
|
}
|
|
19715
|
-
async update(integration, input) {
|
|
19716
|
-
const response = await this.client.patch(
|
|
19717
|
-
`/integrations/${encodeURIComponent(integrationId(integration))}`,
|
|
19718
|
-
input
|
|
19719
|
-
);
|
|
19720
|
-
return new Integration(response.data, this.client);
|
|
19721
|
-
}
|
|
19722
|
-
async unlink(integration) {
|
|
19723
|
-
await this.client.delete(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
19724
|
-
}
|
|
19725
19746
|
};
|
|
19726
|
-
var Integration = class {
|
|
19747
|
+
var Integration = class _Integration {
|
|
19727
19748
|
constructor(data, client) {
|
|
19728
19749
|
this.data = data;
|
|
19729
19750
|
this.client = client;
|
|
@@ -19737,11 +19758,15 @@ var Integration = class {
|
|
|
19737
19758
|
get label() {
|
|
19738
19759
|
return this.data.label;
|
|
19739
19760
|
}
|
|
19740
|
-
update(input) {
|
|
19741
|
-
|
|
19761
|
+
async update(input) {
|
|
19762
|
+
const response = await this.client.patch(
|
|
19763
|
+
`/integrations/${encodeURIComponent(this.id)}`,
|
|
19764
|
+
input
|
|
19765
|
+
);
|
|
19766
|
+
return new _Integration(response.data, this.client);
|
|
19742
19767
|
}
|
|
19743
|
-
unlink() {
|
|
19744
|
-
|
|
19768
|
+
async unlink() {
|
|
19769
|
+
await this.client.delete(`/integrations/${encodeURIComponent(this.id)}`);
|
|
19745
19770
|
}
|
|
19746
19771
|
};
|
|
19747
19772
|
function integrationId(integration) {
|
|
@@ -19769,16 +19794,6 @@ var SandboxIntegrationApi = class {
|
|
|
19769
19794
|
const response = await this.client.get(this.bindingPath(integration));
|
|
19770
19795
|
return new SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19771
19796
|
}
|
|
19772
|
-
async update(integration, input) {
|
|
19773
|
-
const response = await this.client.patch(this.bindingPath(integration), {
|
|
19774
|
-
...input,
|
|
19775
|
-
integration: input.integration === void 0 ? void 0 : integrationId(input.integration)
|
|
19776
|
-
});
|
|
19777
|
-
return new SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19778
|
-
}
|
|
19779
|
-
async detach(integration) {
|
|
19780
|
-
await this.client.delete(this.bindingPath(integration));
|
|
19781
|
-
}
|
|
19782
19797
|
path() {
|
|
19783
19798
|
return `/notebook/${this.notebookId}/integrations`;
|
|
19784
19799
|
}
|
|
@@ -19786,7 +19801,7 @@ var SandboxIntegrationApi = class {
|
|
|
19786
19801
|
return `${this.path()}/${encodeURIComponent(sandboxIntegrationId(integration))}`;
|
|
19787
19802
|
}
|
|
19788
19803
|
};
|
|
19789
|
-
var SandboxIntegration = class {
|
|
19804
|
+
var SandboxIntegration = class _SandboxIntegration {
|
|
19790
19805
|
constructor(data, notebookId, client) {
|
|
19791
19806
|
this.data = data;
|
|
19792
19807
|
this.notebookId = notebookId;
|
|
@@ -19801,11 +19816,18 @@ var SandboxIntegration = class {
|
|
|
19801
19816
|
get effects() {
|
|
19802
19817
|
return this.data.effects;
|
|
19803
19818
|
}
|
|
19804
|
-
update(input) {
|
|
19805
|
-
|
|
19819
|
+
async update(input) {
|
|
19820
|
+
const response = await this.client.patch(this.path(), {
|
|
19821
|
+
...input,
|
|
19822
|
+
integration: input.integration === void 0 ? void 0 : integrationId(input.integration)
|
|
19823
|
+
});
|
|
19824
|
+
return new _SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19825
|
+
}
|
|
19826
|
+
async detach() {
|
|
19827
|
+
await this.client.delete(this.path());
|
|
19806
19828
|
}
|
|
19807
|
-
|
|
19808
|
-
return
|
|
19829
|
+
path() {
|
|
19830
|
+
return `/notebook/${this.notebookId}/integrations/${encodeURIComponent(this.id)}`;
|
|
19809
19831
|
}
|
|
19810
19832
|
};
|
|
19811
19833
|
function sandboxIntegrationId(integration) {
|
|
@@ -19822,87 +19844,20 @@ function normalizeNotebookSecretInputs(input) {
|
|
|
19822
19844
|
...typeof value === "string" ? { value } : value
|
|
19823
19845
|
}));
|
|
19824
19846
|
}
|
|
19825
|
-
var NotebookInitError = class extends Error {
|
|
19826
|
-
constructor(message, data = {}) {
|
|
19827
|
-
super(message);
|
|
19828
|
-
this.message = message;
|
|
19829
|
-
this.data = data;
|
|
19830
|
-
this.name = "NotebookInitError";
|
|
19831
|
-
}
|
|
19832
|
-
};
|
|
19833
|
-
var ApiError = class extends Error {
|
|
19834
|
-
constructor(response, body) {
|
|
19835
|
-
const data = parseApiErrorBody(body);
|
|
19836
|
-
const apiMessage = apiErrorMessage(data, body);
|
|
19837
|
-
super(`PHPSandbox API Error: ${response.status} ${response.statusText}${apiMessage === "" ? "" : ` - ${apiMessage}`}`);
|
|
19838
|
-
this.response = response;
|
|
19839
|
-
this.body = body;
|
|
19840
|
-
this.status = response.status;
|
|
19841
|
-
this.data = data;
|
|
19842
|
-
this.apiMessage = apiMessage === "" ? void 0 : apiMessage;
|
|
19843
|
-
}
|
|
19844
|
-
};
|
|
19845
|
-
function parseApiErrorBody(body) {
|
|
19846
|
-
try {
|
|
19847
|
-
return JSON.parse(body);
|
|
19848
|
-
} catch {
|
|
19849
|
-
return null;
|
|
19850
|
-
}
|
|
19851
|
-
}
|
|
19852
|
-
function apiErrorMessage(data, fallback) {
|
|
19853
|
-
if (data !== null && typeof data === "object") {
|
|
19854
|
-
const record2 = data;
|
|
19855
|
-
if (typeof record2.message === "string" && record2.message.trim() !== "") {
|
|
19856
|
-
return record2.message.trim();
|
|
19857
|
-
}
|
|
19858
|
-
if (record2.error !== void 0) {
|
|
19859
|
-
return typeof record2.error === "string" ? record2.error.trim() : JSON.stringify(record2.error);
|
|
19860
|
-
}
|
|
19861
|
-
}
|
|
19862
|
-
return fallback.trim();
|
|
19863
|
-
}
|
|
19864
19847
|
var NotebookApi = class {
|
|
19865
19848
|
constructor(client) {
|
|
19866
19849
|
this.client = client;
|
|
19867
|
-
this.secrets = new NotebookSecretApi(client);
|
|
19868
|
-
this.composerCredentials = new NotebookComposerCredentialApi(client);
|
|
19869
|
-
this.preview = new NotebookPreviewApi(client);
|
|
19870
|
-
this.mail = new NotebookMailApi(client);
|
|
19871
|
-
this.publication = new NotebookPublicationApi(client);
|
|
19872
19850
|
}
|
|
19873
|
-
async create(template, input = {}
|
|
19851
|
+
async create(template, input = {}) {
|
|
19874
19852
|
const response = await this.client.post("/notebook", { template, ...input });
|
|
19875
|
-
|
|
19876
|
-
if (!init) {
|
|
19877
|
-
return instance;
|
|
19878
|
-
}
|
|
19879
|
-
return this.init(instance);
|
|
19853
|
+
return new NotebookInstance(response.data, this.client);
|
|
19880
19854
|
}
|
|
19881
19855
|
async get(id) {
|
|
19882
19856
|
const response = await this.client.get(`/notebook/${id}`);
|
|
19883
19857
|
return new NotebookInstance(response.data, this.client);
|
|
19884
19858
|
}
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
return new NotebookInstance(response.data, this.client);
|
|
19888
|
-
}
|
|
19889
|
-
async destroy(id) {
|
|
19890
|
-
await this.client.delete(`/notebook/${id}`);
|
|
19891
|
-
}
|
|
19892
|
-
async fork(id, input = {}) {
|
|
19893
|
-
const response = await this.client.post(`/notebook/${id}/fork`, input);
|
|
19894
|
-
return new NotebookInstance(response.data, this.client);
|
|
19895
|
-
}
|
|
19896
|
-
async gitCredentials(id) {
|
|
19897
|
-
const response = await this.client.post(`/notebook/${id}/git/credentials`);
|
|
19898
|
-
return response.data;
|
|
19899
|
-
}
|
|
19900
|
-
openFromData(data) {
|
|
19901
|
-
return this.init(new NotebookInstance(data, this.client));
|
|
19902
|
-
}
|
|
19903
|
-
async init(instance) {
|
|
19904
|
-
await instance.ready();
|
|
19905
|
-
return instance;
|
|
19859
|
+
open(data) {
|
|
19860
|
+
return new NotebookInstance(data, this.client);
|
|
19906
19861
|
}
|
|
19907
19862
|
};
|
|
19908
19863
|
function normalizeApiBaseUrl(url2) {
|
|
@@ -19913,15 +19868,15 @@ function normalizeApiBaseUrl(url2) {
|
|
|
19913
19868
|
baseUrl.hash = "";
|
|
19914
19869
|
return baseUrl.toString();
|
|
19915
19870
|
}
|
|
19916
|
-
var
|
|
19917
|
-
constructor(token, url2 = "https://api.phpsandbox.io/v1", options = {}) {
|
|
19918
|
-
this.runtimeTransportValue = "realtime";
|
|
19871
|
+
var ClientImplementation = class {
|
|
19872
|
+
constructor(token, url2 = "https://api.phpsandbox.io/v1", options = {}, runtimeTransport = "realtime") {
|
|
19919
19873
|
this.fetch = globalThis.fetch;
|
|
19920
19874
|
this.publications = new PublicationApi(this);
|
|
19921
19875
|
this.notebook = new NotebookApi(this);
|
|
19922
19876
|
this.servers = new ServerApi(this);
|
|
19923
19877
|
this.integrations = new IntegrationApi(this);
|
|
19924
|
-
this.options =
|
|
19878
|
+
this.options = { ...options };
|
|
19879
|
+
this.runtimeTransportValue = runtimeTransport;
|
|
19925
19880
|
this.baseUrl = normalizeApiBaseUrl(url2);
|
|
19926
19881
|
if (options.fetch) {
|
|
19927
19882
|
this.fetch = options.fetch;
|
|
@@ -19951,23 +19906,23 @@ var Client = class {
|
|
|
19951
19906
|
return this.makeRequest("PATCH", path, { body: body === void 0 ? void 0 : JSON.stringify(body) });
|
|
19952
19907
|
}
|
|
19953
19908
|
async stream(path) {
|
|
19954
|
-
const response = await this.
|
|
19955
|
-
|
|
19909
|
+
const response = await this.fetchResponse(
|
|
19910
|
+
authenticatedRequest(new URL(path.replace(/^\//, ""), this.baseUrl), {
|
|
19956
19911
|
method: "GET",
|
|
19957
19912
|
headers: this.headers
|
|
19958
19913
|
})
|
|
19959
19914
|
);
|
|
19960
19915
|
if (!response.ok) {
|
|
19961
|
-
throw
|
|
19916
|
+
throw remoteError("core", errorPayload(await responsePayload(response)), response);
|
|
19962
19917
|
}
|
|
19963
19918
|
if (!response.body) {
|
|
19964
|
-
throw new
|
|
19919
|
+
throw new TransportError("PHPSandbox API response body is not readable.", "InvalidResponse", response);
|
|
19965
19920
|
}
|
|
19966
19921
|
return response.body;
|
|
19967
19922
|
}
|
|
19968
19923
|
async sse(url2) {
|
|
19969
|
-
const response = await this.
|
|
19970
|
-
|
|
19924
|
+
const response = await this.fetchResponse(
|
|
19925
|
+
authenticatedRequest(url2, {
|
|
19971
19926
|
method: "GET",
|
|
19972
19927
|
headers: {
|
|
19973
19928
|
...this.headers,
|
|
@@ -19976,140 +19931,89 @@ var Client = class {
|
|
|
19976
19931
|
})
|
|
19977
19932
|
);
|
|
19978
19933
|
if (!response.ok) {
|
|
19979
|
-
throw
|
|
19934
|
+
throw remoteError("core", errorPayload(await responsePayload(response)), response);
|
|
19980
19935
|
}
|
|
19981
19936
|
if (!response.body) {
|
|
19982
|
-
throw new
|
|
19937
|
+
throw new TransportError("PHPSandbox API SSE response body is not readable.", "InvalidResponse", response);
|
|
19983
19938
|
}
|
|
19984
19939
|
return response.body;
|
|
19985
19940
|
}
|
|
19986
19941
|
async makeRequest(method, path, init) {
|
|
19987
|
-
const response = await this.
|
|
19988
|
-
|
|
19942
|
+
const response = await this.fetchResponse(
|
|
19943
|
+
authenticatedRequest(new URL(path.replace(/^\//, ""), this.baseUrl), {
|
|
19989
19944
|
method,
|
|
19990
19945
|
...init,
|
|
19991
19946
|
headers: this.headers
|
|
19992
19947
|
})
|
|
19993
19948
|
);
|
|
19994
19949
|
if (!response.ok) {
|
|
19995
|
-
throw
|
|
19950
|
+
throw remoteError("core", errorPayload(await responsePayload(response)), response);
|
|
19996
19951
|
}
|
|
19997
19952
|
if (response.status === 204) {
|
|
19998
19953
|
return { data: void 0 };
|
|
19999
19954
|
}
|
|
20000
19955
|
const body = await response.text();
|
|
20001
|
-
|
|
20002
|
-
|
|
20003
|
-
}
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20008
|
-
|
|
20009
|
-
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
|
|
20013
|
-
}
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
this.client = client;
|
|
20017
|
-
}
|
|
20018
|
-
async list(id, options) {
|
|
20019
|
-
const params = new URLSearchParams();
|
|
20020
|
-
if (options?.environment) params.set("environment", options.environment);
|
|
20021
|
-
const query = params.toString();
|
|
20022
|
-
const response = await this.client.get(`/notebook/${id}/secrets${query ? `?${query}` : ""}`);
|
|
20023
|
-
return response.data;
|
|
20024
|
-
}
|
|
20025
|
-
async set(id, name, input) {
|
|
20026
|
-
const payload = typeof input === "string" ? { name, value: input } : { name, ...input };
|
|
20027
|
-
const response = await this.client.put(`/notebook/${id}/secrets`, payload);
|
|
20028
|
-
return response.data;
|
|
20029
|
-
}
|
|
20030
|
-
async setMany(id, input) {
|
|
20031
|
-
const response = await this.client.put(`/notebook/${id}/secrets`, {
|
|
20032
|
-
secrets: normalizeNotebookSecretInputs(input)
|
|
20033
|
-
});
|
|
20034
|
-
return response.data;
|
|
20035
|
-
}
|
|
20036
|
-
async delete(id, name, options) {
|
|
20037
|
-
const params = new URLSearchParams();
|
|
20038
|
-
if (options?.environment) params.set("environment", options.environment);
|
|
20039
|
-
const query = params.toString();
|
|
20040
|
-
await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ""}`);
|
|
20041
|
-
}
|
|
20042
|
-
};
|
|
20043
|
-
var NotebookComposerCredentialApi = class {
|
|
20044
|
-
constructor(client) {
|
|
20045
|
-
this.client = client;
|
|
20046
|
-
}
|
|
20047
|
-
async set(id, input) {
|
|
20048
|
-
const response = await this.client.put(`/notebook/${id}/composer/credentials`, input);
|
|
20049
|
-
return response.data;
|
|
19956
|
+
if (body === "") {
|
|
19957
|
+
throw new TransportError("PHPSandbox API returned an empty response.", "InvalidResponse", response);
|
|
19958
|
+
}
|
|
19959
|
+
try {
|
|
19960
|
+
const payload = JSON.parse(body);
|
|
19961
|
+
if (payload === null || typeof payload !== "object" || Array.isArray(payload) || !Object.prototype.hasOwnProperty.call(payload, "data")) {
|
|
19962
|
+
throw new TransportError("PHPSandbox API returned an invalid success response.", "InvalidResponse", response);
|
|
19963
|
+
}
|
|
19964
|
+
return payload;
|
|
19965
|
+
} catch (error51) {
|
|
19966
|
+
if (TransportError.is(error51)) {
|
|
19967
|
+
throw error51;
|
|
19968
|
+
}
|
|
19969
|
+
throw new TransportError("PHPSandbox API returned an invalid JSON response.", "InvalidResponse", error51);
|
|
19970
|
+
}
|
|
20050
19971
|
}
|
|
20051
|
-
async
|
|
20052
|
-
|
|
20053
|
-
|
|
20054
|
-
|
|
19972
|
+
async fetchResponse(request) {
|
|
19973
|
+
try {
|
|
19974
|
+
return await this.fetch(request);
|
|
19975
|
+
} catch (error51) {
|
|
19976
|
+
if (error51 instanceof DOMException && error51.name === "AbortError") {
|
|
19977
|
+
throw error51;
|
|
19978
|
+
}
|
|
19979
|
+
throw new TransportError("Unable to reach the PHPSandbox API.", "ConnectionFailed", error51);
|
|
19980
|
+
}
|
|
20055
19981
|
}
|
|
20056
19982
|
};
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
async get(id, url2) {
|
|
20062
|
-
const query = url2 === void 0 ? "" : `?${new URLSearchParams({ url: url2 }).toString()}`;
|
|
20063
|
-
const response = await this.client.get(`/notebook/${id}/preview${query}`);
|
|
20064
|
-
return response.data;
|
|
20065
|
-
}
|
|
20066
|
-
async setPassword(id, input) {
|
|
20067
|
-
const response = await this.client.put(`/notebook/${id}/preview`, input);
|
|
20068
|
-
return response.data;
|
|
20069
|
-
}
|
|
20070
|
-
async disable(id) {
|
|
20071
|
-
await this.client.delete(`/notebook/${id}/preview`);
|
|
20072
|
-
}
|
|
20073
|
-
async createSession(id, input) {
|
|
20074
|
-
const response = await this.client.post(`/notebook/${id}/preview/session`, input);
|
|
20075
|
-
return response.data;
|
|
19983
|
+
async function responsePayload(response) {
|
|
19984
|
+
const body = await response.text();
|
|
19985
|
+
if (body === "") {
|
|
19986
|
+
return void 0;
|
|
20076
19987
|
}
|
|
20077
|
-
|
|
20078
|
-
|
|
20079
|
-
|
|
19988
|
+
try {
|
|
19989
|
+
return JSON.parse(body);
|
|
19990
|
+
} catch (error51) {
|
|
19991
|
+
throw new TransportError("PHPSandbox API returned an invalid JSON response.", "InvalidResponse", error51);
|
|
20080
19992
|
}
|
|
20081
|
-
}
|
|
20082
|
-
|
|
19993
|
+
}
|
|
19994
|
+
function errorPayload(payload) {
|
|
19995
|
+
return payload !== null && typeof payload === "object" && !Array.isArray(payload) ? payload.error : void 0;
|
|
19996
|
+
}
|
|
19997
|
+
var PHPSandbox = class _PHPSandbox {
|
|
20083
19998
|
constructor(client) {
|
|
20084
19999
|
this.client = client;
|
|
20000
|
+
this.notebook = client.notebook;
|
|
20001
|
+
this.publications = client.publications;
|
|
20002
|
+
this.servers = client.servers;
|
|
20003
|
+
this.integrations = client.integrations;
|
|
20085
20004
|
}
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
return response.data;
|
|
20089
|
-
}
|
|
20090
|
-
async enable(id) {
|
|
20091
|
-
const response = await this.client.put(`/notebook/${id}/mail`);
|
|
20092
|
-
return response.data;
|
|
20093
|
-
}
|
|
20094
|
-
async disable(id) {
|
|
20095
|
-
await this.client.delete(`/notebook/${id}/mail`);
|
|
20096
|
-
}
|
|
20097
|
-
async list(id, options = {}) {
|
|
20098
|
-
const response = await this.client.get(
|
|
20099
|
-
`/notebook/${id}/mails${formatQueryString(options)}`
|
|
20100
|
-
);
|
|
20101
|
-
return response.data;
|
|
20005
|
+
get runtimeTransport() {
|
|
20006
|
+
return this.client.runtimeTransport;
|
|
20102
20007
|
}
|
|
20103
|
-
|
|
20104
|
-
|
|
20105
|
-
return response.data;
|
|
20008
|
+
static realtime(token, url2 = "https://api.phpsandbox.io/v1", options = {}) {
|
|
20009
|
+
return new _PHPSandbox(new ClientImplementation(token, url2, options));
|
|
20106
20010
|
}
|
|
20107
|
-
|
|
20108
|
-
|
|
20011
|
+
static rest(token, url2 = "https://api.phpsandbox.io/v1", options = {}) {
|
|
20012
|
+
return new _PHPSandbox(new ClientImplementation(token, url2, options, "rest"));
|
|
20109
20013
|
}
|
|
20110
20014
|
};
|
|
20111
20015
|
var _initPromise, _NotebookInstance_instances, init_fn;
|
|
20112
|
-
var
|
|
20016
|
+
var _NotebookInstance = class _NotebookInstance {
|
|
20113
20017
|
constructor(data, client) {
|
|
20114
20018
|
this.data = data;
|
|
20115
20019
|
this.client = client;
|
|
@@ -20138,7 +20042,6 @@ var NotebookInstance = class {
|
|
|
20138
20042
|
};
|
|
20139
20043
|
this.socket = new Transport(connectionUrl, this.emitter, {
|
|
20140
20044
|
debug: client.options.debug,
|
|
20141
|
-
startClosed: client.options.startClosed,
|
|
20142
20045
|
webSocket: client.options.webSocket
|
|
20143
20046
|
});
|
|
20144
20047
|
this.watchConnection();
|
|
@@ -20152,12 +20055,8 @@ var NotebookInstance = class {
|
|
|
20152
20055
|
this.auth = new Auth(this);
|
|
20153
20056
|
this.lsp = new Lsp(this);
|
|
20154
20057
|
this.composer = new Composer(this, client);
|
|
20155
|
-
|
|
20156
|
-
this.logs = new Logs(this, telemetry);
|
|
20157
|
-
this.metrics = new Metrics(this, telemetry);
|
|
20158
|
-
this.ports = new Ports(this, telemetry);
|
|
20058
|
+
this.runtime = new Runtime(this);
|
|
20159
20059
|
this.repl = new Repl(this);
|
|
20160
|
-
this.container = new Container(this);
|
|
20161
20060
|
this.shell = new Shell(this);
|
|
20162
20061
|
this.git = new Git(this, client);
|
|
20163
20062
|
this.services = new Services(this);
|
|
@@ -20181,21 +20080,33 @@ var NotebookInstance = class {
|
|
|
20181
20080
|
throw terminalError;
|
|
20182
20081
|
}
|
|
20183
20082
|
const ready = async () => {
|
|
20184
|
-
if (
|
|
20083
|
+
if (!socket.isConnected) {
|
|
20185
20084
|
await socket.connect();
|
|
20186
20085
|
}
|
|
20187
20086
|
return __privateGet(this, _initPromise);
|
|
20188
20087
|
};
|
|
20189
20088
|
return ready();
|
|
20190
20089
|
}
|
|
20191
|
-
fork(input = {}) {
|
|
20192
|
-
|
|
20090
|
+
async fork(input = {}) {
|
|
20091
|
+
const response = await this.client.post(`/notebook/${this.data.id}/fork`, input);
|
|
20092
|
+
return new _NotebookInstance(response.data, this.client);
|
|
20193
20093
|
}
|
|
20194
|
-
publication() {
|
|
20195
|
-
|
|
20094
|
+
async publication() {
|
|
20095
|
+
try {
|
|
20096
|
+
const response = await this.client.get(`/notebook/${this.data.id}/publication`);
|
|
20097
|
+
return new PublicationInstance(response.data, this.client, this.data.id);
|
|
20098
|
+
} catch (error51) {
|
|
20099
|
+
if (RemoteError.is(error51) && error51.status === 404) {
|
|
20100
|
+
return null;
|
|
20101
|
+
}
|
|
20102
|
+
throw error51;
|
|
20103
|
+
}
|
|
20196
20104
|
}
|
|
20197
|
-
publish(input) {
|
|
20198
|
-
|
|
20105
|
+
async publish(input) {
|
|
20106
|
+
const response = await this.client.post(`/notebook/${this.data.id}/publication`, input);
|
|
20107
|
+
const run = new PublicationRun(new PublicationInstance(response.data, this.client, this.data.id), this.client);
|
|
20108
|
+
run.start();
|
|
20109
|
+
return run;
|
|
20199
20110
|
}
|
|
20200
20111
|
run(command, argsOrOpts = [], opts) {
|
|
20201
20112
|
if (Array.isArray(argsOrOpts)) {
|
|
@@ -20209,19 +20120,20 @@ var NotebookInstance = class {
|
|
|
20209
20120
|
}
|
|
20210
20121
|
return this.run(command, argsOrOpts).wait();
|
|
20211
20122
|
}
|
|
20212
|
-
|
|
20213
|
-
|
|
20123
|
+
async destroy() {
|
|
20124
|
+
await this.client.delete(`/notebook/${this.data.id}`);
|
|
20125
|
+
this.socket?.terminate(new RemoteError("Notebook has been deleted.", {
|
|
20126
|
+
source: "runtime",
|
|
20127
|
+
status: 503,
|
|
20128
|
+
code: "NotebookUnavailable",
|
|
20129
|
+
details: { id: this.data.id }
|
|
20130
|
+
}));
|
|
20214
20131
|
}
|
|
20215
|
-
|
|
20216
|
-
return this.
|
|
20217
|
-
this.socket?.terminate(new NotebookUnavailableError("Notebook has been deleted.", { id: this.data.id }));
|
|
20218
|
-
});
|
|
20132
|
+
restart() {
|
|
20133
|
+
return this.invoke("container.restart");
|
|
20219
20134
|
}
|
|
20220
20135
|
stop() {
|
|
20221
|
-
return this.container.stop
|
|
20222
|
-
}
|
|
20223
|
-
restart() {
|
|
20224
|
-
return this.container.restart();
|
|
20136
|
+
return this.invoke("container.stop");
|
|
20225
20137
|
}
|
|
20226
20138
|
invoke(action, data = {}, options = {}) {
|
|
20227
20139
|
if (this.restInvoker !== null) {
|
|
@@ -20238,9 +20150,6 @@ var NotebookInstance = class {
|
|
|
20238
20150
|
}
|
|
20239
20151
|
return this.realtimeSocket().send(action, data || {});
|
|
20240
20152
|
}
|
|
20241
|
-
ping() {
|
|
20242
|
-
return this.invoke("ping");
|
|
20243
|
-
}
|
|
20244
20153
|
listen(event, handler) {
|
|
20245
20154
|
const disposable = this.emitter.listen(event, handler);
|
|
20246
20155
|
this.disposables.push(disposable);
|
|
@@ -20255,9 +20164,6 @@ var NotebookInstance = class {
|
|
|
20255
20164
|
connected() {
|
|
20256
20165
|
return this.waitForSocketConnection({ rejectOnClose: true });
|
|
20257
20166
|
}
|
|
20258
|
-
whenConnected() {
|
|
20259
|
-
return this.waitForSocketConnection({ rejectOnClose: false });
|
|
20260
|
-
}
|
|
20261
20167
|
waitForSocketConnection(options) {
|
|
20262
20168
|
const socket = this.realtimeSocket();
|
|
20263
20169
|
const terminalError = socket.getTerminalError();
|
|
@@ -20329,7 +20235,7 @@ var NotebookInstance = class {
|
|
|
20329
20235
|
}
|
|
20330
20236
|
restInitialization() {
|
|
20331
20237
|
if (this.restInvoker === null) {
|
|
20332
|
-
throw new
|
|
20238
|
+
throw new PHPSandboxError("This operation requires the REST transport.");
|
|
20333
20239
|
}
|
|
20334
20240
|
if (__privateGet(this, _initPromise) === null) {
|
|
20335
20241
|
__privateSet(this, _initPromise, this.restInvoker.ready().then((result) => {
|
|
@@ -20342,15 +20248,12 @@ var NotebookInstance = class {
|
|
|
20342
20248
|
}
|
|
20343
20249
|
return __privateGet(this, _initPromise);
|
|
20344
20250
|
}
|
|
20345
|
-
update(input) {
|
|
20346
|
-
return this.client.notebook.update(this.data.id, input);
|
|
20347
|
-
}
|
|
20348
20251
|
onDidInitialize(handler) {
|
|
20349
20252
|
return this.listen("notebook.initialized", handler);
|
|
20350
20253
|
}
|
|
20351
20254
|
async reconnect() {
|
|
20352
20255
|
const socket = this.realtimeSocket();
|
|
20353
|
-
const whenConnected = this.
|
|
20256
|
+
const whenConnected = this.waitForSocketConnection({ rejectOnClose: false });
|
|
20354
20257
|
socket.reconnect();
|
|
20355
20258
|
this.initialized = false;
|
|
20356
20259
|
await whenConnected;
|
|
@@ -20359,7 +20262,7 @@ var NotebookInstance = class {
|
|
|
20359
20262
|
}
|
|
20360
20263
|
realtimeSocket() {
|
|
20361
20264
|
if (this.socket === null) {
|
|
20362
|
-
throw new
|
|
20265
|
+
throw new PHPSandboxError("This operation requires the realtime transport.");
|
|
20363
20266
|
}
|
|
20364
20267
|
return this.socket;
|
|
20365
20268
|
}
|
|
@@ -20373,7 +20276,12 @@ init_fn = function() {
|
|
|
20373
20276
|
initializationListener.dispose();
|
|
20374
20277
|
this.initialized = result;
|
|
20375
20278
|
if (result.type === "error") {
|
|
20376
|
-
reject(new
|
|
20279
|
+
reject(new RemoteError(result.message, {
|
|
20280
|
+
source: "runtime",
|
|
20281
|
+
status: 503,
|
|
20282
|
+
code: "NotebookInitializationFailed",
|
|
20283
|
+
details: result.data
|
|
20284
|
+
}));
|
|
20377
20285
|
return;
|
|
20378
20286
|
}
|
|
20379
20287
|
resolve(result);
|
|
@@ -20388,34 +20296,39 @@ init_fn = function() {
|
|
|
20388
20296
|
});
|
|
20389
20297
|
return __privateGet(this, _initPromise);
|
|
20390
20298
|
};
|
|
20299
|
+
var NotebookInstance = _NotebookInstance;
|
|
20391
20300
|
var NotebookSecrets = class {
|
|
20392
20301
|
constructor(client, notebookId) {
|
|
20393
20302
|
this.client = client;
|
|
20394
20303
|
this.notebookId = notebookId;
|
|
20395
20304
|
}
|
|
20396
|
-
list(options) {
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
return
|
|
20404
|
-
}
|
|
20405
|
-
delete(name, options) {
|
|
20406
|
-
return this.client.notebook.secrets.delete(this.notebookId, name, options);
|
|
20305
|
+
async list(options) {
|
|
20306
|
+
const params = new URLSearchParams();
|
|
20307
|
+
if (options?.environment) params.set("environment", options.environment);
|
|
20308
|
+
const query = params.toString();
|
|
20309
|
+
const response = await this.client.get(
|
|
20310
|
+
`/notebook/${this.notebookId}/secrets${query ? `?${query}` : ""}`
|
|
20311
|
+
);
|
|
20312
|
+
return response.data;
|
|
20407
20313
|
}
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
this.notebookId = notebookId;
|
|
20314
|
+
async set(name, input) {
|
|
20315
|
+
const payload = typeof input === "string" ? { name, value: input } : { name, ...input };
|
|
20316
|
+
const response = await this.client.put(`/notebook/${this.notebookId}/secrets`, payload);
|
|
20317
|
+
return response.data;
|
|
20413
20318
|
}
|
|
20414
|
-
|
|
20415
|
-
|
|
20319
|
+
async setMany(input) {
|
|
20320
|
+
const response = await this.client.put(`/notebook/${this.notebookId}/secrets`, {
|
|
20321
|
+
secrets: normalizeNotebookSecretInputs(input)
|
|
20322
|
+
});
|
|
20323
|
+
return response.data;
|
|
20416
20324
|
}
|
|
20417
|
-
|
|
20418
|
-
|
|
20325
|
+
async delete(name, options) {
|
|
20326
|
+
const params = new URLSearchParams();
|
|
20327
|
+
if (options?.environment) params.set("environment", options.environment);
|
|
20328
|
+
const query = params.toString();
|
|
20329
|
+
await this.client.delete(
|
|
20330
|
+
`/notebook/${this.notebookId}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ""}`
|
|
20331
|
+
);
|
|
20419
20332
|
}
|
|
20420
20333
|
};
|
|
20421
20334
|
var NotebookPreview = class {
|
|
@@ -20423,20 +20336,31 @@ var NotebookPreview = class {
|
|
|
20423
20336
|
this.client = client;
|
|
20424
20337
|
this.notebookId = notebookId;
|
|
20425
20338
|
}
|
|
20426
|
-
get(url2) {
|
|
20427
|
-
|
|
20339
|
+
async get(url2) {
|
|
20340
|
+
const query = url2 === void 0 ? "" : `?${new URLSearchParams({ url: url2 }).toString()}`;
|
|
20341
|
+
const response = await this.client.get(`/notebook/${this.notebookId}/preview${query}`);
|
|
20342
|
+
return response.data;
|
|
20428
20343
|
}
|
|
20429
|
-
setPassword(input) {
|
|
20430
|
-
|
|
20344
|
+
async setPassword(input) {
|
|
20345
|
+
const response = await this.client.put(`/notebook/${this.notebookId}/preview`, input);
|
|
20346
|
+
return response.data;
|
|
20431
20347
|
}
|
|
20432
|
-
disable() {
|
|
20433
|
-
|
|
20348
|
+
async disable() {
|
|
20349
|
+
await this.client.delete(`/notebook/${this.notebookId}/preview`);
|
|
20434
20350
|
}
|
|
20435
|
-
createSession(input) {
|
|
20436
|
-
|
|
20351
|
+
async createSession(input) {
|
|
20352
|
+
const response = await this.client.post(
|
|
20353
|
+
`/notebook/${this.notebookId}/preview/session`,
|
|
20354
|
+
input
|
|
20355
|
+
);
|
|
20356
|
+
return response.data;
|
|
20437
20357
|
}
|
|
20438
|
-
createHandoff(input) {
|
|
20439
|
-
|
|
20358
|
+
async createHandoff(input) {
|
|
20359
|
+
const response = await this.client.post(
|
|
20360
|
+
`/notebook/${this.notebookId}/preview/handoff`,
|
|
20361
|
+
input
|
|
20362
|
+
);
|
|
20363
|
+
return response.data;
|
|
20440
20364
|
}
|
|
20441
20365
|
};
|
|
20442
20366
|
var NotebookMail = class {
|
|
@@ -20444,23 +20368,30 @@ var NotebookMail = class {
|
|
|
20444
20368
|
this.client = client;
|
|
20445
20369
|
this.notebookId = notebookId;
|
|
20446
20370
|
}
|
|
20447
|
-
status() {
|
|
20448
|
-
|
|
20371
|
+
async status() {
|
|
20372
|
+
const response = await this.client.get(`/notebook/${this.notebookId}/mail`);
|
|
20373
|
+
return response.data;
|
|
20449
20374
|
}
|
|
20450
|
-
enable() {
|
|
20451
|
-
|
|
20375
|
+
async enable() {
|
|
20376
|
+
const response = await this.client.put(`/notebook/${this.notebookId}/mail`);
|
|
20377
|
+
return response.data;
|
|
20452
20378
|
}
|
|
20453
|
-
disable() {
|
|
20454
|
-
|
|
20379
|
+
async disable() {
|
|
20380
|
+
await this.client.delete(`/notebook/${this.notebookId}/mail`);
|
|
20455
20381
|
}
|
|
20456
|
-
list(options = {}) {
|
|
20457
|
-
return this.client.
|
|
20382
|
+
async list(options = {}) {
|
|
20383
|
+
return this.client.get(
|
|
20384
|
+
`/notebook/${this.notebookId}/mails${formatQueryString(options)}`
|
|
20385
|
+
);
|
|
20458
20386
|
}
|
|
20459
|
-
get(hash2) {
|
|
20460
|
-
|
|
20387
|
+
async get(hash2) {
|
|
20388
|
+
const response = await this.client.get(
|
|
20389
|
+
`/notebook/${this.notebookId}/mails/${encodeURIComponent(hash2)}`
|
|
20390
|
+
);
|
|
20391
|
+
return response.data;
|
|
20461
20392
|
}
|
|
20462
|
-
delete(hash2) {
|
|
20463
|
-
|
|
20393
|
+
async delete(hash2) {
|
|
20394
|
+
await this.client.delete(`/notebook/${this.notebookId}/mails/${encodeURIComponent(hash2)}`);
|
|
20464
20395
|
}
|
|
20465
20396
|
};
|
|
20466
20397
|
function formatQueryString(params) {
|
|
@@ -20474,88 +20405,17 @@ function formatQueryString(params) {
|
|
|
20474
20405
|
return query === "" ? "" : `?${query}`;
|
|
20475
20406
|
}
|
|
20476
20407
|
export {
|
|
20477
|
-
ApiError,
|
|
20478
|
-
Client,
|
|
20479
|
-
CommandError,
|
|
20480
|
-
ComposerCredentials,
|
|
20481
|
-
ErrorEvent,
|
|
20482
|
-
Feedback,
|
|
20483
20408
|
FileChangeFilter,
|
|
20484
20409
|
FileChangeType,
|
|
20485
20410
|
FileType,
|
|
20486
|
-
Filesystem,
|
|
20487
|
-
FilesystemError,
|
|
20488
|
-
FilesystemErrorType,
|
|
20489
|
-
GitTarget,
|
|
20490
|
-
GitTargetApi,
|
|
20491
|
-
Integration,
|
|
20492
|
-
IntegrationApi,
|
|
20493
20411
|
LspConnection,
|
|
20494
|
-
NotebookApi,
|
|
20495
|
-
NotebookComposerCredentialApi,
|
|
20496
|
-
NotebookInitError,
|
|
20497
20412
|
NotebookInstance,
|
|
20498
|
-
NotebookMail,
|
|
20499
|
-
NotebookMailApi,
|
|
20500
|
-
NotebookPreview,
|
|
20501
|
-
NotebookPreviewApi,
|
|
20502
|
-
NotebookPublicationApi,
|
|
20503
|
-
NotebookSecretApi,
|
|
20504
|
-
NotebookSecrets,
|
|
20505
|
-
NotebookState,
|
|
20506
|
-
NotebookUnavailableError,
|
|
20507
20413
|
PHPSandbox,
|
|
20508
20414
|
PHPSandboxError,
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
PromiseTimeoutError,
|
|
20512
|
-
PublicationApi,
|
|
20513
|
-
PublicationBuildStatusSchema,
|
|
20514
|
-
PublicationDomainDnsRecordTypeSchema,
|
|
20515
|
-
PublicationEventDataSchema,
|
|
20516
|
-
PublicationInstance,
|
|
20517
|
-
PublicationJurisdictionSchema,
|
|
20518
|
-
PublicationLogChunkDataSchema,
|
|
20519
|
-
PublicationLogStreamSchema,
|
|
20520
|
-
PublicationProtectionModeSchema,
|
|
20521
|
-
PublicationProviderNameSchema,
|
|
20522
|
-
PublicationRegionSchema,
|
|
20523
|
-
PublicationReleaseStatusSchema,
|
|
20524
|
-
PublicationRun,
|
|
20525
|
-
PublicationSizeSchema,
|
|
20526
|
-
PublicationStatusSchema,
|
|
20527
|
-
PublishStreamErrorSchema,
|
|
20528
|
-
PublishStreamEventSchema,
|
|
20529
|
-
PublishStreamLogEventSchema,
|
|
20530
|
-
PublishStreamLogSchema,
|
|
20531
|
-
PublishStreamLogStreamSchema,
|
|
20532
|
-
PublishStreamPhaseEventSchema,
|
|
20533
|
-
PublishStreamPhaseSchema,
|
|
20534
|
-
PublishStreamResultEventSchema,
|
|
20535
|
-
PublishStreamResultSchema,
|
|
20536
|
-
PublishStreamSseDoneEventSchema,
|
|
20537
|
-
PublishStreamSseErrorEventSchema,
|
|
20538
|
-
PublishStreamSseEventNameSchema,
|
|
20539
|
-
PublishStreamSseEventSchema,
|
|
20540
|
-
PublishStreamSseLogEventSchema,
|
|
20541
|
-
PublishStreamSsePhaseEventSchema,
|
|
20542
|
-
PublishStreamSseResultEventSchema,
|
|
20543
|
-
RateLimitError,
|
|
20544
|
-
RuntimeTelemetry,
|
|
20545
|
-
SandboxIntegration,
|
|
20546
|
-
SandboxIntegrationApi,
|
|
20547
|
-
SendTimeoutError,
|
|
20548
|
-
ServerApi,
|
|
20549
|
-
ServerInstance,
|
|
20550
|
-
ShellProcess,
|
|
20551
|
-
UnsupportedRuntimeTransportError,
|
|
20552
|
-
integrationId,
|
|
20415
|
+
RemoteError,
|
|
20416
|
+
TransportError,
|
|
20553
20417
|
notebookBuiltinServices,
|
|
20554
|
-
notebookKnownServices
|
|
20555
|
-
once,
|
|
20556
|
-
sandboxIntegrationId,
|
|
20557
|
-
timeout,
|
|
20558
|
-
watchRuntimeTelemetry
|
|
20418
|
+
notebookKnownServices
|
|
20559
20419
|
};
|
|
20560
20420
|
/*! Bundled license information:
|
|
20561
20421
|
|