@sandbox-kit/daytona 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +55 -2
- package/dist/checks/provider_checks.d.ts +2 -0
- package/dist/checks/provider_checks.js +137 -0
- package/dist/config/provider_config.d.ts +4 -0
- package/dist/config/provider_config.js +49 -0
- package/dist/daytona.d.ts +22 -0
- package/dist/daytona.js +108 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +79 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/mappings/mappings.d.ts +7 -0
- package/dist/mappings/mappings.js +341 -0
- package/dist/mappings/provider_mappings.d.ts +14 -0
- package/dist/mappings/provider_mappings.js +282 -0
- package/dist/mappings.d.ts +8 -0
- package/dist/mappings.js +332 -0
- package/dist/provider.checks.gen.d.ts +3 -0
- package/dist/provider.checks.gen.js +91 -0
- package/dist/provider.config.gen.d.ts +5 -0
- package/dist/provider.config.gen.js +36 -0
- package/dist/provider.d.ts +13 -0
- package/dist/provider.errors.gen.d.ts +3 -0
- package/dist/provider.errors.gen.js +78 -0
- package/dist/provider.gen.d.ts +14 -0
- package/dist/provider.gen.js +11 -0
- package/dist/provider.js +10 -0
- package/dist/provider.mappings.gen.d.ts +12 -0
- package/dist/provider.mappings.gen.js +275 -0
- package/dist/provider_checks.d.ts +3 -0
- package/dist/provider_checks.js +137 -0
- package/dist/provider_config.d.ts +5 -0
- package/dist/provider_config.js +49 -0
- package/dist/provider_mappings.d.ts +15 -0
- package/dist/provider_mappings.js +274 -0
- package/package.json +63 -4
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// Provider field mappings between shared CreateOptions/Config and the native SDK.
|
|
2
|
+
// Inventoried in specs/providers/daytona.yaml groups; kept in sync by hand (not emitted).
|
|
3
|
+
import { ErrorKind, PolicyMode, ValueOrigin, sandboxError } from "@sandbox-kit/sandbox";
|
|
4
|
+
export function mapLifetimePolicies(source, operation = "create") {
|
|
5
|
+
const target = {};
|
|
6
|
+
if (source === undefined)
|
|
7
|
+
return target;
|
|
8
|
+
if (source.idleStop !== undefined) {
|
|
9
|
+
const policy = source.idleStop;
|
|
10
|
+
const mode = policy.mode ?? PolicyMode.Default;
|
|
11
|
+
if (mode === PolicyMode.Disabled) {
|
|
12
|
+
target.autoStopInterval = 0;
|
|
13
|
+
}
|
|
14
|
+
else if (mode === PolicyMode.After) {
|
|
15
|
+
if (policy.after === undefined)
|
|
16
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_stop", "duration is required", operation);
|
|
17
|
+
const afterMs = policy.after;
|
|
18
|
+
if (afterMs === 0)
|
|
19
|
+
mappingError(ErrorKind.Unsupported, "lifetime.idle_stop", "immediate action is not representable", operation);
|
|
20
|
+
if (!Number.isFinite(afterMs) || afterMs < 0 || afterMs % 60_000 !== 0)
|
|
21
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_stop", "delay cannot be represented in whole minutes", operation);
|
|
22
|
+
const minutes = afterMs / 60_000;
|
|
23
|
+
target.autoStopInterval = minutes;
|
|
24
|
+
}
|
|
25
|
+
else if (mode !== PolicyMode.Default) {
|
|
26
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_stop", "unknown policy mode", operation);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (source.idlePause !== undefined) {
|
|
30
|
+
const policy = source.idlePause;
|
|
31
|
+
const mode = policy.mode ?? PolicyMode.Default;
|
|
32
|
+
if (mode === PolicyMode.Disabled) {
|
|
33
|
+
target.autoPauseInterval = 0;
|
|
34
|
+
}
|
|
35
|
+
else if (mode === PolicyMode.After) {
|
|
36
|
+
if (policy.after === undefined)
|
|
37
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_pause", "duration is required", operation);
|
|
38
|
+
const afterMs = policy.after;
|
|
39
|
+
if (afterMs === 0)
|
|
40
|
+
mappingError(ErrorKind.Unsupported, "lifetime.idle_pause", "immediate action is not representable", operation);
|
|
41
|
+
if (!Number.isFinite(afterMs) || afterMs < 0 || afterMs % 60_000 !== 0)
|
|
42
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_pause", "delay cannot be represented in whole minutes", operation);
|
|
43
|
+
const minutes = afterMs / 60_000;
|
|
44
|
+
target.autoPauseInterval = minutes;
|
|
45
|
+
}
|
|
46
|
+
else if (mode !== PolicyMode.Default) {
|
|
47
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.idle_pause", "unknown policy mode", operation);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (source.stoppedArchive !== undefined) {
|
|
51
|
+
const policy = source.stoppedArchive;
|
|
52
|
+
const mode = policy.mode ?? PolicyMode.Default;
|
|
53
|
+
if (mode === PolicyMode.Disabled) {
|
|
54
|
+
mappingError(ErrorKind.Unsupported, "lifetime.stopped_archive", "explicit disabling is not representable", operation);
|
|
55
|
+
}
|
|
56
|
+
else if (mode === PolicyMode.After) {
|
|
57
|
+
if (policy.after === undefined)
|
|
58
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_archive", "duration is required", operation);
|
|
59
|
+
const afterMs = policy.after;
|
|
60
|
+
if (afterMs === 0)
|
|
61
|
+
mappingError(ErrorKind.Unsupported, "lifetime.stopped_archive", "immediate action is not representable", operation);
|
|
62
|
+
if (!Number.isFinite(afterMs) || afterMs < 0 || afterMs % 60_000 !== 0)
|
|
63
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_archive", "delay cannot be represented in whole minutes", operation);
|
|
64
|
+
const minutes = afterMs / 60_000;
|
|
65
|
+
if (minutes > 43200)
|
|
66
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_archive", "delay exceeds documented maximum", operation);
|
|
67
|
+
target.autoArchiveInterval = minutes;
|
|
68
|
+
}
|
|
69
|
+
else if (mode !== PolicyMode.Default) {
|
|
70
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_archive", "unknown policy mode", operation);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (source.stoppedDelete !== undefined) {
|
|
74
|
+
const policy = source.stoppedDelete;
|
|
75
|
+
const mode = policy.mode ?? PolicyMode.Default;
|
|
76
|
+
if (mode === PolicyMode.Disabled) {
|
|
77
|
+
mappingError(ErrorKind.Unsupported, "lifetime.stopped_delete", "explicit disabling is not representable", operation);
|
|
78
|
+
}
|
|
79
|
+
else if (mode === PolicyMode.After) {
|
|
80
|
+
if (policy.after === undefined)
|
|
81
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_delete", "duration is required", operation);
|
|
82
|
+
const afterMs = policy.after;
|
|
83
|
+
if (!Number.isFinite(afterMs) || afterMs < 0 || afterMs % 60_000 !== 0)
|
|
84
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_delete", "delay cannot be represented in whole minutes", operation);
|
|
85
|
+
const minutes = afterMs / 60_000;
|
|
86
|
+
target.autoDeleteInterval = minutes;
|
|
87
|
+
}
|
|
88
|
+
else if (mode !== PolicyMode.Default) {
|
|
89
|
+
mappingError(ErrorKind.InvalidArgument, "lifetime.stopped_delete", "unknown policy mode", operation);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return target;
|
|
93
|
+
}
|
|
94
|
+
export function mapCommonCreateFields(source, operation = "create") {
|
|
95
|
+
const target = {};
|
|
96
|
+
if (source === undefined)
|
|
97
|
+
return target;
|
|
98
|
+
{
|
|
99
|
+
if (source.name !== undefined) {
|
|
100
|
+
const value = source.name;
|
|
101
|
+
target.name = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
{
|
|
105
|
+
if (source.environment !== undefined) {
|
|
106
|
+
const value = source.environment;
|
|
107
|
+
target.envVars = { ...value };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
{
|
|
111
|
+
if (source.labels !== undefined) {
|
|
112
|
+
const value = source.labels;
|
|
113
|
+
target.labels = { ...value };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return target;
|
|
117
|
+
}
|
|
118
|
+
export function mapResources(source, operation = "create") {
|
|
119
|
+
const target = {};
|
|
120
|
+
if (source === undefined)
|
|
121
|
+
return target;
|
|
122
|
+
{
|
|
123
|
+
if (source.cpuCores !== undefined) {
|
|
124
|
+
const value = source.cpuCores;
|
|
125
|
+
if (!Number.isInteger(value) || value > 2147483647)
|
|
126
|
+
mappingError(ErrorKind.InvalidArgument, "resources.cpu_cores", "cpu_cores cannot be represented", operation);
|
|
127
|
+
target.cpu = Number(value);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
{
|
|
131
|
+
if (source.memoryMib !== undefined) {
|
|
132
|
+
const value = source.memoryMib;
|
|
133
|
+
if (value % 1024n !== 0n || value / 1024n > 2147483647n)
|
|
134
|
+
mappingError(ErrorKind.InvalidArgument, "resources.memory_mib", "memory_mib cannot be represented", operation);
|
|
135
|
+
target.memory = Number(value / 1024n);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
{
|
|
139
|
+
if (source.diskMib !== undefined) {
|
|
140
|
+
const value = source.diskMib;
|
|
141
|
+
if (value % 1024n !== 0n || value / 1024n > 2147483647n)
|
|
142
|
+
mappingError(ErrorKind.InvalidArgument, "resources.disk_mib", "disk_mib cannot be represented", operation);
|
|
143
|
+
target.disk = Number(value / 1024n);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return target;
|
|
147
|
+
}
|
|
148
|
+
export function mapSandboxInfo(source, operation = "create") {
|
|
149
|
+
const target = {};
|
|
150
|
+
if (source === undefined)
|
|
151
|
+
return target;
|
|
152
|
+
const origins = {};
|
|
153
|
+
target.origins = origins;
|
|
154
|
+
{
|
|
155
|
+
if (source.id !== undefined) {
|
|
156
|
+
const value = source.id;
|
|
157
|
+
target.id = value;
|
|
158
|
+
origins["id"] = ValueOrigin.Provider;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
{
|
|
162
|
+
if (source.name !== undefined) {
|
|
163
|
+
const value = source.name;
|
|
164
|
+
target.name = value;
|
|
165
|
+
origins["name"] = ValueOrigin.Provider;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
{
|
|
169
|
+
if (source.state !== undefined) {
|
|
170
|
+
const value = source.state;
|
|
171
|
+
target.providerState = String(value);
|
|
172
|
+
origins["provider_state"] = ValueOrigin.Provider;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
{
|
|
176
|
+
if (source.target !== undefined) {
|
|
177
|
+
const value = source.target;
|
|
178
|
+
target.region = value;
|
|
179
|
+
origins["region"] = ValueOrigin.Provider;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
{
|
|
183
|
+
if (source.labels !== undefined) {
|
|
184
|
+
const value = source.labels;
|
|
185
|
+
target.labels = { ...value };
|
|
186
|
+
origins["labels"] = ValueOrigin.Provider;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
target.provider = "daytona";
|
|
190
|
+
return target;
|
|
191
|
+
}
|
|
192
|
+
export function mapAllocatedResources(source, operation = "create") {
|
|
193
|
+
const target = {};
|
|
194
|
+
if (source === undefined)
|
|
195
|
+
return target;
|
|
196
|
+
if (!((source.cpu ?? 0) > 0 && (source.memory ?? 0) > 0 && (source.disk ?? 0) > 0))
|
|
197
|
+
return target;
|
|
198
|
+
{
|
|
199
|
+
if (source.cpu !== undefined) {
|
|
200
|
+
const value = source.cpu;
|
|
201
|
+
target.cpuCores = Number(value);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
{
|
|
205
|
+
if (source.memory !== undefined) {
|
|
206
|
+
const value = source.memory;
|
|
207
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
208
|
+
mappingError(ErrorKind.InvalidResponse, "memory", "memory cannot be represented", operation);
|
|
209
|
+
target.memoryMib = BigInt(value) * 1024n;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
{
|
|
213
|
+
if (source.disk !== undefined) {
|
|
214
|
+
const value = source.disk;
|
|
215
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
216
|
+
mappingError(ErrorKind.InvalidResponse, "disk", "disk cannot be represented", operation);
|
|
217
|
+
target.diskMib = BigInt(value) * 1024n;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return target;
|
|
221
|
+
}
|
|
222
|
+
export function mapClientSettings(source, operation = "initialize") {
|
|
223
|
+
const target = {};
|
|
224
|
+
if (source === undefined)
|
|
225
|
+
return target;
|
|
226
|
+
{
|
|
227
|
+
if (source.endpoint !== undefined) {
|
|
228
|
+
const value = source.endpoint;
|
|
229
|
+
target.apiUrl = value;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
{
|
|
233
|
+
if (source.region !== undefined) {
|
|
234
|
+
const value = source.region;
|
|
235
|
+
target.target = value;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return target;
|
|
239
|
+
}
|
|
240
|
+
export function mapAPIKeyCredentials(source, operation = "initialize") {
|
|
241
|
+
const target = {};
|
|
242
|
+
if (source === undefined)
|
|
243
|
+
return target;
|
|
244
|
+
{
|
|
245
|
+
const value = source.key;
|
|
246
|
+
target.apiKey = value;
|
|
247
|
+
}
|
|
248
|
+
return target;
|
|
249
|
+
}
|
|
250
|
+
export function mapBearerAuth(source, operation = "initialize") {
|
|
251
|
+
const target = {};
|
|
252
|
+
if (source === undefined)
|
|
253
|
+
return target;
|
|
254
|
+
{
|
|
255
|
+
const value = source.token;
|
|
256
|
+
target.jwtToken = value;
|
|
257
|
+
}
|
|
258
|
+
return target;
|
|
259
|
+
}
|
|
260
|
+
export function mapScope(source, operation = "initialize") {
|
|
261
|
+
const target = {};
|
|
262
|
+
if (source === undefined)
|
|
263
|
+
return target;
|
|
264
|
+
{
|
|
265
|
+
if (source.organizationId !== undefined) {
|
|
266
|
+
const value = source.organizationId;
|
|
267
|
+
target.organizationId = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return target;
|
|
271
|
+
}
|
|
272
|
+
function mappingError(kind, field, message, operation) {
|
|
273
|
+
throw sandboxError({ kind, provider: "daytona", operation, field, message: "sandbox-kit daytona: " + message });
|
|
274
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandbox-kit/daytona",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "daytona provider for sandbox kit",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "npm@11.19.0",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": "^20.0.0 || ^22.0.0 || >=24.15.0"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/sandbox-kit/kit.git",
|
|
14
|
+
"directory": "sdks/typescript/providers/daytona"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/sandbox-kit/kit/tree/main/sdks/typescript/providers/daytona",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/sandbox-kit/kit/issues"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"imports": {
|
|
37
|
+
"#mappings/*.js": {
|
|
38
|
+
"@sandbox-kit/source": "./src/mappings/*.ts",
|
|
39
|
+
"default": "./dist/mappings/*.js"
|
|
40
|
+
},
|
|
41
|
+
"#checks/*.js": {
|
|
42
|
+
"@sandbox-kit/source": "./src/checks/*.ts",
|
|
43
|
+
"default": "./dist/checks/*.js"
|
|
44
|
+
},
|
|
45
|
+
"#config/*.js": {
|
|
46
|
+
"@sandbox-kit/source": "./src/config/*.ts",
|
|
47
|
+
"default": "./dist/config/*.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.build.json",
|
|
52
|
+
"prepublishOnly": "npm run build",
|
|
53
|
+
"test": "tsc -p tsconfig.test.json && vitest run"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@bufbuild/protobuf": "2.16.0",
|
|
57
|
+
"@daytona/sdk": "0.225.0",
|
|
58
|
+
"@sandbox-kit/sandbox": "0.1.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/node": "24.10.1",
|
|
62
|
+
"typescript": "5.9.3",
|
|
63
|
+
"vitest": "4.1.11"
|
|
64
|
+
}
|
|
65
|
+
}
|