@phpsandbox/sdk 0.1.14 → 0.1.16
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/dist/browser/phpsandbox-sdk.esm.js +18 -11
- package/dist/browser/phpsandbox-sdk.esm.min.js +9 -9
- package/dist/browser/phpsandbox-sdk.iife.js +18 -11
- package/dist/browser/phpsandbox-sdk.iife.min.js +9 -9
- package/dist/errors/index.d.ts +7 -1
- package/dist/errors/index.js +2 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.js +11 -10
- package/package.json +1 -1
package/dist/errors/index.d.ts
CHANGED
|
@@ -29,9 +29,15 @@ export declare class RemoteError<TCode extends RemoteErrorCode = RemoteErrorCode
|
|
|
29
29
|
};
|
|
30
30
|
is<TExpectedCode extends RemoteErrorCode>(code: TExpectedCode): this is this & RemoteError<TExpectedCode>;
|
|
31
31
|
}
|
|
32
|
+
export interface HttpResponseDiagnostics {
|
|
33
|
+
readonly status: number;
|
|
34
|
+
readonly statusText: string;
|
|
35
|
+
readonly body: string;
|
|
36
|
+
}
|
|
32
37
|
export declare class TransportError<TCode extends TransportErrorCode = TransportErrorCode> extends PHPSandboxError {
|
|
33
38
|
readonly code: TCode;
|
|
34
|
-
|
|
39
|
+
readonly response?: HttpResponseDiagnostics;
|
|
40
|
+
constructor(message: string, code: TCode, cause?: unknown, response?: HttpResponseDiagnostics);
|
|
35
41
|
static is(error: unknown): error is TransportError;
|
|
36
42
|
static is<TCode extends TransportErrorCode>(error: unknown, code: TCode): error is TransportError<TCode>;
|
|
37
43
|
is<TExpectedCode extends TransportErrorCode>(code: TExpectedCode): this is this & TransportError<TExpectedCode>;
|
package/dist/errors/index.js
CHANGED
|
@@ -56,9 +56,10 @@ export class RemoteError extends PHPSandboxError {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
export class TransportError extends PHPSandboxError {
|
|
59
|
-
constructor(message, code, cause) {
|
|
59
|
+
constructor(message, code, cause, response) {
|
|
60
60
|
super(message, cause);
|
|
61
61
|
this.code = code;
|
|
62
|
+
this.response = response;
|
|
62
63
|
}
|
|
63
64
|
static is(error, code) {
|
|
64
65
|
return error instanceof TransportError && (code === undefined || error.code === code);
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { notebookBuiltinServices, notebookKnownServices } from './services.js';
|
|
|
31
31
|
export type { NotebookBuiltinServiceName, NotebookKnownServiceName, NotebookServiceCommand, NotebookServiceKind, NotebookServiceName, NotebookServiceSource, NotebookServiceState, NotebookServiceStatus, ServiceLogOptions, ServiceLogStreamOptions, } from './services.js';
|
|
32
32
|
export type { ConfigPortMapping, ProjectConfig } from './config.js';
|
|
33
33
|
export { PHPSandboxError, RemoteError, TransportError, } from './errors/index.js';
|
|
34
|
-
export type { RemoteErrorCode, RemoteErrorSource, TransportErrorCode, ValidationErrorDetails, } from './errors/index.js';
|
|
34
|
+
export type { HttpResponseDiagnostics, RemoteErrorCode, RemoteErrorSource, TransportErrorCode, ValidationErrorDetails, } from './errors/index.js';
|
|
35
35
|
export type { BuiltInPublicationProviderName, CloudflareContainersProviderOptions, LaravelCloudProviderData, LaravelCloudProviderInput, LaravelCloudRegion, PublicationBuildData, PublicationBuildStatus, PublicationData, PublicationEventData, PublicationInstance, PublicationJurisdiction, PublicationLogChunkData, PublicationLogStream, PublicationPlacement, PublicationProtectionData, PublicationProtectionInput, PublicationProtectionMode, PublicationProtectionSessionData, PublicationProvider, PublicationProviderData, PublicationProviderInput, PublicationProviderInputs, PublicationProviderName, PublicationRegion, PublicationReleaseData, PublicationReleaseStatus, PublicationRun, PublicationSize, PublicationStatus, PublishInput, PublishStreamEvent, PublishStreamLog, PublishStreamPhase, PublishStreamResult, PublishStreamSseEvent, SshServerProviderOptions, UpdatePublicationProtectionInput, } from './publications.js';
|
|
36
36
|
export type { CreateServerInput, ServerData, ServerInstance, ServerListOptions, ServerSshOptions } from './servers.js';
|
|
37
37
|
export type { ConfigureFeedbackInput, FeedbackData, FeedbackListOptions, FeedbackSource, FeedbackStatus, FeedbackType, FeedbackWidgetConfig, FeedbackWidgetTarget, SubmitFeedbackInput, UpdateFeedbackInput, } from './feedback.js';
|
|
@@ -52,16 +52,25 @@ export type NotebookInitResponse = {
|
|
|
52
52
|
provisioned: boolean;
|
|
53
53
|
provisioningAction: NotebookProvisioningAction | null;
|
|
54
54
|
};
|
|
55
|
-
export
|
|
56
|
-
|
|
55
|
+
export interface NotebookDownloadProgress {
|
|
56
|
+
totalBytes: number;
|
|
57
|
+
downloadedBytes: number;
|
|
58
|
+
}
|
|
59
|
+
export interface NotebookInitProgressMessage {
|
|
57
60
|
message: string;
|
|
58
61
|
details?: string;
|
|
59
|
-
kind?: NotebookInitProgressKind;
|
|
60
62
|
step?: string;
|
|
61
63
|
line?: string;
|
|
62
64
|
chunk?: string;
|
|
63
65
|
command?: string;
|
|
64
66
|
}
|
|
67
|
+
export type NotebookInitProgress = NotebookInitProgressMessage & ({
|
|
68
|
+
phase: 'downloading';
|
|
69
|
+
download: NotebookDownloadProgress;
|
|
70
|
+
} | {
|
|
71
|
+
phase: 'waiting' | 'preparing' | 'extracting' | 'provisioning' | 'starting';
|
|
72
|
+
download?: never;
|
|
73
|
+
});
|
|
65
74
|
export type NotebookInitErrorCode = 'GitHubImportCredentialMissing' | 'NotebookDiskQuotaExceeded' | 'NotebookNotFound' | 'NotebookSetupJsonInvalid' | 'NotebookBackupRestoreFailed';
|
|
66
75
|
export interface NotebookInitErrorData {
|
|
67
76
|
errorCode?: NotebookInitErrorCode;
|
|
@@ -211,11 +220,14 @@ export interface NotebookPreviewDataEnabled {
|
|
|
211
220
|
export type NotebookPreviewData = NotebookPreviewDataDisabled | NotebookPreviewDataEnabled;
|
|
212
221
|
export type NotebookPreviewDataWithUrl = NotebookPreviewDataDisabled | (NotebookPreviewDataEnabled & {
|
|
213
222
|
url: string;
|
|
223
|
+
accessUrl: string;
|
|
214
224
|
});
|
|
215
225
|
export interface SetNotebookPreviewInput {
|
|
216
226
|
password: string;
|
|
217
227
|
}
|
|
218
228
|
export interface NotebookPreviewSessionData {
|
|
229
|
+
/** Open this URL to establish preview access. */
|
|
230
|
+
accessUrl: string;
|
|
219
231
|
previewSessionId: string;
|
|
220
232
|
token: string;
|
|
221
233
|
expiresAt: string;
|
|
@@ -230,6 +242,8 @@ export interface CreateNotebookPreviewHandoffInput {
|
|
|
230
242
|
url: string;
|
|
231
243
|
}
|
|
232
244
|
export interface NotebookPreviewHandoffData {
|
|
245
|
+
/** Open this URL to establish preview access. */
|
|
246
|
+
accessUrl: string;
|
|
233
247
|
handoffId: string;
|
|
234
248
|
previewSessionId: string;
|
|
235
249
|
token: string;
|
package/dist/index.js
CHANGED
|
@@ -114,7 +114,7 @@ class ClientImplementation {
|
|
|
114
114
|
headers: this.headers,
|
|
115
115
|
}));
|
|
116
116
|
if (!response.ok) {
|
|
117
|
-
throw
|
|
117
|
+
throw await responseError(response);
|
|
118
118
|
}
|
|
119
119
|
if (!response.body) {
|
|
120
120
|
throw new TransportError('PHPSandbox API response body is not readable.', 'InvalidResponse', response);
|
|
@@ -130,7 +130,7 @@ class ClientImplementation {
|
|
|
130
130
|
},
|
|
131
131
|
}));
|
|
132
132
|
if (!response.ok) {
|
|
133
|
-
throw
|
|
133
|
+
throw await responseError(response);
|
|
134
134
|
}
|
|
135
135
|
if (!response.body) {
|
|
136
136
|
throw new TransportError('PHPSandbox API SSE response body is not readable.', 'InvalidResponse', response);
|
|
@@ -144,7 +144,7 @@ class ClientImplementation {
|
|
|
144
144
|
headers: this.headers,
|
|
145
145
|
}));
|
|
146
146
|
if (!response.ok) {
|
|
147
|
-
throw
|
|
147
|
+
throw await responseError(response);
|
|
148
148
|
}
|
|
149
149
|
if (response.status === 204) {
|
|
150
150
|
return { data: undefined };
|
|
@@ -179,16 +179,17 @@ class ClientImplementation {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
async function
|
|
182
|
+
async function responseError(response) {
|
|
183
183
|
const body = await response.text();
|
|
184
|
-
if (body === '') {
|
|
185
|
-
return undefined;
|
|
186
|
-
}
|
|
187
184
|
try {
|
|
188
|
-
return JSON.parse(body);
|
|
185
|
+
return remoteError('core', errorPayload(body === '' ? undefined : JSON.parse(body)), response);
|
|
189
186
|
}
|
|
190
|
-
catch
|
|
191
|
-
|
|
187
|
+
catch {
|
|
188
|
+
return new TransportError(`PHPSandbox API returned an invalid error response (HTTP ${response.status}).`, 'InvalidResponse', response, {
|
|
189
|
+
status: response.status,
|
|
190
|
+
statusText: response.statusText,
|
|
191
|
+
body,
|
|
192
|
+
});
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
function errorPayload(payload) {
|