@sandbox-kit/modal 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandbox-kit/modal",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "modal provider for sandbox kit",
5
5
  "keywords": [
6
6
  "sandbox-kit",
@@ -59,13 +59,14 @@
59
59
  }
60
60
  },
61
61
  "scripts": {
62
+ "clean": "rm -rf dist",
62
63
  "build": "tsc -p tsconfig.build.json",
63
- "prepublishOnly": "npm run build",
64
+ "prepublishOnly": "npm run clean && npm run build",
64
65
  "test": "tsc -p tsconfig.test.json && vitest run"
65
66
  },
66
67
  "dependencies": {
67
68
  "@bufbuild/protobuf": "2.16.0",
68
- "@sandbox-kit/sandbox": "0.1.1",
69
+ "@sandbox-kit/sandbox": "0.1.2",
69
70
  "modal": "0.11.1"
70
71
  },
71
72
  "devDependencies": {
@@ -1,17 +0,0 @@
1
- import { type ModalClientParams, type Sandbox, type SandboxCreateParams } from "modal";
2
- import { type Config, type CreateOptions, type SandboxInfo } from "@sandbox-kit/sandbox";
3
- import type { ProviderState } from "./provider_config.js";
4
- export interface ModalCreatePlan {
5
- readonly app: string;
6
- readonly environment?: string;
7
- readonly image: string;
8
- readonly params: SandboxCreateParams;
9
- readonly secretNames: readonly string[];
10
- readonly proxyName?: string;
11
- readonly waitUntilReady: boolean;
12
- readonly readyTimeoutMs?: number;
13
- }
14
- export declare function mapClientConfig(config: Config): ModalClientParams;
15
- export declare function mapCreateRequest(request: CreateOptions, config: ProviderState): ModalCreatePlan;
16
- export declare function mapSandboxInfo(value: Sandbox, request?: CreateOptions): SandboxInfo;
17
- //# sourceMappingURL=mappings.d.ts.map
package/dist/mappings.js DELETED
@@ -1,317 +0,0 @@
1
- // Provider-specific orchestration around generated portable field mappings.
2
- import { Probe, } from "modal";
3
- import { EgressMode, ErrorKind, IsolationKind, PolicyMode, PortTransport, SecretInjection, SandboxState, ValueOrigin, WaitCondition, sandboxError } from "@sandbox-kit/sandbox";
4
- import { mapCommonCreateFields as generatedMapCommonCreateFields, mapIdleDuration as generatedMapIdleDuration, mapLifetimeDuration as generatedMapLifetimeDuration, mapResources as generatedMapResources, mapSandboxIdentity as generatedMapSandboxIdentity, } from "./provider_mappings.js";
5
- import { validateProviderCreate } from "./provider_checks.js";
6
- import { mapGeneratedClientConfig } from "./provider_config.js";
7
- export function mapClientConfig(config) {
8
- const result = mapGeneratedClientConfig(config);
9
- if (config.timeout !== undefined)
10
- result.timeoutMs = finiteDurationMs(config.timeout, "timeout", true);
11
- return result;
12
- }
13
- export function mapCreateRequest(request, config) {
14
- validateProviderCreate(request);
15
- const app = config.scope?.appName === undefined
16
- ? invalid("scope.appName", "Modal app name is required")
17
- : nonblank(config.scope.appName, "scope.appName");
18
- if (request.source?.image === undefined)
19
- unsupported("source", "Modal requires an explicit image source");
20
- const params = generatedMapCommonCreateFields(request);
21
- if (request.name !== undefined)
22
- params.name = nonblank(request.name, "name");
23
- if (config.region !== undefined)
24
- params.regions = [nonblankConfig(config.region, "region")];
25
- mapRuntime(request, params);
26
- mapIsolation(request, params);
27
- mapResources(request, params);
28
- mapPlacement(request, params);
29
- mapNetwork(request, params);
30
- const secretNames = mapSecurity(request, params);
31
- mapLifetime(request, params);
32
- mapReadiness(request, params);
33
- const wait = mapProvisioning(request, params);
34
- mapObservability(request, params);
35
- if (request.providerOptions !== undefined)
36
- unsupported("providerOptions", "Modal provider options are not mapped");
37
- return {
38
- app,
39
- ...(config.scope?.environment === undefined
40
- ? {}
41
- : { environment: config.scope.environment }),
42
- image: nonblank(request.source.image.reference, "source.image.reference"),
43
- params,
44
- secretNames,
45
- ...(request.network?.proxyReference === undefined
46
- ? {}
47
- : {
48
- proxyName: nonblank(request.network.proxyReference, "network.proxyReference"),
49
- }),
50
- ...wait,
51
- };
52
- }
53
- function mapRuntime(r, p) {
54
- const v = r.runtime;
55
- if (!v)
56
- return;
57
- if (v.workingDirectory !== undefined)
58
- p.workdir = v.workingDirectory;
59
- if (v.entrypoint !== undefined)
60
- p.command = [...v.entrypoint];
61
- if (v.pty !== undefined)
62
- p.pty = v.pty;
63
- if (v.language !== undefined ||
64
- v.version !== undefined ||
65
- v.user !== undefined)
66
- unsupported("runtime", "language, version, and user must come from the Modal image");
67
- }
68
- function mapIsolation(r, p) {
69
- const v = r.isolation;
70
- if (!v)
71
- return;
72
- const kind = v.kind ?? IsolationKind.Default;
73
- if (kind === IsolationKind.LinuxVm)
74
- p.runtime = "vm";
75
- else if (kind === IsolationKind.Container)
76
- p.runtime = "gvisor";
77
- else if (kind !== IsolationKind.Default)
78
- unsupported("isolation.kind", "requested Modal isolation is unsupported");
79
- if (v.providerKind !== undefined || v.nestedVirtualization !== undefined)
80
- unsupported("isolation", "provider kind and nested virtualization are unsupported");
81
- }
82
- function mapResources(r, p) {
83
- const v = r.resources;
84
- if (!v)
85
- return;
86
- if (v.cpuLimitCores !== undefined)
87
- positive(v.cpuLimitCores, "resources.cpuLimitCores");
88
- if (v.memoryMib !== undefined)
89
- integer(v.memoryMib, "resources.memoryMib", 128);
90
- if (v.memoryLimitMib !== undefined)
91
- integer(v.memoryLimitMib, "resources.memoryLimitMib", 1);
92
- if (v.diskMib !== undefined)
93
- unsupported("resources.diskMib", "Modal disk override is unsupported");
94
- Object.assign(p, generatedMapResources(v));
95
- }
96
- function mapPlacement(r, p) {
97
- const v = r.placement;
98
- if (!v)
99
- return;
100
- if (v.cloud !== undefined)
101
- p.cloud = v.cloud;
102
- if (v.regions !== undefined)
103
- p.regions = [...v.regions];
104
- if (v.target !== undefined)
105
- unsupported("placement.target", "Modal placement target is unsupported");
106
- }
107
- function mapNetwork(r, p) {
108
- const v = r.network;
109
- if (!v)
110
- return;
111
- const egress = v.egress ?? EgressMode.Default;
112
- if (egress === EgressMode.BlockAll)
113
- p.blockNetwork = true;
114
- else if (egress !== EgressMode.Default &&
115
- egress !== EgressMode.AllowAll &&
116
- egress !== EgressMode.Restricted)
117
- invalid("network.egress", "unknown egress mode");
118
- if (v.outboundCidrs !== undefined)
119
- p.outboundCidrAllowlist = [...v.outboundCidrs];
120
- if (v.outboundDomains !== undefined)
121
- p.outboundDomainAllowlist = [...v.outboundDomains];
122
- if (v.inboundCidrs !== undefined) {
123
- if (!v.inboundCidrs.length)
124
- unsupported("network.inboundCidrs", "empty inbound deny-all is not representable");
125
- p.inboundCidrAllowlist = [...v.inboundCidrs];
126
- }
127
- if (v.privateNetwork !== undefined)
128
- p.i6pn = v.privateNetwork;
129
- if (v.customDomain !== undefined)
130
- p.customDomain = v.customDomain;
131
- if (v.ports) {
132
- p.encryptedPorts = [];
133
- p.h2Ports = [];
134
- p.unencryptedPorts = [];
135
- for (const x of v.ports) {
136
- const port = x.port;
137
- if (port === undefined)
138
- invalid("network.ports.port", "port is required");
139
- const transport = x.transport ?? PortTransport.Default;
140
- if (transport === PortTransport.Tls)
141
- p.encryptedPorts.push(port);
142
- else if (transport === PortTransport.Http2Tls)
143
- p.h2Ports.push(port);
144
- else if (transport === PortTransport.Plain)
145
- p.unencryptedPorts.push(port);
146
- else
147
- invalid("network.ports.transport", "explicit transport is required");
148
- }
149
- }
150
- if (v.linkedSandbox !== undefined || v.outboundProxyUrl !== undefined)
151
- unsupported("network", "linked sandbox and outbound proxy URL mappings are unsupported");
152
- }
153
- function mapSecurity(r, p) {
154
- const v = r.security;
155
- if (!v)
156
- return [];
157
- if (v.workloadIdentity !== undefined)
158
- p.includeOidcIdentityToken = v.workloadIdentity;
159
- if (v.publicAccess !== undefined)
160
- unsupported("security.publicAccess", "Modal public access is represented by ports");
161
- const names = [];
162
- for (const s of v.secrets ?? []) {
163
- if (s.environmentVariable !== undefined)
164
- unsupported("security.secrets.environmentVariable", "per-variable secret renaming is unsupported");
165
- const injection = s.injection ?? SecretInjection.Default;
166
- if (injection !== SecretInjection.Default &&
167
- injection !== SecretInjection.Environment)
168
- unsupported("security.secrets.injection", "egress-placeholder injection is unsupported");
169
- names.push(nonblank(s.reference, "security.secrets.reference"));
170
- }
171
- return names;
172
- }
173
- function mapLifetime(r, p) {
174
- const v = r.lifetime;
175
- if (!v)
176
- return;
177
- if (v.maximumLifetime !== undefined)
178
- finiteDurationMs(v.maximumLifetime, "lifetime.maximumLifetime", false);
179
- Object.assign(p, generatedMapLifetimeDuration(v));
180
- if (v.idleTerminate) {
181
- const mode = v.idleTerminate.mode ?? PolicyMode.Default;
182
- if (mode === PolicyMode.Disabled)
183
- p.idleTimeoutMs = 0;
184
- else if (mode === PolicyMode.After) {
185
- if (v.idleTerminate.after === undefined)
186
- invalid("lifetime.idleTerminate.after", "duration is required");
187
- finiteDurationMs(v.idleTerminate.after, "lifetime.idleTerminate.after", false);
188
- Object.assign(p, generatedMapIdleDuration(v.idleTerminate));
189
- }
190
- else if (mode !== PolicyMode.Default)
191
- invalid("lifetime.idleTerminate.mode", "unknown policy mode");
192
- }
193
- if (v.ephemeral !== undefined ||
194
- v.idleStop !== undefined ||
195
- v.idlePause !== undefined ||
196
- v.stoppedArchive !== undefined ||
197
- v.stoppedDelete !== undefined)
198
- unsupported("lifetime", "requested lifecycle policy is unsupported by Modal");
199
- }
200
- function mapReadiness(r, p) {
201
- const v = r.readiness;
202
- if (!v)
203
- return;
204
- if (v.tcpPort !== undefined) {
205
- p.readinessProbe = Probe.withTcp(v.tcpPort);
206
- }
207
- else if (v.command !== undefined)
208
- p.readinessProbe = Probe.withExec([...(v.command.argv ?? [])]);
209
- else
210
- invalid("readiness", "probe is required");
211
- }
212
- function mapProvisioning(r, _p) {
213
- const v = r.provisioning;
214
- if (!v)
215
- return { waitUntilReady: false };
216
- if (v.queueTimeout !== undefined)
217
- unsupported("provisioning.queueTimeout", "Modal queue timeout is unsupported");
218
- const waitFor = v.waitFor ?? WaitCondition.Default;
219
- if (waitFor === WaitCondition.Default || waitFor === WaitCondition.Scheduled)
220
- return { waitUntilReady: false };
221
- if (waitFor === WaitCondition.Ready) {
222
- if (v.timeout === undefined || v.timeout <= 0)
223
- invalid("provisioning.timeout", "ready wait requires a positive timeout");
224
- if (!r.readiness)
225
- invalid("readiness", "ready wait requires a probe");
226
- return { waitUntilReady: true, readyTimeoutMs: v.timeout };
227
- }
228
- unsupported("provisioning.waitFor", "requested wait condition is unsupported");
229
- }
230
- function mapObservability(r, p) {
231
- const v = r.observability;
232
- if (!v)
233
- return;
234
- if (v.verbose !== undefined)
235
- p.verbose = v.verbose;
236
- if (v.telemetryEndpoint !== undefined)
237
- unsupported("observability.telemetryEndpoint", "per-sandbox telemetry endpoint is unsupported");
238
- }
239
- export function mapSandboxInfo(value, request) {
240
- const mapped = generatedMapSandboxIdentity(value);
241
- const origins = { ...(mapped.origins ?? {}) };
242
- const result = {
243
- id: mapped.id ?? value.sandboxId,
244
- provider: "modal",
245
- state: SandboxState.Running,
246
- labels: {},
247
- origins,
248
- };
249
- if (request?.name !== undefined) {
250
- mutable(result).name = request.name;
251
- origins.name = ValueOrigin.Request;
252
- }
253
- if (request?.labels !== undefined) {
254
- mutable(result).labels = { ...request.labels };
255
- origins.labels = ValueOrigin.Request;
256
- }
257
- if (request?.isolation !== undefined) {
258
- mutable(result).isolation = { ...request.isolation };
259
- origins.isolation = ValueOrigin.Request;
260
- }
261
- return result;
262
- }
263
- function mutable(v) {
264
- return v;
265
- }
266
- function nonblank(v, f) {
267
- if (!v.trim())
268
- invalid(f, "must not be blank");
269
- return v;
270
- }
271
- function nonblankConfig(v, f) {
272
- if (!v.trim())
273
- configInvalid(f, "must not be blank");
274
- return v;
275
- }
276
- function positive(v, f) {
277
- if (!Number.isFinite(v) || v <= 0)
278
- invalid(f, "must be positive");
279
- return v;
280
- }
281
- function integer(v, f, min) {
282
- if (v < BigInt(min) || v > 2147483647n)
283
- invalid(f, "is outside the supported range");
284
- return Number(v);
285
- }
286
- function finiteDurationMs(v, f, zero) {
287
- if (!Number.isFinite(v) || v < 0 || (!zero && v === 0))
288
- invalid(f, "must be a finite positive duration");
289
- return v;
290
- }
291
- function invalid(field, message) {
292
- throw sandboxError({
293
- kind: ErrorKind.InvalidArgument,
294
- provider: "modal",
295
- operation: "create",
296
- field,
297
- message: "sandbox-kit modal: " + message,
298
- });
299
- }
300
- function unsupported(field, message) {
301
- throw sandboxError({
302
- kind: ErrorKind.Unsupported,
303
- provider: "modal",
304
- operation: "create",
305
- field,
306
- message: "sandbox-kit modal: " + message,
307
- });
308
- }
309
- function configInvalid(field, message) {
310
- throw sandboxError({
311
- kind: ErrorKind.InvalidArgument,
312
- provider: "modal",
313
- operation: "initialize",
314
- field,
315
- message: "sandbox-kit modal: " + message,
316
- });
317
- }
@@ -1,3 +0,0 @@
1
- import { type CreateOptionsWire } from "@sandbox-kit/sandbox";
2
- export declare function validateProviderCreate(request: CreateOptionsWire): void;
3
- //# sourceMappingURL=provider.checks.gen.d.ts.map
@@ -1,101 +0,0 @@
1
- // Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
2
- // source: kit/providers/modal/v1/provider.proto + specs/providers/modal.yaml
3
- import { durationMs } from "@bufbuild/protobuf/wkt";
4
- import { ErrorKind, PolicyMode, sandboxError } from "@sandbox-kit/sandbox";
5
- export function validateProviderCreate(request) {
6
- const value0_0 = request.resources;
7
- if (value0_0 !== undefined) {
8
- const value0 = value0_0.cpuCores;
9
- if (value0 !== undefined) {
10
- if (value0 < 0.125)
11
- fail(ErrorKind.InvalidArgument, "resources.cpuCores", "resources.cpu_cores is outside supported values");
12
- }
13
- }
14
- const value1_0 = request.resources;
15
- if (value1_0 !== undefined) {
16
- const value1 = value1_0.memoryMib;
17
- if (value1 !== undefined) {
18
- if (value1 < BigInt("128"))
19
- fail(ErrorKind.InvalidArgument, "resources.memoryMib", "resources.memory_mib is outside supported values");
20
- }
21
- }
22
- const value2_0 = request.runtime;
23
- if (value2_0 !== undefined) {
24
- const value2 = value2_0.workingDirectory;
25
- if (value2 !== undefined) {
26
- if (!validAbsolutePath(value2))
27
- fail(ErrorKind.InvalidArgument, "runtime.workingDirectory", "runtime.working_directory is outside supported values");
28
- }
29
- }
30
- const value3_0 = request.placement;
31
- if (value3_0 !== undefined) {
32
- const value3 = value3_0.cloud;
33
- if (value3 !== undefined) {
34
- if (value3 !== "aws" && value3 !== "gcp" && value3 !== "oci" && value3 !== "auto")
35
- fail(ErrorKind.Unsupported, "placement.cloud", "placement.cloud is outside supported values");
36
- }
37
- }
38
- const value4_0 = request.network;
39
- if (value4_0 !== undefined) {
40
- const value4_1 = value4_0.outboundCidrs;
41
- if (value4_1 !== undefined) {
42
- for (const value4 of value4_1.entries ?? []) {
43
- if (value4 !== "" && !validCidr(value4))
44
- fail(ErrorKind.InvalidArgument, "network.outboundCidrs.entries", "network.outbound_cidrs.entries is outside supported values");
45
- }
46
- }
47
- }
48
- const value5_0 = request.network;
49
- if (value5_0 !== undefined) {
50
- const value5_1 = value5_0.inboundCidrs;
51
- if (value5_1 !== undefined) {
52
- for (const value5 of value5_1.entries ?? []) {
53
- if (!validCidr(value5))
54
- fail(ErrorKind.InvalidArgument, "network.inboundCidrs.entries", "network.inbound_cidrs.entries is outside supported values");
55
- }
56
- }
57
- }
58
- const value6_0 = request.network;
59
- if (value6_0 !== undefined) {
60
- const value6_1 = value6_0.outboundDomains;
61
- if (value6_1 !== undefined) {
62
- for (const value6 of value6_1.entries ?? []) {
63
- if (value6 !== "" && !validDomain(value6))
64
- fail(ErrorKind.InvalidArgument, "network.outboundDomains.entries", "network.outbound_domains.entries is outside supported values");
65
- }
66
- }
67
- }
68
- for (const value7 of Object.keys(request.environment ?? {})) {
69
- if (!validEnvName(value7))
70
- fail(ErrorKind.InvalidArgument, "environment", "environment is outside supported values");
71
- }
72
- }
73
- function delayed(policy) { return (policy?.mode ?? PolicyMode.Default) === PolicyMode.After && policy?.after !== undefined && durationMs(policy.after) > 0; }
74
- function immediate(policy) { return (policy?.mode ?? PolicyMode.Default) === PolicyMode.After && policy?.after !== undefined && durationMs(policy.after) === 0; }
75
- function validEnvName(value) { return /^[A-Za-z_][A-Za-z0-9_]*$/.test(value); }
76
- function validAbsolutePath(value) { return value.startsWith("/"); }
77
- function validHttpUrl(value) { try {
78
- const parsed = new URL(value);
79
- return parsed.hostname !== "" && (parsed.protocol === "http:" || parsed.protocol === "https:");
80
- }
81
- catch {
82
- return false;
83
- } }
84
- function validDomain(value) { const domain = value.startsWith("*.") ? value.slice(2) : value; return domain.length <= 253 && /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?$/i.test(domain); }
85
- function validCidr(value) { const separator = value.lastIndexOf("/"); if (separator <= 0)
86
- return false; const address = value.slice(0, separator); const prefix = Number(value.slice(separator + 1)); if (!Number.isInteger(prefix))
87
- return false; return address.includes(":") ? prefix >= 0 && prefix <= 128 && validIpv6(address) : prefix >= 0 && prefix <= 32 && validIpv4(address); }
88
- function validIpv4(value) { const parts = value.split("."); return parts.length === 4 && parts.every((part) => /^(0|[1-9][0-9]{0,2})$/.test(part) && Number(part) <= 255); }
89
- function validIpv6(value) { if ((value.match(/::/g)?.length ?? 0) > 1)
90
- return false; const halves = value.split("::"); if (halves.length > 2)
91
- return false; const count = (part) => { if (part === "")
92
- return 0; const groups = part.split(":"); let total = 0; for (const group of groups) {
93
- if (/^[0-9a-f]{1,4}$/i.test(group))
94
- total++;
95
- else if (validIpv4(group))
96
- total += 2;
97
- else
98
- return undefined;
99
- } return total; }; const left = count(halves[0] ?? ""); const right = count(halves[1] ?? ""); return left !== undefined && right !== undefined && (halves.length === 2 ? left + right < 8 : left === 8); }
100
- function invalid(field, message) { fail(ErrorKind.InvalidArgument, field, message); }
101
- function fail(kind, field, message) { throw sandboxError({ kind, provider: "modal", operation: "create", field, message: "sandbox-kit modal: " + message }); }
@@ -1,9 +0,0 @@
1
- import type { ModalClientParams as NativeClientConfig } from "modal";
2
- import { type ConfigWire, type ConfigWire, type Scope } from "@sandbox-kit/sandbox";
3
- export declare function mapGeneratedClientConfig(config: ConfigWire): NativeClientConfig;
4
- export interface ProviderState {
5
- readonly scope?: ConfigWire["scope"] | Scope;
6
- readonly region?: string;
7
- }
8
- export declare function captureProviderState(config: ConfigWire | ConfigWire): ProviderState;
9
- //# sourceMappingURL=provider.config.gen.d.ts.map
@@ -1,40 +0,0 @@
1
- // Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
2
- // source: kit/providers/modal/v1/provider.proto + specs/providers/modal.yaml
3
- import { ErrorKind, materializeClientConfig, sandboxError, validateConfig, } from "@sandbox-kit/sandbox";
4
- import { mapClientScope, mapOAuthAuth, mapTokenPairCredentials } from "./provider.mappings.gen.js";
5
- export function mapGeneratedClientConfig(config) {
6
- let source = config;
7
- validateConfig(source, "modal", "initialize");
8
- const target = {};
9
- if (source.endpoint !== undefined)
10
- unsupported("endpoint", "Endpoint cannot be configured through this SDK's public client constructor");
11
- if (source.scope !== undefined) {
12
- const mapped = mapClientScope(source.scope, "initialize");
13
- Object.assign(target, mapped);
14
- if (source.scope.organizationId !== undefined)
15
- unsupported("scope.organizationId", "unsupported client configuration field");
16
- if (source.scope.projectId !== undefined)
17
- unsupported("scope.projectId", "unsupported client configuration field");
18
- }
19
- const credentials = source.auth?.credentials;
20
- if (credentials?.case === "tokenPair") {
21
- const mapped = mapTokenPairCredentials(credentials.value, "initialize");
22
- Object.assign(target, mapped);
23
- }
24
- else if (credentials?.case === "oauthRefresh") {
25
- const mapped = mapOAuthAuth(credentials.value, "initialize");
26
- Object.assign(target, mapped);
27
- }
28
- else if (credentials?.case !== undefined) {
29
- unsupported("auth", "unsupported authentication mode");
30
- }
31
- return target;
32
- }
33
- export function captureProviderState(config) {
34
- const source = materializeClientConfig(config);
35
- return {
36
- ...(source.scope === undefined ? {} : { scope: structuredClone(source.scope) }),
37
- ...(source.region === undefined ? {} : { region: source.region }),
38
- };
39
- }
40
- function unsupported(field, message) { throw sandboxError({ kind: ErrorKind.Unsupported, provider: "modal", operation: "initialize", field, message: "sandbox-kit modal: " + message }); }
@@ -1,3 +0,0 @@
1
- import { SandboxError } from "@sandbox-kit/sandbox";
2
- export declare function mapModalError(error: unknown, operation: string): SandboxError;
3
- //# sourceMappingURL=provider.errors.gen.d.ts.map
@@ -1,36 +0,0 @@
1
- // Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
2
- // source: kit/providers/modal/v1/provider.proto + specs/providers/modal.yaml
3
- import { AlreadyExistsError, ClientClosedError, ConflictError, InvalidError, NotFoundError, ResourceExhaustedError, SandboxTimeoutError, TimeoutError } from "modal";
4
- import { ErrorKind, SandboxError, sandboxError } from "@sandbox-kit/sandbox";
5
- export function mapModalError(error, operation) {
6
- if (error instanceof SandboxError)
7
- return error;
8
- if (error instanceof DOMException && error.name === "AbortError")
9
- return create(ErrorKind.Canceled, error, operation);
10
- if (error instanceof DOMException && error.name === "TimeoutError")
11
- return create(ErrorKind.Timeout, error, operation);
12
- let kind = ErrorKind.Unknown;
13
- if (kind === ErrorKind.Unknown && error instanceof InvalidError)
14
- kind = ErrorKind.InvalidArgument;
15
- if (kind === ErrorKind.Unknown && error instanceof NotFoundError)
16
- kind = ErrorKind.NotFound;
17
- if (kind === ErrorKind.Unknown && error instanceof AlreadyExistsError)
18
- kind = ErrorKind.AlreadyExists;
19
- if (kind === ErrorKind.Unknown && error instanceof ConflictError)
20
- kind = ErrorKind.Conflict;
21
- if (kind === ErrorKind.Unknown && error instanceof ResourceExhaustedError)
22
- kind = ErrorKind.ResourceExhausted;
23
- if (kind === ErrorKind.Unknown && error instanceof TimeoutError)
24
- kind = ErrorKind.Timeout;
25
- if (kind === ErrorKind.Unknown && error instanceof SandboxTimeoutError)
26
- kind = ErrorKind.Timeout;
27
- if (kind === ErrorKind.Unknown && error instanceof ClientClosedError)
28
- kind = ErrorKind.FailedPrecondition;
29
- let statusCode;
30
- let providerCode;
31
- let providerSource;
32
- return create(kind, error, operation, statusCode, providerCode, providerSource);
33
- }
34
- function create(kind, error, operation, statusCode, providerCode, providerSource) {
35
- return sandboxError({ kind, provider: "modal", operation, field: "", message: error instanceof Error ? error.message : "sandbox-kit modal: provider operation failed", ...(statusCode === undefined ? {} : { statusCode }), ...(providerCode === undefined ? {} : { providerCode }), ...(providerSource === undefined ? {} : { providerSource }) }, error);
36
- }
@@ -1,14 +0,0 @@
1
- import type { Backend, ConfigWire, CreateOptionsWire, CreateResult, OperationOptions, Provider } from "@sandbox-kit/sandbox";
2
- export declare const providerName: "modal";
3
- /** @internal Shared generated provider identity wiring. */
4
- export declare abstract class ProviderBase implements Provider {
5
- readonly name: "modal";
6
- abstract initialize(config: ConfigWire): Backend;
7
- }
8
- /** @internal Shared generated backend identity and required operation surface. */
9
- export declare abstract class BackendBase implements Backend {
10
- readonly name: "modal";
11
- abstract create(request: CreateOptionsWire, options: OperationOptions): Promise<CreateResult>;
12
- abstract close(options: OperationOptions): Promise<void>;
13
- }
14
- //# sourceMappingURL=provider.gen.d.ts.map
@@ -1,11 +0,0 @@
1
- // Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
2
- // source: kit/providers/modal/v1/provider.proto + specs/providers/modal.yaml
3
- export const providerName = "modal";
4
- /** @internal Shared generated provider identity wiring. */
5
- export class ProviderBase {
6
- name = providerName;
7
- }
8
- /** @internal Shared generated backend identity and required operation surface. */
9
- export class BackendBase {
10
- name = providerName;
11
- }
@@ -1,11 +0,0 @@
1
- import { type AutomaticAction, type CreateOptionsWire, type LifetimePolicy, type OAuthCredentials, type Resources, type SandboxInfo, type Scope, type TokenPairCredentials } from "@sandbox-kit/sandbox";
2
- import type { ModalClientParams as NativeModalClientParams, Sandbox as NativeSandbox, SandboxCreateParams as NativeSandboxCreateParams } from "modal";
3
- export declare function mapSandboxIdentity(source: NativeSandbox | undefined, operation?: string): Partial<SandboxInfo>;
4
- export declare function mapClientScope(source: Scope | undefined, operation?: string): NativeModalClientParams;
5
- export declare function mapCommonCreateFields(source: CreateOptionsWire | undefined, operation?: string): NativeSandboxCreateParams;
6
- export declare function mapResources(source: Resources | undefined, operation?: string): NativeSandboxCreateParams;
7
- export declare function mapLifetimeDuration(source: LifetimePolicy | undefined, operation?: string): NativeSandboxCreateParams;
8
- export declare function mapIdleDuration(source: AutomaticAction | undefined, operation?: string): NativeSandboxCreateParams;
9
- export declare function mapTokenPairCredentials(source: TokenPairCredentials | undefined, operation?: string): NativeModalClientParams;
10
- export declare function mapOAuthAuth(source: OAuthCredentials | undefined, operation?: string): NativeModalClientParams;
11
- //# sourceMappingURL=provider.mappings.gen.d.ts.map
@@ -1,161 +0,0 @@
1
- // Code generated by protoc-gen-kit-typescript. DO NOT EDIT.
2
- // source: kit/providers/modal/v1/provider.proto + specs/providers/modal.yaml
3
- import { durationMs } from "@bufbuild/protobuf/wkt";
4
- import { ErrorKind, PolicyMode, ValueOrigin, sandboxError } from "@sandbox-kit/sandbox";
5
- export function mapSandboxIdentity(source, operation = "create") {
6
- const target = {};
7
- if (source === undefined)
8
- return target;
9
- const origins = {};
10
- target.origins = origins;
11
- {
12
- if (source.sandboxId !== undefined) {
13
- const value = source.sandboxId;
14
- target.id = value;
15
- origins["id"] = ValueOrigin.Provider;
16
- }
17
- }
18
- target.provider = "modal";
19
- return target;
20
- }
21
- export function mapClientScope(source, operation = "initialize") {
22
- const target = {};
23
- if (source === undefined)
24
- return target;
25
- {
26
- if (source.environment !== undefined) {
27
- const value = source.environment;
28
- target.environment = value;
29
- }
30
- }
31
- return target;
32
- }
33
- export function mapCommonCreateFields(source, operation = "create") {
34
- const target = {};
35
- if (source === undefined)
36
- return target;
37
- {
38
- if (source.name !== undefined) {
39
- const value = source.name;
40
- target.name = value;
41
- }
42
- }
43
- {
44
- if (source.environment !== undefined) {
45
- const value = source.environment;
46
- target.env = { ...value };
47
- }
48
- }
49
- {
50
- if (source.labels !== undefined) {
51
- const value = source.labels;
52
- target.tags = { ...value };
53
- }
54
- }
55
- return target;
56
- }
57
- export function mapResources(source, operation = "create") {
58
- const target = {};
59
- if (source === undefined)
60
- return target;
61
- {
62
- if (source.cpuCores !== undefined) {
63
- const value = source.cpuCores;
64
- target.cpu = value;
65
- }
66
- }
67
- {
68
- if (source.cpuLimitCores !== undefined) {
69
- const value = source.cpuLimitCores;
70
- target.cpuLimit = value;
71
- }
72
- }
73
- {
74
- if (source.memoryMib !== undefined) {
75
- const value = source.memoryMib;
76
- if (value > 2147483647n)
77
- mappingError(ErrorKind.InvalidArgument, "resources.memory_mib", "memory_mib cannot be represented", operation);
78
- target.memoryMiB = Number(value);
79
- }
80
- }
81
- {
82
- if (source.memoryLimitMib !== undefined) {
83
- const value = source.memoryLimitMib;
84
- if (value > 2147483647n)
85
- mappingError(ErrorKind.InvalidArgument, "resources.memory_limit_mib", "memory_limit_mib cannot be represented", operation);
86
- target.memoryLimitMiB = Number(value);
87
- }
88
- }
89
- return target;
90
- }
91
- export function mapLifetimeDuration(source, operation = "create") {
92
- const target = {};
93
- if (source === undefined)
94
- return target;
95
- {
96
- if (source.maximumLifetime !== undefined) {
97
- const value = durationMs(source.maximumLifetime);
98
- if (value > 86400000)
99
- mappingError(ErrorKind.InvalidArgument, "lifetime.maximum_lifetime", "maximum_lifetime cannot be represented", operation);
100
- target.timeoutMs = value;
101
- }
102
- }
103
- return target;
104
- }
105
- export function mapIdleDuration(source, operation = "create") {
106
- const target = {};
107
- if (source === undefined)
108
- return target;
109
- {
110
- if (source.after !== undefined) {
111
- const value = durationMs(source.after);
112
- if (value > 4294967295000)
113
- mappingError(ErrorKind.InvalidArgument, "lifetime.idle_terminate.after", "after cannot be represented", operation);
114
- target.idleTimeoutMs = value;
115
- }
116
- }
117
- return target;
118
- }
119
- export function mapTokenPairCredentials(source, operation = "initialize") {
120
- const target = {};
121
- if (source === undefined)
122
- return target;
123
- {
124
- const value = source.id;
125
- target.tokenId = value;
126
- }
127
- {
128
- const value = source.secret;
129
- target.tokenSecret = value;
130
- }
131
- return target;
132
- }
133
- export function mapOAuthAuth(source, operation = "create") {
134
- const target = {};
135
- if (source === undefined)
136
- return target;
137
- {
138
- const value = source.refreshToken;
139
- target.oauthRefreshToken = value;
140
- }
141
- {
142
- const value = source.clientId;
143
- target.oauthClientId = value;
144
- }
145
- {
146
- if (source.clientSecret !== undefined) {
147
- const value = source.clientSecret;
148
- target.oauthClientSecret = value;
149
- }
150
- }
151
- {
152
- if (source.jwtKey !== undefined) {
153
- const value = source.jwtKey;
154
- target.oauthJwtKey = value;
155
- }
156
- }
157
- return target;
158
- }
159
- function mappingError(kind, field, message, operation) {
160
- throw sandboxError({ kind, provider: "modal", operation, field, message: "sandbox-kit modal: " + message });
161
- }
@@ -1,3 +0,0 @@
1
- import type { CreateOptions } from "@sandbox-kit/sandbox";
2
- export declare function validateProviderCreate(request: CreateOptions): void;
3
- //# sourceMappingURL=provider_checks.d.ts.map
@@ -1,106 +0,0 @@
1
- import { ErrorKind, sandboxError } from "@sandbox-kit/sandbox";
2
- // validateProviderCreate rejects creation settings this provider cannot honor.
3
- // Rules are inventoried in specs/providers/modal.yaml checks.
4
- export function validateProviderCreate(request) {
5
- const cpuCores = request.resources?.cpuCores;
6
- if (cpuCores !== undefined && cpuCores < 0.125) {
7
- fail(ErrorKind.InvalidArgument, "resources.cpuCores", "resources.cpu_cores is outside supported values");
8
- }
9
- const memoryMib = request.resources?.memoryMib;
10
- if (memoryMib !== undefined && memoryMib < BigInt("128")) {
11
- fail(ErrorKind.InvalidArgument, "resources.memoryMib", "resources.memory_mib is outside supported values");
12
- }
13
- const workingDirectory = request.runtime?.workingDirectory;
14
- if (workingDirectory !== undefined && !workingDirectory.startsWith("/")) {
15
- fail(ErrorKind.InvalidArgument, "runtime.workingDirectory", "runtime.working_directory is outside supported values");
16
- }
17
- const cloud = request.placement?.cloud;
18
- if (cloud !== undefined &&
19
- cloud !== "aws" &&
20
- cloud !== "gcp" &&
21
- cloud !== "oci" &&
22
- cloud !== "auto") {
23
- fail(ErrorKind.Unsupported, "placement.cloud", "placement.cloud is outside supported values");
24
- }
25
- for (const value of request.network?.outboundCidrs ?? []) {
26
- if (value !== "" && !validCidr(value)) {
27
- fail(ErrorKind.InvalidArgument, "network.outboundCidrs.entries", "network.outbound_cidrs.entries is outside supported values");
28
- }
29
- }
30
- for (const value of request.network?.inboundCidrs ?? []) {
31
- if (!validCidr(value)) {
32
- fail(ErrorKind.InvalidArgument, "network.inboundCidrs.entries", "network.inbound_cidrs.entries is outside supported values");
33
- }
34
- }
35
- for (const value of request.network?.outboundDomains ?? []) {
36
- if (value !== "" && !validDomain(value)) {
37
- fail(ErrorKind.InvalidArgument, "network.outboundDomains.entries", "network.outbound_domains.entries is outside supported values");
38
- }
39
- }
40
- for (const value of Object.keys(request.environment ?? {})) {
41
- if (!validEnvName(value)) {
42
- fail(ErrorKind.InvalidArgument, "environment", "environment is outside supported values");
43
- }
44
- }
45
- }
46
- function validEnvName(value) {
47
- return /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
48
- }
49
- function validDomain(value) {
50
- const domain = value.startsWith("*.") ? value.slice(2) : value;
51
- return (domain.length <= 253 &&
52
- /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?$/i.test(domain));
53
- }
54
- function validCidr(value) {
55
- const separator = value.lastIndexOf("/");
56
- if (separator <= 0)
57
- return false;
58
- const address = value.slice(0, separator);
59
- const prefix = Number(value.slice(separator + 1));
60
- if (!Number.isInteger(prefix))
61
- return false;
62
- return address.includes(":")
63
- ? prefix >= 0 && prefix <= 128 && validIpv6(address)
64
- : prefix >= 0 && prefix <= 32 && validIpv4(address);
65
- }
66
- function validIpv4(value) {
67
- const parts = value.split(".");
68
- return (parts.length === 4 &&
69
- parts.every((part) => /^(0|[1-9][0-9]{0,2})$/.test(part) && Number(part) <= 255));
70
- }
71
- function validIpv6(value) {
72
- if ((value.match(/::/g)?.length ?? 0) > 1)
73
- return false;
74
- const halves = value.split("::");
75
- if (halves.length > 2)
76
- return false;
77
- const count = (part) => {
78
- if (part === "")
79
- return 0;
80
- const groups = part.split(":");
81
- let total = 0;
82
- for (const group of groups) {
83
- if (/^[0-9a-f]{1,4}$/i.test(group))
84
- total++;
85
- else if (validIpv4(group))
86
- total += 2;
87
- else
88
- return undefined;
89
- }
90
- return total;
91
- };
92
- const left = count(halves[0] ?? "");
93
- const right = count(halves[1] ?? "");
94
- return (left !== undefined &&
95
- right !== undefined &&
96
- (halves.length === 2 ? left + right < 8 : left === 8));
97
- }
98
- function fail(kind, field, message) {
99
- throw sandboxError({
100
- kind,
101
- provider: "modal",
102
- operation: "create",
103
- field,
104
- message: "sandbox-kit modal: " + message,
105
- });
106
- }
@@ -1,9 +0,0 @@
1
- import type { ModalClientParams as NativeClientConfig } from "modal";
2
- import { type Config, type Scope } from "@sandbox-kit/sandbox";
3
- export declare function mapGeneratedClientConfig(config: Config): NativeClientConfig;
4
- export interface ProviderState {
5
- readonly scope?: Scope;
6
- readonly region?: string;
7
- }
8
- export declare function captureProviderState(config: Config): ProviderState;
9
- //# sourceMappingURL=provider_config.d.ts.map
@@ -1,46 +0,0 @@
1
- // Client configuration composition for the native SDK constructor.
2
- // Kept in sync with specs/providers/modal.yaml client: rules (not emitted).
3
- import { ErrorKind, sandboxError, validateConfig, } from "@sandbox-kit/sandbox";
4
- import { mapClientScope, mapOAuthAuth, mapTokenPairCredentials, } from "./provider_mappings.js";
5
- export function mapGeneratedClientConfig(config) {
6
- const source = config;
7
- validateConfig(source, "modal", "initialize");
8
- const target = {};
9
- if (source.endpoint !== undefined)
10
- unsupported("endpoint", "Endpoint cannot be configured through this SDK's public client constructor");
11
- if (source.scope !== undefined) {
12
- const mapped = mapClientScope(source.scope, "initialize");
13
- Object.assign(target, mapped);
14
- if (source.scope.organizationId !== undefined)
15
- unsupported("scope.organizationId", "unsupported client configuration field");
16
- if (source.scope.projectId !== undefined)
17
- unsupported("scope.projectId", "unsupported client configuration field");
18
- }
19
- if (source.auth?.tokenPair !== undefined) {
20
- Object.assign(target, mapTokenPairCredentials(source.auth.tokenPair, "initialize"));
21
- }
22
- else if (source.auth?.oauthRefresh !== undefined) {
23
- Object.assign(target, mapOAuthAuth(source.auth.oauthRefresh, "initialize"));
24
- }
25
- else if (source.auth !== undefined) {
26
- unsupported("auth", "unsupported authentication mode");
27
- }
28
- return target;
29
- }
30
- export function captureProviderState(config) {
31
- return {
32
- ...(config.scope === undefined
33
- ? {}
34
- : { scope: structuredClone(config.scope) }),
35
- ...(config.region === undefined ? {} : { region: config.region }),
36
- };
37
- }
38
- function unsupported(field, message) {
39
- throw sandboxError({
40
- kind: ErrorKind.Unsupported,
41
- provider: "modal",
42
- operation: "initialize",
43
- field,
44
- message: "sandbox-kit modal: " + message,
45
- });
46
- }
@@ -1,15 +0,0 @@
1
- import { type SandboxInfo, type Scope } from "@sandbox-kit/sandbox";
2
- import type { CreateOptions, OAuthCredentials, Resources, TokenPairCredentials } from "@sandbox-kit/sandbox";
3
- import type { ModalClientParams as NativeModalClientParams, Sandbox as NativeSandbox, SandboxCreateParams as NativeSandboxCreateParams } from "modal";
4
- type PublicLifetime = NonNullable<CreateOptions["lifetime"]>;
5
- type PublicIdleTerminate = NonNullable<PublicLifetime["idleTerminate"]>;
6
- export declare function mapSandboxIdentity(source: NativeSandbox | undefined, operation?: string): Partial<SandboxInfo>;
7
- export declare function mapClientScope(source: Scope | undefined, operation?: string): NativeModalClientParams;
8
- export declare function mapCommonCreateFields(source: CreateOptions | undefined, operation?: string): NativeSandboxCreateParams;
9
- export declare function mapResources(source: Resources | undefined, operation?: string): NativeSandboxCreateParams;
10
- export declare function mapLifetimeDuration(source: PublicLifetime | undefined, operation?: string): NativeSandboxCreateParams;
11
- export declare function mapIdleDuration(source: PublicIdleTerminate | undefined, operation?: string): NativeSandboxCreateParams;
12
- export declare function mapTokenPairCredentials(source: TokenPairCredentials | undefined, operation?: string): NativeModalClientParams;
13
- export declare function mapOAuthAuth(source: OAuthCredentials | undefined, operation?: string): NativeModalClientParams;
14
- export {};
15
- //# sourceMappingURL=provider_mappings.d.ts.map
@@ -1,179 +0,0 @@
1
- // Provider field mappings between shared CreateOptions/Config and the native SDK.
2
- // Inventoried in specs/providers/modal.yaml groups; kept in sync by hand (not emitted).
3
- import { ErrorKind, ValueOrigin, sandboxError } from "@sandbox-kit/sandbox";
4
- export function mapSandboxIdentity(source, operation = "create") {
5
- const target = {};
6
- if (source === undefined)
7
- return target;
8
- const origins = {};
9
- target.origins = origins;
10
- {
11
- if (source.sandboxId !== undefined) {
12
- const value = source.sandboxId;
13
- target.id = value;
14
- origins["id"] = ValueOrigin.Provider;
15
- }
16
- }
17
- target.provider = "modal";
18
- return target;
19
- }
20
- export function mapClientScope(source, operation = "initialize") {
21
- const target = {};
22
- if (source === undefined)
23
- return target;
24
- {
25
- if (source.environment !== undefined) {
26
- const value = source.environment;
27
- target.environment = value;
28
- }
29
- }
30
- return target;
31
- }
32
- export function mapCommonCreateFields(source, operation = "create") {
33
- const target = {};
34
- if (source === undefined)
35
- return target;
36
- {
37
- if (source.name !== undefined) {
38
- const value = source.name;
39
- target.name = value;
40
- }
41
- }
42
- {
43
- if (source.environment !== undefined) {
44
- const value = source.environment;
45
- target.env = { ...value };
46
- }
47
- }
48
- {
49
- if (source.labels !== undefined) {
50
- const value = source.labels;
51
- target.tags = { ...value };
52
- }
53
- }
54
- return target;
55
- }
56
- export function mapResources(source, operation = "create") {
57
- const target = {};
58
- if (source === undefined)
59
- return target;
60
- {
61
- if (source.cpuCores !== undefined) {
62
- target.cpu = scaledCpuCores(source.cpuCores, "resources.cpu_cores", operation);
63
- }
64
- }
65
- {
66
- if (source.cpuLimitCores !== undefined) {
67
- target.cpuLimit = scaledCpuCores(source.cpuLimitCores, "resources.cpu_limit_cores", operation);
68
- }
69
- }
70
- {
71
- if (source.memoryMib !== undefined) {
72
- const value = source.memoryMib;
73
- if (value > 2147483647n)
74
- mappingError(ErrorKind.InvalidArgument, "resources.memory_mib", "memory_mib cannot be represented", operation);
75
- target.memoryMiB = Number(value);
76
- }
77
- }
78
- {
79
- if (source.memoryLimitMib !== undefined) {
80
- const value = source.memoryLimitMib;
81
- if (value > 2147483647n)
82
- mappingError(ErrorKind.InvalidArgument, "resources.memory_limit_mib", "memory_limit_mib cannot be represented", operation);
83
- target.memoryLimitMiB = Number(value);
84
- }
85
- }
86
- return target;
87
- }
88
- export function mapLifetimeDuration(source, operation = "create") {
89
- const target = {};
90
- if (source === undefined)
91
- return target;
92
- {
93
- if (source.maximumLifetime !== undefined) {
94
- target.timeoutMs = durationSecondsMs(source.maximumLifetime, "lifetime.maximum_lifetime", 86_400, operation);
95
- }
96
- }
97
- return target;
98
- }
99
- export function mapIdleDuration(source, operation = "create") {
100
- const target = {};
101
- if (source === undefined)
102
- return target;
103
- {
104
- if (source.after !== undefined) {
105
- target.idleTimeoutMs = durationSecondsMs(source.after, "lifetime.idle_terminate.after", 4_294_967_295, operation);
106
- }
107
- }
108
- return target;
109
- }
110
- /** Modal CPU fields are millis-scaled: value must equal round(value*1000)/1000. */
111
- function scaledCpuCores(value, field, operation) {
112
- const scaled = Math.round(value * 1000);
113
- if (!Number.isFinite(value) ||
114
- value < 0 ||
115
- value !== scaled / 1000 ||
116
- scaled > 4_294_967_295) {
117
- mappingError(ErrorKind.InvalidArgument, field, field.slice(field.lastIndexOf(".") + 1) + " cannot be represented", operation);
118
- }
119
- return value * 1000 < scaled ? scaled / 1000 : value;
120
- }
121
- /** Modal lifetime/idle timeouts are whole seconds expressed as milliseconds. */
122
- function durationSecondsMs(value, field, maximumSeconds, operation) {
123
- if (!Number.isFinite(value) ||
124
- value <= 0 ||
125
- value % 1000 !== 0 ||
126
- value / 1000 > maximumSeconds) {
127
- mappingError(ErrorKind.InvalidArgument, field, field.slice(field.lastIndexOf(".") + 1) + " cannot be represented", operation);
128
- }
129
- return value;
130
- }
131
- export function mapTokenPairCredentials(source, operation = "initialize") {
132
- const target = {};
133
- if (source === undefined)
134
- return target;
135
- {
136
- const value = source.id;
137
- target.tokenId = value;
138
- }
139
- {
140
- const value = source.secret;
141
- target.tokenSecret = value;
142
- }
143
- return target;
144
- }
145
- export function mapOAuthAuth(source, operation = "create") {
146
- const target = {};
147
- if (source === undefined)
148
- return target;
149
- {
150
- const value = source.refreshToken;
151
- target.oauthRefreshToken = value;
152
- }
153
- {
154
- const value = source.clientId;
155
- target.oauthClientId = value;
156
- }
157
- {
158
- if (source.clientSecret !== undefined) {
159
- const value = source.clientSecret;
160
- target.oauthClientSecret = value;
161
- }
162
- }
163
- {
164
- if (source.jwtKey !== undefined) {
165
- const value = source.jwtKey;
166
- target.oauthJwtKey = value;
167
- }
168
- }
169
- return target;
170
- }
171
- function mappingError(kind, field, message, operation) {
172
- throw sandboxError({
173
- kind,
174
- provider: "modal",
175
- operation,
176
- field,
177
- message: "sandbox-kit modal: " + message,
178
- });
179
- }