@miosa/sdk 1.2.5 → 1.2.7

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.
Files changed (92) hide show
  1. package/README.md +107 -59
  2. package/dist/index.d.ts +513 -193
  3. package/dist/index.js +1266 -891
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -2
  6. package/src/client.ts +0 -293
  7. package/src/errors.ts +0 -136
  8. package/src/http.test.ts +0 -374
  9. package/src/http.ts +0 -390
  10. package/src/index.ts +0 -569
  11. package/src/resources/admin.ts +0 -348
  12. package/src/resources/analytics.ts +0 -60
  13. package/src/resources/api-keys.ts +0 -119
  14. package/src/resources/audit-log.ts +0 -64
  15. package/src/resources/benchmarks.ts +0 -104
  16. package/src/resources/builder-sessions.ts +0 -75
  17. package/src/resources/channels.ts +0 -143
  18. package/src/resources/checkpoints.ts +0 -225
  19. package/src/resources/command-center.ts +0 -73
  20. package/src/resources/community.ts +0 -103
  21. package/src/resources/completions.ts +0 -104
  22. package/src/resources/computer-auto-stop.ts +0 -43
  23. package/src/resources/computer-env.ts +0 -76
  24. package/src/resources/computer-logs.ts +0 -50
  25. package/src/resources/computer-osa.ts +0 -76
  26. package/src/resources/computer-ports.ts +0 -91
  27. package/src/resources/computer-terminal.ts +0 -61
  28. package/src/resources/computer-volumes.ts +0 -64
  29. package/src/resources/computer.ts +0 -551
  30. package/src/resources/computers.ts +0 -75
  31. package/src/resources/credits.ts +0 -43
  32. package/src/resources/cron-jobs.ts +0 -191
  33. package/src/resources/custom_domains.ts +0 -123
  34. package/src/resources/dashboard.ts +0 -49
  35. package/src/resources/databases.ts +0 -218
  36. package/src/resources/deployments.test.ts +0 -197
  37. package/src/resources/deployments.ts +0 -1208
  38. package/src/resources/desktop.ts +0 -134
  39. package/src/resources/devices.test.ts +0 -92
  40. package/src/resources/devices.ts +0 -291
  41. package/src/resources/egress.test.ts +0 -318
  42. package/src/resources/egressAudit.ts +0 -245
  43. package/src/resources/egressNetwork.ts +0 -450
  44. package/src/resources/egressSecrets.ts +0 -577
  45. package/src/resources/email.ts +0 -212
  46. package/src/resources/embeddings.ts +0 -36
  47. package/src/resources/events.ts +0 -296
  48. package/src/resources/exec.ts +0 -319
  49. package/src/resources/external-keys.ts +0 -79
  50. package/src/resources/files.test.ts +0 -339
  51. package/src/resources/files.ts +0 -220
  52. package/src/resources/flat-custom-domains.ts +0 -127
  53. package/src/resources/functions.ts +0 -178
  54. package/src/resources/health-checks.ts +0 -165
  55. package/src/resources/integrations.ts +0 -183
  56. package/src/resources/mcp.ts +0 -70
  57. package/src/resources/models.ts +0 -45
  58. package/src/resources/network_policy.ts +0 -73
  59. package/src/resources/open-computers/agents.ts +0 -91
  60. package/src/resources/open-computers/apps.ts +0 -102
  61. package/src/resources/open-computers/clusters.ts +0 -88
  62. package/src/resources/open-computers/desktop.ts +0 -34
  63. package/src/resources/open-computers/files.ts +0 -97
  64. package/src/resources/open-computers/hosts.ts +0 -85
  65. package/src/resources/open-computers/index.ts +0 -98
  66. package/src/resources/open-computers/jobs.ts +0 -75
  67. package/src/resources/open-computers/open_computers.test.ts +0 -288
  68. package/src/resources/open-computers/secrets.ts +0 -115
  69. package/src/resources/open-computers/terminal.ts +0 -33
  70. package/src/resources/open-computers/tunnels.ts +0 -87
  71. package/src/resources/open-computers/types.ts +0 -343
  72. package/src/resources/open-computers/workspaces.ts +0 -135
  73. package/src/resources/org-invites.ts +0 -189
  74. package/src/resources/project-auth.ts +0 -142
  75. package/src/resources/project-integrations.ts +0 -133
  76. package/src/resources/provider-defaults.ts +0 -89
  77. package/src/resources/regions.ts +0 -94
  78. package/src/resources/sandbox-templates.ts +0 -195
  79. package/src/resources/sandboxes.live.test.ts +0 -92
  80. package/src/resources/sandboxes.test.ts +0 -655
  81. package/src/resources/sandboxes.ts +0 -1437
  82. package/src/resources/settings.ts +0 -143
  83. package/src/resources/snapshots-standalone.ts +0 -51
  84. package/src/resources/storage.ts +0 -221
  85. package/src/resources/tenant.ts +0 -66
  86. package/src/resources/usage.ts +0 -85
  87. package/src/resources/volumes.ts +0 -117
  88. package/src/resources/webhooks.ts +0 -239
  89. package/src/resources/workspace-invites.ts +0 -188
  90. package/src/resources/workspace-members.test.ts +0 -121
  91. package/src/resources/workspace-members.ts +0 -143
  92. package/src/types.ts +0 -463
