@phpsandbox/sdk 0.0.56 → 0.0.58

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/index.js CHANGED
@@ -28,6 +28,7 @@ import Git from './git.js';
28
28
  import { createBeacon } from './beacon/index.js';
29
29
  import { NotebookUnavailableError } from './errors/index.js';
30
30
  import { DeploymentApi, NotebookDeploymentApi } from './deployments.js';
31
+ import { ServerApi } from './servers.js';
31
32
  export * from './types.js';
32
33
  export { Transport } from './socket/index.js';
33
34
  export * from './lsp.js';
@@ -42,6 +43,7 @@ export * from './utils/promise.js';
42
43
  export * from './beacon/index.js';
43
44
  export * from './errors/index.js';
44
45
  export * from './deployments.js';
46
+ export * from './servers.js';
45
47
  function normalizeNotebookSecretInputs(input) {
46
48
  if (Array.isArray(input)) {
47
49
  return input;
@@ -97,7 +99,7 @@ export class NotebookApi {
97
99
  this.secrets = new NotebookSecretApi(client);
98
100
  this.preview = new NotebookPreviewApi(client);
99
101
  this.mail = new NotebookMailApi(client);
100
- this.deployments = new NotebookDeploymentApi(client);
102
+ this.deployment = new NotebookDeploymentApi(client);
101
103
  }
102
104
  async create(template, input = {}, init = true) {
103
105
  const response = await this.client.post('/notebook', { template, ...input });
@@ -151,6 +153,7 @@ export class Client {
151
153
  this.fetch = globalThis.fetch;
152
154
  this.deployments = new DeploymentApi(this);
153
155
  this.notebook = new NotebookApi(this);
156
+ this.servers = new ServerApi(this);
154
157
  this.options = Object.assign({ startClosed: true }, options);
155
158
  this.baseUrl = normalizeApiBaseUrl(url);
156
159
  if (options.fetch) {
@@ -187,6 +190,22 @@ export class Client {
187
190
  }
188
191
  return response.body;
189
192
  }
193
+ async sse(url) {
194
+ const response = await this.fetch(new Request(url, {
195
+ method: 'GET',
196
+ headers: {
197
+ ...this.headers,
198
+ 'Accept': 'text/event-stream',
199
+ },
200
+ }));
201
+ if (!response.ok) {
202
+ throw new ApiError(response, await response.text());
203
+ }
204
+ if (!response.body) {
205
+ throw new Error('PHPSandbox API Error: SSE response body is not readable');
206
+ }
207
+ return response.body;
208
+ }
190
209
  async makeRequest(method, path, init) {
191
210
  const response = await this.fetch(new Request(new URL(path.replace(/^\//, ''), this.baseUrl), {
192
211
  method,
@@ -209,8 +228,12 @@ export class NotebookSecretApi {
209
228
  constructor(client) {
210
229
  this.client = client;
211
230
  }
212
- async list(id) {
213
- const response = await this.client.get(`/notebook/${id}/secrets`);
231
+ async list(id, options) {
232
+ const params = new URLSearchParams();
233
+ if (options?.environment)
234
+ params.set('environment', options.environment);
235
+ const query = params.toString();
236
+ const response = await this.client.get(`/notebook/${id}/secrets${query ? `?${query}` : ''}`);
214
237
  return response.data;
215
238
  }
216
239
  async set(id, name, input) {
@@ -224,8 +247,12 @@ export class NotebookSecretApi {
224
247
  });
225
248
  return response.data;
226
249
  }
227
- async delete(id, name) {
228
- await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}`);
250
+ async delete(id, name, options) {
251
+ const params = new URLSearchParams();
252
+ if (options?.environment)
253
+ params.set('environment', options.environment);
254
+ const query = params.toString();
255
+ await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ''}`);
229
256
  }
230
257
  }
231
258
  export class NotebookPreviewApi {
@@ -305,7 +332,7 @@ export class NotebookInstance {
305
332
  this.container = new Container(this);
306
333
  this.laravel = new Laravel(this);
307
334
  this.shell = new Shell(this);
308
- this.git = new Git(this);
335
+ this.git = new Git(this, client);
309
336
  this.services = new Services(this);
310
337
  this.config = new Config(this);
311
338
  this.secrets = new NotebookSecrets(client, this.data.id);
@@ -334,8 +361,11 @@ export class NotebookInstance {
334
361
  fork(input = {}) {
335
362
  return this.client.notebook.fork(this.data.id, input);
336
363
  }
337
- deploy(input = {}) {
338
- return this.client.notebook.deployments.create(this.data.id, input);
364
+ deployment() {
365
+ return this.client.notebook.deployment.current(this.data.id);
366
+ }
367
+ publish(input) {
368
+ return this.client.notebook.deployment.publish(this.data.id, input);
339
369
  }
340
370
  gitCredentials() {
341
371
  return this.client.notebook.gitCredentials(this.data.id);
@@ -501,8 +531,8 @@ export class NotebookSecrets {
501
531
  this.client = client;
502
532
  this.notebookId = notebookId;
503
533
  }
504
- list() {
505
- return this.client.notebook.secrets.list(this.notebookId);
534
+ list(options) {
535
+ return this.client.notebook.secrets.list(this.notebookId, options);
506
536
  }
507
537
  set(name, input) {
508
538
  return this.client.notebook.secrets.set(this.notebookId, name, input);
@@ -510,8 +540,8 @@ export class NotebookSecrets {
510
540
  setMany(input) {
511
541
  return this.client.notebook.secrets.setMany(this.notebookId, input);
512
542
  }
513
- delete(name) {
514
- return this.client.notebook.secrets.delete(this.notebookId, name);
543
+ delete(name, options) {
544
+ return this.client.notebook.secrets.delete(this.notebookId, name, options);
515
545
  }
516
546
  }
517
547
  export class NotebookPreview {
@@ -0,0 +1,417 @@
1
+ import { z } from 'zod';
2
+ export declare const DeploymentTargetProviderSchema: z.ZodEnum<{
3
+ okraCloudflareContainer: "okraCloudflareContainer";
4
+ okraSshAgent: "okraSshAgent";
5
+ okraLaravelCloud: "okraLaravelCloud";
6
+ }>;
7
+ export declare const DeploymentStatusSchema: z.ZodEnum<{
8
+ stopped: "stopped";
9
+ deleted: "deleted";
10
+ pending: "pending";
11
+ queued: "queued";
12
+ building: "building";
13
+ deploying: "deploying";
14
+ healthy: "healthy";
15
+ failed: "failed";
16
+ deleting: "deleting";
17
+ delete_failed: "delete_failed";
18
+ }>;
19
+ export declare const DeploymentBuildStatusSchema: z.ZodEnum<{
20
+ running: "running";
21
+ pending: "pending";
22
+ queued: "queued";
23
+ failed: "failed";
24
+ succeeded: "succeeded";
25
+ cancelled: "cancelled";
26
+ }>;
27
+ export declare const DeploymentReleaseStatusSchema: z.ZodEnum<{
28
+ created: "created";
29
+ deleted: "deleted";
30
+ ready: "ready";
31
+ }>;
32
+ export declare const DeploymentSizeSchema: z.ZodEnum<{
33
+ small: "small";
34
+ basic: "basic";
35
+ nano: "nano";
36
+ medium: "medium";
37
+ large: "large";
38
+ lite: "lite";
39
+ "standard-1": "standard-1";
40
+ "standard-2": "standard-2";
41
+ }>;
42
+ export declare const DeploymentRegionSchema: z.ZodEnum<{
43
+ ENAM: "ENAM";
44
+ WNAM: "WNAM";
45
+ EEUR: "EEUR";
46
+ WEUR: "WEUR";
47
+ APAC: "APAC";
48
+ SAM: "SAM";
49
+ ME: "ME";
50
+ OC: "OC";
51
+ AFR: "AFR";
52
+ }>;
53
+ export declare const DeploymentJurisdictionSchema: z.ZodEnum<{
54
+ eu: "eu";
55
+ fedramp: "fedramp";
56
+ }>;
57
+ export declare const DeploymentDomainDnsRecordTypeSchema: z.ZodEnum<{
58
+ CNAME: "CNAME";
59
+ ALIAS: "ALIAS";
60
+ ANAME: "ANAME";
61
+ }>;
62
+ export declare const DeploymentProtectionModeSchema: z.ZodEnum<{
63
+ none: "none";
64
+ password: "password";
65
+ }>;
66
+ export declare const DeploymentLogStreamSchema: z.ZodEnum<{
67
+ build: "build";
68
+ runtime: "runtime";
69
+ }>;
70
+ export declare const DeployStreamLogStreamSchema: z.ZodEnum<{
71
+ build: "build";
72
+ runtime: "runtime";
73
+ deploy: "deploy";
74
+ }>;
75
+ export declare const DeploymentEventDataSchema: z.ZodObject<{
76
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
77
+ sequence: z.ZodNumber;
78
+ type: z.ZodString;
79
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
80
+ createdAt: z.ZodNullable<z.ZodString>;
81
+ }, z.core.$loose>;
82
+ export declare const DeploymentLogChunkDataSchema: z.ZodObject<{
83
+ sequence: z.ZodNumber;
84
+ stream: z.ZodEnum<{
85
+ build: "build";
86
+ runtime: "runtime";
87
+ }>;
88
+ content: z.ZodString;
89
+ createdAt: z.ZodNullable<z.ZodString>;
90
+ }, z.core.$loose>;
91
+ export declare const DeployStreamPhaseSchema: z.ZodObject<{
92
+ name: z.ZodString;
93
+ status: z.ZodOptional<z.ZodEnum<{
94
+ running: "running";
95
+ failed: "failed";
96
+ completed: "completed";
97
+ }>>;
98
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ }, z.core.$strict>;
100
+ export declare const DeployStreamLogSchema: z.ZodObject<{
101
+ stream: z.ZodEnum<{
102
+ build: "build";
103
+ runtime: "runtime";
104
+ deploy: "deploy";
105
+ }>;
106
+ content: z.ZodString;
107
+ }, z.core.$strict>;
108
+ export declare const DeployStreamResultSchema: z.ZodObject<{
109
+ success: z.ZodBoolean;
110
+ deploymentId: z.ZodString;
111
+ buildId: z.ZodString;
112
+ releaseId: z.ZodString;
113
+ status: z.ZodEnum<{
114
+ stopped: "stopped";
115
+ deleted: "deleted";
116
+ pending: "pending";
117
+ queued: "queued";
118
+ building: "building";
119
+ deploying: "deploying";
120
+ healthy: "healthy";
121
+ failed: "failed";
122
+ deleting: "deleting";
123
+ delete_failed: "delete_failed";
124
+ }>;
125
+ }, z.core.$strict>;
126
+ export declare const DeployStreamPhaseEventSchema: z.ZodObject<{
127
+ name: z.ZodString;
128
+ status: z.ZodOptional<z.ZodEnum<{
129
+ running: "running";
130
+ failed: "failed";
131
+ completed: "completed";
132
+ }>>;
133
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
134
+ type: z.ZodLiteral<"phase">;
135
+ }, z.core.$strict>;
136
+ export declare const DeployStreamLogEventSchema: z.ZodObject<{
137
+ stream: z.ZodEnum<{
138
+ build: "build";
139
+ runtime: "runtime";
140
+ deploy: "deploy";
141
+ }>;
142
+ content: z.ZodString;
143
+ type: z.ZodLiteral<"log">;
144
+ }, z.core.$strict>;
145
+ export declare const DeployStreamResultEventSchema: z.ZodObject<{
146
+ success: z.ZodBoolean;
147
+ deploymentId: z.ZodString;
148
+ buildId: z.ZodString;
149
+ releaseId: z.ZodString;
150
+ status: z.ZodEnum<{
151
+ stopped: "stopped";
152
+ deleted: "deleted";
153
+ pending: "pending";
154
+ queued: "queued";
155
+ building: "building";
156
+ deploying: "deploying";
157
+ healthy: "healthy";
158
+ failed: "failed";
159
+ deleting: "deleting";
160
+ delete_failed: "delete_failed";
161
+ }>;
162
+ type: z.ZodLiteral<"result">;
163
+ }, z.core.$strict>;
164
+ export declare const DeployStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
165
+ name: z.ZodString;
166
+ status: z.ZodOptional<z.ZodEnum<{
167
+ running: "running";
168
+ failed: "failed";
169
+ completed: "completed";
170
+ }>>;
171
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
172
+ type: z.ZodLiteral<"phase">;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ stream: z.ZodEnum<{
175
+ build: "build";
176
+ runtime: "runtime";
177
+ deploy: "deploy";
178
+ }>;
179
+ content: z.ZodString;
180
+ type: z.ZodLiteral<"log">;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ success: z.ZodBoolean;
183
+ deploymentId: z.ZodString;
184
+ buildId: z.ZodString;
185
+ releaseId: z.ZodString;
186
+ status: z.ZodEnum<{
187
+ stopped: "stopped";
188
+ deleted: "deleted";
189
+ pending: "pending";
190
+ queued: "queued";
191
+ building: "building";
192
+ deploying: "deploying";
193
+ healthy: "healthy";
194
+ failed: "failed";
195
+ deleting: "deleting";
196
+ delete_failed: "delete_failed";
197
+ }>;
198
+ type: z.ZodLiteral<"result">;
199
+ }, z.core.$strict>], "type">;
200
+ export declare const DeployStreamErrorSchema: z.ZodObject<{
201
+ message: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$loose>;
203
+ export declare const DeployStreamSseEventNameSchema: z.ZodEnum<{
204
+ error: "error";
205
+ log: "log";
206
+ phase: "phase";
207
+ result: "result";
208
+ done: "done";
209
+ }>;
210
+ export declare const DeployStreamSsePhaseEventSchema: z.ZodObject<{
211
+ event: z.ZodLiteral<"phase">;
212
+ data: z.ZodObject<{
213
+ name: z.ZodString;
214
+ status: z.ZodOptional<z.ZodEnum<{
215
+ running: "running";
216
+ failed: "failed";
217
+ completed: "completed";
218
+ }>>;
219
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
220
+ }, z.core.$strict>;
221
+ }, z.core.$strict>;
222
+ export declare const DeployStreamSseLogEventSchema: z.ZodObject<{
223
+ event: z.ZodLiteral<"log">;
224
+ data: z.ZodObject<{
225
+ stream: z.ZodEnum<{
226
+ build: "build";
227
+ runtime: "runtime";
228
+ deploy: "deploy";
229
+ }>;
230
+ content: z.ZodString;
231
+ }, z.core.$strict>;
232
+ }, z.core.$strict>;
233
+ export declare const DeployStreamSseDoneEventSchema: z.ZodObject<{
234
+ event: z.ZodLiteral<"done">;
235
+ data: z.ZodObject<{
236
+ success: z.ZodBoolean;
237
+ deploymentId: z.ZodString;
238
+ buildId: z.ZodString;
239
+ releaseId: z.ZodString;
240
+ status: z.ZodEnum<{
241
+ stopped: "stopped";
242
+ deleted: "deleted";
243
+ pending: "pending";
244
+ queued: "queued";
245
+ building: "building";
246
+ deploying: "deploying";
247
+ healthy: "healthy";
248
+ failed: "failed";
249
+ deleting: "deleting";
250
+ delete_failed: "delete_failed";
251
+ }>;
252
+ }, z.core.$strict>;
253
+ }, z.core.$strict>;
254
+ export declare const DeployStreamSseResultEventSchema: z.ZodObject<{
255
+ event: z.ZodLiteral<"result">;
256
+ data: z.ZodObject<{
257
+ success: z.ZodBoolean;
258
+ deploymentId: z.ZodString;
259
+ buildId: z.ZodString;
260
+ releaseId: z.ZodString;
261
+ status: z.ZodEnum<{
262
+ stopped: "stopped";
263
+ deleted: "deleted";
264
+ pending: "pending";
265
+ queued: "queued";
266
+ building: "building";
267
+ deploying: "deploying";
268
+ healthy: "healthy";
269
+ failed: "failed";
270
+ deleting: "deleting";
271
+ delete_failed: "delete_failed";
272
+ }>;
273
+ }, z.core.$strict>;
274
+ }, z.core.$strict>;
275
+ export declare const DeployStreamSseErrorEventSchema: z.ZodObject<{
276
+ event: z.ZodLiteral<"error">;
277
+ data: z.ZodObject<{
278
+ message: z.ZodOptional<z.ZodString>;
279
+ }, z.core.$loose>;
280
+ }, z.core.$strict>;
281
+ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
282
+ event: z.ZodLiteral<"phase">;
283
+ data: z.ZodObject<{
284
+ name: z.ZodString;
285
+ status: z.ZodOptional<z.ZodEnum<{
286
+ running: "running";
287
+ failed: "failed";
288
+ completed: "completed";
289
+ }>>;
290
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
291
+ }, z.core.$strict>;
292
+ }, z.core.$strict>, z.ZodObject<{
293
+ event: z.ZodLiteral<"log">;
294
+ data: z.ZodObject<{
295
+ stream: z.ZodEnum<{
296
+ build: "build";
297
+ runtime: "runtime";
298
+ deploy: "deploy";
299
+ }>;
300
+ content: z.ZodString;
301
+ }, z.core.$strict>;
302
+ }, z.core.$strict>, z.ZodObject<{
303
+ event: z.ZodLiteral<"done">;
304
+ data: z.ZodObject<{
305
+ success: z.ZodBoolean;
306
+ deploymentId: z.ZodString;
307
+ buildId: z.ZodString;
308
+ releaseId: z.ZodString;
309
+ status: z.ZodEnum<{
310
+ stopped: "stopped";
311
+ deleted: "deleted";
312
+ pending: "pending";
313
+ queued: "queued";
314
+ building: "building";
315
+ deploying: "deploying";
316
+ healthy: "healthy";
317
+ failed: "failed";
318
+ deleting: "deleting";
319
+ delete_failed: "delete_failed";
320
+ }>;
321
+ }, z.core.$strict>;
322
+ }, z.core.$strict>, z.ZodObject<{
323
+ event: z.ZodLiteral<"result">;
324
+ data: z.ZodObject<{
325
+ success: z.ZodBoolean;
326
+ deploymentId: z.ZodString;
327
+ buildId: z.ZodString;
328
+ releaseId: z.ZodString;
329
+ status: z.ZodEnum<{
330
+ stopped: "stopped";
331
+ deleted: "deleted";
332
+ pending: "pending";
333
+ queued: "queued";
334
+ building: "building";
335
+ deploying: "deploying";
336
+ healthy: "healthy";
337
+ failed: "failed";
338
+ deleting: "deleting";
339
+ delete_failed: "delete_failed";
340
+ }>;
341
+ }, z.core.$strict>;
342
+ }, z.core.$strict>, z.ZodObject<{
343
+ event: z.ZodLiteral<"error">;
344
+ data: z.ZodObject<{
345
+ message: z.ZodOptional<z.ZodString>;
346
+ }, z.core.$loose>;
347
+ }, z.core.$strict>], "event">, z.ZodTransform<{
348
+ name: string;
349
+ type: "phase";
350
+ status?: "running" | "failed" | "completed";
351
+ data?: Record<string, unknown>;
352
+ } | {
353
+ stream: "build" | "runtime" | "deploy";
354
+ content: string;
355
+ type: "log";
356
+ } | {
357
+ success: boolean;
358
+ deploymentId: string;
359
+ buildId: string;
360
+ releaseId: string;
361
+ status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
362
+ type: "result";
363
+ }, {
364
+ event: "phase";
365
+ data: {
366
+ name: string;
367
+ status?: "running" | "failed" | "completed";
368
+ data?: Record<string, unknown>;
369
+ };
370
+ } | {
371
+ event: "log";
372
+ data: {
373
+ stream: "build" | "runtime" | "deploy";
374
+ content: string;
375
+ };
376
+ } | {
377
+ event: "done";
378
+ data: {
379
+ success: boolean;
380
+ deploymentId: string;
381
+ buildId: string;
382
+ releaseId: string;
383
+ status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
384
+ };
385
+ } | {
386
+ event: "result";
387
+ data: {
388
+ success: boolean;
389
+ deploymentId: string;
390
+ buildId: string;
391
+ releaseId: string;
392
+ status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
393
+ };
394
+ } | {
395
+ event: "error";
396
+ data: {
397
+ [x: string]: unknown;
398
+ message?: string;
399
+ };
400
+ }>>;
401
+ export type DeploymentTargetProvider = z.infer<typeof DeploymentTargetProviderSchema>;
402
+ export type DeploymentStatus = z.infer<typeof DeploymentStatusSchema>;
403
+ export type DeploymentBuildStatus = z.infer<typeof DeploymentBuildStatusSchema>;
404
+ export type DeploymentReleaseStatus = z.infer<typeof DeploymentReleaseStatusSchema>;
405
+ export type DeploymentSize = z.infer<typeof DeploymentSizeSchema>;
406
+ export type DeploymentRegion = z.infer<typeof DeploymentRegionSchema>;
407
+ export type DeploymentJurisdiction = z.infer<typeof DeploymentJurisdictionSchema>;
408
+ export type DeploymentDomainDnsRecordType = z.infer<typeof DeploymentDomainDnsRecordTypeSchema>;
409
+ export type DeploymentProtectionMode = z.infer<typeof DeploymentProtectionModeSchema>;
410
+ export type DeploymentLogStream = z.infer<typeof DeploymentLogStreamSchema>;
411
+ export type DeploymentEventData = z.infer<typeof DeploymentEventDataSchema>;
412
+ export type DeploymentLogChunkData = z.infer<typeof DeploymentLogChunkDataSchema>;
413
+ export type DeployStreamPhase = z.infer<typeof DeployStreamPhaseSchema>;
414
+ export type DeployStreamLog = z.infer<typeof DeployStreamLogSchema>;
415
+ export type DeployStreamResult = z.infer<typeof DeployStreamResultSchema>;
416
+ export type DeployStreamEvent = z.infer<typeof DeployStreamEventSchema>;
417
+ export type DeployStreamSseEvent = z.infer<typeof DeployStreamSseEventSchema>;
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ export const DeploymentTargetProviderSchema = z.enum([
3
+ 'okraCloudflareContainer',
4
+ 'okraSshAgent',
5
+ 'okraLaravelCloud',
6
+ ]);
7
+ export const DeploymentStatusSchema = z.enum([
8
+ 'pending',
9
+ 'queued',
10
+ 'building',
11
+ 'deploying',
12
+ 'healthy',
13
+ 'failed',
14
+ 'stopped',
15
+ 'deleting',
16
+ 'deleted',
17
+ 'delete_failed',
18
+ ]);
19
+ export const DeploymentBuildStatusSchema = z.enum([
20
+ 'pending',
21
+ 'queued',
22
+ 'running',
23
+ 'succeeded',
24
+ 'failed',
25
+ 'cancelled',
26
+ ]);
27
+ export const DeploymentReleaseStatusSchema = z.enum(['created', 'ready', 'deleted']);
28
+ export const DeploymentSizeSchema = z.enum([
29
+ 'nano',
30
+ 'small',
31
+ 'medium',
32
+ 'large',
33
+ 'lite',
34
+ 'basic',
35
+ 'standard-1',
36
+ 'standard-2',
37
+ ]);
38
+ export const DeploymentRegionSchema = z.enum([
39
+ 'ENAM',
40
+ 'WNAM',
41
+ 'EEUR',
42
+ 'WEUR',
43
+ 'APAC',
44
+ 'SAM',
45
+ 'ME',
46
+ 'OC',
47
+ 'AFR',
48
+ ]);
49
+ export const DeploymentJurisdictionSchema = z.enum(['eu', 'fedramp']);
50
+ export const DeploymentDomainDnsRecordTypeSchema = z.enum(['CNAME', 'ALIAS', 'ANAME']);
51
+ export const DeploymentProtectionModeSchema = z.enum(['none', 'password']);
52
+ export const DeploymentLogStreamSchema = z.enum(['build', 'runtime']);
53
+ export const DeployStreamLogStreamSchema = z.enum(['build', 'deploy', 'runtime']);
54
+ export const DeploymentEventDataSchema = z.object({
55
+ id: z.union([z.number(), z.string()]).optional(),
56
+ sequence: z.number(),
57
+ type: z.string(),
58
+ payload: z.record(z.string(), z.unknown()),
59
+ createdAt: z.string().nullable(),
60
+ }).passthrough();
61
+ export const DeploymentLogChunkDataSchema = z.object({
62
+ sequence: z.number(),
63
+ stream: DeploymentLogStreamSchema,
64
+ content: z.string(),
65
+ createdAt: z.string().nullable(),
66
+ }).passthrough();
67
+ export const DeployStreamPhaseSchema = z.object({
68
+ name: z.string(),
69
+ status: z.enum(['running', 'completed', 'failed']).optional(),
70
+ data: z.record(z.string(), z.unknown()).optional(),
71
+ }).strict();
72
+ export const DeployStreamLogSchema = z.object({
73
+ stream: DeployStreamLogStreamSchema,
74
+ content: z.string(),
75
+ }).strict();
76
+ export const DeployStreamResultSchema = z.object({
77
+ success: z.boolean(),
78
+ deploymentId: z.string(),
79
+ buildId: z.string(),
80
+ releaseId: z.string(),
81
+ status: DeploymentStatusSchema,
82
+ }).strict();
83
+ export const DeployStreamPhaseEventSchema = DeployStreamPhaseSchema.extend({
84
+ type: z.literal('phase'),
85
+ }).strict();
86
+ export const DeployStreamLogEventSchema = DeployStreamLogSchema.extend({
87
+ type: z.literal('log'),
88
+ }).strict();
89
+ export const DeployStreamResultEventSchema = DeployStreamResultSchema.extend({
90
+ type: z.literal('result'),
91
+ }).strict();
92
+ export const DeployStreamEventSchema = z.discriminatedUnion('type', [
93
+ DeployStreamPhaseEventSchema,
94
+ DeployStreamLogEventSchema,
95
+ DeployStreamResultEventSchema,
96
+ ]);
97
+ export const DeployStreamErrorSchema = z.object({
98
+ message: z.string().optional(),
99
+ }).passthrough();
100
+ export const DeployStreamSseEventNameSchema = z.enum(['phase', 'log', 'done', 'result', 'error']);
101
+ export const DeployStreamSsePhaseEventSchema = z.object({
102
+ event: z.literal('phase'),
103
+ data: DeployStreamPhaseSchema,
104
+ }).strict();
105
+ export const DeployStreamSseLogEventSchema = z.object({
106
+ event: z.literal('log'),
107
+ data: DeployStreamLogSchema,
108
+ }).strict();
109
+ export const DeployStreamSseDoneEventSchema = z.object({
110
+ event: z.literal('done'),
111
+ data: DeployStreamResultSchema,
112
+ }).strict();
113
+ export const DeployStreamSseResultEventSchema = z.object({
114
+ event: z.literal('result'),
115
+ data: DeployStreamResultSchema,
116
+ }).strict();
117
+ export const DeployStreamSseErrorEventSchema = z.object({
118
+ event: z.literal('error'),
119
+ data: DeployStreamErrorSchema,
120
+ }).strict();
121
+ export const DeployStreamSseEventSchema = z.discriminatedUnion('event', [
122
+ DeployStreamSsePhaseEventSchema,
123
+ DeployStreamSseLogEventSchema,
124
+ DeployStreamSseDoneEventSchema,
125
+ DeployStreamSseResultEventSchema,
126
+ DeployStreamSseErrorEventSchema,
127
+ ]).transform((event) => {
128
+ if (event.event === 'error') {
129
+ throw new Error(event.data.message ?? 'Deploy failed');
130
+ }
131
+ const type = event.event === 'done' ? 'result' : event.event;
132
+ return DeployStreamEventSchema.parse({ type, ...event.data });
133
+ });