@phpsandbox/sdk 0.1.2 → 0.1.6
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 +31 -6
- package/dist/browser/phpsandbox-sdk.esm.js +327 -54
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +327 -54
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/feedback.d.ts +73 -0
- package/dist/feedback.js +38 -0
- package/dist/filesystem.d.ts +19 -24
- package/dist/filesystem.js +75 -1
- package/dist/git.d.ts +28 -11
- package/dist/git.js +41 -10
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/integrations.d.ts +43 -0
- package/dist/integrations.js +48 -0
- package/dist/publications.d.ts +5 -21
- package/dist/publications.js +1 -8
- package/dist/runtime/rest.js +0 -5
- package/dist/sandbox-integrations.d.ts +44 -0
- package/dist/sandbox-integrations.js +63 -0
- package/dist/schemas/publications.d.ts +11 -1
- package/dist/schemas/publications.js +3 -1
- package/dist/terminal.d.ts +0 -7
- package/docs/api-summary.md +33 -3
- package/examples/README.md +1 -1
- package/examples/publish-cloudflare-container.ts +15 -0
- package/examples/publish-laravel-cloud.ts +33 -22
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -111,6 +111,7 @@ Each `NotebookInstance` exposes service clients:
|
|
|
111
111
|
- `notebook.container` (`Container`)
|
|
112
112
|
- `notebook.composer` (`Composer`)
|
|
113
113
|
- `notebook.git` (`Git`)
|
|
114
|
+
- `notebook.integrations` (`SandboxIntegrationApi`)
|
|
114
115
|
- `notebook.lsp` (`Lsp`)
|
|
115
116
|
- `notebook.repl` (`Repl`)
|
|
116
117
|
- `notebook.auth` (`Auth`)
|
|
@@ -119,6 +120,7 @@ Each `NotebookInstance` exposes service clients:
|
|
|
119
120
|
- `notebook.metrics` (`Metrics`)
|
|
120
121
|
- `notebook.services` (`Services`)
|
|
121
122
|
- `notebook.mail` (`NotebookMail`)
|
|
123
|
+
- `notebook.feedback` (`Feedback`)
|
|
122
124
|
|
|
123
125
|
Notes:
|
|
124
126
|
|
|
@@ -242,18 +244,19 @@ console.log(installed.map((pkg) => pkg.name));
|
|
|
242
244
|
```ts
|
|
243
245
|
await notebook.git.checkpoint('Jane Doe <jane@example.com>', 'Initial checkpoint');
|
|
244
246
|
|
|
245
|
-
await
|
|
246
|
-
|
|
247
|
-
type: '
|
|
247
|
+
const github = await client.integrations.link({
|
|
248
|
+
provider: 'github',
|
|
249
|
+
authorization: { type: 'token', token: process.env.GITHUB_TOKEN! },
|
|
248
250
|
});
|
|
251
|
+
await notebook.integrations.attach({ integration: github });
|
|
249
252
|
|
|
250
|
-
await notebook.git.
|
|
253
|
+
const target = await notebook.git.targets.create({
|
|
251
254
|
provider: 'github',
|
|
252
255
|
repository: 'acme/my-repo',
|
|
253
|
-
author: 'Jane Doe
|
|
256
|
+
author: { name: 'Jane Doe', email: 'jane@example.com' },
|
|
254
257
|
branch: 'main',
|
|
255
|
-
credential: { secret: 'GITHUB_TOKEN' },
|
|
256
258
|
});
|
|
259
|
+
await target.sync();
|
|
257
260
|
|
|
258
261
|
const history = await notebook.git.log('main');
|
|
259
262
|
console.log(history[0]);
|
|
@@ -306,6 +309,28 @@ await notebook.mail.delete(mail.hash);
|
|
|
306
309
|
await notebook.mail.disable();
|
|
307
310
|
```
|
|
308
311
|
|
|
312
|
+
### Feedback
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
await sandbox.feedback.configure({
|
|
316
|
+
widget: {
|
|
317
|
+
targets: ['preview', 'publication'],
|
|
318
|
+
types: ['bug', 'suggestion', 'question'],
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
const feedback = await sandbox.feedback.submit({
|
|
323
|
+
type: 'bug',
|
|
324
|
+
message: 'Saving the profile failed.',
|
|
325
|
+
author: { externalId: 'customer-42', email: 'ada@example.com' },
|
|
326
|
+
context: { url: 'https://app.example.com/profile', path: '/profile' },
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
await sandbox.feedback.update(feedback.id, { status: 'resolved' });
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The server-side SDK uses the same PHPSandbox API token as the rest of the sandbox. Set `widget: null` to remove the optional popout without disabling API ingestion.
|
|
333
|
+
|
|
309
334
|
### Events
|
|
310
335
|
|
|
311
336
|
```ts
|
|
@@ -12,6 +12,32 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12
12
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
13
13
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
14
14
|
|
|
15
|
+
// src/errors/index.ts
|
|
16
|
+
var PromiseTimeoutError = class extends Error {
|
|
17
|
+
constructor(message, time3) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.time = time3;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
|
|
23
|
+
static fromPromiseTimeoutError(error51) {
|
|
24
|
+
return new _SendTimeoutError(error51.message, error51.time);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var NotebookUnavailableError = class extends Error {
|
|
28
|
+
constructor(message = "Notebook is no longer available", raw = {}) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.raw = raw;
|
|
31
|
+
this.name = "NotebookUnavailableError";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var UnsupportedRuntimeTransportError = class extends Error {
|
|
35
|
+
constructor(message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = "UnsupportedRuntimeTransportError";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
15
41
|
// src/types.ts
|
|
16
42
|
var ErrorEvent = class extends Error {
|
|
17
43
|
constructor(code, message, raw = {}) {
|
|
@@ -226,6 +252,77 @@ var Filesystem = class {
|
|
|
226
252
|
}
|
|
227
253
|
});
|
|
228
254
|
}
|
|
255
|
+
follow(path, options = {}) {
|
|
256
|
+
if (this.okra.runtimeTransport === "rest") {
|
|
257
|
+
return new ReadableStream({
|
|
258
|
+
start(controller) {
|
|
259
|
+
controller.error(new UnsupportedRuntimeTransportError("Following files requires the realtime transport."));
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const id = nanoid();
|
|
264
|
+
let disposable = null;
|
|
265
|
+
let abort = null;
|
|
266
|
+
let started = false;
|
|
267
|
+
let closed = false;
|
|
268
|
+
const stop = async () => {
|
|
269
|
+
if (closed) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
closed = true;
|
|
273
|
+
disposable?.dispose();
|
|
274
|
+
disposable = null;
|
|
275
|
+
if (abort && options.signal) {
|
|
276
|
+
options.signal.removeEventListener("abort", abort);
|
|
277
|
+
}
|
|
278
|
+
abort = null;
|
|
279
|
+
if (started) {
|
|
280
|
+
await this.okra.invoke("fs.cancelFollow", { id }).catch(() => false);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
return new ReadableStream({
|
|
284
|
+
start: (controller) => {
|
|
285
|
+
disposable = this.okra.listen(`fs.follow.${id}`, (event) => {
|
|
286
|
+
if (!closed) {
|
|
287
|
+
controller.enqueue(event.data);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
if (options.signal) {
|
|
291
|
+
abort = () => {
|
|
292
|
+
void stop().finally(() => controller.error(options.signal?.reason ?? new Error("Aborted")));
|
|
293
|
+
};
|
|
294
|
+
if (options.signal.aborted) {
|
|
295
|
+
abort();
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
options.signal.addEventListener("abort", abort, { once: true });
|
|
299
|
+
}
|
|
300
|
+
started = true;
|
|
301
|
+
void this.okra.invoke("fs.follow", { id, path, lines: options.lines ?? 10 }).then(() => {
|
|
302
|
+
if (!closed) {
|
|
303
|
+
closed = true;
|
|
304
|
+
disposable?.dispose();
|
|
305
|
+
if (abort && options.signal) {
|
|
306
|
+
options.signal.removeEventListener("abort", abort);
|
|
307
|
+
}
|
|
308
|
+
abort = null;
|
|
309
|
+
controller.close();
|
|
310
|
+
}
|
|
311
|
+
}).catch((error51) => {
|
|
312
|
+
if (!closed) {
|
|
313
|
+
closed = true;
|
|
314
|
+
disposable?.dispose();
|
|
315
|
+
if (abort && options.signal) {
|
|
316
|
+
options.signal.removeEventListener("abort", abort);
|
|
317
|
+
}
|
|
318
|
+
abort = null;
|
|
319
|
+
controller.error(error51);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
cancel: stop
|
|
324
|
+
});
|
|
325
|
+
}
|
|
229
326
|
find(query, options = {
|
|
230
327
|
useIgnoreFiles: false,
|
|
231
328
|
followSymlinks: false,
|
|
@@ -304,7 +401,7 @@ var Filesystem = class {
|
|
|
304
401
|
return this.okra.invoke("fs.textSearch", { query, options: { ...defaultOptions, ...options } }).finally(() => disposable.dispose());
|
|
305
402
|
}
|
|
306
403
|
tail(path, options = {}) {
|
|
307
|
-
return this.okra.invoke("fs.tail", { path, lines: options.lines ?? 10 }).catch((e) => this.handleError(e));
|
|
404
|
+
return this.okra.invoke("fs.tail", { path, lines: options.lines ?? 10 }).then(({ content }) => content).catch((e) => this.handleError(e));
|
|
308
405
|
}
|
|
309
406
|
stat(path) {
|
|
310
407
|
return this.okra.invoke("fs.stat", { path }).catch((e) => this.handleError(e));
|
|
@@ -408,32 +505,6 @@ async function collectBytes(stream) {
|
|
|
408
505
|
return output;
|
|
409
506
|
}
|
|
410
507
|
|
|
411
|
-
// src/errors/index.ts
|
|
412
|
-
var PromiseTimeoutError = class extends Error {
|
|
413
|
-
constructor(message, time3) {
|
|
414
|
-
super(message);
|
|
415
|
-
this.time = time3;
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
|
|
419
|
-
static fromPromiseTimeoutError(error51) {
|
|
420
|
-
return new _SendTimeoutError(error51.message, error51.time);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
var NotebookUnavailableError = class extends Error {
|
|
424
|
-
constructor(message = "Notebook is no longer available", raw = {}) {
|
|
425
|
-
super(message);
|
|
426
|
-
this.raw = raw;
|
|
427
|
-
this.name = "NotebookUnavailableError";
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
var UnsupportedRuntimeTransportError = class extends Error {
|
|
431
|
-
constructor(message) {
|
|
432
|
-
super(message);
|
|
433
|
-
this.name = "UnsupportedRuntimeTransportError";
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
|
|
437
508
|
// src/utils/promise.ts
|
|
438
509
|
var timeout = (prom, time3) => {
|
|
439
510
|
let timer;
|
|
@@ -4095,6 +4166,7 @@ var Git = class {
|
|
|
4095
4166
|
constructor(okra, client) {
|
|
4096
4167
|
this.okra = okra;
|
|
4097
4168
|
this.client = client;
|
|
4169
|
+
this.targets = new GitTargetApi(okra.data.id, client);
|
|
4098
4170
|
}
|
|
4099
4171
|
checkpoint(author, message, branch = "main", allowEmpty = false) {
|
|
4100
4172
|
return this.okra.invoke("git.checkpoint", { author, message, branch, allowEmpty });
|
|
@@ -4102,17 +4174,6 @@ var Git = class {
|
|
|
4102
4174
|
checkout(branch, create = true) {
|
|
4103
4175
|
return this.okra.invoke("git.checkout", { branch, create });
|
|
4104
4176
|
}
|
|
4105
|
-
async sync(input) {
|
|
4106
|
-
const response = await this.client.post(
|
|
4107
|
-
`/notebook/${this.okra.data.id}/git/sync-targets`,
|
|
4108
|
-
this.omitUndefined({ ...input })
|
|
4109
|
-
);
|
|
4110
|
-
return response.data;
|
|
4111
|
-
}
|
|
4112
|
-
async syncTargets() {
|
|
4113
|
-
const response = await this.client.get(`/notebook/${this.okra.data.id}/git/sync-targets`);
|
|
4114
|
-
return response.data;
|
|
4115
|
-
}
|
|
4116
4177
|
log(ref = "main") {
|
|
4117
4178
|
return this.okra.invoke("git.log", { ref });
|
|
4118
4179
|
}
|
|
@@ -4181,10 +4242,56 @@ var Git = class {
|
|
|
4181
4242
|
url2.hash = "";
|
|
4182
4243
|
return url2.toString();
|
|
4183
4244
|
}
|
|
4184
|
-
|
|
4185
|
-
|
|
4245
|
+
};
|
|
4246
|
+
var GitTargetApi = class {
|
|
4247
|
+
constructor(notebookId, client) {
|
|
4248
|
+
this.notebookId = notebookId;
|
|
4249
|
+
this.client = client;
|
|
4250
|
+
}
|
|
4251
|
+
async create(input) {
|
|
4252
|
+
const response = await this.client.post(
|
|
4253
|
+
`/notebook/${this.notebookId}/git/targets`,
|
|
4254
|
+
omitUndefined({ ...input })
|
|
4255
|
+
);
|
|
4256
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
4257
|
+
}
|
|
4258
|
+
async list() {
|
|
4259
|
+
const response = await this.client.get(`/notebook/${this.notebookId}/git/targets`);
|
|
4260
|
+
return response.data.map((target) => new GitTarget(target, this.notebookId, this.client));
|
|
4261
|
+
}
|
|
4262
|
+
async get(target) {
|
|
4263
|
+
const response = await this.client.get(
|
|
4264
|
+
`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}`
|
|
4265
|
+
);
|
|
4266
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
4267
|
+
}
|
|
4268
|
+
async sync(target, input = {}) {
|
|
4269
|
+
const response = await this.client.post(
|
|
4270
|
+
`/notebook/${this.notebookId}/git/targets/${encodeURIComponent(gitTargetId(target))}/sync`,
|
|
4271
|
+
omitUndefined({ ...input })
|
|
4272
|
+
);
|
|
4273
|
+
return new GitTarget(response.data, this.notebookId, this.client);
|
|
4274
|
+
}
|
|
4275
|
+
};
|
|
4276
|
+
var GitTarget = class {
|
|
4277
|
+
constructor(data, notebookId, client) {
|
|
4278
|
+
this.data = data;
|
|
4279
|
+
this.notebookId = notebookId;
|
|
4280
|
+
this.client = client;
|
|
4281
|
+
}
|
|
4282
|
+
get id() {
|
|
4283
|
+
return this.data.id;
|
|
4284
|
+
}
|
|
4285
|
+
sync(input = {}) {
|
|
4286
|
+
return new GitTargetApi(this.notebookId, this.client).sync(this, input);
|
|
4186
4287
|
}
|
|
4187
4288
|
};
|
|
4289
|
+
function gitTargetId(target) {
|
|
4290
|
+
return typeof target === "string" ? target : target.id;
|
|
4291
|
+
}
|
|
4292
|
+
function omitUndefined(input) {
|
|
4293
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
4294
|
+
}
|
|
4188
4295
|
|
|
4189
4296
|
// node_modules/zod/v4/classic/external.js
|
|
4190
4297
|
var external_exports = {};
|
|
@@ -18753,11 +18860,15 @@ var PublicationDomainDnsRecordTypeSchema = external_exports.enum(["CNAME", "ALIA
|
|
|
18753
18860
|
var PublicationProtectionModeSchema = external_exports.enum(["none", "password"]);
|
|
18754
18861
|
var PublicationLogStreamSchema = external_exports.enum(["build", "runtime"]);
|
|
18755
18862
|
var PublishStreamLogStreamSchema = external_exports.enum(["build", "publish", "runtime"]);
|
|
18863
|
+
var PublicationEventPayloadSchema = external_exports.preprocess(
|
|
18864
|
+
(payload) => Array.isArray(payload) && payload.length === 0 ? {} : payload,
|
|
18865
|
+
external_exports.record(external_exports.string(), external_exports.unknown())
|
|
18866
|
+
);
|
|
18756
18867
|
var PublicationEventDataSchema = external_exports.object({
|
|
18757
18868
|
id: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
|
|
18758
18869
|
sequence: external_exports.number(),
|
|
18759
18870
|
type: external_exports.string(),
|
|
18760
|
-
payload:
|
|
18871
|
+
payload: PublicationEventPayloadSchema,
|
|
18761
18872
|
createdAt: external_exports.string().nullable()
|
|
18762
18873
|
}).passthrough();
|
|
18763
18874
|
var PublicationLogChunkDataSchema = external_exports.object({
|
|
@@ -18778,6 +18889,7 @@ var PublishStreamLogSchema = external_exports.object({
|
|
|
18778
18889
|
var PublishStreamResultSchema = external_exports.object({
|
|
18779
18890
|
success: external_exports.boolean(),
|
|
18780
18891
|
publicationId: external_exports.string(),
|
|
18892
|
+
url: external_exports.string().url(),
|
|
18781
18893
|
buildId: external_exports.string(),
|
|
18782
18894
|
releaseId: external_exports.string(),
|
|
18783
18895
|
status: PublicationStatusSchema
|
|
@@ -18889,10 +19001,6 @@ var PublicationApi = class {
|
|
|
18889
19001
|
const response = await this.client.delete(`/publications/${id}/protection`);
|
|
18890
19002
|
return new PublicationInstance(response.data, this.client);
|
|
18891
19003
|
}
|
|
18892
|
-
async setFeedback(id, input) {
|
|
18893
|
-
const response = await this.client.put(`/publications/${id}/feedback`, input);
|
|
18894
|
-
return new PublicationInstance(response.data, this.client);
|
|
18895
|
-
}
|
|
18896
19004
|
async listDomains(id) {
|
|
18897
19005
|
const response = await this.client.get(
|
|
18898
19006
|
`/publications/${id}/domains`
|
|
@@ -19002,7 +19110,7 @@ var PublicationRun = class {
|
|
|
19002
19110
|
if (event.type === "result") {
|
|
19003
19111
|
const { type: _, ...result } = event;
|
|
19004
19112
|
this.finalResult = result;
|
|
19005
|
-
this.resolveResult?.(
|
|
19113
|
+
this.resolveResult?.(this.finalResult);
|
|
19006
19114
|
}
|
|
19007
19115
|
}
|
|
19008
19116
|
if (!this.finalResult) {
|
|
@@ -19093,9 +19201,6 @@ var PublicationInstance = class _PublicationInstance {
|
|
|
19093
19201
|
disableProtection() {
|
|
19094
19202
|
return this.client.publications.disableProtection(this.data.id);
|
|
19095
19203
|
}
|
|
19096
|
-
setFeedback(input) {
|
|
19097
|
-
return this.client.publications.setFeedback(this.data.id, input);
|
|
19098
|
-
}
|
|
19099
19204
|
domains() {
|
|
19100
19205
|
return this.client.publications.listDomains(this.data.id);
|
|
19101
19206
|
}
|
|
@@ -19348,18 +19453,13 @@ var restActionRoutes = {
|
|
|
19348
19453
|
"container.stats": { method: "GET", path: "/runtime/container/stats" },
|
|
19349
19454
|
"terminal.list": { method: "GET", path: "/runtime/terminals" },
|
|
19350
19455
|
"shell.exec": { method: "POST", path: "/runtime/executions" },
|
|
19351
|
-
"fs.info": { method: "POST", path: "/runtime/files/info" },
|
|
19352
19456
|
"fs.readFile": { method: "GET", path: "/runtime/files/content" },
|
|
19353
19457
|
"fs.writeFile": { method: "PUT", path: "/runtime/files/content" },
|
|
19354
|
-
"fs.write": { method: "PUT", path: "/runtime/files/text" },
|
|
19355
|
-
"fs.mkdir": { method: "POST", path: "/runtime/directories" },
|
|
19356
19458
|
"fs.createDirectory": { method: "PUT", path: "/runtime/directories" },
|
|
19357
19459
|
"fs.readDirectory": { method: "POST", path: "/runtime/directories/read" },
|
|
19358
19460
|
"fs.stat": { method: "POST", path: "/runtime/files/stat" },
|
|
19359
|
-
"fs.move": { method: "POST", path: "/runtime/files/move" },
|
|
19360
19461
|
"fs.rename": { method: "POST", path: "/runtime/files/rename" },
|
|
19361
19462
|
"fs.copy": { method: "POST", path: "/runtime/files/copy" },
|
|
19362
|
-
"fs.remove": { method: "POST", path: "/runtime/files/remove" },
|
|
19363
19463
|
"fs.delete": { method: "DELETE", path: "/runtime/files" },
|
|
19364
19464
|
"fs.tail": { method: "POST", path: "/runtime/files/tail" },
|
|
19365
19465
|
"fs.find": { method: "POST", path: "/runtime/files/find" },
|
|
@@ -19554,6 +19654,164 @@ function runtimeAbort(options) {
|
|
|
19554
19654
|
};
|
|
19555
19655
|
}
|
|
19556
19656
|
|
|
19657
|
+
// src/feedback.ts
|
|
19658
|
+
var Feedback = class {
|
|
19659
|
+
constructor(client, notebookId) {
|
|
19660
|
+
this.client = client;
|
|
19661
|
+
this.notebookId = notebookId;
|
|
19662
|
+
}
|
|
19663
|
+
async configure(input) {
|
|
19664
|
+
const response = await this.client.put(this.path("/configuration"), input);
|
|
19665
|
+
return response.data;
|
|
19666
|
+
}
|
|
19667
|
+
async configuration() {
|
|
19668
|
+
const response = await this.client.get(this.path("/configuration"));
|
|
19669
|
+
return response.data;
|
|
19670
|
+
}
|
|
19671
|
+
async submit(input) {
|
|
19672
|
+
const response = await this.client.post(this.path(), input);
|
|
19673
|
+
return response.data;
|
|
19674
|
+
}
|
|
19675
|
+
async list(options = {}) {
|
|
19676
|
+
const query = new URLSearchParams();
|
|
19677
|
+
for (const [name, value] of Object.entries(options)) {
|
|
19678
|
+
if (value !== void 0) query.set(name, String(value));
|
|
19679
|
+
}
|
|
19680
|
+
const response = await this.client.get(
|
|
19681
|
+
`${this.path()}${query.size === 0 ? "" : `?${query.toString()}`}`
|
|
19682
|
+
);
|
|
19683
|
+
return response.data;
|
|
19684
|
+
}
|
|
19685
|
+
async get(id) {
|
|
19686
|
+
const response = await this.client.get(this.path(`/${encodeURIComponent(id)}`));
|
|
19687
|
+
return response.data;
|
|
19688
|
+
}
|
|
19689
|
+
async update(id, input) {
|
|
19690
|
+
const response = await this.client.patch(this.path(`/${encodeURIComponent(id)}`), input);
|
|
19691
|
+
return response.data;
|
|
19692
|
+
}
|
|
19693
|
+
path(suffix = "") {
|
|
19694
|
+
return `/notebook/${this.notebookId}/feedback${suffix}`;
|
|
19695
|
+
}
|
|
19696
|
+
};
|
|
19697
|
+
|
|
19698
|
+
// src/integrations.ts
|
|
19699
|
+
var IntegrationApi = class {
|
|
19700
|
+
constructor(client) {
|
|
19701
|
+
this.client = client;
|
|
19702
|
+
}
|
|
19703
|
+
async link(input) {
|
|
19704
|
+
const response = await this.client.post("/integrations", input);
|
|
19705
|
+
return new Integration(response.data, this.client);
|
|
19706
|
+
}
|
|
19707
|
+
async list() {
|
|
19708
|
+
const response = await this.client.get("/integrations");
|
|
19709
|
+
return response.data.map((integration) => new Integration(integration, this.client));
|
|
19710
|
+
}
|
|
19711
|
+
async get(integration) {
|
|
19712
|
+
const response = await this.client.get(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
19713
|
+
return new Integration(response.data, this.client);
|
|
19714
|
+
}
|
|
19715
|
+
async update(integration, input) {
|
|
19716
|
+
const response = await this.client.patch(
|
|
19717
|
+
`/integrations/${encodeURIComponent(integrationId(integration))}`,
|
|
19718
|
+
input
|
|
19719
|
+
);
|
|
19720
|
+
return new Integration(response.data, this.client);
|
|
19721
|
+
}
|
|
19722
|
+
async unlink(integration) {
|
|
19723
|
+
await this.client.delete(`/integrations/${encodeURIComponent(integrationId(integration))}`);
|
|
19724
|
+
}
|
|
19725
|
+
};
|
|
19726
|
+
var Integration = class {
|
|
19727
|
+
constructor(data, client) {
|
|
19728
|
+
this.data = data;
|
|
19729
|
+
this.client = client;
|
|
19730
|
+
}
|
|
19731
|
+
get id() {
|
|
19732
|
+
return this.data.id;
|
|
19733
|
+
}
|
|
19734
|
+
get provider() {
|
|
19735
|
+
return this.data.provider;
|
|
19736
|
+
}
|
|
19737
|
+
get label() {
|
|
19738
|
+
return this.data.label;
|
|
19739
|
+
}
|
|
19740
|
+
update(input) {
|
|
19741
|
+
return new IntegrationApi(this.client).update(this, input);
|
|
19742
|
+
}
|
|
19743
|
+
unlink() {
|
|
19744
|
+
return new IntegrationApi(this.client).unlink(this);
|
|
19745
|
+
}
|
|
19746
|
+
};
|
|
19747
|
+
function integrationId(integration) {
|
|
19748
|
+
return typeof integration === "string" ? integration : integration.id;
|
|
19749
|
+
}
|
|
19750
|
+
|
|
19751
|
+
// src/sandbox-integrations.ts
|
|
19752
|
+
var SandboxIntegrationApi = class {
|
|
19753
|
+
constructor(notebookId, client) {
|
|
19754
|
+
this.notebookId = notebookId;
|
|
19755
|
+
this.client = client;
|
|
19756
|
+
}
|
|
19757
|
+
async attach(input) {
|
|
19758
|
+
const response = await this.client.post(this.path(), {
|
|
19759
|
+
...input,
|
|
19760
|
+
integration: integrationId(input.integration)
|
|
19761
|
+
});
|
|
19762
|
+
return new SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19763
|
+
}
|
|
19764
|
+
async list() {
|
|
19765
|
+
const response = await this.client.get(this.path());
|
|
19766
|
+
return response.data.map((integration) => new SandboxIntegration(integration, this.notebookId, this.client));
|
|
19767
|
+
}
|
|
19768
|
+
async get(integration) {
|
|
19769
|
+
const response = await this.client.get(this.bindingPath(integration));
|
|
19770
|
+
return new SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19771
|
+
}
|
|
19772
|
+
async update(integration, input) {
|
|
19773
|
+
const response = await this.client.patch(this.bindingPath(integration), {
|
|
19774
|
+
...input,
|
|
19775
|
+
integration: input.integration === void 0 ? void 0 : integrationId(input.integration)
|
|
19776
|
+
});
|
|
19777
|
+
return new SandboxIntegration(response.data, this.notebookId, this.client);
|
|
19778
|
+
}
|
|
19779
|
+
async detach(integration) {
|
|
19780
|
+
await this.client.delete(this.bindingPath(integration));
|
|
19781
|
+
}
|
|
19782
|
+
path() {
|
|
19783
|
+
return `/notebook/${this.notebookId}/integrations`;
|
|
19784
|
+
}
|
|
19785
|
+
bindingPath(integration) {
|
|
19786
|
+
return `${this.path()}/${encodeURIComponent(sandboxIntegrationId(integration))}`;
|
|
19787
|
+
}
|
|
19788
|
+
};
|
|
19789
|
+
var SandboxIntegration = class {
|
|
19790
|
+
constructor(data, notebookId, client) {
|
|
19791
|
+
this.data = data;
|
|
19792
|
+
this.notebookId = notebookId;
|
|
19793
|
+
this.client = client;
|
|
19794
|
+
}
|
|
19795
|
+
get id() {
|
|
19796
|
+
return this.data.id;
|
|
19797
|
+
}
|
|
19798
|
+
get integration() {
|
|
19799
|
+
return new Integration(this.data.integration, this.client);
|
|
19800
|
+
}
|
|
19801
|
+
get effects() {
|
|
19802
|
+
return this.data.effects;
|
|
19803
|
+
}
|
|
19804
|
+
update(input) {
|
|
19805
|
+
return new SandboxIntegrationApi(this.notebookId, this.client).update(this, input);
|
|
19806
|
+
}
|
|
19807
|
+
detach() {
|
|
19808
|
+
return new SandboxIntegrationApi(this.notebookId, this.client).detach(this);
|
|
19809
|
+
}
|
|
19810
|
+
};
|
|
19811
|
+
function sandboxIntegrationId(integration) {
|
|
19812
|
+
return typeof integration === "string" ? integration : integration.id;
|
|
19813
|
+
}
|
|
19814
|
+
|
|
19557
19815
|
// src/index.ts
|
|
19558
19816
|
function normalizeNotebookSecretInputs(input) {
|
|
19559
19817
|
if (Array.isArray(input)) {
|
|
@@ -19662,6 +19920,7 @@ var Client = class {
|
|
|
19662
19920
|
this.publications = new PublicationApi(this);
|
|
19663
19921
|
this.notebook = new NotebookApi(this);
|
|
19664
19922
|
this.servers = new ServerApi(this);
|
|
19923
|
+
this.integrations = new IntegrationApi(this);
|
|
19665
19924
|
this.options = Object.assign({ startClosed: true }, options);
|
|
19666
19925
|
this.baseUrl = normalizeApiBaseUrl(url2);
|
|
19667
19926
|
if (options.fetch) {
|
|
@@ -19688,6 +19947,9 @@ var Client = class {
|
|
|
19688
19947
|
put(path, body) {
|
|
19689
19948
|
return this.makeRequest("PUT", path, { body: body === void 0 ? void 0 : JSON.stringify(body) });
|
|
19690
19949
|
}
|
|
19950
|
+
patch(path, body) {
|
|
19951
|
+
return this.makeRequest("PATCH", path, { body: body === void 0 ? void 0 : JSON.stringify(body) });
|
|
19952
|
+
}
|
|
19691
19953
|
async stream(path) {
|
|
19692
19954
|
const response = await this.fetch(
|
|
19693
19955
|
new Request(new URL(path.replace(/^\//, ""), this.baseUrl), {
|
|
@@ -19901,8 +20163,10 @@ var NotebookInstance = class {
|
|
|
19901
20163
|
this.services = new Services(this);
|
|
19902
20164
|
this.config = new Config(this);
|
|
19903
20165
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
20166
|
+
this.integrations = new SandboxIntegrationApi(this.data.id, client);
|
|
19904
20167
|
this.preview = new NotebookPreview(client, this.data.id);
|
|
19905
20168
|
this.mail = new NotebookMail(client, this.data.id);
|
|
20169
|
+
this.feedback = new Feedback(client, this.data.id);
|
|
19906
20170
|
}
|
|
19907
20171
|
get runtimeTransport() {
|
|
19908
20172
|
return this.client.runtimeTransport;
|
|
@@ -20215,12 +20479,17 @@ export {
|
|
|
20215
20479
|
CommandError,
|
|
20216
20480
|
ComposerCredentials,
|
|
20217
20481
|
ErrorEvent,
|
|
20482
|
+
Feedback,
|
|
20218
20483
|
FileChangeFilter,
|
|
20219
20484
|
FileChangeType,
|
|
20220
20485
|
FileType,
|
|
20221
20486
|
Filesystem,
|
|
20222
20487
|
FilesystemError,
|
|
20223
20488
|
FilesystemErrorType,
|
|
20489
|
+
GitTarget,
|
|
20490
|
+
GitTargetApi,
|
|
20491
|
+
Integration,
|
|
20492
|
+
IntegrationApi,
|
|
20224
20493
|
LspConnection,
|
|
20225
20494
|
NotebookApi,
|
|
20226
20495
|
NotebookComposerCredentialApi,
|
|
@@ -20273,14 +20542,18 @@ export {
|
|
|
20273
20542
|
PublishStreamSseResultEventSchema,
|
|
20274
20543
|
RateLimitError,
|
|
20275
20544
|
RuntimeTelemetry,
|
|
20545
|
+
SandboxIntegration,
|
|
20546
|
+
SandboxIntegrationApi,
|
|
20276
20547
|
SendTimeoutError,
|
|
20277
20548
|
ServerApi,
|
|
20278
20549
|
ServerInstance,
|
|
20279
20550
|
ShellProcess,
|
|
20280
20551
|
UnsupportedRuntimeTransportError,
|
|
20552
|
+
integrationId,
|
|
20281
20553
|
notebookBuiltinServices,
|
|
20282
20554
|
notebookKnownServices,
|
|
20283
20555
|
once,
|
|
20556
|
+
sandboxIntegrationId,
|
|
20284
20557
|
timeout,
|
|
20285
20558
|
watchRuntimeTelemetry
|
|
20286
20559
|
};
|