@phpsandbox/sdk 0.0.68 → 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.
- package/README.md +10 -13
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -3
- package/dist/beacon/index.d.ts +2 -0
- package/dist/beacon/index.js +5 -0
- package/dist/browser/phpsandbox-sdk.esm.js +306 -1010
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +306 -1010
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/filesystem.d.ts +2 -1
- package/dist/filesystem.js +35 -2
- package/dist/index.d.ts +14 -19
- package/dist/index.js +16 -24
- package/dist/publications.d.ts +222 -0
- package/dist/{deployments.js → publications.js} +64 -69
- package/dist/repl.d.ts +0 -2
- package/dist/repl.js +0 -3
- package/dist/schemas/{deployments.d.ts → publications.d.ts} +68 -68
- package/dist/schemas/publications.js +133 -0
- package/dist/shell.d.ts +43 -22
- package/dist/shell.js +103 -75
- package/dist/terminal.d.ts +1 -3
- package/dist/terminal.js +2 -5
- package/docs/api-summary.md +13 -10
- package/docs/cdn-usage.md +4 -4
- package/docs/getting-started.md +6 -6
- package/examples/README.md +8 -9
- package/examples/basic.ts +1 -1
- package/examples/git-merge-smoke.ts +2 -2
- package/examples/laravel-load-test.ts +13 -18
- package/examples/notebook-readonly-smoke.ts +8 -8
- package/examples/publication-provider-label.ts +11 -0
- package/examples/{deploy-cloudflare-container.ts → publish-cloudflare-container.ts} +11 -11
- package/examples/{deploy-laravel-cloud.ts → publish-laravel-cloud.ts} +11 -11
- package/examples/{deploy-ssh-agent.ts → publish-ssh-agent.ts} +15 -16
- package/package.json +7 -2
- package/dist/deployments.d.ts +0 -251
- package/dist/laravel.d.ts +0 -22
- package/dist/laravel.js +0 -11
- package/dist/schemas/deployments.js +0 -133
- package/examples/deployment-provider-label.ts +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from '../src/index.js';
|
|
2
|
-
import {
|
|
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.
|
|
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
|
|
21
|
-
if (
|
|
22
|
-
throw new Error(`Notebook is already published to ${
|
|
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 =
|
|
26
|
-
? await
|
|
25
|
+
const run = publication
|
|
26
|
+
? await publication.publish()
|
|
27
27
|
: await notebook.publish({
|
|
28
28
|
slug,
|
|
29
|
-
|
|
30
|
-
|
|
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.
|
|
47
|
-
console.log('
|
|
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 {
|
|
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.
|
|
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
|
|
29
|
-
if (
|
|
30
|
-
throw new Error(`Notebook is already published to ${
|
|
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 =
|
|
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.
|
|
46
|
-
console.log('
|
|
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
|
|
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
|
-
|
|
105
|
-
|
|
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 {
|
|
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.
|
|
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
|
|
33
|
-
if (
|
|
34
|
-
throw new Error(`Notebook is already published to ${
|
|
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 =
|
|
38
|
-
? await
|
|
37
|
+
const run = publication
|
|
38
|
+
? await publication.publish()
|
|
39
39
|
: await notebook.publish({
|
|
40
40
|
slug,
|
|
41
|
-
|
|
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.
|
|
56
|
-
console.log('
|
|
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(`
|
|
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.
|
|
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.
|
|
81
|
+
host: process.env.PHPSANDBOX_PUBLISH_SERVER_HOST ?? 'localhost',
|
|
83
82
|
ssh: {
|
|
84
83
|
user: process.env.USER ?? 'local',
|
|
85
|
-
port: Number(process.env.
|
|
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
|
|
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.
|
|
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/
|
|
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
|
},
|
package/dist/deployments.d.ts
DELETED
|
@@ -1,251 +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
|
-
originUrl: string | null;
|
|
158
|
-
currentRelease?: DeploymentReleaseData | null;
|
|
159
|
-
domains?: DeploymentDomainData[];
|
|
160
|
-
latestBuild?: DeploymentBuildData<TProvider> | null;
|
|
161
|
-
deployedAt: string | null;
|
|
162
|
-
createdAt: string | null;
|
|
163
|
-
updatedAt: string | null;
|
|
164
|
-
}
|
|
165
|
-
export interface UpdateDeploymentProtectionInput {
|
|
166
|
-
mode: DeploymentProtectionMode;
|
|
167
|
-
password?: string;
|
|
168
|
-
}
|
|
169
|
-
export interface DeploymentProtectionSessionData {
|
|
170
|
-
previewSessionId: string;
|
|
171
|
-
token: string;
|
|
172
|
-
expiresAt: string;
|
|
173
|
-
url: string;
|
|
174
|
-
}
|
|
175
|
-
export interface UpdateDeploymentFeedbackInput {
|
|
176
|
-
enabled: boolean;
|
|
177
|
-
config?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
export declare class NotebookDeploymentApi {
|
|
180
|
-
private readonly client;
|
|
181
|
-
constructor(client: Client);
|
|
182
|
-
current<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(notebookId: string): Promise<DeploymentInstance<TProvider> | null>;
|
|
183
|
-
publish<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(notebookId: string, input?: PublishInput): Promise<DeploymentRun<TProvider>>;
|
|
184
|
-
slugAvailability(id: string, slug: string): Promise<DeploymentSlugAvailabilityData>;
|
|
185
|
-
}
|
|
186
|
-
export declare class DeploymentApi {
|
|
187
|
-
private readonly client;
|
|
188
|
-
constructor(client: Client);
|
|
189
|
-
get<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
|
|
190
|
-
delete(id: string): Promise<void>;
|
|
191
|
-
setProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
|
|
192
|
-
protection(id: string): Promise<DeploymentProtectionData>;
|
|
193
|
-
createProtectionSession(id: string): Promise<DeploymentProtectionSessionData>;
|
|
194
|
-
disableProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
|
|
195
|
-
setFeedback<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
|
|
196
|
-
listDomains(id: string): Promise<DeploymentDomainData[]>;
|
|
197
|
-
createDomain(id: string, input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
|
|
198
|
-
refreshDomain(id: string, domainId: string): Promise<DeploymentDomainData>;
|
|
199
|
-
deleteDomain(id: string, domainId: string): Promise<void>;
|
|
200
|
-
events(id: string): Promise<ReadableStream<DeploymentEventData>>;
|
|
201
|
-
buildLogs(id: string, buildId: string): Promise<ReadableStream<DeploymentLogChunkData>>;
|
|
202
|
-
logs(id: string): Promise<ReadableStream<DeploymentLogChunkData>>;
|
|
203
|
-
}
|
|
204
|
-
export declare class DeploymentRun<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
|
|
205
|
-
readonly initial: DeploymentInstance<TProvider>;
|
|
206
|
-
private readonly client;
|
|
207
|
-
private started;
|
|
208
|
-
private completed;
|
|
209
|
-
private finalError;
|
|
210
|
-
private finalResult;
|
|
211
|
-
private resultPromise;
|
|
212
|
-
private resolveResult;
|
|
213
|
-
private rejectResult;
|
|
214
|
-
private readonly bufferedEvents;
|
|
215
|
-
private readonly subscribers;
|
|
216
|
-
constructor(initial: DeploymentInstance<TProvider>, client: Client);
|
|
217
|
-
events(): AsyncIterable<DeployStreamEvent>;
|
|
218
|
-
result(): Promise<DeployStreamResult>;
|
|
219
|
-
deployment(): Promise<DeploymentInstance<TProvider>>;
|
|
220
|
-
start(): this;
|
|
221
|
-
private subscribe;
|
|
222
|
-
private consumeStream;
|
|
223
|
-
private publish;
|
|
224
|
-
private closeSubscribers;
|
|
225
|
-
private fail;
|
|
226
|
-
}
|
|
227
|
-
export declare class DeploymentInstance<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
|
|
228
|
-
readonly data: DeploymentData<TProvider>;
|
|
229
|
-
private readonly client;
|
|
230
|
-
private readonly notebookId?;
|
|
231
|
-
constructor(data: DeploymentData<TProvider>, client: Client, notebookId?: string);
|
|
232
|
-
refresh(): Promise<DeploymentInstance<TProvider>>;
|
|
233
|
-
publish(): Promise<DeploymentRun<TProvider>>;
|
|
234
|
-
delete(): Promise<void>;
|
|
235
|
-
wait(options?: {
|
|
236
|
-
intervalMs?: number;
|
|
237
|
-
timeoutMs?: number;
|
|
238
|
-
}): Promise<DeploymentInstance<TProvider>>;
|
|
239
|
-
events(): Promise<ReadableStream<DeploymentEventData>>;
|
|
240
|
-
buildLogs(buildId?: string): Promise<ReadableStream<DeploymentLogChunkData>>;
|
|
241
|
-
logs(): Promise<ReadableStream<DeploymentLogChunkData>>;
|
|
242
|
-
setProtection(input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
|
|
243
|
-
protection(): Promise<DeploymentProtectionData>;
|
|
244
|
-
createProtectionSession(): Promise<DeploymentProtectionSessionData>;
|
|
245
|
-
disableProtection(): Promise<DeploymentInstance<TProvider>>;
|
|
246
|
-
setFeedback(input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
|
|
247
|
-
domains(): Promise<DeploymentDomainData[]>;
|
|
248
|
-
addDomain(input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
|
|
249
|
-
refreshDomain(domainId: string): Promise<DeploymentDomainData>;
|
|
250
|
-
deleteDomain(domainId: string): Promise<void>;
|
|
251
|
-
}
|
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
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DeploymentTargetProvider } from '../src/index.js';
|
|
2
|
-
|
|
3
|
-
const deploymentTargetProviderLabels: Record<DeploymentTargetProvider, string> = {
|
|
4
|
-
okraCloudflareContainer: 'Cloudflare Containers',
|
|
5
|
-
okraSshAgent: 'SSH Agent',
|
|
6
|
-
okraLaravelCloud: 'Laravel Cloud',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export function deploymentTargetProviderLabel(provider: DeploymentTargetProvider): string {
|
|
10
|
-
return deploymentTargetProviderLabels[provider] ?? provider;
|
|
11
|
-
}
|