@phpsandbox/sdk 0.1.14 → 0.1.15
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 +6 -1
- 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';
|
|
@@ -211,11 +211,14 @@ export interface NotebookPreviewDataEnabled {
|
|
|
211
211
|
export type NotebookPreviewData = NotebookPreviewDataDisabled | NotebookPreviewDataEnabled;
|
|
212
212
|
export type NotebookPreviewDataWithUrl = NotebookPreviewDataDisabled | (NotebookPreviewDataEnabled & {
|
|
213
213
|
url: string;
|
|
214
|
+
accessUrl: string;
|
|
214
215
|
});
|
|
215
216
|
export interface SetNotebookPreviewInput {
|
|
216
217
|
password: string;
|
|
217
218
|
}
|
|
218
219
|
export interface NotebookPreviewSessionData {
|
|
220
|
+
/** Open this URL to establish preview access. */
|
|
221
|
+
accessUrl: string;
|
|
219
222
|
previewSessionId: string;
|
|
220
223
|
token: string;
|
|
221
224
|
expiresAt: string;
|
|
@@ -230,6 +233,8 @@ export interface CreateNotebookPreviewHandoffInput {
|
|
|
230
233
|
url: string;
|
|
231
234
|
}
|
|
232
235
|
export interface NotebookPreviewHandoffData {
|
|
236
|
+
/** Open this URL to establish preview access. */
|
|
237
|
+
accessUrl: string;
|
|
233
238
|
handoffId: string;
|
|
234
239
|
previewSessionId: string;
|
|
235
240
|
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) {
|