@phpsandbox/sdk 0.0.68 → 0.1.2

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.
Files changed (56) hide show
  1. package/README.md +66 -32
  2. package/dist/auth.d.ts +0 -1
  3. package/dist/auth.js +0 -3
  4. package/dist/beacon/index.d.ts +2 -0
  5. package/dist/beacon/index.js +5 -0
  6. package/dist/browser/phpsandbox-sdk.esm.js +842 -1320
  7. package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
  8. package/dist/browser/phpsandbox-sdk.iife.js +842 -1320
  9. package/dist/browser/phpsandbox-sdk.iife.min.js +23 -23
  10. package/dist/composer.d.ts +36 -23
  11. package/dist/composer.js +61 -11
  12. package/dist/container.d.ts +2 -6
  13. package/dist/container.js +0 -28
  14. package/dist/filesystem.d.ts +58 -17
  15. package/dist/filesystem.js +169 -51
  16. package/dist/index.d.ts +30 -26
  17. package/dist/index.js +37 -32
  18. package/dist/log.d.ts +11 -5
  19. package/dist/log.js +10 -7
  20. package/dist/metrics.d.ts +10 -0
  21. package/dist/metrics.js +13 -0
  22. package/dist/ports.d.ts +10 -0
  23. package/dist/ports.js +13 -0
  24. package/dist/publications.d.ts +222 -0
  25. package/dist/{deployments.js → publications.js} +64 -69
  26. package/dist/repl.d.ts +0 -2
  27. package/dist/repl.js +0 -3
  28. package/dist/runtime/rest.js +1 -4
  29. package/dist/runtime-telemetry.d.ts +15 -0
  30. package/dist/runtime-telemetry.js +111 -0
  31. package/dist/schemas/{deployments.d.ts → publications.d.ts} +76 -76
  32. package/dist/schemas/publications.js +133 -0
  33. package/dist/services.d.ts +2 -9
  34. package/dist/services.js +3 -10
  35. package/dist/shell.d.ts +52 -22
  36. package/dist/shell.js +103 -75
  37. package/dist/terminal.d.ts +18 -14
  38. package/dist/terminal.js +29 -49
  39. package/docs/api-summary.md +37 -29
  40. package/docs/cdn-usage.md +4 -4
  41. package/docs/getting-started.md +17 -17
  42. package/examples/README.md +8 -9
  43. package/examples/basic.ts +2 -2
  44. package/examples/git-merge-smoke.ts +3 -6
  45. package/examples/laravel-load-test.ts +80 -98
  46. package/examples/notebook-readonly-smoke.ts +38 -41
  47. package/examples/publication-provider-label.ts +11 -0
  48. package/examples/{deploy-cloudflare-container.ts → publish-cloudflare-container.ts} +11 -11
  49. package/examples/{deploy-laravel-cloud.ts → publish-laravel-cloud.ts} +11 -11
  50. package/examples/{deploy-ssh-agent.ts → publish-ssh-agent.ts} +15 -16
  51. package/package.json +7 -2
  52. package/dist/deployments.d.ts +0 -251
  53. package/dist/laravel.d.ts +0 -22
  54. package/dist/laravel.js +0 -11
  55. package/dist/schemas/deployments.js +0 -133
  56. package/examples/deployment-provider-label.ts +0 -11
@@ -1,10 +1,10 @@
1
1
  import { z } from 'zod';
