@distilled.cloud/daytona 0.0.0-placeholder → 1.0.0-rc.13
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 +201 -0
- package/README.md +34 -0
- package/lib/credentials.d.ts +46 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +67 -0
- package/lib/credentials.js.map +1 -0
- package/lib/endpoints.d.ts +15 -0
- package/lib/endpoints.d.ts.map +1 -0
- package/lib/endpoints.js +28 -0
- package/lib/endpoints.js.map +1 -0
- package/lib/errors.d.ts +53 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +30 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +30 -0
- package/lib/index.js.map +1 -0
- package/lib/pagination.d.ts +10 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +10 -0
- package/lib/pagination.js.map +1 -0
- package/lib/protocol.d.ts +18 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +75 -0
- package/lib/protocol.js.map +1 -0
- package/lib/response-validation.test.d.ts +4 -0
- package/lib/response-validation.test.d.ts.map +1 -0
- package/lib/response-validation.test.js +31 -0
- package/lib/response-validation.test.js.map +1 -0
- package/lib/retry.d.ts +50 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +43 -0
- package/lib/retry.js.map +1 -0
- package/lib/services/api_keys.d.ts +120 -0
- package/lib/services/api_keys.d.ts.map +1 -0
- package/lib/services/api_keys.js +126 -0
- package/lib/services/api_keys.js.map +1 -0
- package/lib/services/audit.d.ts +159 -0
- package/lib/services/audit.d.ts.map +1 -0
- package/lib/services/audit.js +126 -0
- package/lib/services/audit.js.map +1 -0
- package/lib/services/computer_use.d.ts +484 -0
- package/lib/services/computer_use.d.ts.map +1 -0
- package/lib/services/computer_use.js +672 -0
- package/lib/services/computer_use.js.map +1 -0
- package/lib/services/config.d.ts +138 -0
- package/lib/services/config.d.ts.map +1 -0
- package/lib/services/config.js +88 -0
- package/lib/services/config.js.map +1 -0
- package/lib/services/docker_registry.d.ts +126 -0
- package/lib/services/docker_registry.d.ts.map +1 -0
- package/lib/services/docker_registry.js +135 -0
- package/lib/services/docker_registry.js.map +1 -0
- package/lib/services/file_system.d.ts +203 -0
- package/lib/services/file_system.d.ts.map +1 -0
- package/lib/services/file_system.js +255 -0
- package/lib/services/file_system.js.map +1 -0
- package/lib/services/git.d.ts +338 -0
- package/lib/services/git.d.ts.map +1 -0
- package/lib/services/git.js +417 -0
- package/lib/services/git.js.map +1 -0
- package/lib/services/health.d.ts +41 -0
- package/lib/services/health.d.ts.map +1 -0
- package/lib/services/health.js +49 -0
- package/lib/services/health.js.map +1 -0
- package/lib/services/index.d.ts +31 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +32 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/info.d.ts +37 -0
- package/lib/services/info.d.ts.map +1 -0
- package/lib/services/info.js +55 -0
- package/lib/services/info.js.map +1 -0
- package/lib/services/interpreter.d.ts +56 -0
- package/lib/services/interpreter.d.ts.map +1 -0
- package/lib/services/interpreter.js +83 -0
- package/lib/services/interpreter.js.map +1 -0
- package/lib/services/jobs.d.ts +104 -0
- package/lib/services/jobs.d.ts.map +1 -0
- package/lib/services/jobs.js +94 -0
- package/lib/services/jobs.js.map +1 -0
- package/lib/services/lsp.d.ts +137 -0
- package/lib/services/lsp.d.ts.map +1 -0
- package/lib/services/lsp.js +160 -0
- package/lib/services/lsp.js.map +1 -0
- package/lib/services/object_storage.d.ts +31 -0
- package/lib/services/object_storage.d.ts.map +1 -0
- package/lib/services/object_storage.js +33 -0
- package/lib/services/object_storage.js.map +1 -0
- package/lib/services/organizations.d.ts +963 -0
- package/lib/services/organizations.d.ts.map +1 -0
- package/lib/services/organizations.js +1143 -0
- package/lib/services/organizations.js.map +1 -0
- package/lib/services/port.d.ts +29 -0
- package/lib/services/port.d.ts.map +1 -0
- package/lib/services/port.js +41 -0
- package/lib/services/port.js.map +1 -0
- package/lib/services/preview.d.ts +73 -0
- package/lib/services/preview.d.ts.map +1 -0
- package/lib/services/preview.js +125 -0
- package/lib/services/preview.js.map +1 -0
- package/lib/services/process.d.ts +329 -0
- package/lib/services/process.d.ts.map +1 -0
- package/lib/services/process.js +421 -0
- package/lib/services/process.js.map +1 -0
- package/lib/services/regions.d.ts +41 -0
- package/lib/services/regions.d.ts.map +1 -0
- package/lib/services/regions.js +36 -0
- package/lib/services/regions.js.map +1 -0
- package/lib/services/runners.d.ts +358 -0
- package/lib/services/runners.d.ts.map +1 -0
- package/lib/services/runners.js +316 -0
- package/lib/services/runners.js.map +1 -0
- package/lib/services/sandbox.d.ts +1276 -0
- package/lib/services/sandbox.d.ts.map +1 -0
- package/lib/services/sandbox.js +1218 -0
- package/lib/services/sandbox.js.map +1 -0
- package/lib/services/secret.d.ts +120 -0
- package/lib/services/secret.d.ts.map +1 -0
- package/lib/services/secret.js +113 -0
- package/lib/services/secret.js.map +1 -0
- package/lib/services/server.d.ts +44 -0
- package/lib/services/server.d.ts.map +1 -0
- package/lib/services/server.js +46 -0
- package/lib/services/server.js.map +1 -0
- package/lib/services/snapshots.d.ts +208 -0
- package/lib/services/snapshots.d.ts.map +1 -0
- package/lib/services/snapshots.js +189 -0
- package/lib/services/snapshots.js.map +1 -0
- package/lib/services/system.d.ts +24 -0
- package/lib/services/system.d.ts.map +1 -0
- package/lib/services/system.js +31 -0
- package/lib/services/system.js.map +1 -0
- package/lib/services/telemetry.d.ts +141 -0
- package/lib/services/telemetry.d.ts.map +1 -0
- package/lib/services/telemetry.js +165 -0
- package/lib/services/telemetry.js.map +1 -0
- package/lib/services/usage.d.ts +111 -0
- package/lib/services/usage.d.ts.map +1 -0
- package/lib/services/usage.js +146 -0
- package/lib/services/usage.js.map +1 -0
- package/lib/services/users.d.ts +125 -0
- package/lib/services/users.d.ts.map +1 -0
- package/lib/services/users.js +172 -0
- package/lib/services/users.js.map +1 -0
- package/lib/services/volumes.d.ts +83 -0
- package/lib/services/volumes.d.ts.map +1 -0
- package/lib/services/volumes.js +96 -0
- package/lib/services/volumes.js.map +1 -0
- package/lib/services/warm_pools.d.ts +79 -0
- package/lib/services/warm_pools.d.ts.map +1 -0
- package/lib/services/warm_pools.js +90 -0
- package/lib/services/warm_pools.js.map +1 -0
- package/lib/services/webhooks.d.ts +67 -0
- package/lib/services/webhooks.d.ts.map +1 -0
- package/lib/services/webhooks.js +103 -0
- package/lib/services/webhooks.js.map +1 -0
- package/lib/traits.d.ts +10 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +11 -0
- package/lib/traits.js.map +1 -0
- package/package.json +78 -7
- package/src/credentials.ts +135 -0
- package/src/endpoints.ts +28 -0
- package/src/errors.ts +85 -0
- package/src/index.ts +33 -0
- package/src/pagination.ts +9 -0
- package/src/protocol.ts +108 -0
- package/src/response-validation.test.ts +45 -0
- package/src/retry.ts +74 -0
- package/src/services/api_keys.ts +378 -0
- package/src/services/audit.ts +416 -0
- package/src/services/computer_use.ts +1496 -0
- package/src/services/config.ts +256 -0
- package/src/services/docker_registry.ts +325 -0
- package/src/services/file_system.ts +575 -0
- package/src/services/git.ts +928 -0
- package/src/services/health.ts +116 -0
- package/src/services/index.ts +31 -0
- package/src/services/info.ts +116 -0
- package/src/services/interpreter.ts +182 -0
- package/src/services/jobs.ts +249 -0
- package/src/services/lsp.ts +367 -0
- package/src/services/object_storage.ts +75 -0
- package/src/services/organizations.ts +2712 -0
- package/src/services/port.ts +87 -0
- package/src/services/preview.ts +256 -0
- package/src/services/process.ts +948 -0
- package/src/services/regions.ts +90 -0
- package/src/services/runners.ts +811 -0
- package/src/services/sandbox.ts +3158 -0
- package/src/services/secret.ts +289 -0
- package/src/services/server.ts +111 -0
- package/src/services/snapshots.ts +508 -0
- package/src/services/system.ts +64 -0
- package/src/services/telemetry.ts +385 -0
- package/src/services/usage.ts +316 -0
- package/src/services/users.ts +380 -0
- package/src/services/volumes.ts +233 -0
- package/src/services/warm_pools.ts +209 -0
- package/src/services/webhooks.ts +214 -0
- package/src/traits.ts +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/services/webhooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAEjD,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAEjD,MAAM,WAAW,0CAA0C;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AACD,eAAO,MAAM,0CAA0C,EAgBxC,CAAC,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAEpE,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;CACb;AACD,eAAO,MAAM,sBAAsB,EAOtB,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAE9C,MAAM,WAAW,+CAA+C;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AACD,eAAO,MAAM,+CAA+C,EAgB7C,CAAC,CAAC,MAAM,CAAC,+CAA+C,CAAC,CAAC;AAEzE,MAAM,WAAW,2BAA2B;IAC1C,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,UAAU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EACtC,gBAAgB,CAOf,CAAC;AAEJ,MAAM,MAAM,wCAAwC,GAAG,cAAc,CAAC;AACtE,8CAA8C;AAC9C,eAAO,MAAM,mCAAmC,EAAE,GAAG,CAAC,eAAe,CACnE,0CAA0C,EAC1C,2BAA2B,EAC3B,wCAAwC,EACxC,gBAAgB,CAOf,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-daytona/specs/{openapi,toolbox-openapi,analytics-openapi}.json). Do not edit.
|
|
2
|
+
import * as S from "@distilled.cloud/core/schema";
|
|
3
|
+
import * as API from "@distilled.cloud/core/api";
|
|
4
|
+
import * as T from "../traits.js";
|
|
5
|
+
import { DaytonaProtocol, } from "../protocol.js";
|
|
6
|
+
import { UnknownDaytonaError } from "../errors.js";
|
|
7
|
+
import * as Retry from "../retry.js";
|
|
8
|
+
export const GetWebhookControllerAppPortalAccessRequest =
|
|
9
|
+
/*@__PURE__*/ S.suspend(() => S.Struct({
|
|
10
|
+
organizationId: S.String.pipe(T.Label()),
|
|
11
|
+
xDaytonaOrganizationID: S.optional(S.String.pipe(T.Header("X-Daytona-Organization-ID"))),
|
|
12
|
+
}).pipe(T.Http({
|
|
13
|
+
method: "POST",
|
|
14
|
+
uri: "/webhooks/organizations/{organizationId}/app-portal-access",
|
|
15
|
+
code: 200,
|
|
16
|
+
}))).annotate({
|
|
17
|
+
identifier: "GetWebhookControllerAppPortalAccessRequest",
|
|
18
|
+
});
|
|
19
|
+
export const WebhookAppPortalAccess = /*@__PURE__*/ S.suspend(() => S.Struct({
|
|
20
|
+
token: S.String,
|
|
21
|
+
url: S.String,
|
|
22
|
+
})).annotate({
|
|
23
|
+
identifier: "WebhookAppPortalAccess",
|
|
24
|
+
});
|
|
25
|
+
export const GetWebhookControllerInitializationStatusRequest =
|
|
26
|
+
/*@__PURE__*/ S.suspend(() => S.Struct({
|
|
27
|
+
organizationId: S.String.pipe(T.Label()),
|
|
28
|
+
xDaytonaOrganizationID: S.optional(S.String.pipe(T.Header("X-Daytona-Organization-ID"))),
|
|
29
|
+
}).pipe(T.Http({
|
|
30
|
+
method: "GET",
|
|
31
|
+
uri: "/webhooks/organizations/{organizationId}/initialization-status",
|
|
32
|
+
code: 200,
|
|
33
|
+
}))).annotate({
|
|
34
|
+
identifier: "GetWebhookControllerInitializationStatusRequest",
|
|
35
|
+
});
|
|
36
|
+
export const WebhookInitializationStatus = /*@__PURE__*/ S.suspend(() => S.Struct({
|
|
37
|
+
organizationId: S.String,
|
|
38
|
+
svixApplicationId: S.NullOr(S.String),
|
|
39
|
+
lastError: S.NullOr(S.String),
|
|
40
|
+
retryCount: S.Number,
|
|
41
|
+
createdAt: S.String,
|
|
42
|
+
updatedAt: S.String,
|
|
43
|
+
})).annotate({
|
|
44
|
+
identifier: "WebhookInitializationStatus",
|
|
45
|
+
});
|
|
46
|
+
export const RefreshWebhookControllerEndpointsRequest = /*@__PURE__*/ S.suspend(() => S.Struct({
|
|
47
|
+
organizationId: S.String.pipe(T.Label()),
|
|
48
|
+
xDaytonaOrganizationID: S.optional(S.String.pipe(T.Header("X-Daytona-Organization-ID"))),
|
|
49
|
+
}).pipe(T.Http({
|
|
50
|
+
method: "POST",
|
|
51
|
+
uri: "/webhooks/organizations/{organizationId}/refresh-endpoints",
|
|
52
|
+
code: 200,
|
|
53
|
+
}))).annotate({
|
|
54
|
+
identifier: "RefreshWebhookControllerEndpointsRequest",
|
|
55
|
+
});
|
|
56
|
+
export const RefreshWebhookControllerEndpointsResponse =
|
|
57
|
+
/*@__PURE__*/ S.suspend(() => S.Struct({})).annotate({
|
|
58
|
+
identifier: "RefreshWebhookControllerEndpointsResponse",
|
|
59
|
+
});
|
|
60
|
+
export const WebhookControllerInitializeWebhooksRequest =
|
|
61
|
+
/*@__PURE__*/ S.suspend(() => S.Struct({
|
|
62
|
+
organizationId: S.String.pipe(T.Label()),
|
|
63
|
+
xDaytonaOrganizationID: S.optional(S.String.pipe(T.Header("X-Daytona-Organization-ID"))),
|
|
64
|
+
}).pipe(T.Http({
|
|
65
|
+
method: "POST",
|
|
66
|
+
uri: "/webhooks/organizations/{organizationId}/initialize",
|
|
67
|
+
code: 200,
|
|
68
|
+
}))).annotate({
|
|
69
|
+
identifier: "WebhookControllerInitializeWebhooksRequest",
|
|
70
|
+
});
|
|
71
|
+
/** Get Svix Consumer App Portal access for an organization */
|
|
72
|
+
export const getWebhookControllerAppPortalAccess = /*@__PURE__*/ API.make(() => ({
|
|
73
|
+
input: GetWebhookControllerAppPortalAccessRequest,
|
|
74
|
+
output: WebhookAppPortalAccess,
|
|
75
|
+
errors: [UnknownDaytonaError],
|
|
76
|
+
protocol: DaytonaProtocol,
|
|
77
|
+
retry: Retry.Retry,
|
|
78
|
+
}));
|
|
79
|
+
/** Get webhook initialization status for an organization */
|
|
80
|
+
export const getWebhookControllerInitializationStatus = /*@__PURE__*/ API.make(() => ({
|
|
81
|
+
input: GetWebhookControllerInitializationStatusRequest,
|
|
82
|
+
output: WebhookInitializationStatus,
|
|
83
|
+
errors: [UnknownDaytonaError],
|
|
84
|
+
protocol: DaytonaProtocol,
|
|
85
|
+
retry: Retry.Retry,
|
|
86
|
+
}));
|
|
87
|
+
/** Refresh cached endpoint presence flag for an organization */
|
|
88
|
+
export const refreshWebhookControllerEndpoints = /*@__PURE__*/ API.make(() => ({
|
|
89
|
+
input: RefreshWebhookControllerEndpointsRequest,
|
|
90
|
+
output: RefreshWebhookControllerEndpointsResponse,
|
|
91
|
+
errors: [UnknownDaytonaError],
|
|
92
|
+
protocol: DaytonaProtocol,
|
|
93
|
+
retry: Retry.Retry,
|
|
94
|
+
}));
|
|
95
|
+
/** Initialize webhooks for an organization */
|
|
96
|
+
export const webhookControllerInitializeWebhooks = /*@__PURE__*/ API.make(() => ({
|
|
97
|
+
input: WebhookControllerInitializeWebhooksRequest,
|
|
98
|
+
output: WebhookInitializationStatus,
|
|
99
|
+
errors: [UnknownDaytonaError],
|
|
100
|
+
protocol: DaytonaProtocol,
|
|
101
|
+
retry: Retry.Retry,
|
|
102
|
+
}));
|
|
103
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/services/webhooks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAC/J,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACjD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,eAAe,GAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AASrC,MAAM,CAAC,MAAM,0CAA0C;AACrD,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAC3B,CAAC,CAAC,MAAM,CAAC;IACP,cAAc,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACxC,sBAAsB,EAAE,CAAC,CAAC,QAAQ,CAChC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,CACrD;CACF,CAAC,CAAC,IAAI,CACL,CAAC,CAAC,IAAI,CAAC;IACL,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,4DAA4D;IACjE,IAAI,EAAE,GAAG;CACV,CAAC,CACH,CACF,CAAC,QAAQ,CAAC;IACT,UAAU,EAAE,4CAA4C;CACzD,CAAgE,CAAC;AAQpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CACjE,CAAC,CAAC,MAAM,CAAC;IACP,KAAK,EAAE,CAAC,CAAC,MAAM;IACf,GAAG,EAAE,CAAC,CAAC,MAAM;CACd,CAAC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ports the generic protocol traits from core so generated operations
|
|
5
|
+
* import everything from one place. Daytona speaks plain bearer-REST JSON
|
|
6
|
+
* with no success envelope, so there are no provider-specific traits.
|
|
7
|
+
*/
|
|
8
|
+
export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, type HttpTrait, type ErrorMatcher, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
|
|
9
|
+
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
10
|
+
//# sourceMappingURL=traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC"}
|
package/lib/traits.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daytona SDK trait surface — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the generic protocol traits from core so generated operations
|
|
5
|
+
* import everything from one place. Daytona speaks plain bearer-REST JSON
|
|
6
|
+
* with no success envelope, so there are no provider-specific traits.
|
|
7
|
+
*/
|
|
8
|
+
export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
|
|
9
|
+
// Bearer-REST protocol traits (sensitive strings, bare-payload responses).
|
|
10
|
+
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
11
|
+
//# sourceMappingURL=traits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAGhB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,2EAA2E;AAC3E,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/daytona",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Placeholder package for initial npm registration.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
3
|
+
"version": "1.0.0-rc.13",
|
|
6
4
|
"repository": {
|
|
7
5
|
"type": "git",
|
|
8
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
9
7
|
"directory": "packages/daytona"
|
|
10
8
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "src/index.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"lib",
|
|
15
|
+
"src"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"bun": "./src/index.ts",
|
|
21
|
+
"worker": "./src/index.ts",
|
|
22
|
+
"default": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./Credentials": {
|
|
25
|
+
"types": "./lib/credentials.d.ts",
|
|
26
|
+
"bun": "./src/credentials.ts",
|
|
27
|
+
"worker": "./src/credentials.ts",
|
|
28
|
+
"default": "./lib/credentials.js"
|
|
29
|
+
},
|
|
30
|
+
"./Errors": {
|
|
31
|
+
"types": "./lib/errors.d.ts",
|
|
32
|
+
"bun": "./src/errors.ts",
|
|
33
|
+
"worker": "./src/errors.ts",
|
|
34
|
+
"default": "./lib/errors.js"
|
|
35
|
+
},
|
|
36
|
+
"./Pagination": {
|
|
37
|
+
"types": "./lib/pagination.d.ts",
|
|
38
|
+
"bun": "./src/pagination.ts",
|
|
39
|
+
"worker": "./src/pagination.ts",
|
|
40
|
+
"default": "./lib/pagination.js"
|
|
41
|
+
},
|
|
42
|
+
"./Protocol": {
|
|
43
|
+
"types": "./lib/protocol.d.ts",
|
|
44
|
+
"bun": "./src/protocol.ts",
|
|
45
|
+
"worker": "./src/protocol.ts",
|
|
46
|
+
"default": "./lib/protocol.js"
|
|
47
|
+
},
|
|
48
|
+
"./Retry": {
|
|
49
|
+
"types": "./lib/retry.d.ts",
|
|
50
|
+
"bun": "./src/retry.ts",
|
|
51
|
+
"worker": "./src/retry.ts",
|
|
52
|
+
"default": "./lib/retry.js"
|
|
53
|
+
},
|
|
54
|
+
"./Traits": {
|
|
55
|
+
"types": "./lib/traits.d.ts",
|
|
56
|
+
"bun": "./src/traits.ts",
|
|
57
|
+
"worker": "./src/traits.ts",
|
|
58
|
+
"default": "./lib/traits.js"
|
|
59
|
+
},
|
|
60
|
+
"./*": {
|
|
61
|
+
"types": "./lib/services/*.d.ts",
|
|
62
|
+
"bun": "./src/services/*.ts",
|
|
63
|
+
"worker": "./src/services/*.ts",
|
|
64
|
+
"default": "./lib/services/*.js"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@distilled.cloud/core": "1.0.0-rc.13"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/bun": "1.3.14",
|
|
72
|
+
"@types/node": "26.2.0",
|
|
73
|
+
"@effect/platform-bun": "^4.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"effect": "^4.0.0"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "tsc -b",
|
|
80
|
+
"convert": "bun scripts/convert.ts",
|
|
81
|
+
"generate": "bun scripts/generate.ts",
|
|
82
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
83
|
+
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-daytona",
|
|
84
|
+
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-daytona"
|
|
14
85
|
}
|
|
15
|
-
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daytona credentials — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* The `Credentials` service resolves `{ apiKey, apiBaseUrl, analyticsBaseUrl,
|
|
5
|
+
* toolboxBaseUrl, sandboxId?, organizationId? }` per request; the protocol
|
|
6
|
+
* layer formats the `Authorization: Bearer <apiKey>` header from it. The
|
|
7
|
+
* key is a Daytona API key from https://app.daytona.io/dashboard/keys.
|
|
8
|
+
*
|
|
9
|
+
* Daytona speaks from THREE endpoints:
|
|
10
|
+
*
|
|
11
|
+
* • Platform (`https://app.daytona.io/api`) — sandboxes, orgs, snapshots
|
|
12
|
+
* • Analytics (`https://analytics.app.daytona.io`) — telemetry and usage
|
|
13
|
+
* • Toolbox (`https://proxy.app.daytona.io/toolbox/{sandboxId}`) —
|
|
14
|
+
* in-sandbox fs/git/process/computer-use. The sandbox id is part of
|
|
15
|
+
* the CLIENT configuration, not of any operation input: set `sandboxId`
|
|
16
|
+
* (or a fully-resolved `toolboxBaseUrl`) to call those services.
|
|
17
|
+
*
|
|
18
|
+
* The protocol picks the endpoint per request from the operation's route
|
|
19
|
+
* (see protocol.ts). `DAYTONA_API_KEY` / `DAYTONA_API_URL` are what the
|
|
20
|
+
* official SDKs read.
|
|
21
|
+
*/
|
|
22
|
+
import * as EffectConfig from "effect/Config";
|
|
23
|
+
import * as Context from "effect/Context";
|
|
24
|
+
import * as Effect from "effect/Effect";
|
|
25
|
+
import * as Layer from "effect/Layer";
|
|
26
|
+
import * as Redacted from "effect/Redacted";
|
|
27
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
28
|
+
|
|
29
|
+
/** Daytona Cloud's platform API root. */
|
|
30
|
+
export const DEFAULT_API_BASE_URL = "https://app.daytona.io/api";
|
|
31
|
+
|
|
32
|
+
/** Daytona Cloud's analytics API root. */
|
|
33
|
+
export const DEFAULT_ANALYTICS_BASE_URL = "https://analytics.app.daytona.io";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Toolbox endpoint template. `{sandboxId}` is replaced with the configured
|
|
37
|
+
* sandbox (the docs' `{toolboxProxyUrl}/{sandboxId}` form). Pass a fully
|
|
38
|
+
* resolved URL — e.g. a sandbox's `toolboxProxyUrl` — to skip substitution.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_TOOLBOX_BASE_URL =
|
|
41
|
+
"https://proxy.app.daytona.io/toolbox/{sandboxId}";
|
|
42
|
+
|
|
43
|
+
export interface Config {
|
|
44
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
45
|
+
readonly apiBaseUrl: string;
|
|
46
|
+
readonly analyticsBaseUrl: string;
|
|
47
|
+
readonly toolboxBaseUrl: string;
|
|
48
|
+
/**
|
|
49
|
+
* Sandbox scope for the toolbox services. Calling a toolbox operation
|
|
50
|
+
* without a sandbox configured (and with a `{sandboxId}` template still
|
|
51
|
+
* in `toolboxBaseUrl`) fails with `ConfigError`.
|
|
52
|
+
*/
|
|
53
|
+
readonly sandboxId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Sent as `X-Daytona-Organization-ID` when set. Required with JWT auth
|
|
56
|
+
* to pick an organization; API keys already carry one.
|
|
57
|
+
*/
|
|
58
|
+
readonly organizationId?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class Credentials extends Context.Service<
|
|
62
|
+
Credentials,
|
|
63
|
+
Effect.Effect<Config>
|
|
64
|
+
>()("DaytonaCredentials") {}
|
|
65
|
+
|
|
66
|
+
const envConfig = EffectConfig.all({
|
|
67
|
+
apiKey: EffectConfig.String("DAYTONA_API_KEY"),
|
|
68
|
+
apiBaseUrl: EffectConfig.String("DAYTONA_API_URL").pipe(
|
|
69
|
+
EffectConfig.withDefault(DEFAULT_API_BASE_URL),
|
|
70
|
+
),
|
|
71
|
+
analyticsBaseUrl: EffectConfig.String("DAYTONA_ANALYTICS_URL").pipe(
|
|
72
|
+
EffectConfig.withDefault(DEFAULT_ANALYTICS_BASE_URL),
|
|
73
|
+
),
|
|
74
|
+
toolboxBaseUrl: EffectConfig.String("DAYTONA_TOOLBOX_URL").pipe(
|
|
75
|
+
EffectConfig.withDefault(DEFAULT_TOOLBOX_BASE_URL),
|
|
76
|
+
),
|
|
77
|
+
sandboxId: EffectConfig.String("DAYTONA_SANDBOX_ID").pipe(
|
|
78
|
+
EffectConfig.option,
|
|
79
|
+
),
|
|
80
|
+
organizationId: EffectConfig.String("DAYTONA_ORGANIZATION_ID").pipe(
|
|
81
|
+
EffectConfig.option,
|
|
82
|
+
),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const CredentialsFromEnv = Layer.succeed(
|
|
86
|
+
Credentials,
|
|
87
|
+
envConfig.pipe(
|
|
88
|
+
Effect.mapError(
|
|
89
|
+
() =>
|
|
90
|
+
new ConfigError({
|
|
91
|
+
message: "DAYTONA_API_KEY environment variable is required",
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
Effect.map(
|
|
95
|
+
({
|
|
96
|
+
apiKey,
|
|
97
|
+
apiBaseUrl,
|
|
98
|
+
analyticsBaseUrl,
|
|
99
|
+
toolboxBaseUrl,
|
|
100
|
+
sandboxId,
|
|
101
|
+
organizationId,
|
|
102
|
+
}) => ({
|
|
103
|
+
apiKey: Redacted.make(apiKey),
|
|
104
|
+
apiBaseUrl,
|
|
105
|
+
analyticsBaseUrl,
|
|
106
|
+
toolboxBaseUrl,
|
|
107
|
+
sandboxId: sandboxId._tag === "Some" ? sandboxId.value : undefined,
|
|
108
|
+
organizationId:
|
|
109
|
+
organizationId._tag === "Some" ? organizationId.value : undefined,
|
|
110
|
+
}),
|
|
111
|
+
),
|
|
112
|
+
Effect.orDie,
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/** Convenience layer from a plain API key + optional endpoints/scope. */
|
|
117
|
+
export const credentials = (config: {
|
|
118
|
+
readonly apiKey: string;
|
|
119
|
+
readonly apiBaseUrl?: string;
|
|
120
|
+
readonly analyticsBaseUrl?: string;
|
|
121
|
+
readonly toolboxBaseUrl?: string;
|
|
122
|
+
readonly sandboxId?: string;
|
|
123
|
+
readonly organizationId?: string;
|
|
124
|
+
}): Layer.Layer<Credentials> =>
|
|
125
|
+
Layer.succeed(
|
|
126
|
+
Credentials,
|
|
127
|
+
Effect.succeed({
|
|
128
|
+
apiKey: Redacted.make(config.apiKey),
|
|
129
|
+
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
130
|
+
analyticsBaseUrl: config.analyticsBaseUrl ?? DEFAULT_ANALYTICS_BASE_URL,
|
|
131
|
+
toolboxBaseUrl: config.toolboxBaseUrl ?? DEFAULT_TOOLBOX_BASE_URL,
|
|
132
|
+
sandboxId: config.sandboxId,
|
|
133
|
+
organizationId: config.organizationId,
|
|
134
|
+
}),
|
|
135
|
+
);
|
package/src/endpoints.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First path segments of the Toolbox API.
|
|
3
|
+
*
|
|
4
|
+
* Daytona speaks from THREE hosts, and the route picks between them (see
|
|
5
|
+
* protocol.ts). Toolbox paths have no sandbox id in the OpenAPI document —
|
|
6
|
+
* the sandbox is a prefix on the base URL — so the protocol recognises a
|
|
7
|
+
* toolbox call by this set of roots. Convert asserts the live spec still
|
|
8
|
+
* matches (the list is duplicated in `scripts/convert.ts` so convert
|
|
9
|
+
* does not import across the scripts/src tsconfig rootDir boundary); a
|
|
10
|
+
* new root fails convert rather than silently hitting the platform host.
|
|
11
|
+
*/
|
|
12
|
+
export const TOOLBOX_ROOTS = [
|
|
13
|
+
"computeruse",
|
|
14
|
+
"env",
|
|
15
|
+
"files",
|
|
16
|
+
"git",
|
|
17
|
+
"init",
|
|
18
|
+
"lsp",
|
|
19
|
+
"port",
|
|
20
|
+
"process",
|
|
21
|
+
"system",
|
|
22
|
+
"user-home-dir",
|
|
23
|
+
"version",
|
|
24
|
+
"work-dir",
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
/** Analytics paths are `/organization/{organizationId}/…` (singular). */
|
|
28
|
+
export const ANALYTICS_PREFIX = "/organization/";
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daytona-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds the unknown-error
|
|
5
|
+
* and parse-error wrappers. Daytona declares failures as HTTP statuses
|
|
6
|
+
* against a shared `{ message }` (toolbox) or untyped (platform) body —
|
|
7
|
+
* no operation narrows which codes it can produce — so the SDK dispatches
|
|
8
|
+
* on the status (the classes here) and carries any machine-readable `code`
|
|
9
|
+
* through on {@link UnknownDaytonaError}.
|
|
10
|
+
*/
|
|
11
|
+
export {
|
|
12
|
+
BadGateway,
|
|
13
|
+
BadRequest,
|
|
14
|
+
Conflict,
|
|
15
|
+
ConfigError,
|
|
16
|
+
Forbidden,
|
|
17
|
+
GatewayTimeout,
|
|
18
|
+
InternalServerError,
|
|
19
|
+
Locked,
|
|
20
|
+
NotFound,
|
|
21
|
+
ServiceUnavailable,
|
|
22
|
+
TooManyRequests,
|
|
23
|
+
Unauthorized,
|
|
24
|
+
UnprocessableEntity,
|
|
25
|
+
HTTP_STATUS_MAP,
|
|
26
|
+
DEFAULT_ERRORS,
|
|
27
|
+
API_ERRORS,
|
|
28
|
+
} from "@distilled.cloud/core/errors";
|
|
29
|
+
import type {
|
|
30
|
+
BadRequest as CoreBadRequest,
|
|
31
|
+
Conflict as CoreConflict,
|
|
32
|
+
DefaultErrors as CoreDefaultErrors,
|
|
33
|
+
Forbidden as CoreForbidden,
|
|
34
|
+
Locked as CoreLocked,
|
|
35
|
+
NotFound as CoreNotFound,
|
|
36
|
+
UnprocessableEntity as CoreUnprocessableEntity,
|
|
37
|
+
} from "@distilled.cloud/core/errors";
|
|
38
|
+
|
|
39
|
+
import * as Schema from "effect/Schema";
|
|
40
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Unknown Daytona error — returned when a failed response's HTTP status has
|
|
44
|
+
* no mapped error class.
|
|
45
|
+
*/
|
|
46
|
+
export class UnknownDaytonaError extends Schema.TaggedError<UnknownDaytonaError>()(
|
|
47
|
+
"UnknownDaytonaError",
|
|
48
|
+
{
|
|
49
|
+
code: Schema.optional(Schema.String),
|
|
50
|
+
message: Schema.optional(Schema.String),
|
|
51
|
+
body: Schema.Unknown,
|
|
52
|
+
},
|
|
53
|
+
).pipe(Category.withServerError) {}
|
|
54
|
+
|
|
55
|
+
/** Schema parse error wrapper. */
|
|
56
|
+
export class DaytonaParseError extends Schema.TaggedError<DaytonaParseError>()(
|
|
57
|
+
"DaytonaParseError",
|
|
58
|
+
{
|
|
59
|
+
body: Schema.Unknown,
|
|
60
|
+
cause: Schema.Unknown,
|
|
61
|
+
},
|
|
62
|
+
).pipe(Category.withParseError) {}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Errors any Daytona operation may surface in addition to the shared HTTP
|
|
66
|
+
* status errors.
|
|
67
|
+
*/
|
|
68
|
+
export type ClientErrors = UnknownDaytonaError | DaytonaParseError;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Default Daytona operation errors.
|
|
72
|
+
*
|
|
73
|
+
* EVERY operation carries the whole set: the specs type failures only as a
|
|
74
|
+
* per-operation status list (and often not even that), so any documented
|
|
75
|
+
* status can come back from any call.
|
|
76
|
+
*/
|
|
77
|
+
export type DefaultErrors =
|
|
78
|
+
| CoreDefaultErrors
|
|
79
|
+
| CoreBadRequest
|
|
80
|
+
| CoreForbidden
|
|
81
|
+
| CoreNotFound
|
|
82
|
+
| CoreConflict
|
|
83
|
+
| CoreUnprocessableEntity
|
|
84
|
+
| CoreLocked
|
|
85
|
+
| ClientErrors;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/daytona — Daytona SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
5
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the three
|
|
6
|
+
* OpenAPI documents mirrored at `specs/spec-mirror-daytona/specs/`).
|
|
7
|
+
* Everything else in this folder is hand-written.
|
|
8
|
+
*
|
|
9
|
+
* One module per API tag. Platform tags (`sandbox`, `organizations`,
|
|
10
|
+
* `snapshots`, …) hit `https://app.daytona.io/api`. Toolbox tags
|
|
11
|
+
* (`process`, `git`, `fileSystem`, `computerUse`, …) hit the sandbox
|
|
12
|
+
* toolbox proxy — configure `sandboxId` on the credentials to call them.
|
|
13
|
+
* Analytics tags (`telemetry`, `usage`) hit
|
|
14
|
+
* `https://analytics.app.daytona.io`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import * as Daytona from "@distilled.cloud/daytona";
|
|
19
|
+
*
|
|
20
|
+
* const sandbox = yield* Daytona.sandbox.createSandbox({});
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export * from "./credentials.ts";
|
|
24
|
+
export * from "./errors.ts";
|
|
25
|
+
export * as T from "./traits.ts";
|
|
26
|
+
export {
|
|
27
|
+
DaytonaProtocol,
|
|
28
|
+
type DaytonaOpError,
|
|
29
|
+
type DaytonaOpContext,
|
|
30
|
+
} from "./protocol.ts";
|
|
31
|
+
export { paginateToken } from "./pagination.ts";
|
|
32
|
+
export * as Retry from "./retry.ts";
|
|
33
|
+
export * from "./services/index.ts";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daytona pagination — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Audit logs page by token (`nextToken` in and out, items under `items`).
|
|
5
|
+
* The OpenAPI converter stamps `smithy.api#paginated` when it recognises
|
|
6
|
+
* that shape; generated operations pass core's {@link paginateToken}
|
|
7
|
+
* strategy to `API.makePaginated`.
|
|
8
|
+
*/
|
|
9
|
+
export { paginateToken } from "@distilled.cloud/core/pagination";
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DaytonaProtocol — the shared bearer-REST protocol instantiated for Daytona.
|
|
3
|
+
*
|
|
4
|
+
* Daytona speaks plain JSON with no success envelope. FAILURES carry a
|
|
5
|
+
* `{ message }` body (toolbox `ErrorResponse`) or an untyped NestJS
|
|
6
|
+
* `{ message, statusCode, error }` page (platform). The factory's default
|
|
7
|
+
* envelope already reads `message`.
|
|
8
|
+
*
|
|
9
|
+
* Daytona serves THREE endpoints, and the route picks between them:
|
|
10
|
+
*
|
|
11
|
+
* • `/organization/…` → analytics (`analyticsBaseUrl`)
|
|
12
|
+
* • toolbox roots (`/files`, `/process`, `/git`, `/computeruse`, …) →
|
|
13
|
+
* `toolboxBaseUrl` with `{sandboxId}` substituted
|
|
14
|
+
* • everything else → platform (`apiBaseUrl`)
|
|
15
|
+
*
|
|
16
|
+
* A toolbox call without a configured sandbox (when the toolbox URL still
|
|
17
|
+
* contains `{sandboxId}`) fails with `ConfigError`.
|
|
18
|
+
*/
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
20
|
+
import type * as Layer from "effect/Layer";
|
|
21
|
+
import * as Redacted from "effect/Redacted";
|
|
22
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
23
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
24
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
25
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
26
|
+
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
27
|
+
import { Credentials, type Config } from "./credentials.ts";
|
|
28
|
+
import {
|
|
29
|
+
UnknownDaytonaError,
|
|
30
|
+
type DefaultErrors,
|
|
31
|
+
DaytonaParseError,
|
|
32
|
+
} from "./errors.ts";
|
|
33
|
+
import { ANALYTICS_PREFIX, TOOLBOX_ROOTS } from "./endpoints.ts";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Error channel shared by every generated Daytona operation. Generated
|
|
37
|
+
* service files annotate operations with `API.OperationMethod<I, O,
|
|
38
|
+
* DaytonaOpError, DaytonaOpContext>` explicitly so the compiler never infers
|
|
39
|
+
* these back out of the schema generics.
|
|
40
|
+
*/
|
|
41
|
+
export type DaytonaOpError =
|
|
42
|
+
| DefaultErrors
|
|
43
|
+
| ConfigError
|
|
44
|
+
| HttpClientError.HttpClientError;
|
|
45
|
+
|
|
46
|
+
/** Context (requirements) shared by every generated Daytona operation. */
|
|
47
|
+
export type DaytonaOpContext = Credentials | HttpClient.HttpClient;
|
|
48
|
+
|
|
49
|
+
const TOOLBOX_ROOT_SET: ReadonlySet<string> = new Set(TOOLBOX_ROOTS);
|
|
50
|
+
|
|
51
|
+
const firstSegment = (uri: string): string =>
|
|
52
|
+
uri.split("/").filter(Boolean)[0] ?? "";
|
|
53
|
+
|
|
54
|
+
const isAnalytics = (uri: string): boolean =>
|
|
55
|
+
uri === "/organization" || uri.startsWith(ANALYTICS_PREFIX);
|
|
56
|
+
|
|
57
|
+
const isToolbox = (uri: string): boolean =>
|
|
58
|
+
TOOLBOX_ROOT_SET.has(firstSegment(uri));
|
|
59
|
+
|
|
60
|
+
const baseUrlFor = (creds: Config, uri: string): string => {
|
|
61
|
+
if (isAnalytics(uri)) return creds.analyticsBaseUrl;
|
|
62
|
+
if (!isToolbox(uri)) return creds.apiBaseUrl;
|
|
63
|
+
|
|
64
|
+
if (!creds.toolboxBaseUrl.includes("{sandboxId}")) {
|
|
65
|
+
return creds.toolboxBaseUrl;
|
|
66
|
+
}
|
|
67
|
+
if (creds.sandboxId === undefined || creds.sandboxId === "") {
|
|
68
|
+
throw new ConfigError({
|
|
69
|
+
message:
|
|
70
|
+
`Daytona operation on ${uri} is toolbox-scoped (${creds.toolboxBaseUrl}) — ` +
|
|
71
|
+
`configure a sandbox (DAYTONA_SANDBOX_ID or credentials({ sandboxId })) to call it`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return creds.toolboxBaseUrl.replaceAll("{sandboxId}", creds.sandboxId);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const DaytonaProtocol: Layer.Layer<API.Protocol> =
|
|
78
|
+
makeRestProtocol<Config>({
|
|
79
|
+
// Resolved on the CALLING fiber per request (the layer is memoized per
|
|
80
|
+
// process); the Credentials service holds an effect, so a key rotated
|
|
81
|
+
// between calls is picked up without rebuilding the layer.
|
|
82
|
+
credentials: Effect.gen(function* () {
|
|
83
|
+
const resolve = yield* Credentials;
|
|
84
|
+
return yield* resolve;
|
|
85
|
+
}),
|
|
86
|
+
baseUrl: (creds, target) => baseUrlFor(creds, target.uri),
|
|
87
|
+
headers: (creds) => {
|
|
88
|
+
const headers: Record<string, string> = {
|
|
89
|
+
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
90
|
+
};
|
|
91
|
+
if (creds.organizationId !== undefined && creds.organizationId !== "") {
|
|
92
|
+
headers["X-Daytona-Organization-ID"] = creds.organizationId;
|
|
93
|
+
}
|
|
94
|
+
return headers;
|
|
95
|
+
},
|
|
96
|
+
unknownError: ({ code, message, body }) =>
|
|
97
|
+
new UnknownDaytonaError({
|
|
98
|
+
code:
|
|
99
|
+
typeof code === "string"
|
|
100
|
+
? code
|
|
101
|
+
: code !== undefined
|
|
102
|
+
? String(code)
|
|
103
|
+
: undefined,
|
|
104
|
+
message,
|
|
105
|
+
body,
|
|
106
|
+
}),
|
|
107
|
+
parseError: ({ body, cause }) => new DaytonaParseError({ body, cause }),
|
|
108
|
+
});
|