@phpsandbox/sdk 0.0.61 → 0.0.63

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,4 +1,4 @@
1
- import { Action, Disposable, NotebookInstance } from './index.js';
1
+ import { Action, Client, ComposerCredentials, Disposable, NotebookInstance } from './index.js';
2
2
  export interface ComposerEvents {
3
3
  'composer.log': string;
4
4
  }
@@ -29,7 +29,8 @@ export type Argument<Name extends string = string, Type extends string | string[
29
29
  export type Options<Name extends string = string, Type extends string | string[] | boolean = string | string[] | boolean> = Record<Name, Type>;
30
30
  export default class Composer {
31
31
  protected okra: NotebookInstance;
32
- constructor(okra: NotebookInstance);
32
+ readonly credentials: ComposerCredentials;
33
+ constructor(okra: NotebookInstance, client: Client);
33
34
  invoke(command: ComposerCommand, args?: Argument, options?: Options): Promise<Result>;
34
35
  dumpAutoload(): Promise<{
35
36
  message: string;
package/dist/composer.js CHANGED
@@ -1,6 +1,8 @@
1
+ import { ComposerCredentials } from './index.js';
1
2
  export default class Composer {
2
- constructor(okra) {
3
+ constructor(okra, client) {
3
4
  this.okra = okra;
5
+ this.credentials = new ComposerCredentials(client, okra.data.id);
4
6
  }
5
7
  invoke(command, args = {}, options = {}) {
6
8
  return this.okra.invoke('composer.invoke', { command, args, options });
package/dist/index.d.ts CHANGED
@@ -58,12 +58,15 @@ export interface NotebookInitProgress {
58
58
  chunk?: string;
59
59
  command?: string;
60
60
  }
61
- export type NotebookInitErrorCode = 'github_import_credential_missing';
61
+ export type NotebookInitErrorCode = 'github_import_credential_missing' | 'notebook_disk_quota_exceeded' | 'notebook_not_found' | 'notebook_setup_json_invalid' | 'notebook_backup_restore_failed';
62
62
  export interface NotebookInitErrorData {
63
63
  errorCode?: NotebookInitErrorCode;
64
64
  details?: string;
65
65
  retryable?: boolean;
66
66
  suggestedAction?: string;
67
+ phase?: string;
68
+ quotaMb?: number;
69
+ usedMb?: number;
67
70
  provider?: string;
68
71
  repository?: string;
69
72
  branch?: string | null;
@@ -118,9 +121,24 @@ export interface CreateNotebookInput extends NotebookLifecycleInput {
118
121
  title: string;
119
122
  visibility: 'public' | 'private' | 'unlisted';
120
123
  import?: CreateNotebookImportInput;
124
+ composerCredentials?: ComposerCredentialInput[];
121
125
  }
122
126
  export type ForkNotebookInput = NotebookLifecycleInput;
123
- export type UpdateNotebookInput = Omit<CreateNotebookInput, 'persistent'>;
127
+ export interface NetworkMatchCondition {
128
+ path?: string;
129
+ method?: string;
130
+ }
131
+ export interface NetworkTransformation {
132
+ match?: NetworkMatchCondition;
133
+ header?: Record<string, string>;
134
+ }
135
+ export type NetworkPolicyAllow = Record<string, NetworkTransformation[]>;
136
+ export type NetworkPolicy = 'allow' | 'deny' | {
137
+ allow: NetworkPolicyAllow;
138
+ };
139
+ export interface UpdateNotebookInput extends Omit<CreateNotebookInput, 'persistent'> {
140
+ network?: NetworkPolicy | null;
141
+ }
124
142
  export interface NotebookPolicyData {
125
143
  auto_delete_when_stale: boolean;
126
144
  stale_after_minutes: number | null;
@@ -155,6 +173,37 @@ export type UpsertNotebookSecretsInput = UpsertNotebookSecretItemInput[] | Recor
155
173
  export interface NotebookSecretDeleteOptions {
156
174
  environment?: SecretEnvironment;
157
175
  }
176
+ export type ComposerCredentialType = 'github-oauth' | 'gitlab-oauth' | 'gitlab-token' | 'bitbucket-oauth' | 'http-basic' | 'bearer';
177
+ export type ComposerCredentialInput = {
178
+ type: 'github-oauth';
179
+ token: string;
180
+ } | {
181
+ type: 'gitlab-oauth';
182
+ url: string;
183
+ token: string;
184
+ } | {
185
+ type: 'gitlab-token';
186
+ url: string;
187
+ token: string;
188
+ } | {
189
+ type: 'bitbucket-oauth';
190
+ consumerKey: string;
191
+ consumerSecret: string;
192
+ } | {
193
+ type: 'http-basic';
194
+ url: string;
195
+ username: string;
196
+ password: string;
197
+ } | {
198
+ type: 'bearer';
199
+ url: string;
200
+ token: string;
201
+ };
202
+ export interface ComposerCredentialInfo {
203
+ type: ComposerCredentialType;
204
+ url: string;
205
+ username?: string;
206
+ }
158
207
  export interface NotebookPreviewDataDisabled {
159
208
  enabled: false;
160
209
  }
@@ -228,6 +277,7 @@ export declare class ApiError extends Error {
228
277
  export declare class NotebookApi {
229
278
  private readonly client;
230
279
  readonly secrets: NotebookSecretApi;
280
+ readonly composerCredentials: NotebookComposerCredentialApi;
231
281
  readonly preview: NotebookPreviewApi;
232
282
  readonly mail: NotebookMailApi;
233
283
  readonly deployment: NotebookDeploymentApi;
@@ -284,6 +334,12 @@ export declare class NotebookSecretApi {
284
334
  setMany(id: string, input: UpsertNotebookSecretsInput): Promise<NotebookSecretData[]>;
285
335
  delete(id: string, name: string, options?: NotebookSecretDeleteOptions): Promise<void>;
286
336
  }
337
+ export declare class NotebookComposerCredentialApi {
338
+ private readonly client;
339
+ constructor(client: Client);
340
+ set(id: string, input: ComposerCredentialInput): Promise<ComposerCredentialInfo>;
341
+ remove(id: string, type: ComposerCredentialType, url?: string): Promise<void>;
342
+ }
287
343
  export declare class NotebookPreviewApi {
288
344
  private readonly client;
289
345
  constructor(client: Client);
@@ -359,7 +415,7 @@ export declare class NotebookInstance {
359
415
  onDidConnect(handler: () => void): Disposable;
360
416
  onDidDisconnect(handler: () => void): Disposable;
361
417
  onDidBootError(handler: (error: NotebookUnavailableError) => void): Disposable;
362
- update(): Promise<void>;
418
+ update(input: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
363
419
  onDidInitialize(handler: (result: NotebookInitResult) => void): Disposable;
364
420
  reconnect(): Promise<NotebookInstance>;
365
421
  beacon(iframe: HTMLIFrameElement, options?: BeaconOptions): Promise<Beacon>;
@@ -373,6 +429,13 @@ export declare class NotebookSecrets {
373
429
  setMany(input: UpsertNotebookSecretsInput): Promise<NotebookSecretData[]>;
374
430
  delete(name: string, options?: NotebookSecretDeleteOptions): Promise<void>;
375
431
  }
432
+ export declare class ComposerCredentials {
433
+ private readonly client;
434
+ private readonly notebookId;
435
+ constructor(client: Client, notebookId: string);
436
+ set(input: ComposerCredentialInput): Promise<ComposerCredentialInfo>;
437
+ remove(type: ComposerCredentialType, url?: string): Promise<void>;
438
+ }
376
439
  export declare class NotebookPreview {
377
440
  private readonly client;
378
441
  private readonly notebookId;
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ export class NotebookApi {
97
97
  constructor(client) {
98
98
  this.client = client;
99
99
  this.secrets = new NotebookSecretApi(client);
100
+ this.composerCredentials = new NotebookComposerCredentialApi(client);
100
101
  this.preview = new NotebookPreviewApi(client);
101
102
  this.mail = new NotebookMailApi(client);
102
103
  this.deployment = new NotebookDeploymentApi(client);
@@ -255,6 +256,21 @@ export class NotebookSecretApi {
255
256
  await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}${query ? `?${query}` : ''}`);
256
257
  }
257
258
  }
259
+ export class NotebookComposerCredentialApi {
260
+ constructor(client) {
261
+ this.client = client;
262
+ }
263
+ async set(id, input) {
264
+ const response = await this.client.put(`/notebook/${id}/composer/credentials`, input);
265
+ return response.data;
266
+ }
267
+ async remove(id, type, url) {
268
+ const params = new URLSearchParams({ type });
269
+ if (url)
270
+ params.set('url', url);
271
+ await this.client.delete(`/notebook/${id}/composer/credentials?${params.toString()}`);
272
+ }
273
+ }
258
274
  export class NotebookPreviewApi {
259
275
  constructor(client) {
260
276
  this.client = client;
@@ -326,7 +342,7 @@ export class NotebookInstance {
326
342
  this.terminal = new Terminal(this);
327
343
  this.auth = new Auth(this);
328
344
  this.lsp = new Lsp(this);
329
- this.composer = new Composer(this);
345
+ this.composer = new Composer(this, client);
330
346
  this.log = new Log(this);
331
347
  this.repl = new Repl(this);
332
348
  this.container = new Container(this);
@@ -475,8 +491,8 @@ export class NotebookInstance {
475
491
  this.disposables.push(disposable);
476
492
  return disposable;
477
493
  }
478
- update() {
479
- return this.invoke('notebook.update');
494
+ update(input) {
495
+ return this.client.notebook.update(this.data.id, input);
480
496
  }
481
497
  onDidInitialize(handler) {
482
498
  return this.listen('notebook.initialized', handler);
@@ -544,6 +560,18 @@ export class NotebookSecrets {
544
560
  return this.client.notebook.secrets.delete(this.notebookId, name, options);
545
561
  }
546
562
  }
563
+ export class ComposerCredentials {
564
+ constructor(client, notebookId) {
565
+ this.client = client;
566
+ this.notebookId = notebookId;
567
+ }
568
+ set(input) {
569
+ return this.client.notebook.composerCredentials.set(this.notebookId, input);
570
+ }
571
+ remove(type, url) {
572
+ return this.client.notebook.composerCredentials.remove(this.notebookId, type, url);
573
+ }
574
+ }
547
575
  export class NotebookPreview {
548
576
  constructor(client, notebookId) {
549
577
  this.client = client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phpsandbox/sdk",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
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",