2
- export declare const DeploymentTargetProviderSchema: z.ZodEnum<{
3
- okraCloudflareContainer: "okraCloudflareContainer";
4
- okraSshAgent: "okraSshAgent";
5
- okraLaravelCloud: "okraLaravelCloud";
2
+ export declare const PublicationProviderNameSchema: z.ZodEnum<{
3
+ "cloudflare-containers": "cloudflare-containers";
4
+ "ssh-server": "ssh-server";
5
+ "laravel-cloud": "laravel-cloud";
6
6
  }>;
7
- export declare const DeploymentStatusSchema: z.ZodEnum<{
7
+ export declare const PublicationStatusSchema: z.ZodEnum<{
8
8
  stopped: "stopped";
9
9
  deleted: "deleted";
10
10
  pending: "pending";
@@ -16,7 +16,7 @@ export declare const DeploymentStatusSchema: z.ZodEnum<{
16
16
  deleting: "deleting";
17
17
  delete_failed: "delete_failed";
18
18
  }>;
19
- export declare const DeploymentBuildStatusSchema: z.ZodEnum<{
19
+ export declare const PublicationBuildStatusSchema: z.ZodEnum<{
20
20
  running: "running";
21
21
  pending: "pending";
22
22
  queued: "queued";
@@ -24,22 +24,22 @@ export declare const DeploymentBuildStatusSchema: z.ZodEnum<{
24
24
  succeeded: "succeeded";
25
25
  cancelled: "cancelled";
26
26
  }>;
27
- export declare const DeploymentReleaseStatusSchema: z.ZodEnum<{
27
+ export declare const PublicationReleaseStatusSchema: z.ZodEnum<{
28
28
  created: "created";
29
29
  deleted: "deleted";
30
30
  ready: "ready";
31
31
  }>;
32
- export declare const DeploymentSizeSchema: z.ZodEnum<{
32
+ export declare const PublicationSizeSchema: z.ZodEnum<{
33
33
  small: "small";
34
- basic: "basic";
35
34
  nano: "nano";
36
35
  medium: "medium";
37
36
  large: "large";
38
37
  lite: "lite";
38
+ basic: "basic";
39
39
  "standard-1": "standard-1";
40
40
  "standard-2": "standard-2";
41
41
  }>;
42
- export declare const DeploymentRegionSchema: z.ZodEnum<{
42
+ export declare const PublicationRegionSchema: z.ZodEnum<{
43
43
  ENAM: "ENAM";
44
44
  WNAM: "WNAM";
45
45
  EEUR: "EEUR";
@@ -50,45 +50,45 @@ export declare const DeploymentRegionSchema: z.ZodEnum<{
50
50
  OC: "OC";
51
51
  AFR: "AFR";
52
52
  }>;
53
- export declare const DeploymentJurisdictionSchema: z.ZodEnum<{
53
+ export declare const PublicationJurisdictionSchema: z.ZodEnum<{
54
54
  eu: "eu";
55
55
  fedramp: "fedramp";
56
56
  }>;
57
- export declare const DeploymentDomainDnsRecordTypeSchema: z.ZodEnum<{
57
+ export declare const PublicationDomainDnsRecordTypeSchema: z.ZodEnum<{
58
58
  CNAME: "CNAME";
59
59
  ALIAS: "ALIAS";
60
60
  ANAME: "ANAME";
61
61
  }>;
62
- export declare const DeploymentProtectionModeSchema: z.ZodEnum<{
62
+ export declare const PublicationProtectionModeSchema: z.ZodEnum<{
63
63
  none: "none";
64
64
  password: "password";
65
65
  }>;
66
- export declare const DeploymentLogStreamSchema: z.ZodEnum<{
67
- build: "build";
66
+ export declare const PublicationLogStreamSchema: z.ZodEnum<{
68
67
  runtime: "runtime";
69
- }>;
70
- export declare const DeployStreamLogStreamSchema: z.ZodEnum<{
71
68
  build: "build";
69
+ }>;
70
+ export declare const PublishStreamLogStreamSchema: z.ZodEnum<{
72
71
  runtime: "runtime";
73
- deploy: "deploy";
72
+ build: "build";
73
+ publish: "publish";
74
74
  }>;
75
- export declare const DeploymentEventDataSchema: z.ZodObject<{
75
+ export declare const PublicationEventDataSchema: z.ZodObject<{
76
76
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
77
77
  sequence: z.ZodNumber;
78
78
  type: z.ZodString;
79
79
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
80
80
  createdAt: z.ZodNullable<z.ZodString>;
81
81
  }, z.core.$loose>;
82
- export declare const DeploymentLogChunkDataSchema: z.ZodObject<{
82
+ export declare const PublicationLogChunkDataSchema: z.ZodObject<{
83
83
  sequence: z.ZodNumber;
84
84
  stream: z.ZodEnum<{
85
- build: "build";
86
85
  runtime: "runtime";
86
+ build: "build";
87
87
  }>;
88
88
  content: z.ZodString;
89
89
  createdAt: z.ZodNullable<z.ZodString>;
90
90
  }, z.core.$loose>;
91
- export declare const DeployStreamPhaseSchema: z.ZodObject<{
91
+ export declare const PublishStreamPhaseSchema: z.ZodObject<{
92
92
  name: z.ZodString;
93
93
  status: z.ZodOptional<z.ZodEnum<{
94
94
  running: "running";
@@ -97,17 +97,17 @@ export declare const DeployStreamPhaseSchema: z.ZodObject<{
97
97
  }>>;
98
98
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
99
  }, z.core.$strict>;
100
- export declare const DeployStreamLogSchema: z.ZodObject<{
100
+ export declare const PublishStreamLogSchema: z.ZodObject<{
101
101
  stream: z.ZodEnum<{
102
- build: "build";
103
102
  runtime: "runtime";
104
- deploy: "deploy";
103
+ build: "build";
104
+ publish: "publish";
105
105
  }>;
106
106
  content: z.ZodString;
107
107
  }, z.core.$strict>;
108
- export declare const DeployStreamResultSchema: z.ZodObject<{
108
+ export declare const PublishStreamResultSchema: z.ZodObject<{
109
109
  success: z.ZodBoolean;
110
- deploymentId: z.ZodString;
110
+ publicationId: z.ZodString;
111
111
  buildId: z.ZodString;
112
112
  releaseId: z.ZodString;
113
113
  status: z.ZodEnum<{
@@ -123,7 +123,7 @@ export declare const DeployStreamResultSchema: z.ZodObject<{
123
123
  delete_failed: "delete_failed";
124
124
  }>;
125
125
  }, z.core.$strict>;
126
- export declare const DeployStreamPhaseEventSchema: z.ZodObject<{
126
+ export declare const PublishStreamPhaseEventSchema: z.ZodObject<{
127
127
  name: z.ZodString;
128
128
  status: z.ZodOptional<z.ZodEnum<{
129
129
  running: "running";
@@ -133,18 +133,18 @@ export declare const DeployStreamPhaseEventSchema: z.ZodObject<{
133
133
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
134
134
  type: z.ZodLiteral<"phase">;
135
135
  }, z.core.$strict>;
136
- export declare const DeployStreamLogEventSchema: z.ZodObject<{
136
+ export declare const PublishStreamLogEventSchema: z.ZodObject<{
137
137
  stream: z.ZodEnum<{
138
- build: "build";
139
138
  runtime: "runtime";
140
- deploy: "deploy";
139
+ build: "build";
140
+ publish: "publish";
141
141
  }>;
142
142
  content: z.ZodString;
143
143
  type: z.ZodLiteral<"log">;
144
144
  }, z.core.$strict>;
145
- export declare const DeployStreamResultEventSchema: z.ZodObject<{
145
+ export declare const PublishStreamResultEventSchema: z.ZodObject<{
146
146
  success: z.ZodBoolean;
147
- deploymentId: z.ZodString;
147
+ publicationId: z.ZodString;
148
148
  buildId: z.ZodString;
149
149
  releaseId: z.ZodString;
150
150
  status: z.ZodEnum<{
@@ -161,7 +161,7 @@ export declare const DeployStreamResultEventSchema: z.ZodObject<{
161
161
  }>;
162
162
  type: z.ZodLiteral<"result">;
163
163
  }, z.core.$strict>;
164
- export declare const DeployStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
164
+ export declare const PublishStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
165
165
  name: z.ZodString;
166
166
  status: z.ZodOptional<z.ZodEnum<{
167
167
  running: "running";
@@ -172,15 +172,15 @@ export declare const DeployStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
172
172
  type: z.ZodLiteral<"phase">;
173
173
  }, z.core.$strict>, z.ZodObject<{
174
174
  stream: z.ZodEnum<{
175
- build: "build";
176
175
  runtime: "runtime";
177
- deploy: "deploy";
176
+ build: "build";
177
+ publish: "publish";
178
178
  }>;
179
179
  content: z.ZodString;
180
180
  type: z.ZodLiteral<"log">;
181
181
  }, z.core.$strict>, z.ZodObject<{
182
182
  success: z.ZodBoolean;
183
- deploymentId: z.ZodString;
183
+ publicationId: z.ZodString;
184
184
  buildId: z.ZodString;
185
185
  releaseId: z.ZodString;
186
186
  status: z.ZodEnum<{
@@ -197,17 +197,17 @@ export declare const DeployStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
197
197
  }>;
198
198
  type: z.ZodLiteral<"result">;
199
199
  }, z.core.$strict>], "type">;
200
- export declare const DeployStreamErrorSchema: z.ZodObject<{
200
+ export declare const PublishStreamErrorSchema: z.ZodObject<{
201
201
  message: z.ZodOptional<z.ZodString>;
202
202
  }, z.core.$loose>;
203
- export declare const DeployStreamSseEventNameSchema: z.ZodEnum<{
203
+ export declare const PublishStreamSseEventNameSchema: z.ZodEnum<{
204
204
  error: "error";
205
- log: "log";
206
205
  phase: "phase";
206
+ log: "log";
207
207
  result: "result";
208
208
  done: "done";
209
209
  }>;
210
- export declare const DeployStreamSsePhaseEventSchema: z.ZodObject<{
210
+ export declare const PublishStreamSsePhaseEventSchema: z.ZodObject<{
211
211
  event: z.ZodLiteral<"phase">;
212
212
  data: z.ZodObject<{
213
213
  name: z.ZodString;
@@ -219,22 +219,22 @@ export declare const DeployStreamSsePhaseEventSchema: z.ZodObject<{
219
219
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
220
220
  }, z.core.$strict>;
221
221
  }, z.core.$strict>;
222
- export declare const DeployStreamSseLogEventSchema: z.ZodObject<{
222
+ export declare const PublishStreamSseLogEventSchema: z.ZodObject<{
223
223
  event: z.ZodLiteral<"log">;
224
224
  data: z.ZodObject<{
225
225
  stream: z.ZodEnum<{
226
- build: "build";
227
226
  runtime: "runtime";
228
- deploy: "deploy";
227
+ build: "build";
228
+ publish: "publish";
229
229
  }>;
230
230
  content: z.ZodString;
231
231
  }, z.core.$strict>;
232
232
  }, z.core.$strict>;
233
- export declare const DeployStreamSseDoneEventSchema: z.ZodObject<{
233
+ export declare const PublishStreamSseDoneEventSchema: z.ZodObject<{
234
234
  event: z.ZodLiteral<"done">;
235
235
  data: z.ZodObject<{
236
236
  success: z.ZodBoolean;
237
- deploymentId: z.ZodString;
237
+ publicationId: z.ZodString;
238
238
  buildId: z.ZodString;
239
239
  releaseId: z.ZodString;
240
240
  status: z.ZodEnum<{
@@ -251,11 +251,11 @@ export declare const DeployStreamSseDoneEventSchema: z.ZodObject<{
251
251
  }>;
252
252
  }, z.core.$strict>;
253
253
  }, z.core.$strict>;
254
- export declare const DeployStreamSseResultEventSchema: z.ZodObject<{
254
+ export declare const PublishStreamSseResultEventSchema: z.ZodObject<{
255
255
  event: z.ZodLiteral<"result">;
256
256
  data: z.ZodObject<{
257
257
  success: z.ZodBoolean;
258
- deploymentId: z.ZodString;
258
+ publicationId: z.ZodString;
259
259
  buildId: z.ZodString;
260
260
  releaseId: z.ZodString;
261
261
  status: z.ZodEnum<{
@@ -272,13 +272,13 @@ export declare const DeployStreamSseResultEventSchema: z.ZodObject<{
272
272
  }>;
273
273
  }, z.core.$strict>;
274
274
  }, z.core.$strict>;
275
- export declare const DeployStreamSseErrorEventSchema: z.ZodObject<{
275
+ export declare const PublishStreamSseErrorEventSchema: z.ZodObject<{
276
276
  event: z.ZodLiteral<"error">;
277
277
  data: z.ZodObject<{
278
278
  message: z.ZodOptional<z.ZodString>;
279
279
  }, z.core.$loose>;
280
280
  }, z.core.$strict>;
281
- export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
281
+ export declare const PublishStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
282
282
  event: z.ZodLiteral<"phase">;
283
283
  data: z.ZodObject<{
284
284
  name: z.ZodString;
@@ -293,9 +293,9 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
293
293
  event: z.ZodLiteral<"log">;
294
294
  data: z.ZodObject<{
295
295
  stream: z.ZodEnum<{
296
- build: "build";
297
296
  runtime: "runtime";
298
- deploy: "deploy";
297
+ build: "build";
298
+ publish: "publish";
299
299
  }>;
300
300
  content: z.ZodString;
301
301
  }, z.core.$strict>;
@@ -303,7 +303,7 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
303
303
  event: z.ZodLiteral<"done">;
304
304
  data: z.ZodObject<{
305
305
  success: z.ZodBoolean;
306
- deploymentId: z.ZodString;
306
+ publicationId: z.ZodString;
307
307
  buildId: z.ZodString;
308
308
  releaseId: z.ZodString;
309
309
  status: z.ZodEnum<{
@@ -323,7 +323,7 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
323
323
  event: z.ZodLiteral<"result">;
324
324
  data: z.ZodObject<{
325
325
  success: z.ZodBoolean;
326
- deploymentId: z.ZodString;
326
+ publicationId: z.ZodString;
327
327
  buildId: z.ZodString;
328
328
  releaseId: z.ZodString;
329
329
  status: z.ZodEnum<{
@@ -350,12 +350,12 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
350
350
  status?: "running" | "failed" | "completed";
351
351
  data?: Record<string, unknown>;
352
352
  } | {
353
- stream: "build" | "runtime" | "deploy";
353
+ stream: "runtime" | "build" | "publish";
354
354
  content: string;
355
355
  type: "log";
356
356
  } | {
357
357
  success: boolean;
358
- deploymentId: string;
358
+ publicationId: string;
359
359
  buildId: string;
360
360
  releaseId: string;
361
361
  status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
@@ -370,14 +370,14 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
370
370
  } | {
371
371
  event: "log";
372
372
  data: {
373
- stream: "build" | "runtime" | "deploy";
373
+ stream: "runtime" | "build" | "publish";
374
374
  content: string;
375
375
  };
376
376
  } | {
377
377
  event: "done";
378
378
  data: {
379
379
  success: boolean;
380
- deploymentId: string;
380
+ publicationId: string;
381
381
  buildId: string;
382
382
  releaseId: string;
383
383
  status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
@@ -386,7 +386,7 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
386
386
  event: "result";
387
387
  data: {
388
388
  success: boolean;
389
- deploymentId: string;
389
+ publicationId: string;
390
390
  buildId: string;
391
391
  releaseId: string;
392
392
  status: "stopped" | "deleted" | "pending" | "queued" | "building" | "deploying" | "healthy" | "failed" | "deleting" | "delete_failed";
@@ -398,20 +398,20 @@ export declare const DeployStreamSseEventSchema: z.ZodPipe<z.ZodDiscriminatedUni
398
398
  message?: string;
399
399
  };
400
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>;
401
+ export type BuiltInPublicationProviderName = z.infer<typeof PublicationProviderNameSchema>;
402
+ export type PublicationStatus = z.infer<typeof PublicationStatusSchema>;
403
+ export type PublicationBuildStatus = z.infer<typeof PublicationBuildStatusSchema>;
404
+ export type PublicationReleaseStatus = z.infer<typeof PublicationReleaseStatusSchema>;
405
+ export type PublicationSize = z.infer<typeof PublicationSizeSchema>;
406
+ export type PublicationRegion = z.infer<typeof PublicationRegionSchema>;
407
+ export type PublicationJurisdiction = z.infer<typeof PublicationJurisdictionSchema>;
408
+ export type PublicationDomainDnsRecordType = z.infer<typeof PublicationDomainDnsRecordTypeSchema>;
409
+ export type PublicationProtectionMode = z.infer<typeof PublicationProtectionModeSchema>;
410
+ export type PublicationLogStream = z.infer<typeof PublicationLogStreamSchema>;
411
+ export type PublicationEventData = z.infer<typeof PublicationEventDataSchema>;
412
+ export type PublicationLogChunkData = z.infer<typeof PublicationLogChunkDataSchema>;
413
+ export type PublishStreamPhase = z.infer<typeof PublishStreamPhaseSchema>;
414
+ export type PublishStreamLog = z.infer<typeof PublishStreamLogSchema>;
415
+ export type PublishStreamResult = z.infer<typeof PublishStreamResultSchema>;
416
+ export type PublishStreamEvent = z.infer<typeof PublishStreamEventSchema>;
417
+ export type PublishStreamSseEvent = z.infer<typeof PublishStreamSseEventSchema>;
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ export const PublicationProviderNameSchema = z.enum([
3
+ 'cloudflare-containers',
4
+ 'ssh-server',
5
+ 'laravel-cloud',
6
+ ]);
7
+ export const PublicationStatusSchema = 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 PublicationBuildStatusSchema = z.enum([
20
+ 'pending',
21
+ 'queued',
22
+ 'running',
23
+ 'succeeded',
24
+ 'failed',
25
+ 'cancelled',
26
+ ]);
27
+ export const PublicationReleaseStatusSchema = z.enum(['created', 'ready', 'deleted']);
28
+ export const PublicationSizeSchema = z.enum([
29
+ 'nano',
30
+ 'small',
31
+ 'medium',
32
+ 'large',
33
+ 'lite',
34
+ 'basic',
35
+ 'standard-1',
36
+ 'standard-2',
37
+ ]);
38
+ export const PublicationRegionSchema = z.enum([
39
+ 'ENAM',
40
+ 'WNAM',
41
+ 'EEUR',
42
+ 'WEUR',
43
+ 'APAC',
44
+ 'SAM',
45
+ 'ME',
46
+ 'OC',
47
+ 'AFR',
48
+ ]);
49
+ export const PublicationJurisdictionSchema = z.enum(['eu', 'fedramp']);
50
+ export const PublicationDomainDnsRecordTypeSchema = z.enum(['CNAME', 'ALIAS', 'ANAME']);
51
+ export const PublicationProtectionModeSchema = z.enum(['none', 'password']);
52
+ export const PublicationLogStreamSchema = z.enum(['build', 'runtime']);
53
+ export const PublishStreamLogStreamSchema = z.enum(['build', 'publish', 'runtime']);
54
+ export const PublicationEventDataSchema = 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 PublicationLogChunkDataSchema = z.object({
62
+ sequence: z.number(),
63
+ stream: PublicationLogStreamSchema,
64
+ content: z.string(),
65
+ createdAt: z.string().nullable(),
66
+ }).passthrough();
67
+ export const PublishStreamPhaseSchema = 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 PublishStreamLogSchema = z.object({
73
+ stream: PublishStreamLogStreamSchema,
74
+ content: z.string(),
75
+ }).strict();
76
+ export const PublishStreamResultSchema = z.object({
77
+ success: z.boolean(),
78
+ publicationId: z.string(),
79
+ buildId: z.string(),
80
+ releaseId: z.string(),
81
+ status: PublicationStatusSchema,
82
+ }).strict();
83
+ export const PublishStreamPhaseEventSchema = PublishStreamPhaseSchema.extend({
84
+ type: z.literal('phase'),
85
+ }).strict();
86
+ export const PublishStreamLogEventSchema = PublishStreamLogSchema.extend({
87
+ type: z.literal('log'),
88
+ }).strict();
89
+ export const PublishStreamResultEventSchema = PublishStreamResultSchema.extend({
90
+ type: z.literal('result'),
91
+ }).strict();
92
+ export const PublishStreamEventSchema = z.discriminatedUnion('type', [
93
+ PublishStreamPhaseEventSchema,
94
+ PublishStreamLogEventSchema,
95
+ PublishStreamResultEventSchema,
96
+ ]);
97
+ export const PublishStreamErrorSchema = z.object({
98
+ message: z.string().optional(),
99
+ }).passthrough();
100
+ export const PublishStreamSseEventNameSchema = z.enum(['phase', 'log', 'done', 'result', 'error']);
101
+ export const PublishStreamSsePhaseEventSchema = z.object({
102
+ event: z.literal('phase'),
103
+ data: PublishStreamPhaseSchema,
104
+ }).strict();
105
+ export const PublishStreamSseLogEventSchema = z.object({
106
+ event: z.literal('log'),
107
+ data: PublishStreamLogSchema,
108
+ }).strict();
109
+ export const PublishStreamSseDoneEventSchema = z.object({
110
+ event: z.literal('done'),
111
+ data: PublishStreamResultSchema,
112
+ }).strict();
113
+ export const PublishStreamSseResultEventSchema = z.object({
114
+ event: z.literal('result'),
115
+ data: PublishStreamResultSchema,
116
+ }).strict();
117
+ export const PublishStreamSseErrorEventSchema = z.object({
118
+ event: z.literal('error'),
119
+ data: PublishStreamErrorSchema,
120
+ }).strict();
121
+ export const PublishStreamSseEventSchema = z.discriminatedUnion('event', [
122
+ PublishStreamSsePhaseEventSchema,
123
+ PublishStreamSseLogEventSchema,
124
+ PublishStreamSseDoneEventSchema,
125
+ PublishStreamSseResultEventSchema,
126
+ PublishStreamSseErrorEventSchema,
127
+ ]).transform((event) => {
128
+ if (event.event === 'error') {
129
+ throw new Error(event.data.message ?? 'Publish failed');
130
+ }
131
+ const type = event.event === 'done' ? 'result' : event.event;
132
+ return PublishStreamEventSchema.parse({ type, ...event.data });
133
+ });
@@ -1,4 +1,4 @@
1
- import { Action, Disposable, NotebookInstance } from './index.js';
1
+ import { Action, NotebookInstance } from './index.js';
2
2
  export type NotebookServiceKind = 'app' | 'web' | 'cache' | 'task';
3
3
  export type NotebookServiceSource = 'built_in' | 'setup_task';
4
4
  export type NotebookServiceState = 'running' | 'starting' | 'stopping' | 'backoff' | 'exited' | 'fatal' | 'stopped' | 'unknown';
@@ -64,20 +64,13 @@ export interface ServiceLogOptions {
64
64
  tail?: number;
65
65
  follow?: false;
66
66
  }
67
- export interface ServiceLogStream {
68
- id: string;
69
- output: ReadableStream<string>;
70
- stop(): Promise<boolean>;
71
- }
72
67
  export default class Services {
73
68
  protected okra: NotebookInstance;
74
69
  constructor(okra: NotebookInstance);
75
70
  list(): Promise<NotebookServiceStatus[]>;
76
71
  run(name: NotebookServiceName, command?: NotebookServiceCommand): Promise<NotebookServiceStatus>;
77
72
  stop(name: NotebookServiceName): Promise<NotebookServiceStatus>;
78
- onLog(id: string, handler: (data: ServiceEvents['service.log']) => void): Disposable;
79
- listen<T extends keyof ServiceEvents>(event: T, handler: (data: ServiceEvents[T]) => void): Disposable;
80
- logs(name: NotebookServiceName, options: ServiceLogStreamOptions): ServiceLogStream;
73
+ logs(name: NotebookServiceName, options: ServiceLogStreamOptions): ReadableStream<string>;
81
74
  logs(name: NotebookServiceName, options?: ServiceLogOptions): Promise<string>;
82
75
  private followLogs;
83
76
  }
package/dist/services.js CHANGED
@@ -18,12 +18,6 @@ export default class Services {
18
18
  stop(name) {
19
19
  return this.okra.invoke('service.stop', { name });
20
20
  }
21
- onLog(id, handler) {
22
- return this.okra.listen(`service.log.${id}`, handler);
23
- }
24
- listen(event, handler) {
25
- return this.okra.listen(event, handler);
26
- }
27
21
  logs(name, options = {}) {
28
22
  if (options.follow) {
29
23
  return this.followLogs(name, options);
@@ -80,10 +74,10 @@ export default class Services {
80
74
  close();
81
75
  return this.okra.invoke('service.stop-logs', { id });
82
76
  });
83
- const output = new ReadableStream({
77
+ return new ReadableStream({
84
78
  start: (_controller) => {
85
79
  controller = _controller;
86
- disposables.add(this.onLog(id, (data) => {
80
+ disposables.add(this.okra.listen(`service.log.${id}`, (data) => {
87
81
  controller?.enqueue(data.output);
88
82
  }));
89
83
  void this.okra
@@ -98,9 +92,8 @@ export default class Services {
98
92
  });
99
93
  },
100
94
  cancel: () => {
101
- void stop();
95
+ return stop().then(() => undefined);
102
96
  },
103
97
  });
104
- return { id, output, stop };
105
98
  }
106
99
  }
package/dist/shell.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { Action, Disposable, NotebookInstance } from './index.js';
1
+ import type { Action, NotebookInstance } from './index.js';
2
2
  import type { SpawnOptions } from './terminal.js';
3
+ export type ProcessOutputSource = 'output' | 'stdout' | 'stderr';
4
+ export interface ProcessOutputChunk {
5
+ source: ProcessOutputSource;
6
+ data: Uint8Array;
7
+ }
3
8
  export interface ShellEventData {
4
9
  'shell.output': {
5
10
  output: string;
11
+ source: ProcessOutputSource;
6
12
  id: string;
7
13
  };
8
14
  }
@@ -16,34 +22,58 @@ export interface ShellExecInput {
16
22
  opts?: Omit<SpawnOptions, 'abortSignal'>;
17
23
  }
18
24
  export interface ShellActions {
19
- 'shell.exec': Action<ShellExecInput, {
20
- output: string;
21
- exitCode: number;
22
- }>;
23
- }
24
- export interface ShellExecution {
25
- output: ReadableStream<string>;
26
- result: Promise<Result>;
25
+ 'shell.exec': Action<ShellExecInput, ProcessResultData>;
26
+ 'shell.input': Action<{
27
+ id: string;
28
+ input: string;
29
+ }, boolean>;
30
+ 'shell.kill': Action<{
31
+ id: string;
32
+ }, boolean>;
27
33
  }
28
- export declare class CommandError extends Error {
34
+ export interface ProcessResultData {
29
35
  output: string;
36
+ stdout: string;
37
+ stderr: string;
30
38
  exitCode: number;
31
- constructor(output: string, exitCode: number);
32
39
  }
33
- declare class Result {
34
- output: string;
35
- exitCode: number;
36
- constructor(output: string, exitCode: number);
40
+ export declare class CommandError extends Error {
41
+ readonly result: ProcessResult;
42
+ constructor(result: ProcessResult);
43
+ }
44
+ export declare class ProcessResult implements ProcessResultData {
45
+ readonly output: string;
46
+ readonly stdout: string;
47
+ readonly stderr: string;
48
+ readonly exitCode: number;
49
+ constructor(output: string, stdout: string, stderr: string, exitCode: number);
37
50
  throw(): this;
38
51
  }
52
+ export declare class ProcessReadable<T> {
53
+ readonly stream: ReadableStream<T>;
54
+ private controller;
55
+ private closed;
56
+ constructor();
57
+ enqueue(value: T): void;
58
+ close(): void;
59
+ fail(error: unknown): void;
60
+ }
61
+ export declare class ShellProcess {
62
+ readonly id: string;
63
+ private readonly okra;
64
+ readonly output: ReadableStream<ProcessOutputChunk>;
65
+ readonly stdout: ReadableStream<Uint8Array>;
66
+ readonly stderr: ReadableStream<Uint8Array>;
67
+ readonly stdin: WritableStream<Uint8Array | string>;
68
+ private readonly completion;
69
+ constructor(id: string, okra: NotebookInstance, command: string | string[], opts: SpawnOptions);
70
+ wait(): Promise<ProcessResult>;
71
+ kill(): Promise<void>;
72
+ }
39
73
  export default class Shell {
40
- protected okra: NotebookInstance;
74
+ protected readonly okra: NotebookInstance;
41
75
  constructor(okra: NotebookInstance);
42
- onOutput(id: string, handler: (data: ShellEvents['shell.output']) => void): Disposable;
43
- listen<T extends keyof ShellEvents>(event: T, handler: (data: ShellEvents[T]) => void): Disposable;
44
- exec(command: string | string[], opts?: SpawnOptions): Promise<Result>;
45
- exec(command: string, args: string[], opts?: SpawnOptions): Promise<Result>;
46
- execStream(command: string | string[], opts?: SpawnOptions): ShellExecution;
47
- execStream(command: string, args: string[], opts?: SpawnOptions): ShellExecution;
76
+ run(command: string | string[], opts?: SpawnOptions): ShellProcess;
77
+ run(command: string, args: string[], opts?: SpawnOptions): ShellProcess;
48
78
  }
49
79
  export {};