@@ -1,142 +0,0 @@
1
- /**
2
- * Project auth — built-in auth for sandboxes and deployments.
3
- */
4
-
5
- import type { HttpClient } from "../http.js";
6
-
7
- // ── Resource shapes ──────────────────────────────────────────────────────────
8
-
9
- export interface ProjectAuthStatus {
10
- enabled?: boolean;
11
- state?: string;
12
- database_id?: string | null;
13
- config?: Record<string, unknown>;
14
- [key: string]: unknown;
15
- }
16
-
17
- // ── Request payloads ─────────────────────────────────────────────────────────
18
-
19
- export type ProjectAuthResourceType = "sandbox" | "deployment";
20
-
21
- export interface ProjectAuthResourceParams {
22
- resourceType?: ProjectAuthResourceType;
23
- resource_type?: ProjectAuthResourceType;
24
- resourceId?: string;
25
- resource_id?: string;
26
- }
27
-
28
- export interface ProjectAuthEnableParams extends ProjectAuthResourceParams {
29
- signupEnabled?: boolean;
30
- signup_enabled?: boolean;
31
- emailConfirmRequired?: boolean;
32
- email_confirm_required?: boolean;
33
- tokenExpirySec?: number;
34
- token_expiry_sec?: number;
35
- config?: Record<string, unknown>;
36
- [key: string]: unknown;
37
- }
38
-
39
- export interface ProjectAuthUpdateParams extends ProjectAuthEnableParams {}
40
-
41
- export interface ProjectAuthDisableParams extends ProjectAuthResourceParams {
42
- [key: string]: unknown;
43
- }
44
-
45
- export interface ProjectAuthStatusParams extends ProjectAuthResourceParams {
46
- [key: string]: unknown;
47
- }
48
-
49
- function resourcePayload(params: ProjectAuthResourceParams): {
50
- resource_type: ProjectAuthResourceType;
51
- resource_id: string;
52
- } {
53
- const resource_type = params.resource_type ?? params.resourceType;
54
- const resource_id = params.resource_id ?? params.resourceId;
55
-
56
- if (!resource_type || !resource_id) {
57
- throw new Error("project auth requires resourceType/resourceId");
58
- }
59
-
60
- return { resource_type, resource_id };
61
- }
62
-
63
- function authConfig(params: ProjectAuthEnableParams): Record<string, unknown> {
64
- return stripUndefined({
65
- ...(params.config ?? {}),
66
- signup_enabled: params.signup_enabled ?? params.signupEnabled,
67
- email_confirm_required:
68
- params.email_confirm_required ?? params.emailConfirmRequired,
69
- token_expiry_sec: params.token_expiry_sec ?? params.tokenExpirySec,
70
- });
71
- }
72
-
73
- function requestBody(params: ProjectAuthEnableParams): Record<string, unknown> {
74
- return stripUndefined({
75
- ...resourcePayload(params),
76
- config: authConfig(params),
77
- });
78
- }
79
-
80
- export interface ProjectAuthLegacyParams {
81
- provider?: string;
82
- config?: Record<string, unknown>;
83
- [key: string]: unknown;
84
- }
85
-
86
- // ── Helpers ───────────────────────────────────────────────────────────────────
87
-
88
- function unwrap<T>(payload: unknown): T {
89
- if (payload && typeof payload === "object") {
90
- const p = payload as Record<string, unknown>;
91
- for (const k of ["data", "project_auth", "config", "items"]) {
92
- if (k in p) return p[k] as T;
93
- }
94
- }
95
- return payload as T;
96
- }
97
-
98
- function stripUndefined(
99
- input: Record<string, unknown>,
100
- ): Record<string, unknown> {
101
- return Object.fromEntries(
102
- Object.entries(input).filter(([, v]) => v !== undefined),
103
- );
104
- }
105
-
106
- // ── Main resource ─────────────────────────────────────────────────────────────
107
-
108
- export class ProjectAuth {
109
- constructor(private readonly http: HttpClient) {}
110
-
111
- /** Get the current project-auth status and config. */
112
- async status(params: ProjectAuthStatusParams): Promise<ProjectAuthStatus> {
113
- const data = await this.http.get<unknown>(
114
- "/project-auth/status",
115
- resourcePayload(params),
116
- );
117
- return unwrap<ProjectAuthStatus>(data);
118
- }
119
-
120
- /** Enable project auth. */
121
- async enable(params: ProjectAuthEnableParams): Promise<ProjectAuthStatus> {
122
- const body = requestBody(params);
123
- const data = await this.http.post<unknown>("/project-auth/enable", body);
124
- return unwrap<ProjectAuthStatus>(data);
125
- }
126
-
127
- /** Disable project auth. */
128
- async disable(params: ProjectAuthDisableParams): Promise<ProjectAuthStatus> {
129
- const data = await this.http.post<unknown>(
130
- "/project-auth/disable",
131
- resourcePayload(params),
132
- );
133
- return unwrap<ProjectAuthStatus>(data);
134
- }
135
-
136
- /** Update project-auth configuration. */
137
- async update(params: ProjectAuthUpdateParams): Promise<ProjectAuthStatus> {
138
- const body = requestBody(params);
139
- const data = await this.http.patch<unknown>("/project-auth/config", body);
140
- return unwrap<ProjectAuthStatus>(data);
141
- }
142
- }
@@ -1,133 +0,0 @@
1
- /**
2
- * Project integrations — third-party API key connections injected into VMs.
3
- */
4
-
5
- import type { HttpClient } from "../http.js";
6
-
7
- // ── Resource shapes ──────────────────────────────────────────────────────────
8
-
9
- export interface ProjectIntegrationData {
10
- id?: string;
11
- project_id?: string;
12
- provider?: string;
13
- status?: string;
14
- [key: string]: unknown;
15
- }
16
-
17
- export interface ProjectIntegrationCatalogEntry {
18
- provider?: string;
19
- name?: string;
20
- description?: string;
21
- schema?: Record<string, unknown>;
22
- [key: string]: unknown;
23
- }
24
-
25
- // ── Request payloads ─────────────────────────────────────────────────────────
26
-
27
- export interface ProjectIntegrationListParams {
28
- project_id?: string;
29
- provider?: string;
30
- [key: string]: string | number | boolean | undefined;
31
- }
32
-
33
- export interface ProjectIntegrationCreateParams {
34
- project_id?: string;
35
- provider?: string;
36
- credentials?: Record<string, unknown>;
37
- [key: string]: unknown;
38
- }
39
-
40
- export interface ProjectIntegrationUpdateParams {
41
- credentials?: Record<string, unknown>;
42
- [key: string]: unknown;
43
- }
44
-
45
- // ── Helpers ───────────────────────────────────────────────────────────────────
46
-
47
- function unwrap<T>(payload: unknown): T {
48
- if (payload && typeof payload === "object") {
49
- const p = payload as Record<string, unknown>;
50
- for (const k of ["data", "project_integrations", "catalog", "items"]) {
51
- if (k in p) return p[k] as T;
52
- }
53
- }
54
- return payload as T;
55
- }
56
-
57
- function listItems<T>(payload: unknown): T[] {
58
- const result = unwrap<T[] | unknown>(payload);
59
- if (Array.isArray(result)) return result;
60
- return [];
61
- }
62
-
63
- function stripUndefined(
64
- input: Record<string, unknown>,
65
- ): Record<string, string | number | boolean | undefined> {
66
- return Object.fromEntries(
67
- Object.entries(input).filter(([, v]) => v !== undefined),
68
- ) as Record<string, string | number | boolean | undefined>;
69
- }
70
-
71
- function stripUndefObj(
72
- input: Record<string, unknown>,
73
- ): Record<string, unknown> {
74
- return Object.fromEntries(
75
- Object.entries(input).filter(([, v]) => v !== undefined),
76
- );
77
- }
78
-
79
- // ── Main resource ─────────────────────────────────────────────────────────────
80
-
81
- export class ProjectIntegrations {
82
- constructor(private readonly http: HttpClient) {}
83
-
84
- /** List project integrations. */
85
- async list(
86
- params: ProjectIntegrationListParams = {},
87
- ): Promise<ProjectIntegrationData[]> {
88
- const query = stripUndefined(params as Record<string, unknown>);
89
- const data = await this.http.get<unknown>("/project-integrations", query);
90
- return listItems<ProjectIntegrationData>(data);
91
- }
92
-
93
- /** List supported providers and their schemas. */
94
- async catalog(): Promise<ProjectIntegrationCatalogEntry[]> {
95
- const data = await this.http.get<unknown>("/project-integrations/catalog");
96
- return listItems<ProjectIntegrationCatalogEntry>(data);
97
- }
98
-
99
- /** Get a project integration by id. */
100
- async get(integrationId: string): Promise<ProjectIntegrationData> {
101
- const data = await this.http.get<unknown>(
102
- `/project-integrations/${integrationId}`,
103
- );
104
- return unwrap<ProjectIntegrationData>(data);
105
- }
106
-
107
- /** Create a project integration. */
108
- async create(
109
- params: ProjectIntegrationCreateParams,
110
- ): Promise<ProjectIntegrationData> {
111
- const body = stripUndefObj(params as Record<string, unknown>);
112
- const data = await this.http.post<unknown>("/project-integrations", body);
113
- return unwrap<ProjectIntegrationData>(data);
114
- }
115
-
116
- /** Update a project integration. */
117
- async update(
118
- integrationId: string,
119
- params: ProjectIntegrationUpdateParams,
120
- ): Promise<ProjectIntegrationData> {
121
- const body = stripUndefObj(params as Record<string, unknown>);
122
- const data = await this.http.patch<unknown>(
123
- `/project-integrations/${integrationId}`,
124
- body,
125
- );
126
- return unwrap<ProjectIntegrationData>(data);
127
- }
128
-
129
- /** Delete a project integration. */
130
- async delete(integrationId: string): Promise<void> {
131
- await this.http.delete<unknown>(`/project-integrations/${integrationId}`);
132
- }
133
- }
@@ -1,89 +0,0 @@
1
- /**
2
- * ProviderDefaults — admin LLM provider routing config.
3
- *
4
- * Routes:
5
- * GET /admin/provider-defaults
6
- * PUT /admin/provider-defaults
7
- * GET /admin/tenants/:id/provider-config
8
- * PUT /admin/tenants/:id/provider-config
9
- * DELETE /admin/tenants/:id/provider-config
10
- *
11
- * Requires admin credential (msk_a_* / msk_p_* or admin JWT).
12
- */
13
-
14
- import type { HttpClient } from "../http.js";
15
-
16
- function unwrap(data: unknown): Record<string, unknown> {
17
- if (data && typeof data === "object") {
18
- const d = data as Record<string, unknown>;
19
- for (const k of ["data", "defaults", "provider_defaults", "config"]) {
20
- if (k in d) return d[k] as Record<string, unknown>;
21
- }
22
- }
23
- return data as Record<string, unknown>;
24
- }
25
-
26
- export class ProviderDefaults {
27
- constructor(private readonly http: HttpClient) {}
28
-
29
- /** Get the current fleet-wide provider defaults. */
30
- async list(): Promise<Record<string, unknown>> {
31
- return unwrap(await this.http.get<unknown>("/admin/provider-defaults"));
32
- }
33
-
34
- /** Return the defaults entry for a single provider, or {} if missing. */
35
- async get(provider: string): Promise<Record<string, unknown>> {
36
- const data = await this.list();
37
- const providers =
38
- (data.providers as Record<string, unknown> | undefined) ?? data;
39
- if (
40
- typeof providers === "object" &&
41
- providers !== null &&
42
- provider in providers
43
- ) {
44
- return providers[provider] as Record<string, unknown>;
45
- }
46
- return {};
47
- }
48
-
49
- /** Replace the fleet-wide defaults (PUT /admin/provider-defaults). */
50
- async update(
51
- opts: Record<string, unknown>,
52
- ): Promise<Record<string, unknown>> {
53
- const body = Object.fromEntries(
54
- Object.entries(opts).filter(([, v]) => v !== undefined),
55
- );
56
- return unwrap(
57
- await this.http.put<unknown>("/admin/provider-defaults", body),
58
- );
59
- }
60
-
61
- // ── Per-tenant overrides ────────────────────────────────────────────────
62
-
63
- async getTenant(tenantId: string): Promise<Record<string, unknown>> {
64
- return unwrap(
65
- await this.http.get<unknown>(
66
- `/admin/tenants/${tenantId}/provider-config`,
67
- ),
68
- );
69
- }
70
-
71
- async setTenant(
72
- tenantId: string,
73
- opts: Record<string, unknown>,
74
- ): Promise<Record<string, unknown>> {
75
- const body = Object.fromEntries(
76
- Object.entries(opts).filter(([, v]) => v !== undefined),
77
- );
78
- return unwrap(
79
- await this.http.put<unknown>(
80
- `/admin/tenants/${tenantId}/provider-config`,
81
- body,
82
- ),
83
- );
84
- }
85
-
86
- async resetTenant(tenantId: string): Promise<void> {
87
- await this.http.delete(`/admin/tenants/${tenantId}/provider-config`);
88
- }
89
- }
@@ -1,94 +0,0 @@
1
- /**
2
- * Regions — datacenter availability, sizes, pricing, templates.
3
- */
4
-
5
- import type { HttpClient } from "../http.js";
6
-
7
- // ── Resource shapes ──────────────────────────────────────────────────────────
8
-
9
- export interface RegionData {
10
- id?: string;
11
- name?: string;
12
- slug?: string;
13
- available?: boolean;
14
- [key: string]: unknown;
15
- }
16
-
17
- export interface SizeData {
18
- id?: string;
19
- name?: string;
20
- slug?: string;
21
- cpu?: number;
22
- memory_mb?: number;
23
- [key: string]: unknown;
24
- }
25
-
26
- export interface TemplateData {
27
- id?: string;
28
- name?: string;
29
- slug?: string;
30
- [key: string]: unknown;
31
- }
32
-
33
- // ── Helpers ───────────────────────────────────────────────────────────────────
34
-
35
- function unwrap<T>(payload: unknown): T {
36
- if (payload && typeof payload === "object") {
37
- const p = payload as Record<string, unknown>;
38
- for (const k of [
39
- "data",
40
- "regions",
41
- "sizes",
42
- "pricing",
43
- "templates",
44
- "items",
45
- ]) {
46
- if (k in p) return p[k] as T;
47
- }
48
- }
49
- return payload as T;
50
- }
51
-
52
- function listItems<T>(payload: unknown): T[] {
53
- const result = unwrap<T[] | unknown>(payload);
54
- if (Array.isArray(result)) return result;
55
- return [];
56
- }
57
-
58
- // ── Main resource ─────────────────────────────────────────────────────────────
59
-
60
- export class Regions {
61
- constructor(private readonly http: HttpClient) {}
62
-
63
- /** List datacenter regions. */
64
- async listRegions(): Promise<RegionData[]> {
65
- const data = await this.http.get<unknown>("/compute/regions");
66
- return listItems<RegionData>(data);
67
- }
68
-
69
- /** List available compute sizes. */
70
- async listSizes(): Promise<SizeData[]> {
71
- const data = await this.http.get<unknown>("/compute/sizes");
72
- return listItems<SizeData>(data);
73
- }
74
-
75
- /** Get static compute pricing data. */
76
- async pricing(): Promise<unknown> {
77
- const data = await this.http.get<unknown>("/compute/pricing");
78
- return unwrap(data);
79
- }
80
-
81
- /** List community computer templates. */
82
- async listTemplates(): Promise<TemplateData[]> {
83
- const data = await this.http.get<unknown>("/compute/templates");
84
- return listItems<TemplateData>(data);
85
- }
86
-
87
- /** Get a single community template by id. */
88
- async getTemplate(templateId: string): Promise<TemplateData> {
89
- const data = await this.http.get<unknown>(
90
- `/compute/templates/${templateId}`,
91
- );
92
- return unwrap<TemplateData>(data);
93
- }
94
- }
@@ -1,195 +0,0 @@
1
- /**
2
- * SandboxTemplates resource — tenant sandbox template management.
3
- */
4
-
5
- import { randomUUID } from "node:crypto";
6
-
7
- import type { HttpClient } from "../http.js";
8
-
9
- // ── Branded IDs ──────────────────────────────────────────────────────────────
10
-
11
- export type SandboxTemplateResourceId = string & {
12
- readonly __brand: "SandboxTemplateResourceId";
13
- };
14
- export type SandboxTemplateBuildResourceId = string & {
15
- readonly __brand: "SandboxTemplateBuildResourceId";
16
- };
17
-
18
- // ── Resource shapes ──────────────────────────────────────────────────────────
19
-
20
- export interface SandboxTemplateResourceData {
21
- id: SandboxTemplateResourceId;
22
- tenant_id: string;
23
- name: string;
24
- state?: string;
25
- build_spec?: Record<string, unknown>;
26
- aliases?: string[];
27
- created_at?: string;
28
- updated_at?: string;
29
- [key: string]: unknown;
30
- }
31
-
32
- export interface SandboxTemplateBuildResourceData {
33
- id: SandboxTemplateBuildResourceId;
34
- template_id: SandboxTemplateResourceId;
35
- state?: string;
36
- started_at?: string | null;
37
- finished_at?: string | null;
38
- error?: string | null;
39
- created_at?: string;
40
- [key: string]: unknown;
41
- }
42
-
43
- // ── Request payloads ─────────────────────────────────────────────────────────
44
-
45
- export interface SandboxTemplateListParams {
46
- include_aliases?: boolean;
47
- includeAliases?: boolean;
48
- }
49
-
50
- export interface TemplateCreateParams {
51
- name: string;
52
- build_spec: Record<string, unknown>;
53
- buildSpec?: Record<string, unknown>;
54
- idempotencyKey?: string;
55
- [key: string]: unknown;
56
- }
57
-
58
- export interface TemplateBuildCreateParams {
59
- idempotencyKey?: string;
60
- [key: string]: unknown;
61
- }
62
-
63
- // ── Helpers ───────────────────────────────────────────────────────────────────
64
-
65
- function unwrap<T>(payload: unknown): T {
66
- if (payload && typeof payload === "object" && "data" in (payload as object)) {
67
- return (payload as { data: T }).data;
68
- }
69
- return payload as T;
70
- }
71
-
72
- function listItems<T>(
73
- payload: unknown,
74
- candidateKeys: string[] = ["data", "templates", "builds", "items"],
75
- ): T[] {
76
- if (Array.isArray(payload)) return payload;
77
- if (!payload || typeof payload !== "object") return [];
78
- const p = payload as Record<string, unknown>;
79
- if (Array.isArray(p.data)) return p.data as T[];
80
- for (const key of candidateKeys) {
81
- if (Array.isArray(p[key])) return p[key] as T[];
82
- }
83
- return [];
84
- }
85
-
86
- function stripUndefined(
87
- input: Record<string, unknown>,
88
- ): Record<string, unknown> {
89
- return Object.fromEntries(
90
- Object.entries(input).filter(([, v]) => v !== undefined),
91
- );
92
- }
93
-
94
- function idempotencyKey(key?: string): string {
95
- return key ?? randomUUID();
96
- }
97
-
98
- // ── Main resource ─────────────────────────────────────────────────────────────
99
-
100
- export class SandboxTemplates {
101
- constructor(private readonly http: HttpClient) {}
102
-
103
- async list(
104
- params: SandboxTemplateListParams = {},
105
- ): Promise<SandboxTemplateResourceData[]> {
106
- const includeAliases =
107
- params.includeAliases ?? params.include_aliases ?? false;
108
- const query = includeAliases
109
- ? ({ include_aliases: true } as Record<
110
- string,
111
- string | number | boolean | undefined
112
- >)
113
- : undefined;
114
- const data = await this.http.get<unknown>("/sandbox-templates", query);
115
- return listItems<SandboxTemplateResourceData>(data, [
116
- "data",
117
- "templates",
118
- "items",
119
- ]);
120
- }
121
-
122
- async get(templateId: string): Promise<SandboxTemplateResourceData> {
123
- const data = await this.http.get<unknown>(
124
- `/sandbox-templates/${templateId}`,
125
- );
126
- return unwrap<SandboxTemplateResourceData>(data);
127
- }
128
-
129
- async create(
130
- params: TemplateCreateParams,
131
- ): Promise<SandboxTemplateResourceData> {
132
- const {
133
- idempotencyKey: ikey,
134
- buildSpec,
135
- build_spec,
136
- name,
137
- ...rest
138
- } = params;
139
- const body = stripUndefined({
140
- name,
141
- build_spec: buildSpec ?? build_spec,
142
- ...rest,
143
- });
144
- const data = await this.http.request<unknown>("/sandbox-templates", {
145
- method: "POST",
146
- body,
147
- headers: { "Idempotency-Key": idempotencyKey(ikey) },
148
- });
149
- return unwrap<SandboxTemplateResourceData>(data);
150
- }
151
-
152
- async buildSpecSchema(): Promise<Record<string, unknown>> {
153
- const data = await this.http.get<unknown>("/sandbox-templates/build-spec");
154
- return (data ?? {}) as Record<string, unknown>;
155
- }
156
-
157
- async validate(
158
- buildSpec: Record<string, unknown>,
159
- ): Promise<Record<string, unknown>> {
160
- const data = await this.http.post<unknown>("/sandbox-templates/validate", {
161
- build_spec: buildSpec,
162
- });
163
- return (data ?? {}) as Record<string, unknown>;
164
- }
165
-
166
- async listBuilds(
167
- templateId: string,
168
- ): Promise<SandboxTemplateBuildResourceData[]> {
169
- const data = await this.http.get<unknown>(
170
- `/sandbox-templates/${templateId}/builds`,
171
- );
172
- return listItems<SandboxTemplateBuildResourceData>(data, [
173
- "data",
174
- "builds",
175
- "items",
176
- ]);
177
- }
178
-
179
- async createBuild(
180
- templateId: string,
181
- params: TemplateBuildCreateParams = {},
182
- ): Promise<SandboxTemplateBuildResourceData> {
183
- const { idempotencyKey: ikey, ...rest } = params;
184
- const body = stripUndefined(rest as Record<string, unknown>);
185
- const data = await this.http.request<unknown>(
186
- `/sandbox-templates/${templateId}/builds`,
187
- {
188
- method: "POST",
189
- body,
190
- headers: { "Idempotency-Key": idempotencyKey(ikey) },
191
- },
192
- );
193
- return unwrap<SandboxTemplateBuildResourceData>(data);
194
- }
195
- }