@phpsandbox/sdk 0.0.56 → 0.0.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,138 +1,175 @@
1
- import type { Client, PaginatedApiResponse } from './index.js';
2
- export type DeploymentStrategy = 'auto' | 'laravel' | 'phpsandbox' | 'compose' | 'custom';
3
- export type DeploymentTargetProvider = 'okra' | 'cloudflare-containers';
4
- export type DeploymentRuntimeProvider = 'docker' | 'compose' | 'cloudflare-container';
5
- export type DeploymentStatus = 'pending' | 'queued' | 'building' | 'deploying' | 'healthy' | 'failed' | 'stopped' | 'deleting' | 'deleted' | 'delete_failed';
6
- export type DeploymentSize = 'nano' | 'small' | 'medium' | 'large' | 'lite' | 'basic' | 'standard-1' | 'standard-2';
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';
7
4
  export interface DeploymentPlacement {
8
- regions?: Array<'ENAM' | 'WNAM' | 'EEUR' | 'WEUR' | 'APAC' | 'SAM' | 'ME' | 'OC' | 'AFR' | string>;
9
- jurisdiction?: 'eu' | 'fedramp' | string;
10
- }
11
- export interface DeployInput {
12
- name?: string;
13
- slug?: string;
14
- strategy?: DeploymentStrategy;
15
- target_provider?: DeploymentTargetProvider;
16
- runtime_provider?: DeploymentRuntimeProvider;
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 {
17
32
  size?: DeploymentSize;
18
- sleep_after?: string;
33
+ sleepAfter?: string;
19
34
  placement?: DeploymentPlacement;
20
35
  instances?: number;
21
- source_ref?: string;
22
- password?: string;
23
- feedback_enabled?: boolean;
24
- metadata?: Record<string, unknown>;
25
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;
26
102
  export interface DeploymentSlugAvailabilityData {
27
103
  slug: string;
28
104
  available: boolean;
29
105
  domain: string;
30
106
  }
31
- export interface DeploymentBuildData {
107
+ export interface DeploymentBuildData<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
32
108
  id: string;
33
- status: string;
34
- source_ref: string | null;
35
- strategy: DeploymentStrategy | string;
36
- target_provider: DeploymentTargetProvider | string;
37
- runtime_provider: DeploymentRuntimeProvider | string | null;
38
- size: DeploymentSize | string;
39
- artifact_path: string | null;
40
- artifact_checksum: string | null;
41
- error_message: string | null;
42
- started_at: string | null;
43
- finished_at: string | null;
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;
44
116
  }
45
117
  export interface DeploymentReleaseData {
46
118
  id: string;
47
- status: string;
48
- artifact_path: string;
49
- artifact_checksum: string;
119
+ status: DeploymentReleaseStatus;
50
120
  manifest: Record<string, unknown>;
51
121
  }
52
122
  export interface DeploymentDomainDnsData {
53
- type: 'CNAME' | 'ALIAS' | 'ANAME' | string;
123
+ type: DeploymentDomainDnsRecordType;
54
124
  name: string;
55
125
  value: string;
56
126
  }
57
127
  export interface DeploymentDomainData {
58
128
  id: string;
59
- deployment_id: string;
129
+ deploymentId: string | null;
60
130
  hostname: string;
61
131
  status: string;
62
132
  provider: string;
63
- provider_hostname_id: string | null;
133
+ providerHostnameId: string | null;
64
134
  dns: DeploymentDomainDnsData;
65
135
  ssl: {
66
136
  status: string | null;
67
137
  };
68
- validation_errors: unknown[];
69
- validation_records: unknown[];
138
+ validationErrors: unknown[];
139
+ validationRecords: unknown[];
70
140
  metadata: Record<string, unknown>;
71
- verified_at: string | null;
72
- created_at: string | null;
73
- updated_at: string | null;
141
+ verifiedAt: string | null;
142
+ createdAt: string | null;
143
+ updatedAt: string | null;
74
144
  }
75
145
  export interface CreateDeploymentDomainInput {
76
146
  hostname: string;
77
147
  }
78
- export interface DeploymentData {
148
+ export interface DeploymentData<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider> {
79
149
  id: string;
80
- notebook_id: string;
81
- name: string;
82
150
  slug: string;
83
151
  url: string;
84
- status: DeploymentStatus | string;
85
- strategy: DeploymentStrategy | string;
86
- target_provider: DeploymentTargetProvider | string;
87
- runtime_provider: DeploymentRuntimeProvider | string | null;
88
- size: DeploymentSize | string;
89
- sleep_after: string;
90
- placement: DeploymentPlacement | null;
91
- instances: number;
92
- origin_url: string | null;
93
- protection: {
94
- mode: 'none' | 'password' | string;
95
- enabled: boolean;
96
- };
97
- feedback: {
98
- enabled: boolean;
99
- config: Record<string, unknown>;
100
- };
101
- current_release?: DeploymentReleaseData | null;
152
+ status: DeploymentStatus;
153
+ strategy: string;
154
+ targetProvider: TProvider;
155
+ options: DeploymentOptionsForProvider<TProvider>;
156
+ okraUrl: string | null;
157
+ originUrl: string | null;
158
+ currentRelease?: DeploymentReleaseData | null;
102
159
  domains?: DeploymentDomainData[];
103
- latest_build?: DeploymentBuildData | null;
104
- deployed_at: string | null;
105
- created_at: string | null;
106
- updated_at: string | null;
107
- }
108
- export interface DeploymentEventData {
109
- id?: number | string;
110
- sequence: number;
111
- type: string;
112
- payload: Record<string, unknown>;
113
- created_at: string | null;
114
- }
115
- export interface DeploymentLogChunkData {
116
- sequence: number;
117
- stream: 'build' | 'runtime' | string;
118
- content: string;
119
- created_at: string | null;
160
+ latestBuild?: DeploymentBuildData<TProvider> | null;
161
+ deployedAt: string | null;
162
+ createdAt: string | null;
163
+ updatedAt: string | null;
120
164
  }
121
165
  export interface UpdateDeploymentProtectionInput {
122
- mode: 'none' | 'password';
166
+ mode: DeploymentProtectionMode;
123
167
  password?: string;
124
168
  }
125
- export interface DeploymentProtectionData {
126
- mode: 'none' | 'password' | string;
127
- enabled: boolean;
128
- token?: string;
129
- expires_at?: string;
130
- url?: string;
131
- }
132
169
  export interface DeploymentProtectionSessionData {
133
- preview_session_id: string;
170
+ previewSessionId: string;
134
171
  token: string;
135
- expires_at: string;
172
+ expiresAt: string;
136
173
  url: string;
137
174
  }
138
175
  export interface UpdateDeploymentFeedbackInput {
@@ -142,21 +179,20 @@ export interface UpdateDeploymentFeedbackInput {
142
179
  export declare class NotebookDeploymentApi {
143
180
  private readonly client;
144
181
  constructor(client: Client);
145
- create(id: string, input?: DeployInput): Promise<DeploymentInstance>;
146
- list(id: string): Promise<PaginatedApiResponse<DeploymentData>>;
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>>;
147
184
  slugAvailability(id: string, slug: string): Promise<DeploymentSlugAvailabilityData>;
148
185
  }
149
186
  export declare class DeploymentApi {
150
187
  private readonly client;
151
188
  constructor(client: Client);
152
- get(id: string): Promise<DeploymentInstance>;
153
- redeploy(id: string, input?: DeployInput): Promise<DeploymentInstance>;
189
+ get<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
154
190
  delete(id: string): Promise<void>;
155
- setProtection(id: string, input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance>;
191
+ setProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
156
192
  protection(id: string): Promise<DeploymentProtectionData>;
157
193
  createProtectionSession(id: string): Promise<DeploymentProtectionSessionData>;
158
- disableProtection(id: string): Promise<DeploymentInstance>;
159
- setFeedback(id: string, input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance>;
194
+ disableProtection<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string): Promise<DeploymentInstance<TProvider>>;
195
+ setFeedback<TProvider extends DeploymentTargetProvider = DeploymentTargetProvider>(id: string, input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
160
196
  listDomains(id: string): Promise<DeploymentDomainData[]>;
161
197
  createDomain(id: string, input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
162
198
  refreshDomain(id: string, domainId: string): Promise<DeploymentDomainData>;
@@ -165,25 +201,49 @@ export declare class DeploymentApi {
165
201
  buildLogs(id: string, buildId: string): Promise<ReadableStream<DeploymentLogChunkData>>;
166
202
  logs(id: string): Promise<ReadableStream<DeploymentLogChunkData>>;
167
203
  }
168
- export declare class DeploymentInstance {
169
- readonly data: DeploymentData;
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>;
170
229
  private readonly client;
171
- constructor(data: DeploymentData, client: Client);
172
- refresh(): Promise<DeploymentInstance>;
173
- redeploy(input?: DeployInput): Promise<DeploymentInstance>;
230
+ private readonly notebookId?;
231
+ constructor(data: DeploymentData<TProvider>, client: Client, notebookId?: string);
232
+ refresh(): Promise<DeploymentInstance<TProvider>>;
233
+ publish(): Promise<DeploymentRun<TProvider>>;
174
234
  delete(): Promise<void>;
175
235
  wait(options?: {
176
236
  intervalMs?: number;
177
237
  timeoutMs?: number;
178
- }): Promise<DeploymentInstance>;
238
+ }): Promise<DeploymentInstance<TProvider>>;
179
239
  events(): Promise<ReadableStream<DeploymentEventData>>;
180
240
  buildLogs(buildId?: string): Promise<ReadableStream<DeploymentLogChunkData>>;
181
241
  logs(): Promise<ReadableStream<DeploymentLogChunkData>>;
182
- setProtection(input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance>;
242
+ setProtection(input: UpdateDeploymentProtectionInput): Promise<DeploymentInstance<TProvider>>;
183
243
  protection(): Promise<DeploymentProtectionData>;
184
244
  createProtectionSession(): Promise<DeploymentProtectionSessionData>;
185
- disableProtection(): Promise<DeploymentInstance>;
186
- setFeedback(input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance>;
245
+ disableProtection(): Promise<DeploymentInstance<TProvider>>;
246
+ setFeedback(input: UpdateDeploymentFeedbackInput): Promise<DeploymentInstance<TProvider>>;
187
247
  domains(): Promise<DeploymentDomainData[]>;
188
248
  addDomain(input: CreateDeploymentDomainInput): Promise<DeploymentDomainData>;
189
249
  refreshDomain(domainId: string): Promise<DeploymentDomainData>;