@phpsandbox/sdk 0.0.60 → 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
@@ -121,9 +121,24 @@ export interface CreateNotebookInput extends NotebookLifecycleInput {
121
121
  title: string;
122
122
  visibility: 'public' | 'private' | 'unlisted';
123
123
  import?: CreateNotebookImportInput;
124
+ composerCredentials?: ComposerCredentialInput[];
124
125
  }
125
126
  export type ForkNotebookInput = NotebookLifecycleInput;
126
- 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
+ }
127
142
  export interface NotebookPolicyData {
128
143
  auto_delete_when_stale: boolean;
129
144
  stale_after_minutes: number | null;
@@ -158,6 +173,37 @@ export type UpsertNotebookSecretsInput = UpsertNotebookSecretItemInput[] | Recor
158
173
  export interface NotebookSecretDeleteOptions {
159
174
  environment?: SecretEnvironment;
160
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
+ }
161
207
  export interface NotebookPreviewDataDisabled {
162
208
  enabled: false;
163
209
  }
@@ -231,6 +277,7 @@ export declare class ApiError extends Error {
231
277
  export declare class NotebookApi {
232
278
  private readonly client;
233
279
  readonly secrets: NotebookSecretApi;
280
+ readonly composerCredentials: NotebookComposerCredentialApi;
234
281
  readonly preview: NotebookPreviewApi;
235
282
  readonly mail: NotebookMailApi;
236
283
  readonly deployment: NotebookDeploymentApi;
@@ -287,6 +334,12 @@ export declare class NotebookSecretApi {
287
334
  setMany(id: string, input: UpsertNotebookSecretsInput): Promise<NotebookSecretData[]>;
288
335
  delete(id: string, name: string, options?: NotebookSecretDeleteOptions): Promise<void>;
289
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
+ }
290
343
  export declare class NotebookPreviewApi {
291
344
  private readonly client;
292
345
  constructor(client: Client);
@@ -362,7 +415,7 @@ export declare class NotebookInstance {
362
415
  onDidConnect(handler: () => void): Disposable;
363
416
  onDidDisconnect(handler: () => void): Disposable;
364
417
  onDidBootError(handler: (error: NotebookUnavailableError) => void): Disposable;
365
- update(): Promise<void>;
418
+ update(input: Partial<UpdateNotebookInput>): Promise<NotebookInstance>;
366
419
  onDidInitialize(handler: (result: NotebookInitResult) => void): Disposable;
367
420
  reconnect(): Promise<NotebookInstance>;
368
421
  beacon(iframe: HTMLIFrameElement, options?: BeaconOptions): Promise<Beacon>;
@@ -376,6 +429,13 @@ export declare class NotebookSecrets {
376
429
  setMany(input: UpsertNotebookSecretsInput): Promise<NotebookSecretData[]>;
377
430
  delete(name: string, options?: NotebookSecretDeleteOptions): Promise<void>;
378
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
+ }
379
439
  export declare class NotebookPreview {
380
440
  private readonly client;
381
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);
@@ -122,7 +123,7 @@ export class NotebookApi {
122
123
  }
123
124
  async fork(id, input = {}) {
124
125
  const response = await this.client.post(`/notebook/${id}/fork`, input);
125
- return this.init(new NotebookInstance(response.data, this.client));
126
+ return new NotebookInstance(response.data, this.client);
126
127
  }
127
128
  async gitCredentials(id) {
128
129
  const response = await this.client.post(`/notebook/${id}/git/credentials`);
@@ -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.60",
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",