@phpsandbox/sdk 0.0.67 → 0.1.1

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 (42) hide show
  1. package/README.md +10 -13
  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 +311 -1016
  7. package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
  8. package/dist/browser/phpsandbox-sdk.iife.js +311 -1016
  9. package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
  10. package/dist/filesystem.d.ts +2 -1
  11. package/dist/filesystem.js +35 -2
  12. package/dist/index.d.ts +15 -24
  13. package/dist/index.js +19 -28
  14. package/dist/publications.d.ts +222 -0
  15. package/dist/{deployments.js → publications.js} +65 -70
  16. package/dist/repl.d.ts +0 -2
  17. package/dist/repl.js +0 -3
  18. package/dist/runtime/rest.js +1 -1
  19. package/dist/schemas/{deployments.d.ts → publications.d.ts} +68 -68
  20. package/dist/schemas/publications.js +133 -0
  21. package/dist/shell.d.ts +43 -22
  22. package/dist/shell.js +103 -75
  23. package/dist/terminal.d.ts +1 -3
  24. package/dist/terminal.js +2 -5
  25. package/docs/api-summary.md +13 -10
  26. package/docs/cdn-usage.md +4 -4
  27. package/docs/getting-started.md +6 -6
  28. package/examples/README.md +8 -9
  29. package/examples/basic.ts +1 -1
  30. package/examples/git-merge-smoke.ts +2 -2
  31. package/examples/laravel-load-test.ts +14 -19
  32. package/examples/notebook-readonly-smoke.ts +11 -11
  33. package/examples/publication-provider-label.ts +11 -0
  34. package/examples/{deploy-cloudflare-container.ts → publish-cloudflare-container.ts} +11 -11
  35. package/examples/{deploy-laravel-cloud.ts → publish-laravel-cloud.ts} +11 -11
  36. package/examples/{deploy-ssh-agent.ts → publish-ssh-agent.ts} +15 -16
  37. package/package.json +7 -2
  38. package/dist/deployments.d.ts +0 -253
  39. package/dist/laravel.d.ts +0 -22
  40. package/dist/laravel.js +0 -11
  41. package/dist/schemas/deployments.js +0 -133
  42. package/examples/deployment-provider-label.ts +0 -11
@@ -103,13 +103,13 @@ async function main(): Promise<void> {
103
103
  const result = await client.get<NotebookData>(`/notebook/${options.notebookId}`);
104
104
  return {
105
105
  data: result.data,
106
- detail: `id=${result.data.id} type=${result.data.type ?? ''} title=${result.data.title ?? ''} runtimeUrl=${redactUrl(result.data.runtimeUrl ?? result.data.okraUrl)}`,
106
+ detail: `id=${result.data.id} type=${result.data.type ?? ''} title=${result.data.title ?? ''} runtimeUrl=${redactUrl(result.data.runtimeUrl)}`,
107
107
  };
108
108
  });
109
109
 
110
110
  notebookData = {
111
111
  ...response.data,
112
- runtimeUrl: resolveRuntimeUrl(response.data.runtimeUrl ?? response.data.okraUrl, options),
112
+ runtimeUrl: resolveRuntimeUrl(response.data.runtimeUrl, options),
113
113
  };
114
114
 
115
115
  notebook = new NotebookInstance(notebookData, client);
