@lizard-build/sdk 0.1.22 → 0.1.23
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/dist/index.d.mts +401 -20
- package/dist/index.d.ts +401 -20
- package/dist/index.js +426 -11
- package/dist/index.mjs +425 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -422,19 +422,437 @@ var Sandbox = class extends SandboxClient {
|
|
|
422
422
|
Sandbox.defaultTemplate = "base";
|
|
423
423
|
Sandbox.defaultTimeoutMs = DEFAULT_SANDBOX_TIMEOUT_MS;
|
|
424
424
|
|
|
425
|
+
// src/platform/client.ts
|
|
426
|
+
var PlatformClient = class {
|
|
427
|
+
constructor(opts) {
|
|
428
|
+
this.config = new ConnectionConfig(opts);
|
|
429
|
+
}
|
|
430
|
+
async get(path) {
|
|
431
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
432
|
+
headers: this.config.headers
|
|
433
|
+
});
|
|
434
|
+
if (!res.ok) await handleApiError(res);
|
|
435
|
+
return res.json();
|
|
436
|
+
}
|
|
437
|
+
async post(path, body) {
|
|
438
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
439
|
+
method: "POST",
|
|
440
|
+
headers: this.config.headers,
|
|
441
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
442
|
+
});
|
|
443
|
+
if (!res.ok) await handleApiError(res);
|
|
444
|
+
return res.json();
|
|
445
|
+
}
|
|
446
|
+
async patch(path, body) {
|
|
447
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
448
|
+
method: "PATCH",
|
|
449
|
+
headers: this.config.headers,
|
|
450
|
+
body: JSON.stringify(body)
|
|
451
|
+
});
|
|
452
|
+
if (!res.ok) await handleApiError(res);
|
|
453
|
+
return res.json();
|
|
454
|
+
}
|
|
455
|
+
async delete(path, body) {
|
|
456
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
457
|
+
method: "DELETE",
|
|
458
|
+
headers: this.config.headers,
|
|
459
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
460
|
+
});
|
|
461
|
+
if (!res.ok) await handleApiError(res);
|
|
462
|
+
if (res.status === 204 || res.headers.get("content-length") === "0") return void 0;
|
|
463
|
+
return res.json();
|
|
464
|
+
}
|
|
465
|
+
async postForm(path, form) {
|
|
466
|
+
const headers = { "X-API-Key": this.config.apiKey };
|
|
467
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
468
|
+
method: "POST",
|
|
469
|
+
headers,
|
|
470
|
+
body: form
|
|
471
|
+
});
|
|
472
|
+
if (!res.ok) await handleApiError(res);
|
|
473
|
+
return res.json();
|
|
474
|
+
}
|
|
475
|
+
/** Stream SSE events from a path, calling handler for each data line. */
|
|
476
|
+
async *streamSse(path) {
|
|
477
|
+
const res = await fetch(`${this.config.apiUrl}${path}`, {
|
|
478
|
+
headers: this.config.headers
|
|
479
|
+
});
|
|
480
|
+
if (!res.ok) await handleApiError(res);
|
|
481
|
+
if (!res.body) return;
|
|
482
|
+
const reader = res.body.getReader();
|
|
483
|
+
const decoder = new TextDecoder();
|
|
484
|
+
let buf = "";
|
|
485
|
+
while (true) {
|
|
486
|
+
const { done, value } = await reader.read();
|
|
487
|
+
if (done) break;
|
|
488
|
+
buf += decoder.decode(value, { stream: true });
|
|
489
|
+
const events = buf.split("\n\n");
|
|
490
|
+
buf = events.pop();
|
|
491
|
+
for (const evt of events) {
|
|
492
|
+
const dataLine = evt.split("\n").find((l) => l.startsWith("data: "));
|
|
493
|
+
if (dataLine) yield dataLine.slice(6);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
// src/platform/projects.ts
|
|
500
|
+
var ProjectsAPI = class {
|
|
501
|
+
constructor(client) {
|
|
502
|
+
this.client = client;
|
|
503
|
+
}
|
|
504
|
+
/** List all projects the API key can access. */
|
|
505
|
+
list(opts) {
|
|
506
|
+
const qs = opts?.workspaceId ? `?workspaceId=${opts.workspaceId}` : "";
|
|
507
|
+
return this.client.get(`/api/projects${qs}`);
|
|
508
|
+
}
|
|
509
|
+
/** Get a project by ID. */
|
|
510
|
+
get(id) {
|
|
511
|
+
return this.client.get(`/api/projects/${id}`);
|
|
512
|
+
}
|
|
513
|
+
/** Create a new project. */
|
|
514
|
+
create(opts) {
|
|
515
|
+
return this.client.post("/api/projects", opts);
|
|
516
|
+
}
|
|
517
|
+
/** Update a project's name. */
|
|
518
|
+
update(id, opts) {
|
|
519
|
+
return this.client.patch(`/api/projects/${id}`, opts);
|
|
520
|
+
}
|
|
521
|
+
/** Delete a project. */
|
|
522
|
+
delete(id) {
|
|
523
|
+
return this.client.delete(`/api/projects/${id}`);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
// src/platform/services.ts
|
|
528
|
+
var DeployHandle = class {
|
|
529
|
+
constructor(client, serviceId, buildId) {
|
|
530
|
+
this._client = client;
|
|
531
|
+
this._serviceId = serviceId;
|
|
532
|
+
this._buildId = buildId;
|
|
533
|
+
}
|
|
534
|
+
get serviceId() {
|
|
535
|
+
return this._serviceId;
|
|
536
|
+
}
|
|
537
|
+
/** Stream build + runtime log lines until the deploy finishes. */
|
|
538
|
+
async *logs() {
|
|
539
|
+
const path = `/api/apps/${this._serviceId}/logs?limit=1000`;
|
|
540
|
+
const res = await fetch(`${this._client.config.apiUrl}${path}`, {
|
|
541
|
+
headers: this._client.config.headers
|
|
542
|
+
});
|
|
543
|
+
if (!res.ok) return;
|
|
544
|
+
const body = await res.json();
|
|
545
|
+
const lines = Array.isArray(body) ? body : body.logs ?? [];
|
|
546
|
+
for (const l of lines) yield typeof l === "string" ? l : JSON.stringify(l);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Poll until the deploy reaches a terminal state.
|
|
550
|
+
* @returns `{ url, status }` on success; throws `LizardError` on failure.
|
|
551
|
+
*/
|
|
552
|
+
async wait(opts) {
|
|
553
|
+
const deadline = Date.now() + (opts?.timeoutMs ?? 10 * 6e4);
|
|
554
|
+
const pollMs = opts?.pollMs ?? 3e3;
|
|
555
|
+
while (Date.now() < deadline) {
|
|
556
|
+
const svc = await this._client.get(`/api/apps/${this._serviceId}`);
|
|
557
|
+
if (svc.deployStatus === "idle") {
|
|
558
|
+
if (svc.status === "running") return { url: svc.domain ? `https://${svc.domain}` : null, status: "running" };
|
|
559
|
+
if (svc.status === "crashed") throw new LizardError(`Service crashed after deploy`);
|
|
560
|
+
}
|
|
561
|
+
if (svc.deployStatus === "failed") throw new LizardError(`Deploy failed`);
|
|
562
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
563
|
+
}
|
|
564
|
+
throw new TimeoutError(`Deploy did not complete within ${opts?.timeoutMs ?? 6e5}ms`);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var ServicesAPI = class {
|
|
568
|
+
constructor(client) {
|
|
569
|
+
this.client = client;
|
|
570
|
+
}
|
|
571
|
+
/** List all services in a project. */
|
|
572
|
+
list(opts) {
|
|
573
|
+
return this.client.get(`/api/projects/${opts.projectId}/apps`);
|
|
574
|
+
}
|
|
575
|
+
/** Get a service by ID. */
|
|
576
|
+
get(id) {
|
|
577
|
+
return this.client.get(`/api/apps/${id}`);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Create a service and start a deploy from a git repo.
|
|
581
|
+
* Returns a DeployHandle to track progress.
|
|
582
|
+
*/
|
|
583
|
+
async deploy(opts) {
|
|
584
|
+
const body = {
|
|
585
|
+
name: opts.name,
|
|
586
|
+
sourceType: opts.sourceType ?? "github",
|
|
587
|
+
repoUrl: opts.repoUrl,
|
|
588
|
+
branch: opts.branch ?? "main",
|
|
589
|
+
startCommand: opts.startCommand,
|
|
590
|
+
buildCommand: opts.buildCommand,
|
|
591
|
+
containerPort: opts.port ?? opts.containerPort,
|
|
592
|
+
region: opts.region
|
|
593
|
+
};
|
|
594
|
+
const svc = await this.client.post(`/api/projects/${opts.projectId}/apps`, body);
|
|
595
|
+
return new DeployHandle(this.client, svc.id);
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Upload a tarball and deploy it.
|
|
599
|
+
*
|
|
600
|
+
* @param opts.source - A `Buffer`, `Blob`, or `Uint8Array` of a `.tar.gz` file.
|
|
601
|
+
*/
|
|
602
|
+
async upload(opts) {
|
|
603
|
+
const form = new FormData();
|
|
604
|
+
const blob = opts.source instanceof Blob ? opts.source : new Blob([opts.source], { type: "application/gzip" });
|
|
605
|
+
form.append("file", blob, "source.tar.gz");
|
|
606
|
+
form.append("name", opts.name);
|
|
607
|
+
if (opts.startCommand) form.append("startCommand", opts.startCommand);
|
|
608
|
+
if (opts.buildCommand) form.append("buildCommand", opts.buildCommand);
|
|
609
|
+
if (opts.port !== void 0) form.append("containerPort", String(opts.port));
|
|
610
|
+
if (opts.region) form.append("region", opts.region);
|
|
611
|
+
const result = await this.client.postForm(
|
|
612
|
+
`/api/projects/${opts.projectId}/apps/upload`,
|
|
613
|
+
form
|
|
614
|
+
);
|
|
615
|
+
return new DeployHandle(this.client, result.id, result.buildId);
|
|
616
|
+
}
|
|
617
|
+
/** Trigger a redeploy (rebuild from current source). */
|
|
618
|
+
async redeploy(id) {
|
|
619
|
+
await this.client.post(`/api/apps/${id}/redeploy`, {});
|
|
620
|
+
return new DeployHandle(this.client, id);
|
|
621
|
+
}
|
|
622
|
+
/** Restart a service without rebuilding. */
|
|
623
|
+
restart(id) {
|
|
624
|
+
return this.client.post(`/api/apps/${id}/restart`, {});
|
|
625
|
+
}
|
|
626
|
+
/** Scale a service. */
|
|
627
|
+
scale(id, opts) {
|
|
628
|
+
return this.client.post(`/api/apps/${id}/scale`, opts);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Get recent log lines. For a live tail, use the WebSocket API instead.
|
|
632
|
+
*
|
|
633
|
+
* @param opts.limit - Max lines to return (default 200, max 1000).
|
|
634
|
+
*/
|
|
635
|
+
async logs(id, opts) {
|
|
636
|
+
const qs = new URLSearchParams();
|
|
637
|
+
if (opts?.limit) qs.set("limit", String(opts.limit));
|
|
638
|
+
if (opts?.since) qs.set("since", opts.since);
|
|
639
|
+
const result = await this.client.get(`/api/apps/${id}/logs?${qs}`);
|
|
640
|
+
return Array.isArray(result) ? result : result.logs ?? [];
|
|
641
|
+
}
|
|
642
|
+
/** Execute a command inside the running service VM. */
|
|
643
|
+
exec(id, cmd, opts) {
|
|
644
|
+
return this.client.post(`/api/apps/${id}/exec`, { cmd, timeoutMs: opts?.timeoutMs });
|
|
645
|
+
}
|
|
646
|
+
/** Update service configuration. */
|
|
647
|
+
update(id, opts) {
|
|
648
|
+
return this.client.patch(`/api/apps/${id}`, opts);
|
|
649
|
+
}
|
|
650
|
+
/** Delete a service. */
|
|
651
|
+
delete(id) {
|
|
652
|
+
return this.client.delete(`/api/apps/${id}`);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
// src/platform/addons.ts
|
|
657
|
+
var AddonsAPI = class {
|
|
658
|
+
constructor(client) {
|
|
659
|
+
this.client = client;
|
|
660
|
+
}
|
|
661
|
+
/** List all addons in a project. */
|
|
662
|
+
list(opts) {
|
|
663
|
+
return this.client.get(`/api/projects/${opts.projectId}/addons`);
|
|
664
|
+
}
|
|
665
|
+
/** Get an addon by ID. */
|
|
666
|
+
get(projectId, addonId) {
|
|
667
|
+
return this.client.get(`/api/projects/${projectId}/addons/${addonId}`);
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Create a new managed addon (database, cache, or object store).
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```ts
|
|
674
|
+
* const pg = await lizard.addons.create({ projectId, type: 'postgres' })
|
|
675
|
+
* // Inject into a service:
|
|
676
|
+
* await lizard.secrets.set({ serviceId: svcId, key: 'DATABASE_URL', value: `${{${pg.name}.DATABASE_URL}}` })
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
create(opts) {
|
|
680
|
+
return this.client.post(`/api/projects/${opts.projectId}/addons`, {
|
|
681
|
+
type: opts.type,
|
|
682
|
+
name: opts.name,
|
|
683
|
+
version: opts.version,
|
|
684
|
+
vcpu: opts.vcpu,
|
|
685
|
+
memoryMb: opts.memoryMb,
|
|
686
|
+
storageGb: opts.storageGb
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
/** Delete an addon. */
|
|
690
|
+
delete(projectId, addonId) {
|
|
691
|
+
return this.client.delete(`/api/projects/${projectId}/addons/${addonId}`);
|
|
692
|
+
}
|
|
693
|
+
/** Resize an addon (CPU / memory / storage). */
|
|
694
|
+
resize(projectId, addonId, opts) {
|
|
695
|
+
return this.client.post(`/api/projects/${projectId}/addons/${addonId}/resize`, opts);
|
|
696
|
+
}
|
|
697
|
+
/** Restart an addon VM. */
|
|
698
|
+
redeploy(projectId, addonId) {
|
|
699
|
+
return this.client.post(`/api/projects/${projectId}/addons/${addonId}/redeploy`, {});
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
// src/platform/secrets.ts
|
|
704
|
+
var SecretsAPI = class {
|
|
705
|
+
constructor(client) {
|
|
706
|
+
this.client = client;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* List secrets for a project or service.
|
|
710
|
+
*
|
|
711
|
+
* @param projectId - The project ID.
|
|
712
|
+
* @param opts.serviceId - If given, list service-scoped secrets instead of project secrets.
|
|
713
|
+
*/
|
|
714
|
+
list(projectId, opts) {
|
|
715
|
+
if (opts?.serviceId) {
|
|
716
|
+
return this.client.get(`/api/apps/${opts.serviceId}/secrets`);
|
|
717
|
+
}
|
|
718
|
+
return this.client.get(`/api/projects/${projectId}/secrets`);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Set one or more secrets.
|
|
722
|
+
*
|
|
723
|
+
* ```ts
|
|
724
|
+
* // Service-scoped secret (default):
|
|
725
|
+
* await lizard.secrets.set(projectId, { key: 'DATABASE_URL', value: '${{postgres.DATABASE_URL}}', serviceId })
|
|
726
|
+
*
|
|
727
|
+
* // Project-scoped (shared across all services):
|
|
728
|
+
* await lizard.secrets.set(projectId, { key: 'LOG_LEVEL', value: 'info', global: true })
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
async set(projectId, secrets) {
|
|
732
|
+
const items = Array.isArray(secrets) ? secrets : [secrets];
|
|
733
|
+
const byService = /* @__PURE__ */ new Map();
|
|
734
|
+
const projectScoped = {};
|
|
735
|
+
for (const s of items) {
|
|
736
|
+
if (s.global || !s.serviceId) {
|
|
737
|
+
projectScoped[s.key] = s.value;
|
|
738
|
+
} else {
|
|
739
|
+
if (!byService.has(s.serviceId)) byService.set(s.serviceId, {});
|
|
740
|
+
byService.get(s.serviceId)[s.key] = s.value;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
const tasks = [];
|
|
744
|
+
if (Object.keys(projectScoped).length > 0) {
|
|
745
|
+
tasks.push(this.client.post(`/api/projects/${projectId}/secrets`, projectScoped));
|
|
746
|
+
}
|
|
747
|
+
for (const [serviceId, kv] of byService) {
|
|
748
|
+
tasks.push(this.client.post(`/api/apps/${serviceId}/secrets`, kv));
|
|
749
|
+
}
|
|
750
|
+
await Promise.all(tasks);
|
|
751
|
+
}
|
|
752
|
+
/** Delete a secret by key. */
|
|
753
|
+
async delete(projectId, opts) {
|
|
754
|
+
if (opts.serviceId) {
|
|
755
|
+
await this.client.delete(`/api/apps/${opts.serviceId}/secrets`, { key: opts.key });
|
|
756
|
+
} else {
|
|
757
|
+
await this.client.delete(`/api/projects/${projectId}/secrets`, { key: opts.key });
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
// src/platform/domains.ts
|
|
763
|
+
var DomainsAPI = class {
|
|
764
|
+
constructor(client) {
|
|
765
|
+
this.client = client;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Show the current domain(s) for a service.
|
|
769
|
+
* The platform-assigned `.onlizard.com` subdomain is always present.
|
|
770
|
+
*/
|
|
771
|
+
list(serviceId) {
|
|
772
|
+
return this.client.get(`/api/apps/${serviceId}/domains`);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Attach a custom domain to a service.
|
|
776
|
+
* Returns the DNS records to add before calling `verify()`.
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```ts
|
|
780
|
+
* const info = await lizard.domains.add(serviceId, 'api.example.com')
|
|
781
|
+
* console.log('Add CNAME:', info.cnameTarget)
|
|
782
|
+
* ```
|
|
783
|
+
*/
|
|
784
|
+
add(serviceId, domain) {
|
|
785
|
+
return this.client.post(`/api/apps/${serviceId}/domains`, { domain });
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Verify that DNS records have propagated and activate the domain.
|
|
789
|
+
* Call after adding the CNAME or TXT record returned by `add()`.
|
|
790
|
+
*/
|
|
791
|
+
verify(serviceId, domain) {
|
|
792
|
+
return this.client.post(`/api/apps/${serviceId}/domains/verify`, { domain });
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// src/platform/metrics.ts
|
|
797
|
+
var MetricsAPI = class {
|
|
798
|
+
constructor(client) {
|
|
799
|
+
this.client = client;
|
|
800
|
+
}
|
|
801
|
+
/** Get CPU metrics for a service or addon. */
|
|
802
|
+
cpu(id, range = "1h") {
|
|
803
|
+
return this.client.get(`/api/apps/${id}/metrics/cpu?range=${range}`);
|
|
804
|
+
}
|
|
805
|
+
/** Get memory metrics for a service or addon. */
|
|
806
|
+
memory(id, range = "1h") {
|
|
807
|
+
return this.client.get(`/api/apps/${id}/metrics/memory?range=${range}`);
|
|
808
|
+
}
|
|
809
|
+
/** Get network I/O metrics for a service. */
|
|
810
|
+
network(id, range = "1h") {
|
|
811
|
+
return this.client.get(`/api/apps/${id}/metrics/network?range=${range}`);
|
|
812
|
+
}
|
|
813
|
+
/** Get disk I/O metrics for a service. */
|
|
814
|
+
disk(id, range = "1h") {
|
|
815
|
+
return this.client.get(`/api/apps/${id}/metrics/disk?range=${range}`);
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Get cost breakdown for a project over the given range.
|
|
819
|
+
* Costs are in USD cents unless the `currency` field says otherwise.
|
|
820
|
+
*/
|
|
821
|
+
cost(projectId, range = "30d") {
|
|
822
|
+
return this.client.get(`/api/projects/${projectId}/metrics/cost?range=${range}`);
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Convenience: fetch all metric types for a service in one call.
|
|
826
|
+
*/
|
|
827
|
+
async all(id, range = "1h") {
|
|
828
|
+
const [cpu, memory, network, disk] = await Promise.all([
|
|
829
|
+
this.cpu(id, range),
|
|
830
|
+
this.memory(id, range),
|
|
831
|
+
this.network(id, range),
|
|
832
|
+
this.disk(id, range)
|
|
833
|
+
]);
|
|
834
|
+
return { cpu, memory, networkRx: network.rx, networkTx: network.tx, diskRead: disk.read, diskWrite: disk.write };
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
|
|
425
838
|
// src/lizard.ts
|
|
426
839
|
var Lizard = class {
|
|
427
840
|
constructor(opts) {
|
|
428
|
-
if (!opts?.project) {
|
|
429
|
-
throw new LizardError(
|
|
430
|
-
'A project is required. Pass project (its ID, slug, or name): new Lizard({ project: "my-project" }).'
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
841
|
this.config = new ConnectionConfig(opts);
|
|
434
842
|
this.projectRef = opts.project;
|
|
843
|
+
const platform = new PlatformClient(opts);
|
|
844
|
+
this._platform = platform;
|
|
845
|
+
this.projects = new ProjectsAPI(platform);
|
|
846
|
+
this.services = new ServicesAPI(platform);
|
|
847
|
+
this.addons = new AddonsAPI(platform);
|
|
848
|
+
this.secrets = new SecretsAPI(platform);
|
|
849
|
+
this.domains = new DomainsAPI(platform);
|
|
850
|
+
this.metrics = new MetricsAPI(platform);
|
|
435
851
|
}
|
|
852
|
+
// ── Sandbox convenience methods (backward-compatible) ──────────────────
|
|
436
853
|
/** Resolve the client's project reference to a stable project ID (cached). */
|
|
437
854
|
async projectId() {
|
|
855
|
+
if (!this.projectRef) throw new LizardError("No project set. Pass project in Lizard({ project }) to use sandbox APIs.");
|
|
438
856
|
return resolveProjectId(this.projectRef, this.config);
|
|
439
857
|
}
|
|
440
858
|
async connectionOpts(extra) {
|
|
@@ -442,12 +860,7 @@ var Lizard = class {
|
|
|
442
860
|
}
|
|
443
861
|
/**
|
|
444
862
|
* Create a new sandbox in this client's project.
|
|
445
|
-
*
|
|
446
|
-
* @example
|
|
447
|
-
* ```ts
|
|
448
|
-
* const sandbox = await lizard.create('base')
|
|
449
|
-
* const sandbox = await lizard.create('code-interpreter-v1', { timeoutMs: 600_000 })
|
|
450
|
-
* ```
|
|
863
|
+
* @requires `project` to be set in the constructor.
|
|
451
864
|
*/
|
|
452
865
|
async create(template, opts) {
|
|
453
866
|
const projectId = await this.projectId();
|
|
@@ -705,6 +1118,7 @@ var Volume = class _Volume {
|
|
|
705
1118
|
export {
|
|
706
1119
|
AuthenticationError,
|
|
707
1120
|
CodeSandbox,
|
|
1121
|
+
DeployHandle,
|
|
708
1122
|
Lizard,
|
|
709
1123
|
LizardError,
|
|
710
1124
|
NotFoundError,
|