@phpsandbox/sdk 0.1.17 → 0.1.19
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 +39 -3
- package/dist/browser/phpsandbox-sdk.esm.min.js +9 -9
- package/dist/browser/phpsandbox-sdk.iife.js +39 -3
- package/dist/browser/phpsandbox-sdk.iife.min.js +9 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/publications.d.ts +36 -0
- package/dist/publications.js +37 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type { NotebookBuiltinServiceName, NotebookKnownServiceName, NotebookServ
|
|
|
32
32
|
export type { ConfigPortMapping, ProjectConfig } from './config.js';
|
|
33
33
|
export { PHPSandboxError, RemoteError, TransportError, } from './errors/index.js';
|
|
34
34
|
export type { HttpResponseDiagnostics, RemoteErrorCode, RemoteErrorSource, TransportErrorCode, ValidationErrorDetails, } from './errors/index.js';
|
|
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';
|
|
35
|
+
export type { BuiltInPublicationProviderName, CloudflareContainersProviderOptions, LaravelCloudProviderData, LaravelCloudProviderInput, LaravelCloudRegion, PublicationBuildData, PublicationBuildStatus, PublicationData, PublicationDomainData, PublicationDomains, 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';
|
|
38
38
|
export type { Integration, IntegrationAuthorization, IntegrationAuthorizationType, IntegrationData, IntegrationProvider, IntegrationReference, LinkIntegrationInput, UpdateIntegrationInput, AttachSandboxIntegrationInput, SandboxIntegration, SandboxIntegrationData, SandboxIntegrationEffect, SandboxIntegrationReference, UpdateSandboxIntegrationInput, } from './integrations/index.js';
|
|
@@ -340,7 +340,7 @@ declare class ClientImplementation {
|
|
|
340
340
|
data: T;
|
|
341
341
|
}>;
|
|
342
342
|
stream(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
343
|
-
sse(url: string): Promise<ReadableStream<Uint8Array>>;
|
|
343
|
+
sse(url: string, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
344
344
|
private makeRequest;
|
|
345
345
|
private fetchResponse;
|
|
346
346
|
}
|
package/dist/index.js
CHANGED
|
@@ -124,13 +124,14 @@ class ClientImplementation {
|
|
|
124
124
|
}
|
|
125
125
|
return response.body;
|
|
126
126
|
}
|
|
127
|
-
async sse(url) {
|
|
127
|
+
async sse(url, signal) {
|
|
128
128
|
const response = await this.fetchResponse(authenticatedRequest(url, {
|
|
129
129
|
method: 'GET',
|
|
130
130
|
headers: {
|
|
131
131
|
...this.headers,
|
|
132
132
|
'Accept': 'text/event-stream',
|
|
133
133
|
},
|
|
134
|
+
...(signal === undefined ? {} : { signal }),
|
|
134
135
|
}));
|
|
135
136
|
if (!response.ok) {
|
|
136
137
|
throw await responseError(response);
|
package/dist/publications.d.ts
CHANGED
|
@@ -106,6 +106,38 @@ export interface PublicationProtectionSessionData {
|
|
|
106
106
|
expiresAt: string;
|
|
107
107
|
url: string;
|
|
108
108
|
}
|
|
109
|
+
export interface PublicationDomainData {
|
|
110
|
+
id: string;
|
|
111
|
+
publicationId: string | null;
|
|
112
|
+
hostname: string;
|
|
113
|
+
status: string;
|
|
114
|
+
provider: string;
|
|
115
|
+
providerHostnameId: string | null;
|
|
116
|
+
dns: {
|
|
117
|
+
type: string | null;
|
|
118
|
+
name: string | null;
|
|
119
|
+
value: string | null;
|
|
120
|
+
};
|
|
121
|
+
ssl: {
|
|
122
|
+
status: string | null;
|
|
123
|
+
};
|
|
124
|
+
validationErrors: unknown[];
|
|
125
|
+
validationRecords: unknown[];
|
|
126
|
+
metadata: Record<string, unknown>;
|
|
127
|
+
verifiedAt: string | null;
|
|
128
|
+
createdAt: string | null;
|
|
129
|
+
updatedAt: string | null;
|
|
130
|
+
}
|
|
131
|
+
export declare class PublicationDomains {
|
|
132
|
+
private readonly client;
|
|
133
|
+
private readonly publicationId;
|
|
134
|
+
constructor(client: Client, publicationId: string);
|
|
135
|
+
list(): Promise<PublicationDomainData[]>;
|
|
136
|
+
create(hostname: string): Promise<PublicationDomainData>;
|
|
137
|
+
refresh(id: string): Promise<PublicationDomainData>;
|
|
138
|
+
delete(id: string): Promise<void>;
|
|
139
|
+
private path;
|
|
140
|
+
}
|
|
109
141
|
export declare class PublicationApi {
|
|
110
142
|
private readonly client;
|
|
111
143
|
constructor(client: Client);
|
|
@@ -114,6 +146,7 @@ export declare class PublicationApi {
|
|
|
114
146
|
export declare class PublicationRun<TProvider extends PublicationProviderName = PublicationProviderName> {
|
|
115
147
|
readonly initial: PublicationInstance<TProvider>;
|
|
116
148
|
private readonly client;
|
|
149
|
+
private readonly streamAbort;
|
|
117
150
|
private started;
|
|
118
151
|
private completed;
|
|
119
152
|
private finalError;
|
|
@@ -128,6 +161,8 @@ export declare class PublicationRun<TProvider extends PublicationProviderName =
|
|
|
128
161
|
result(): Promise<PublishStreamResult>;
|
|
129
162
|
publication(): Promise<PublicationInstance<TProvider>>;
|
|
130
163
|
start(): this;
|
|
164
|
+
/** Stop observing this run; the server-side publication continues. */
|
|
165
|
+
dispose(): void;
|
|
131
166
|
private subscribe;
|
|
132
167
|
private consumeStream;
|
|
133
168
|
private publish;
|
|
@@ -138,6 +173,7 @@ export declare class PublicationInstance<TProvider extends PublicationProviderNa
|
|
|
138
173
|
readonly data: PublicationData<TProvider>;
|
|
139
174
|
private readonly client;
|
|
140
175
|
private readonly notebookId?;
|
|
176
|
+
readonly domains: PublicationDomains;
|
|
141
177
|
constructor(data: PublicationData<TProvider>, client: Client, notebookId?: string);
|
|
142
178
|
refresh(): Promise<PublicationInstance<TProvider>>;
|
|
143
179
|
publish(): Promise<PublicationRun<TProvider>>;
|
package/dist/publications.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { PublicationEventDataSchema, PublicationLogChunkDataSchema, PublishStreamSseEventNameSchema, PublishStreamSseEventSchema, } from './schemas/publications.js';
|
|
2
|
+
export class PublicationDomains {
|
|
3
|
+
constructor(client, publicationId) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
this.publicationId = publicationId;
|
|
6
|
+
}
|
|
7
|
+
async list() {
|
|
8
|
+
return (await this.client.get(this.path())).data;
|
|
9
|
+
}
|
|
10
|
+
async create(hostname) {
|
|
11
|
+
return (await this.client.post(this.path(), { hostname })).data;
|
|
12
|
+
}
|
|
13
|
+
async refresh(id) {
|
|
14
|
+
return (await this.client.post(`${this.path()}/${encodeURIComponent(id)}/refresh`)).data;
|
|
15
|
+
}
|
|
16
|
+
async delete(id) {
|
|
17
|
+
await this.client.delete(`${this.path()}/${encodeURIComponent(id)}`);
|
|
18
|
+
}
|
|
19
|
+
path() {
|
|
20
|
+
return `/publications/${encodeURIComponent(this.publicationId)}/domains`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
2
23
|
export class PublicationApi {
|
|
3
24
|
constructor(client) {
|
|
4
25
|
this.client = client;
|
|
@@ -12,6 +33,7 @@ export class PublicationRun {
|
|
|
12
33
|
constructor(initial, client) {
|
|
13
34
|
this.initial = initial;
|
|
14
35
|
this.client = client;
|
|
36
|
+
this.streamAbort = new AbortController();
|
|
15
37
|
this.started = false;
|
|
16
38
|
this.completed = false;
|
|
17
39
|
this.finalError = null;
|
|
@@ -60,6 +82,19 @@ export class PublicationRun {
|
|
|
60
82
|
void this.consumeStream(eventStreamUrl);
|
|
61
83
|
return this;
|
|
62
84
|
}
|
|
85
|
+
/** Stop observing this run; the server-side publication continues. */
|
|
86
|
+
dispose() {
|
|
87
|
+
if (this.completed)
|
|
88
|
+
return;
|
|
89
|
+
const error = new DOMException('Stopped observing publication; deployment continues.', 'AbortError');
|
|
90
|
+
if (!this.started) {
|
|
91
|
+
this.started = true;
|
|
92
|
+
this.resultPromise = Promise.reject(error);
|
|
93
|
+
this.resultPromise.catch(() => undefined);
|
|
94
|
+
}
|
|
95
|
+
this.streamAbort.abort(error);
|
|
96
|
+
this.fail(error);
|
|
97
|
+
}
|
|
63
98
|
subscribe() {
|
|
64
99
|
const queue = new AsyncPublishEventQueue();
|
|
65
100
|
for (const event of this.bufferedEvents) {
|
|
@@ -78,7 +113,7 @@ export class PublicationRun {
|
|
|
78
113
|
}
|
|
79
114
|
async consumeStream(eventStreamUrl) {
|
|
80
115
|
try {
|
|
81
|
-
const stream = await this.client.sse(eventStreamUrl);
|
|
116
|
+
const stream = await this.client.sse(eventStreamUrl, this.streamAbort.signal);
|
|
82
117
|
for await (const event of readPublishStreamEvents(stream)) {
|
|
83
118
|
this.publish(event);
|
|
84
119
|
if (event.type === 'result') {
|
|
@@ -124,6 +159,7 @@ export class PublicationInstance {
|
|
|
124
159
|
this.data = data;
|
|
125
160
|
this.client = client;
|
|
126
161
|
this.notebookId = notebookId;
|
|
162
|
+
this.domains = new PublicationDomains(client, data.id);
|
|
127
163
|
}
|
|
128
164
|
async refresh() {
|
|
129
165
|
const response = await this.client.get(`/publications/${this.data.id}`);
|