@@ -259,7 +259,7 @@ async function main(): Promise<void> {
259
259
  if (options.includeExec) {
260
260
  await runExecutionChecks(notebook, steps, options);
261
261
  } else {
262
- recordSkippedStep(steps, 'shell.exec', 'Enable with --include-exec.');
262
+ recordSkippedStep(steps, 'shell.run', 'Enable with --include-exec.');
263
263
  recordSkippedStep(steps, 'terminal.spawn', 'Enable with --include-exec.');
264
264
  recordSkippedStep(steps, 'terminal.interactive', 'Enable with --include-exec.');
265
265
  recordSkippedStep(steps, 'terminal.osc', 'Enable with --include-exec.');
@@ -300,7 +300,7 @@ async function main(): Promise<void> {
300
300
  id: notebookData.id,
301
301
  title: notebookData.title,
302
302
  type: notebookData.type,
303
- runtimeUrl: redactUrl(notebookData.runtimeUrl ?? notebookData.okraUrl),
303
+ runtimeUrl: redactUrl(notebookData.runtimeUrl),
304
304
  }
305
305
  : undefined,
306
306
  initTrace,
@@ -323,8 +323,8 @@ async function main(): Promise<void> {
323
323
  }
324
324
 
325
325
  async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifact[], options: SmokeOptions): Promise<void> {
326
- await recordStep(steps, 'shell.exec', options.stepTimeoutMs, async () => {
327
- const result = await notebook.shell.exec(['php', '-r', 'echo "sdk-smoke";']);
326
+ await recordStep(steps, 'shell.run', options.stepTimeoutMs, async () => {
327
+ const result = await notebook.run(['php', '-r', 'echo "sdk-smoke";']).wait();
328
328
  result.throw();
329
329
  if (!result.output.includes('sdk-smoke')) {
330
330
  throw new Error(`Unexpected shell output: ${result.output}`);
@@ -335,7 +335,7 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
335
335
  await recordStep(steps, 'terminal.spawn', options.stepTimeoutMs, async () => {
336
336
  const process = await notebook.terminal.spawn('php', ['-r', 'echo "sdk-smoke";'], { output: true });
337
337
  const [exitCode, output] = await Promise.all([
338
- withTimeout(process.exit, options.stepTimeoutMs, 'waiting for terminal process exit'),
338
+ withTimeout(process.wait(), options.stepTimeoutMs, 'waiting for terminal process exit'),
339
339
  readStreamToString(process.output, options.streamTimeoutMs, options.maxStreamChars),
340
340
  ]);
341
341
 
@@ -359,7 +359,7 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
359
359
  writer.releaseLock();
360
360
 
361
361
  const [exitCode, output] = await Promise.all([
362
- withTimeout(process.exit, options.stepTimeoutMs, 'waiting for interactive terminal process exit'),
362
+ withTimeout(process.wait(), options.stepTimeoutMs, 'waiting for interactive terminal process exit'),
363
363
  readStreamToString(process.output, options.streamTimeoutMs, options.maxStreamChars),
364
364
  ]);
365
365
 
@@ -386,7 +386,7 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
386
386
 
387
387
  try {
388
388
  const [exitCode, output] = await Promise.all([
389
- withTimeout(process.exit, options.stepTimeoutMs, 'waiting for terminal OSC process exit'),
389
+ withTimeout(process.wait(), options.stepTimeoutMs, 'waiting for terminal OSC process exit'),
390
390
  readStreamToString(process.output, options.streamTimeoutMs, options.maxStreamChars),
391
391
  ]);
392
392
 
@@ -453,7 +453,7 @@ function recordSkippedStep(steps: StepArtifact[], name: string, detail: string):
453
453
  console.log(`SKIP ${name} ${detail}`);
454
454
  }
455
455
 
456
- async function readStreamToString(stream: ReadableStream<string>, timeoutMs: number, maxChars: number): Promise<string> {
456
+ async function readStreamToString(stream: ReadableStream<string | Uint8Array>, timeoutMs: number, maxChars: number): Promise<string> {
457
457
  const reader = stream.getReader();
458
458
  let output = '';
459
459
 
@@ -463,7 +463,7 @@ async function readStreamToString(stream: ReadableStream<string>, timeoutMs: num
463
463
  if (chunk.done) {
464
464
  break;
465
465
  }
466
- output += chunk.value ?? '';
466
+ output += chunk.value instanceof Uint8Array ? new TextDecoder().decode(chunk.value) : (chunk.value ?? '');
467
467
  }
468
468
  return output;
469
469
  } finally {
@@ -0,0 +1,11 @@
1
+ import type { PublicationProviderName } from '../src/index.js';
2
+
3
+ const publicationProviderLabels: Record<PublicationProviderName, string> = {
4
+ 'cloudflare-containers': 'Cloudflare Containers',
5
+ 'ssh-server': 'SSH Server',
6
+ 'laravel-cloud': 'Laravel Cloud',
7
+ };
8
+
9
+ export function publicationProviderLabel(provider: PublicationProviderName): string {
10
+ return publicationProviderLabels[provider] ?? provider;
11
+ }
@@ -1,5 +1,5 @@
1
1
  import { Client } from '../src/index.js';
2
- import { deploymentTargetProviderLabel } from './deployment-provider-label.js';
2
+ import { publicationProviderLabel } from './publication-provider-label.js';
3
3
 
4
4
  const token = process.env.PHPSANDBOX_TOKEN;
5
5
  if (!token) {
@@ -11,23 +11,23 @@ if (!notebookId) {
11
11
  throw new Error('Missing PHPSANDBOX_NOTEBOOK_ID');
12
12
  }
13
13
 
14
- const slug = process.env.PHPSANDBOX_DEPLOY_SLUG ?? `sdk-cloudflare-${Date.now().toString(36)}`;
14
+ const slug = process.env.PHPSANDBOX_PUBLISH_SLUG ?? `sdk-cloudflare-${Date.now().toString(36)}`;
15
15
  const apiUrl = process.env.PHPSANDBOX_API_URL;
16
16
  const client = new Client(token, apiUrl);
17
17
  const notebook = await client.notebook.get(notebookId);
18
18
 
19
19
  try {
20
- const deployment = await notebook.deployment();
21
- if (deployment && deployment.data.targetProvider !== 'okraCloudflareContainer') {
22
- throw new Error(`Notebook is already published to ${deploymentTargetProviderLabel(deployment.data.targetProvider)}. Delete that deployment before changing providers.`);
20
+ const publication = await notebook.publication();
21
+ if (publication && publication.data.provider.name !== 'cloudflare-containers') {
22
+ throw new Error(`Notebook is already published to ${publicationProviderLabel(publication.data.provider.name)}. Destroy that publication before changing providers.`);
23
23
  }
24
24
 
25
- const run = deployment
26
- ? await deployment.publish()
25
+ const run = publication
26
+ ? await publication.publish()
27
27
  : await notebook.publish({
28
28
  slug,
29
- targetProvider: 'okraCloudflareContainer',
30
- options: {
29
+ provider: {
30
+ name: 'cloudflare-containers',
31
31
  size: 'small',
32
32
  sleepAfter: '30m',
33
33
  },
@@ -43,8 +43,8 @@ try {
43
43
  }
44
44
  }
45
45
 
46
- const current = await run.deployment();
47
- console.log('deployment:', current.data.id, current.data.status, current.data.url);
46
+ const current = await run.publication();
47
+ console.log('publication:', current.data.id, current.data.status, current.data.url);
48
48
  } finally {
49
49
  notebook.dispose();
50
50
  }
@@ -1,5 +1,5 @@
1
1
  import { Client, type LaravelCloudRegion } from '../src/index.js';
2
- import { deploymentTargetProviderLabel } from './deployment-provider-label.js';
2
+ import { publicationProviderLabel } from './publication-provider-label.js';
3
3
 
4
4
  const token = process.env.PHPSANDBOX_TOKEN;
5
5
  if (!token) {
@@ -13,7 +13,7 @@ if (!notebookId) {
13
13
 
14
14
  const apiKeySecret = 'LARAVEL_CLOUD_API_KEY';
15
15
  const githubTokenSecret = 'GITHUB_TOKEN';
16
- const slug = process.env.PHPSANDBOX_DEPLOY_SLUG ?? `sdk-laravel-cloud-${Date.now().toString(36)}`;
16
+ const slug = process.env.PHPSANDBOX_PUBLISH_SLUG ?? `sdk-laravel-cloud-${Date.now().toString(36)}`;
17
17
  const region: LaravelCloudRegion = 'eu-central-1';
18
18
  const apiUrl = process.env.PHPSANDBOX_API_URL ?? 'https://api.phpsandbox.io/v1';
19
19
 
@@ -25,12 +25,12 @@ const client = new Client(token, apiUrl);
25
25
  const notebook = await client.notebook.get(notebookId);
26
26
 
27
27
  try {
28
- const deployment = await notebook.deployment();
29
- if (deployment && deployment.data.targetProvider !== 'okraLaravelCloud') {
30
- throw new Error(`Notebook is already published to ${deploymentTargetProviderLabel(deployment.data.targetProvider)}. Delete that deployment before changing providers.`);
28
+ const publication = await notebook.publication();
29
+ if (publication && publication.data.provider.name !== 'laravel-cloud') {
30
+ throw new Error(`Notebook is already published to ${publicationProviderLabel(publication.data.provider.name)}. Destroy that publication before changing providers.`);
31
31
  }
32
32
 
33
- const run = deployment ? await deployment.publish() : await publishFirstLaravelCloudDeployment();
33
+ const run = publication ? await publication.publish() : await publishFirstLaravelCloudPublication();
34
34
 
35
35
  for await (const event of run.events()) {
36
36
  if (event.type === 'phase') {
@@ -42,13 +42,13 @@ try {
42
42
  }
43
43
  }
44
44
 
45
- const current = await run.deployment();
46
- console.log('deployment:', current.data.id, current.data.status, current.data.url);
45
+ const current = await run.publication();
46
+ console.log('publication:', current.data.id, current.data.status, current.data.url);
47
47
  } finally {
48
48
  notebook.dispose();
49
49
  }
50
50
 
51
- async function publishFirstLaravelCloudDeployment() {
51
+ async function publishFirstLaravelCloudPublication() {
52
52
  const repository = process.env.PHPSANDBOX_LARAVEL_CLOUD_REPOSITORY;
53
53
  if (!repository) {
54
54
  throw new Error('Missing PHPSANDBOX_LARAVEL_CLOUD_REPOSITORY');
@@ -101,8 +101,8 @@ async function publishFirstLaravelCloudDeployment() {
101
101
 
102
102
  return notebook.publish({
103
103
  slug,
104
- targetProvider: 'okraLaravelCloud',
105
- options: {
104
+ provider: {
105
+ name: 'laravel-cloud',
106
106
  apiKey: {
107
107
  secret: apiKeySecret,
108
108
  },
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { Client, type ServerInstance } from '../src/index.js';
7
- import { deploymentTargetProviderLabel } from './deployment-provider-label.js';
7
+ import { publicationProviderLabel } from './publication-provider-label.js';
8
8
 
9
9
  const token = process.env.PHPSANDBOX_TOKEN;
10
10
  if (!token) {
@@ -16,7 +16,7 @@ if (!notebookId) {
16
16
  throw new Error('Missing PHPSANDBOX_NOTEBOOK_ID');
17
17
  }
18
18
 
19
- const slug = process.env.PHPSANDBOX_DEPLOY_SLUG ?? `sdk-ssh-${Date.now().toString(36)}`;
19
+ const slug = process.env.PHPSANDBOX_PUBLISH_SLUG ?? `sdk-ssh-${Date.now().toString(36)}`;
20
20
  const apiUrl = process.env.PHPSANDBOX_API_URL ?? 'https://api.phpsandbox.io/v1';
21
21
  const isLocal = new URL(apiUrl).hostname.endsWith('.test');
22
22
 
@@ -29,17 +29,16 @@ const notebook = await client.notebook.get(notebookId);
29
29
  let agent: ChildProcessWithoutNullStreams | null = null;
30
30
 
31
31
  try {
32
- const deployment = await notebook.deployment();
33
- if (deployment && deployment.data.targetProvider !== 'okraSshAgent') {
34
- throw new Error(`Notebook is already published to ${deploymentTargetProviderLabel(deployment.data.targetProvider)}. Delete that deployment before changing providers.`);
32
+ const publication = await notebook.publication();
33
+ if (publication && publication.data.provider.name !== 'ssh-server') {
34
+ throw new Error(`Notebook is already published to ${publicationProviderLabel(publication.data.provider.name)}. Destroy that publication before changing providers.`);
35
35
  }
36
36
 
37
- const run = deployment
38
- ? await deployment.publish()
37
+ const run = publication
38
+ ? await publication.publish()
39
39
  : await notebook.publish({
40
40
  slug,
41
- targetProvider: 'okraSshAgent',
42
- options: { serverId: (await resolveServer()).data.id },
41
+ provider: { name: 'ssh-server', serverId: (await resolveServer()).data.id },
43
42
  });
44
43
 
45
44
  for await (const event of run.events()) {
@@ -52,14 +51,14 @@ try {
52
51
  }
53
52
  }
54
53
 
55
- const current = await run.deployment();
56
- console.log('deployment:', current.data.id, current.data.status, current.data.url);
54
+ const current = await run.publication();
55
+ console.log('publication:', current.data.id, current.data.status, current.data.url);
57
56
 
58
57
  if (current.data.url) {
59
58
  const response = await fetch(current.data.url);
60
59
  console.log('http:', response.status, response.statusText, await response.text());
61
60
  if (!response.ok) {
62
- throw new Error(`Deployment URL returned ${response.status} ${response.statusText}`);
61
+ throw new Error(`Publication URL returned ${response.status} ${response.statusText}`);
63
62
  }
64
63
  }
65
64
  } finally {
@@ -70,7 +69,7 @@ try {
70
69
  }
71
70
 
72
71
  async function resolveServer(): Promise<ServerInstance> {
73
- const serverId = process.env.PHPSANDBOX_DEPLOY_SERVER_ID;
72
+ const serverId = process.env.PHPSANDBOX_PUBLISH_SERVER_ID;
74
73
  if (serverId) {
75
74
  const server = await client.servers.get(serverId);
76
75
  console.log('server:', server.data.id, server.data.status);
@@ -79,17 +78,17 @@ async function resolveServer(): Promise<ServerInstance> {
79
78
 
80
79
  const server = await client.servers.create({
81
80
  name: `SDK SSH ${slug}`,
82
- host: process.env.PHPSANDBOX_DEPLOY_SERVER_HOST ?? 'localhost',
81
+ host: process.env.PHPSANDBOX_PUBLISH_SERVER_HOST ?? 'localhost',
83
82
  ssh: {
84
83
  user: process.env.USER ?? 'local',
85
- port: Number(process.env.PHPSANDBOX_DEPLOY_SERVER_PORT ?? 22),
84
+ port: Number(process.env.PHPSANDBOX_PUBLISH_SERVER_PORT ?? 22),
86
85
  },
87
86
  });
88
87
 
89
88
  console.log('server:', server.data.id, server.data.status);
90
89
 
91
90
  if (!isLocal) {
92
- throw new Error('Created server registration. Install the agent on the target server, then rerun with PHPSANDBOX_DEPLOY_SERVER_ID.');
91
+ throw new Error('Created server registration. Install the agent on the target server, then rerun with PHPSANDBOX_PUBLISH_SERVER_ID.');
93
92
  }
94
93
 
95
94
  if (!server.data.token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phpsandbox/sdk",
3
- "version": "0.0.67",
3
+ "version": "0.1.1",
4
4
  "description": "A comprehensive TypeScript SDK for interacting with cloud-based PHP development environments",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -11,6 +11,11 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
13
  "default": "./dist/index.js"
14
+ },
15
+ "./beacon": {
16
+ "types": "./dist/beacon/index.d.ts",
17
+ "import": "./dist/beacon/index.js",
18
+ "default": "./dist/beacon/index.js"
14
19
  }
15
20
  },
16
21
  "files": [
@@ -28,7 +33,7 @@
28
33
  "build:browser": "node build.mjs",
29
34
  "clean": "rm -rf dist",
30
35
  "test": "vitest run",
31
- "check:examples": "tsc --noEmit --module NodeNext --moduleResolution NodeNext --target ES2020 --types node --skipLibCheck --allowSyntheticDefaultImports --esModuleInterop examples/basic.ts examples/deploy-cloudflare-container.ts examples/deploy-laravel-cloud.ts examples/deploy-ssh-agent.ts examples/get.ts examples/git-merge-smoke.ts examples/laravel-load-test.ts examples/notebook-readonly-smoke.ts",
36
+ "check:examples": "tsc --noEmit --module NodeNext --moduleResolution NodeNext --target ES2020 --types node --skipLibCheck --allowSyntheticDefaultImports --esModuleInterop examples/basic.ts examples/publish-cloudflare-container.ts examples/publish-laravel-cloud.ts examples/publish-ssh-agent.ts examples/get.ts examples/git-merge-smoke.ts examples/laravel-load-test.ts examples/notebook-readonly-smoke.ts",
32
37
  "prepublishOnly": "npm test && npm run check:examples && npm run clean && npm run build",
33
38
  "bumpAndPublish": "npm version patch && npm publish --access public"
34
39
  },
@@ -1,253 +0,0 @@
1
- import { type Client, type SecretRef } from './index.js';
2
- import type { DeploymentBuildStatus, DeploymentDomainDnsRecordType, DeploymentEventData, DeploymentJurisdiction, DeploymentLogChunkData, DeploymentProtectionMode, DeploymentRegion, DeploymentReleaseStatus, DeploymentSize, DeploymentStatus, DeploymentTargetProvider, DeployStreamEvent, DeployStreamResult } from './schemas/deployments.js';
3
- export * from './schemas/deployments.js';
4
- export interface DeploymentPlacement {
5
- regions?: DeploymentRegion[];
6
- jurisdiction?: DeploymentJurisdiction;
7
- }
8
- export type LaravelCloudRegion = 'us-east-2' | 'us-east-1' | 'ca-central-1' | 'eu-central-1' | 'eu-west-1' | 'eu-west-2' | 'me-central-1' | 'ap-southeast-1' | 'ap-southeast-2' | 'ap-northeast-1';
9
- export interface DeploymentProtectionData {
10
- mode: DeploymentProtectionMode;
11
- enabled: boolean;
12
- token?: string;
13
- expiresAt?: string;
14
- url?: string;
15
- }
16
- export interface DeploymentFeedbackData {
17
- enabled: boolean;
18
- config: Record<string, unknown>;
19
- }
20
- export type DeploymentProtectionInput = {
21
- mode: 'none';
22
- password?: never;
23
- } | {
24
- mode: 'password';
25
- password: string;
26
- };
27
- export interface DeploymentFeedbackInput {
28
- enabled: boolean;
29
- config?: Record<string, unknown>;
30
- }
31
- export interface OkraCloudflareContainerBuildOptions {
32
- size?: DeploymentSize;
33
- sleepAfter?: string;
34
- placement?: DeploymentPlacement;
35
- instances?: number;
36
- }
37
- export interface OkraCloudflareContainerDeploymentOptions extends OkraCloudflareContainerBuildOptions {
38
- protection: DeploymentProtectionData;
39
- feedback: DeploymentFeedbackData;
40
- }
41
- export interface OkraCloudflareContainerPublishOptions extends OkraCloudflareContainerBuildOptions {
42
- protection?: DeploymentProtectionInput;
43
- feedback?: DeploymentFeedbackInput;
44
- }
45
- export interface OkraSshAgentBuildOptions {
46
- serverId: string;
47
- }
48
- export interface OkraSshAgentDeploymentOptions extends OkraSshAgentBuildOptions {
49
- protection: DeploymentProtectionData;
50
- feedback: DeploymentFeedbackData;
51
- }
52
- export interface OkraSshAgentPublishOptions extends OkraSshAgentBuildOptions {
53
- protection?: DeploymentProtectionInput;
54
- feedback?: DeploymentFeedbackInput;
55
- }
56
- export interface OkraLaravelCloudBuildOptions {
57
- region?: LaravelCloudRegion;
58
- repository?: string;
59
- branch?: string;
60
- sourceControlProviderType?: 'github' | 'gitlab' | 'bitbucket';
61
- apiKeyConfigured?: boolean;
62
- }
63
- export interface OkraLaravelCloudDeploymentOptions extends OkraLaravelCloudBuildOptions {
64
- protection: DeploymentProtectionData;
65
- feedback: DeploymentFeedbackData;
66
- }
67
- export interface OkraLaravelCloudPublishOptions {
68
- apiKey: SecretRef;
69
- region?: LaravelCloudRegion;
70
- protection?: DeploymentProtectionInput;
71
- feedback?: DeploymentFeedbackInput;
72
- }
73
- export interface DeploymentProviderOptions {
74
- okraCloudflareContainer: OkraCloudflareContainerDeploymentOptions;
75
- okraSshAgent: OkraSshAgentDeploymentOptions;
76
- okraLaravelCloud: OkraLaravelCloudDeploymentOptions;
77
- }
78
- export interface DeploymentProviderBuildOptions {
79
- okraCloudflareContainer: OkraCloudflareContainerBuildOptions;
80
- okraSshAgent: OkraSshAgentBuildOptions;
81
- okraLaravelCloud: OkraLaravelCloudBuildOptions;
82
- }
83
- export type DeploymentOptionsForProvider<TProvider extends DeploymentTargetProvider> = DeploymentProviderOptions[TProvider];
84
- export type DeploymentBuildOptionsForProvider<TProvider extends DeploymentTargetProvider> = DeploymentProviderBuildOptions[TProvider];
85
- export interface OkraCloudflareContainerPublishInput {
86
- targetProvider: 'okraCloudflareContainer';
87
- options?: OkraCloudflareContainerPublishOptions;
88
- }
89
- export interface OkraSshAgentPublishInput {
90
- targetProvider: 'okraSshAgent';
91
- options: OkraSshAgentPublishOptions;
92
- }
93
- export interface OkraLaravelCloudPublishInput {
94
- targetProvider: 'okraLaravelCloud';
95
- options: OkraLaravelCloudPublishOptions;
96
- }
97
- export type ProviderPublishInput = OkraCloudflareContainerPublishInput | OkraSshAgentPublishInput | OkraLaravelCloudPublishInput;
98
- export type FirstPublishInput = ProviderPublishInput & {
99
- slug: string;
100
- };
101
- export type PublishInput = FirstPublishInput;
102
- export interface DeploymentSlugAvailabilityData {
103
- slug: string;
104
- available: boolean;
105
- domain: string;
106
- }
107
- export interface DeploymentBuildData<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
108
- id: string;
109
- status: DeploymentBuildStatus;
110
- strategy: string;
111
- targetProvider: TProvider;
112
- options: DeploymentBuildOptionsForProvider<TProvider>;
113
- errorMessage: string | null;
114
- startedAt: string | null;
115
- finishedAt: string | null;
116
- }
117
- export interface DeploymentReleaseData {
118
- id: string;
119
- status: DeploymentReleaseStatus;
120
- manifest: Record<string, unknown>;
121
- }
122
- export interface DeploymentDomainDnsData {
123
- type: DeploymentDomainDnsRecordType;
124
- name: string;
125
- value: string;
126
- }
127
- export interface DeploymentDomainData {
128
- id: string;
129
- deploymentId: string | null;
130
- hostname: string;
131
- status: string;
132
- provider: string;
133
- providerHostnameId: string | null;
134
- dns: DeploymentDomainDnsData;
135
- ssl: {
136
- status: string | null;
137
- };
138
- validationErrors: unknown[];
139
- validationRecords: unknown[];
140
- metadata: Record<string, unknown>;
141
- verifiedAt: string | null;
142
- createdAt: string | null;
143
- updatedAt: string | null;
144
- }
145
- export interface CreateDeploymentDomainInput {
146
- hostname: string;
147
- }
148
- export interface DeploymentData<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
149
- id: string;
150
- slug: string;
151
- url: string;
152
- status: DeploymentStatus;
153
- strategy: string;
154
- targetProvider: TProvider;
155
- options: DeploymentOptionsForProvider<TProvider>;
156
- eventStreamUrl?: string | null;
157
- /** @deprecated Use eventStreamUrl instead. */
158
- okraUrl: string | null;
159
- originUrl: string | null;
160
- currentRelease?: DeploymentReleaseData | null;
161
- domains?: DeploymentDomainData[];
162
- latestBuild?: DeploymentBuildData<TProvider> | null;
163
- deployedAt: string | null;
164
- createdAt: string | null;
165
- updatedAt: string | null;
166
- }
167
- export interface UpdateDeploymentProtectionInput {
168
- mode: DeploymentProtectionMode;
169
- password?: string;
170
- }
171
- export interface DeploymentProtectionSessionData {
172
- previewSessionId: string;
173
- token: string;
174
- expiresAt: string;
175
- url: string;
176
- }
177
- export interface UpdateDeploymentFeedbackInput {
178
- enabled: boolean;
179
- config?: Record<string, unknown>;
180
- }
181
- export declare class NotebookDeploymentApi {
182
- private readonly client;
183
- constructor(client: Client);
184
- current<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(notebookId: string): Promise<DeploymentInstance<TProvider> | null>;
185
- publish<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(notebookId: string, input?: PublishInput): Promise<DeploymentRun<TProvider>>;
186
- slugAvailability(id: string, slug: string): Promise<DeploymentSlugAvailabilityData>;
187
- }
188
- export declare class DeploymentApi {
189
- private readonly client;
190
- constructor(client: Client);
191
- get<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
192
- delete(id: string): Promise<void>;
193
- setProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
194
- protection(id: string): Promise<DeploymentProtectionData>;
195
- createProtectionSession(id: string): Promise<DeploymentProtectionSessionData>;
196
- disableProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
197
- setFeedback<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
198
- listDomains(id: string): Promise<DeploymentDomainData[]>;
199
- createDomain(id: string, input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
200
- refreshDomain(id: string, domainId: string): Promise<DeploymentDomainData>;
201
- deleteDomain(id: string, domainId: string): Promise<void>;
202
- events(id: string): Promise<ReadableStream<DeploymentEventData>>;
203
- buildLogs(id: string, buildId: string): Promise<ReadableStream<DeploymentLogChunkData>>;
204
- logs(id: string): Promise<ReadableStream<DeploymentLogChunkData>>;
205
- }
206
- export declare class DeploymentRun<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
207
- readonly initial: DeploymentInstance<TProvider>;
208
- private readonly client;
209
- private started;
210
- private completed;
211
- private finalError;
212
- private finalResult;
213
- private resultPromise;
214
- private resolveResult;
215
- private rejectResult;
216
- private readonly bufferedEvents;
217
- private readonly subscribers;
218
- constructor(initial: DeploymentInstance<TProvider>, client: Client);
219
- events(): AsyncIterable<DeployStreamEvent>;
220
- result(): Promise<DeployStreamResult>;
221
- deployment(): Promise<DeploymentInstance<TProvider>>;
222
- start(): this;
223
- private subscribe;
224
- private consumeStream;
225
- private publish;
226
- private closeSubscribers;
227
- private fail;
228
- }
229
- export declare class DeploymentInstance<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
230
- readonly data: DeploymentData<TProvider>;
231
- private readonly client;
232
- private readonly notebookId?;
233
- constructor(data: DeploymentData<TProvider>, client: Client, notebookId?: string);
234
- refresh(): Promise<DeploymentInstance<TProvider>>;
235
- publish(): Promise<DeploymentRun<TProvider>>;
236
- delete(): Promise<void>;
237
- wait(options?: {
238
- intervalMs?: number;
239
- timeoutMs?: number;
240
- }): Promise<DeploymentInstance<TProvider>>;
241
- events(): Promise<ReadableStream<DeploymentEventData>>;
242
- buildLogs(buildId?: string): Promise<ReadableStream<DeploymentLogChunkData>>;
243
- logs(): Promise<ReadableStream<DeploymentLogChunkData>>;
244
- setProtection(input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
245
- protection(): Promise<DeploymentProtectionData>;
246
- createProtectionSession(): Promise<DeploymentProtectionSessionData>;
247
- disableProtection(): Promise<DeploymentInstance<TProvider>>;
248
- setFeedback(input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
249
- domains(): Promise<DeploymentDomainData[]>;
250
- addDomain(input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
251
- refreshDomain(domainId: string): Promise<DeploymentDomainData>;
252
- deleteDomain(domainId: string): Promise<void>;
253
- }
package/dist/laravel.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import { Action, NotebookInstance } from './index.js';
2
- export interface Down {
3
- except: string[];
4
- redirect: string | null;
5
- retry: string | null;
6
- refresh: string | null;
7
- secret: string | null;
8
- status: number;
9
- template: string | null;
10
- }
11
- export interface LaravelEvents {
12
- }
13
- export interface LaravelActions {
14
- 'laravel.maintenance.info': Action<{}, Down>;
15
- 'laravel.maintenance.toggle': Action<Down | {}, Down>;
16
- }
17
- export default class Laravel {
18
- protected okra: NotebookInstance;
19
- constructor(okra: NotebookInstance);
20
- maintenanceInfo(): Promise<Down>;
21
- toggleMaintenance(down: Down | {}): Promise<Down>;
22
- }
package/dist/laravel.js DELETED
@@ -1,11 +0,0 @@
1
- export default class Laravel {
2
- constructor(okra) {
3
- this.okra = okra;
4
- }
5
- maintenanceInfo() {
6
- return this.okra.invoke('laravel.maintenance.info', {});
7
- }
8
- toggleMaintenance(down) {
9
- return this.okra.invoke('laravel.maintenance.toggle', down);
10
- }
11
- }