modal 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  App: () => App2,
35
35
  AppService: () => AppService,
36
36
  CloudBucketMount: () => CloudBucketMount2,
37
+ CloudBucketMountService: () => CloudBucketMountService,
37
38
  Cls: () => Cls,
38
39
  ClsInstance: () => ClsInstance,
39
40
  ClsService: () => ClsService,
@@ -47,7 +48,7 @@ __export(index_exports, {
47
48
  ImageService: () => ImageService,
48
49
  InternalFailure: () => InternalFailure,
49
50
  InvalidError: () => InvalidError,
50
- ModalClient: () => ModalClient,
51
+ ModalClient: () => ModalClient2,
51
52
  NotFoundError: () => NotFoundError,
52
53
  Proxy: () => Proxy3,
53
54
  ProxyService: () => ProxyService,
@@ -43324,6 +43325,89 @@ function isSet4(value) {
43324
43325
  var import_uuid = require("uuid");
43325
43326
  var import_nice_grpc10 = require("nice-grpc");
43326
43327
 
43328
+ // src/cloud_bucket_mount.ts
43329
+ var CloudBucketMountService = class {
43330
+ #client;
43331
+ constructor(client2) {
43332
+ this.#client = client2;
43333
+ }
43334
+ create(bucketName, params = {}) {
43335
+ let bucketType = 1 /* S3 */;
43336
+ if (params.bucketEndpointUrl) {
43337
+ const url = new URL(params.bucketEndpointUrl);
43338
+ if (url.hostname.endsWith("r2.cloudflarestorage.com")) {
43339
+ bucketType = 2 /* R2 */;
43340
+ } else if (url.hostname.endsWith("storage.googleapis.com")) {
43341
+ bucketType = 3 /* GCP */;
43342
+ } else {
43343
+ bucketType = 1 /* S3 */;
43344
+ this.#client.logger.debug(
43345
+ "CloudBucketMount received unrecognized bucket endpoint URL. Assuming AWS S3 configuration as fallback.",
43346
+ "bucketEndpointUrl",
43347
+ params.bucketEndpointUrl
43348
+ );
43349
+ }
43350
+ }
43351
+ if (params.requesterPays && !params.secret) {
43352
+ throw new Error("Credentials required in order to use Requester Pays.");
43353
+ }
43354
+ if (params.keyPrefix && !params.keyPrefix.endsWith("/")) {
43355
+ throw new Error(
43356
+ "keyPrefix will be prefixed to all object paths, so it must end in a '/'"
43357
+ );
43358
+ }
43359
+ return new CloudBucketMount2(
43360
+ bucketName,
43361
+ params.secret,
43362
+ params.readOnly ?? false,
43363
+ params.requesterPays ?? false,
43364
+ params.bucketEndpointUrl,
43365
+ params.keyPrefix,
43366
+ params.oidcAuthRoleArn,
43367
+ bucketType
43368
+ );
43369
+ }
43370
+ };
43371
+ var CloudBucketMount2 = class {
43372
+ bucketName;
43373
+ secret;
43374
+ readOnly;
43375
+ requesterPays;
43376
+ bucketEndpointUrl;
43377
+ keyPrefix;
43378
+ oidcAuthRoleArn;
43379
+ #bucketType;
43380
+ constructor(bucketName, secretOrParams, readOnly, requesterPays, bucketEndpointUrl, keyPrefix, oidcAuthRoleArn, bucketType) {
43381
+ if (bucketType !== void 0) {
43382
+ this.bucketName = bucketName;
43383
+ this.secret = secretOrParams;
43384
+ this.readOnly = readOnly;
43385
+ this.requesterPays = requesterPays;
43386
+ this.bucketEndpointUrl = bucketEndpointUrl;
43387
+ this.keyPrefix = keyPrefix;
43388
+ this.oidcAuthRoleArn = oidcAuthRoleArn;
43389
+ this.#bucketType = bucketType;
43390
+ } else {
43391
+ const params = secretOrParams === void 0 ? {} : secretOrParams;
43392
+ return getDefaultClient().cloudBucketMounts.create(bucketName, params);
43393
+ }
43394
+ }
43395
+ /** @ignore */
43396
+ toProto(mountPath) {
43397
+ return {
43398
+ bucketName: this.bucketName,
43399
+ mountPath,
43400
+ credentialsSecretId: this.secret?.secretId ?? "",
43401
+ readOnly: this.readOnly,
43402
+ bucketType: this.#bucketType,
43403
+ requesterPays: this.requesterPays,
43404
+ bucketEndpointUrl: this.bucketEndpointUrl,
43405
+ keyPrefix: this.keyPrefix,
43406
+ oidcAuthRoleArn: this.oidcAuthRoleArn
43407
+ };
43408
+ }
43409
+ };
43410
+
43327
43411
  // src/cls.ts
43328
43412
  var import_nice_grpc3 = require("nice-grpc");
43329
43413
 
@@ -44224,7 +44308,8 @@ var Cls = class _Cls {
44224
44308
  const bindResp = await this.#client.cpClient.functionBindParams({
44225
44309
  functionId: this.#serviceFunctionId,
44226
44310
  serializedParams,
44227
- functionOptions
44311
+ functionOptions,
44312
+ environmentName: this.#client.environmentName()
44228
44313
  });
44229
44314
  return bindResp.boundFunctionId;
44230
44315
  }
@@ -45647,68 +45732,6 @@ async function consumeIterator(iter) {
45647
45732
  }
45648
45733
  }
45649
45734
 
45650
- // src/cloud_bucket_mount.ts
45651
- var CloudBucketMount2 = class {
45652
- bucketName;
45653
- secret;
45654
- readOnly;
45655
- requesterPays;
45656
- bucketEndpointUrl;
45657
- keyPrefix;
45658
- oidcAuthRoleArn;
45659
- constructor(bucketName, params = {}) {
45660
- this.bucketName = bucketName;
45661
- this.secret = params.secret;
45662
- this.readOnly = params.readOnly ?? false;
45663
- this.requesterPays = params.requesterPays ?? false;
45664
- this.bucketEndpointUrl = params.bucketEndpointUrl;
45665
- this.keyPrefix = params.keyPrefix;
45666
- this.oidcAuthRoleArn = params.oidcAuthRoleArn;
45667
- if (this.bucketEndpointUrl) {
45668
- const url = new URL(this.bucketEndpointUrl);
45669
- if (!url.hostname.endsWith("r2.cloudflarestorage.com") && !url.hostname.endsWith("storage.googleapis.com")) {
45670
- console.warn(
45671
- "CloudBucketMount received unrecognized bucket endpoint URL. Assuming AWS S3 configuration as fallback."
45672
- );
45673
- }
45674
- }
45675
- if (this.requesterPays && !this.secret) {
45676
- throw new Error("Credentials required in order to use Requester Pays.");
45677
- }
45678
- if (this.keyPrefix && !this.keyPrefix.endsWith("/")) {
45679
- throw new Error(
45680
- "keyPrefix will be prefixed to all object paths, so it must end in a '/'"
45681
- );
45682
- }
45683
- }
45684
- };
45685
- function endpointUrlToBucketType(bucketEndpointUrl) {
45686
- if (!bucketEndpointUrl) {
45687
- return 1 /* S3 */;
45688
- }
45689
- const url = new URL(bucketEndpointUrl);
45690
- if (url.hostname.endsWith("r2.cloudflarestorage.com")) {
45691
- return 2 /* R2 */;
45692
- } else if (url.hostname.endsWith("storage.googleapis.com")) {
45693
- return 3 /* GCP */;
45694
- } else {
45695
- return 1 /* S3 */;
45696
- }
45697
- }
45698
- function cloudBucketMountToProto(mount, mountPath) {
45699
- return {
45700
- bucketName: mount.bucketName,
45701
- mountPath,
45702
- credentialsSecretId: mount.secret?.secretId ?? "",
45703
- readOnly: mount.readOnly,
45704
- bucketType: endpointUrlToBucketType(mount.bucketEndpointUrl),
45705
- requesterPays: mount.requesterPays,
45706
- bucketEndpointUrl: mount.bucketEndpointUrl,
45707
- keyPrefix: mount.keyPrefix,
45708
- oidcAuthRoleArn: mount.oidcAuthRoleArn
45709
- };
45710
- }
45711
-
45712
45735
  // src/sandbox.ts
45713
45736
  async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45714
45737
  checkForRenamedParams(params, {
@@ -45738,32 +45761,38 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45738
45761
  readOnly: volume.isReadOnly
45739
45762
  })) : [];
45740
45763
  const cloudBucketMounts = params.cloudBucketMounts ? Object.entries(params.cloudBucketMounts).map(
45741
- ([mountPath, mount]) => cloudBucketMountToProto(mount, mountPath)
45764
+ ([mountPath, mount]) => mount.toProto(mountPath)
45742
45765
  ) : [];
45743
45766
  const openPorts = [];
45744
45767
  if (params.encryptedPorts) {
45745
45768
  openPorts.push(
45746
- ...params.encryptedPorts.map((port) => ({
45747
- port,
45748
- unencrypted: false
45749
- }))
45769
+ ...params.encryptedPorts.map(
45770
+ (port) => PortSpec.create({
45771
+ port,
45772
+ unencrypted: false
45773
+ })
45774
+ )
45750
45775
  );
45751
45776
  }
45752
45777
  if (params.h2Ports) {
45753
45778
  openPorts.push(
45754
- ...params.h2Ports.map((port) => ({
45755
- port,
45756
- unencrypted: false,
45757
- tunnelType: 1 /* TUNNEL_TYPE_H2 */
45758
- }))
45779
+ ...params.h2Ports.map(
45780
+ (port) => PortSpec.create({
45781
+ port,
45782
+ unencrypted: false,
45783
+ tunnelType: 1 /* TUNNEL_TYPE_H2 */
45784
+ })
45785
+ )
45759
45786
  );
45760
45787
  }
45761
45788
  if (params.unencryptedPorts) {
45762
45789
  openPorts.push(
45763
- ...params.unencryptedPorts.map((port) => ({
45764
- port,
45765
- unencrypted: true
45766
- }))
45790
+ ...params.unencryptedPorts.map(
45791
+ (port) => PortSpec.create({
45792
+ port,
45793
+ unencrypted: true
45794
+ })
45795
+ )
45767
45796
  );
45768
45797
  }
45769
45798
  const secretIds = (params.secrets || []).map((secret) => secret.secretId);
@@ -45789,9 +45818,9 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45789
45818
  allowedCidrs: []
45790
45819
  };
45791
45820
  }
45792
- const schedulerPlacement = SchedulerPlacement.create({
45793
- regions: params.regions ?? []
45794
- });
45821
+ const schedulerPlacement = params.regions?.length ? SchedulerPlacement.create({
45822
+ regions: params.regions
45823
+ }) : void 0;
45795
45824
  let ptyInfo;
45796
45825
  if (params.pty) {
45797
45826
  ptyInfo = defaultSandboxPTYInfo();
@@ -45848,18 +45877,18 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45848
45877
  idleTimeoutSecs: params.idleTimeoutMs != void 0 ? params.idleTimeoutMs / 1e3 : void 0,
45849
45878
  workdir: params.workdir ?? void 0,
45850
45879
  networkAccess,
45851
- resources: {
45880
+ resources: Resources.create({
45852
45881
  milliCpu,
45853
45882
  milliCpuMax,
45854
45883
  memoryMb,
45855
45884
  memoryMbMax,
45856
45885
  gpuConfig
45857
- },
45886
+ }),
45858
45887
  volumeMounts,
45859
45888
  cloudBucketMounts,
45860
45889
  ptyInfo,
45861
45890
  secretIds,
45862
- openPorts: openPorts.length > 0 ? { ports: openPorts } : void 0,
45891
+ openPorts: PortSpecs.create({ ports: openPorts }),
45863
45892
  cloudProviderStr: params.cloud ?? "",
45864
45893
  schedulerPlacement,
45865
45894
  verbose: params.verbose ?? false,
@@ -46775,7 +46804,7 @@ var AuthTokenManager = class {
46775
46804
 
46776
46805
  // src/version.ts
46777
46806
  function getSDKVersion() {
46778
- return true ? "0.5.4" : "0.0.0";
46807
+ return true ? "0.5.5" : "0.0.0";
46779
46808
  }
46780
46809
 
46781
46810
  // src/logger.ts
@@ -46885,8 +46914,9 @@ function createLogger(logger, logLevel = "") {
46885
46914
  }
46886
46915
 
46887
46916
  // src/client.ts
46888
- var ModalClient = class {
46917
+ var ModalClient2 = class {
46889
46918
  apps;
46919
+ cloudBucketMounts;
46890
46920
  cls;
46891
46921
  functions;
46892
46922
  functionCalls;
@@ -46926,6 +46956,7 @@ var ModalClient = class {
46926
46956
  this.cpClient = params?.cpClient ?? this.createClient(this.profile);
46927
46957
  this.logger.debug("Modal client initialized successfully");
46928
46958
  this.apps = new AppService(this);
46959
+ this.cloudBucketMounts = new CloudBucketMountService(this);
46929
46960
  this.cls = new ClsService(this);
46930
46961
  this.functions = new FunctionService(this);
46931
46962
  this.functionCalls = new FunctionCallService(this);
@@ -47159,7 +47190,7 @@ var defaultClient;
47159
47190
  var defaultClientOptions;
47160
47191
  function getDefaultClient() {
47161
47192
  if (!defaultClient) {
47162
- defaultClient = new ModalClient(defaultClientOptions);
47193
+ defaultClient = new ModalClient2(defaultClientOptions);
47163
47194
  }
47164
47195
  return defaultClient;
47165
47196
  }
@@ -47174,7 +47205,7 @@ function initializeClient(options) {
47174
47205
  tokenSecret: options.tokenSecret,
47175
47206
  environment: options.environment
47176
47207
  };
47177
- defaultClient = new ModalClient(defaultClientOptions);
47208
+ defaultClient = new ModalClient2(defaultClientOptions);
47178
47209
  }
47179
47210
  function close() {
47180
47211
  if (defaultClient) {
@@ -47215,7 +47246,7 @@ var AppService = class {
47215
47246
  };
47216
47247
  function parseGpuConfig(gpu) {
47217
47248
  if (!gpu) {
47218
- return void 0;
47249
+ return GPUConfig.create({});
47219
47250
  }
47220
47251
  let gpuType = gpu;
47221
47252
  let count = 1;
@@ -47229,12 +47260,10 @@ function parseGpuConfig(gpu) {
47229
47260
  );
47230
47261
  }
47231
47262
  }
47232
- return {
47233
- type: 0,
47234
- // Deprecated field, but required by proto
47263
+ return GPUConfig.create({
47235
47264
  count,
47236
47265
  gpuType: gpuType.toUpperCase()
47237
- };
47266
+ });
47238
47267
  }
47239
47268
  var App2 = class {
47240
47269
  appId;
@@ -47247,6 +47276,7 @@ var App2 = class {
47247
47276
  /**
47248
47277
  * @deprecated Use {@link AppService#fromName client.apps.fromName()} instead.
47249
47278
  */
47279
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
47250
47280
  static async lookup(name, options = {}) {
47251
47281
  return getDefaultClient().apps.fromName(name, options);
47252
47282
  }
@@ -47281,6 +47311,7 @@ var App2 = class {
47281
47311
  App,
47282
47312
  AppService,
47283
47313
  CloudBucketMount,
47314
+ CloudBucketMountService,
47284
47315
  Cls,
47285
47316
  ClsInstance,
47286
47317
  ClsService,
package/dist/index.d.cts CHANGED
@@ -4971,6 +4971,98 @@ interface MessageFns<T> {
4971
4971
  fromPartial(object: DeepPartial<T>): T;
4972
4972
  }
4973
4973
 
4974
+ /** Optional parameters for {@link SecretService#fromName client.secrets.fromName()}. */
4975
+ type SecretFromNameParams = {
4976
+ environment?: string;
4977
+ requiredKeys?: string[];
4978
+ };
4979
+ /** Optional parameters for {@link SecretService#fromObject client.secrets.fromObject()}. */
4980
+ type SecretFromObjectParams = {
4981
+ environment?: string;
4982
+ };
4983
+ /** Optional parameters for {@link SecretService#delete client.secrets.delete()}. */
4984
+ type SecretDeleteParams = {
4985
+ environment?: string;
4986
+ allowMissing?: boolean;
4987
+ };
4988
+ /**
4989
+ * Service for managing {@link Secret Secrets}.
4990
+ *
4991
+ * Normally only ever accessed via the client as:
4992
+ * ```typescript
4993
+ * const modal = new ModalClient();
4994
+ * const secret = await modal.secrets.fromName("my-secret");
4995
+ * ```
4996
+ */
4997
+ declare class SecretService {
4998
+ #private;
4999
+ constructor(client: ModalClient);
5000
+ /** Reference a {@link Secret} by its name. */
5001
+ fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5002
+ /** Create a {@link Secret} from a plain object of key-value pairs. */
5003
+ fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5004
+ /**
5005
+ * Delete a named {@link Secret}.
5006
+ *
5007
+ * Warning: Deletion is irreversible and will affect any Apps currently using the Secret.
5008
+ */
5009
+ delete(name: string, params?: SecretDeleteParams): Promise<void>;
5010
+ }
5011
+ /** Secrets provide a dictionary of environment variables for {@link Image}s. */
5012
+ declare class Secret {
5013
+ readonly secretId: string;
5014
+ readonly name?: string;
5015
+ /** @ignore */
5016
+ constructor(secretId: string, name?: string);
5017
+ /**
5018
+ * @deprecated Use {@link SecretService#fromName client.secrets.fromName()} instead.
5019
+ */
5020
+ static fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5021
+ /**
5022
+ * @deprecated Use {@link SecretService#fromObject client.secrets.fromObject()} instead.
5023
+ */
5024
+ static fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5025
+ }
5026
+
5027
+ declare class CloudBucketMountService {
5028
+ #private;
5029
+ constructor(client: ModalClient);
5030
+ create(bucketName: string, params?: {
5031
+ secret?: Secret;
5032
+ readOnly?: boolean;
5033
+ requesterPays?: boolean;
5034
+ bucketEndpointUrl?: string;
5035
+ keyPrefix?: string;
5036
+ oidcAuthRoleArn?: string;
5037
+ }): CloudBucketMount;
5038
+ }
5039
+ /** Cloud Bucket Mounts provide access to cloud storage buckets within Modal Functions. */
5040
+ declare class CloudBucketMount {
5041
+ #private;
5042
+ readonly bucketName: string;
5043
+ readonly secret?: Secret;
5044
+ readonly readOnly: boolean;
5045
+ readonly requesterPays: boolean;
5046
+ readonly bucketEndpointUrl?: string;
5047
+ readonly keyPrefix?: string;
5048
+ readonly oidcAuthRoleArn?: string;
5049
+ /**
5050
+ * @deprecated Use {@link CloudBucketMountService#create client.cloudBucketMounts.create()} instead.
5051
+ */
5052
+ constructor(bucketName: string, params?: {
5053
+ secret?: Secret;
5054
+ readOnly?: boolean;
5055
+ requesterPays?: boolean;
5056
+ bucketEndpointUrl?: string;
5057
+ keyPrefix?: string;
5058
+ oidcAuthRoleArn?: string;
5059
+ });
5060
+ /** @ignore */
5061
+ constructor(bucketName: string, secret: Secret | undefined, readOnly: boolean, requesterPays: boolean, bucketEndpointUrl: string | undefined, keyPrefix: string | undefined, oidcAuthRoleArn: string | undefined, bucketType: CloudBucketMount_BucketType);
5062
+ /** @ignore */
5063
+ toProto(mountPath: string): CloudBucketMount$1;
5064
+ }
5065
+
4974
5066
  /**
4975
5067
  * Service for managing {@link FunctionCall}s.
4976
5068
  *
@@ -5073,59 +5165,6 @@ declare class Function_ {
5073
5165
  getWebUrl(): Promise<string | undefined>;
5074
5166
  }
5075
5167
 
5076
- /** Optional parameters for {@link SecretService#fromName client.secrets.fromName()}. */
5077
- type SecretFromNameParams = {
5078
- environment?: string;
5079
- requiredKeys?: string[];
5080
- };
5081
- /** Optional parameters for {@link SecretService#fromObject client.secrets.fromObject()}. */
5082
- type SecretFromObjectParams = {
5083
- environment?: string;
5084
- };
5085
- /** Optional parameters for {@link SecretService#delete client.secrets.delete()}. */
5086
- type SecretDeleteParams = {
5087
- environment?: string;
5088
- allowMissing?: boolean;
5089
- };
5090
- /**
5091
- * Service for managing {@link Secret Secrets}.
5092
- *
5093
- * Normally only ever accessed via the client as:
5094
- * ```typescript
5095
- * const modal = new ModalClient();
5096
- * const secret = await modal.secrets.fromName("my-secret");
5097
- * ```
5098
- */
5099
- declare class SecretService {
5100
- #private;
5101
- constructor(client: ModalClient);
5102
- /** Reference a {@link Secret} by its name. */
5103
- fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5104
- /** Create a {@link Secret} from a plain object of key-value pairs. */
5105
- fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5106
- /**
5107
- * Delete a named {@link Secret}.
5108
- *
5109
- * Warning: Deletion is irreversible and will affect any Apps currently using the Secret.
5110
- */
5111
- delete(name: string, params?: SecretDeleteParams): Promise<void>;
5112
- }
5113
- /** Secrets provide a dictionary of environment variables for {@link Image}s. */
5114
- declare class Secret {
5115
- readonly secretId: string;
5116
- readonly name?: string;
5117
- /** @ignore */
5118
- constructor(secretId: string, name?: string);
5119
- /**
5120
- * @deprecated Use {@link SecretService#fromName client.secrets.fromName()} instead.
5121
- */
5122
- static fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5123
- /**
5124
- * @deprecated Use {@link SecretService#fromObject client.secrets.fromObject()} instead.
5125
- */
5126
- static fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5127
- }
5128
-
5129
5168
  /** Retry policy configuration for a Modal Function/Cls. */
5130
5169
  declare class Retries {
5131
5170
  readonly maxRetries: number;
@@ -5648,25 +5687,6 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
5648
5687
  writeBytes(bytes: Uint8Array): Promise<void>;
5649
5688
  }
5650
5689
 
5651
- /** Cloud Bucket Mounts provide access to cloud storage buckets within Modal Functions. */
5652
- declare class CloudBucketMount {
5653
- readonly bucketName: string;
5654
- readonly secret?: Secret;
5655
- readonly readOnly: boolean;
5656
- readonly requesterPays: boolean;
5657
- readonly bucketEndpointUrl?: string;
5658
- readonly keyPrefix?: string;
5659
- readonly oidcAuthRoleArn?: string;
5660
- constructor(bucketName: string, params?: {
5661
- secret?: Secret;
5662
- readOnly?: boolean;
5663
- requesterPays?: boolean;
5664
- bucketEndpointUrl?: string;
5665
- keyPrefix?: string;
5666
- oidcAuthRoleArn?: string;
5667
- });
5668
- }
5669
-
5670
5690
  /**
5671
5691
  * Stdin is always present, but this option allow you to drop stdout or stderr
5672
5692
  * if you don't need them. The default is "pipe", matching Node.js behavior.
@@ -5694,7 +5714,7 @@ type SandboxCreateParams = {
5694
5714
  gpu?: string;
5695
5715
  /** Timeout of the Sandbox container in milliseconds, defaults to 10 minutes. */
5696
5716
  timeoutMs?: number;
5697
- /** The amount of time in milliseconds that a sandbox can be idle before being terminated. */
5717
+ /** The amount of time in milliseconds that a Sandbox can be idle before being terminated. */
5698
5718
  idleTimeoutMs?: number;
5699
5719
  /** Working directory of the Sandbox. */
5700
5720
  workdir?: string;
@@ -5740,7 +5760,7 @@ type SandboxCreateParams = {
5740
5760
  * Normally only ever accessed via the client as:
5741
5761
  * ```typescript
5742
5762
  * const modal = new ModalClient();
5743
- * const sandbox = await modal.sandboxes.create(app, image);
5763
+ * const sb = await modal.sandboxes.create(app, image);
5744
5764
  * ```
5745
5765
  */
5746
5766
  declare class SandboxService {
@@ -5949,11 +5969,12 @@ type ModalGrpcClient = Client<typeof ModalClientDefinition, TimeoutOptions & Ret
5949
5969
  *
5950
5970
  * const app = await modal.apps.fromName("my-app");
5951
5971
  * const image = modal.images.fromRegistry("python:3.13");
5952
- * const sandbox = await modal.sandboxes.create(app, image);
5972
+ * const sb = await modal.sandboxes.create(app, image);
5953
5973
  * ```
5954
5974
  */
5955
5975
  declare class ModalClient {
5956
5976
  readonly apps: AppService;
5977
+ readonly cloudBucketMounts: CloudBucketMountService;
5957
5978
  readonly cls: ClsService;
5958
5979
  readonly functions: FunctionService;
5959
5980
  readonly functionCalls: FunctionCallService;
@@ -6118,4 +6139,4 @@ declare class SandboxTimeoutError extends Error {
6118
6139
 
6119
6140
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
6120
6141
 
6121
- export { AlreadyExistsError, App, type AppFromNameParams, AppService, type ClientOptions, CloudBucketMount, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ContainerProcess, type DeleteOptions, type EphemeralOptions, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, FunctionCallService, type FunctionFromNameParams, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, ImageService, InternalFailure, InvalidError, type LogLevel, type Logger, type LookupOptions, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, Retries, Sandbox, type SandboxCreateParams, type SandboxExecParams, SandboxFile, type SandboxFileMode, type SandboxFromNameParams, type SandboxListParams, SandboxService, SandboxTimeoutError, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, VolumeService, checkForRenamedParams, close, initializeClient };
6142
+ export { AlreadyExistsError, App, type AppFromNameParams, AppService, type ClientOptions, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ContainerProcess, type DeleteOptions, type EphemeralOptions, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, FunctionCallService, type FunctionFromNameParams, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, ImageService, InternalFailure, InvalidError, type LogLevel, type Logger, type LookupOptions, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, Retries, Sandbox, type SandboxCreateParams, type SandboxExecParams, SandboxFile, type SandboxFileMode, type SandboxFromNameParams, type SandboxListParams, SandboxService, SandboxTimeoutError, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, VolumeService, checkForRenamedParams, close, initializeClient };
package/dist/index.d.ts CHANGED
@@ -4971,6 +4971,98 @@ interface MessageFns<T> {
4971
4971
  fromPartial(object: DeepPartial<T>): T;
4972
4972
  }
4973
4973
 
4974
+ /** Optional parameters for {@link SecretService#fromName client.secrets.fromName()}. */
4975
+ type SecretFromNameParams = {
4976
+ environment?: string;
4977
+ requiredKeys?: string[];
4978
+ };
4979
+ /** Optional parameters for {@link SecretService#fromObject client.secrets.fromObject()}. */
4980
+ type SecretFromObjectParams = {
4981
+ environment?: string;
4982
+ };
4983
+ /** Optional parameters for {@link SecretService#delete client.secrets.delete()}. */
4984
+ type SecretDeleteParams = {
4985
+ environment?: string;
4986
+ allowMissing?: boolean;
4987
+ };
4988
+ /**
4989
+ * Service for managing {@link Secret Secrets}.
4990
+ *
4991
+ * Normally only ever accessed via the client as:
4992
+ * ```typescript
4993
+ * const modal = new ModalClient();
4994
+ * const secret = await modal.secrets.fromName("my-secret");
4995
+ * ```
4996
+ */
4997
+ declare class SecretService {
4998
+ #private;
4999
+ constructor(client: ModalClient);
5000
+ /** Reference a {@link Secret} by its name. */
5001
+ fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5002
+ /** Create a {@link Secret} from a plain object of key-value pairs. */
5003
+ fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5004
+ /**
5005
+ * Delete a named {@link Secret}.
5006
+ *
5007
+ * Warning: Deletion is irreversible and will affect any Apps currently using the Secret.
5008
+ */
5009
+ delete(name: string, params?: SecretDeleteParams): Promise<void>;
5010
+ }
5011
+ /** Secrets provide a dictionary of environment variables for {@link Image}s. */
5012
+ declare class Secret {
5013
+ readonly secretId: string;
5014
+ readonly name?: string;
5015
+ /** @ignore */
5016
+ constructor(secretId: string, name?: string);
5017
+ /**
5018
+ * @deprecated Use {@link SecretService#fromName client.secrets.fromName()} instead.
5019
+ */
5020
+ static fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5021
+ /**
5022
+ * @deprecated Use {@link SecretService#fromObject client.secrets.fromObject()} instead.
5023
+ */
5024
+ static fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5025
+ }
5026
+
5027
+ declare class CloudBucketMountService {
5028
+ #private;
5029
+ constructor(client: ModalClient);
5030
+ create(bucketName: string, params?: {
5031
+ secret?: Secret;
5032
+ readOnly?: boolean;
5033
+ requesterPays?: boolean;
5034
+ bucketEndpointUrl?: string;
5035
+ keyPrefix?: string;
5036
+ oidcAuthRoleArn?: string;
5037
+ }): CloudBucketMount;
5038
+ }
5039
+ /** Cloud Bucket Mounts provide access to cloud storage buckets within Modal Functions. */
5040
+ declare class CloudBucketMount {
5041
+ #private;
5042
+ readonly bucketName: string;
5043
+ readonly secret?: Secret;
5044
+ readonly readOnly: boolean;
5045
+ readonly requesterPays: boolean;
5046
+ readonly bucketEndpointUrl?: string;
5047
+ readonly keyPrefix?: string;
5048
+ readonly oidcAuthRoleArn?: string;
5049
+ /**
5050
+ * @deprecated Use {@link CloudBucketMountService#create client.cloudBucketMounts.create()} instead.
5051
+ */
5052
+ constructor(bucketName: string, params?: {
5053
+ secret?: Secret;
5054
+ readOnly?: boolean;
5055
+ requesterPays?: boolean;
5056
+ bucketEndpointUrl?: string;
5057
+ keyPrefix?: string;
5058
+ oidcAuthRoleArn?: string;
5059
+ });
5060
+ /** @ignore */
5061
+ constructor(bucketName: string, secret: Secret | undefined, readOnly: boolean, requesterPays: boolean, bucketEndpointUrl: string | undefined, keyPrefix: string | undefined, oidcAuthRoleArn: string | undefined, bucketType: CloudBucketMount_BucketType);
5062
+ /** @ignore */
5063
+ toProto(mountPath: string): CloudBucketMount$1;
5064
+ }
5065
+
4974
5066
  /**
4975
5067
  * Service for managing {@link FunctionCall}s.
4976
5068
  *
@@ -5073,59 +5165,6 @@ declare class Function_ {
5073
5165
  getWebUrl(): Promise<string | undefined>;
5074
5166
  }
5075
5167
 
5076
- /** Optional parameters for {@link SecretService#fromName client.secrets.fromName()}. */
5077
- type SecretFromNameParams = {
5078
- environment?: string;
5079
- requiredKeys?: string[];
5080
- };
5081
- /** Optional parameters for {@link SecretService#fromObject client.secrets.fromObject()}. */
5082
- type SecretFromObjectParams = {
5083
- environment?: string;
5084
- };
5085
- /** Optional parameters for {@link SecretService#delete client.secrets.delete()}. */
5086
- type SecretDeleteParams = {
5087
- environment?: string;
5088
- allowMissing?: boolean;
5089
- };
5090
- /**
5091
- * Service for managing {@link Secret Secrets}.
5092
- *
5093
- * Normally only ever accessed via the client as:
5094
- * ```typescript
5095
- * const modal = new ModalClient();
5096
- * const secret = await modal.secrets.fromName("my-secret");
5097
- * ```
5098
- */
5099
- declare class SecretService {
5100
- #private;
5101
- constructor(client: ModalClient);
5102
- /** Reference a {@link Secret} by its name. */
5103
- fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5104
- /** Create a {@link Secret} from a plain object of key-value pairs. */
5105
- fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5106
- /**
5107
- * Delete a named {@link Secret}.
5108
- *
5109
- * Warning: Deletion is irreversible and will affect any Apps currently using the Secret.
5110
- */
5111
- delete(name: string, params?: SecretDeleteParams): Promise<void>;
5112
- }
5113
- /** Secrets provide a dictionary of environment variables for {@link Image}s. */
5114
- declare class Secret {
5115
- readonly secretId: string;
5116
- readonly name?: string;
5117
- /** @ignore */
5118
- constructor(secretId: string, name?: string);
5119
- /**
5120
- * @deprecated Use {@link SecretService#fromName client.secrets.fromName()} instead.
5121
- */
5122
- static fromName(name: string, params?: SecretFromNameParams): Promise<Secret>;
5123
- /**
5124
- * @deprecated Use {@link SecretService#fromObject client.secrets.fromObject()} instead.
5125
- */
5126
- static fromObject(entries: Record<string, string>, params?: SecretFromObjectParams): Promise<Secret>;
5127
- }
5128
-
5129
5168
  /** Retry policy configuration for a Modal Function/Cls. */
5130
5169
  declare class Retries {
5131
5170
  readonly maxRetries: number;
@@ -5648,25 +5687,6 @@ interface ModalWriteStream<R = any> extends WritableStream<R> {
5648
5687
  writeBytes(bytes: Uint8Array): Promise<void>;
5649
5688
  }
5650
5689
 
5651
- /** Cloud Bucket Mounts provide access to cloud storage buckets within Modal Functions. */
5652
- declare class CloudBucketMount {
5653
- readonly bucketName: string;
5654
- readonly secret?: Secret;
5655
- readonly readOnly: boolean;
5656
- readonly requesterPays: boolean;
5657
- readonly bucketEndpointUrl?: string;
5658
- readonly keyPrefix?: string;
5659
- readonly oidcAuthRoleArn?: string;
5660
- constructor(bucketName: string, params?: {
5661
- secret?: Secret;
5662
- readOnly?: boolean;
5663
- requesterPays?: boolean;
5664
- bucketEndpointUrl?: string;
5665
- keyPrefix?: string;
5666
- oidcAuthRoleArn?: string;
5667
- });
5668
- }
5669
-
5670
5690
  /**
5671
5691
  * Stdin is always present, but this option allow you to drop stdout or stderr
5672
5692
  * if you don't need them. The default is "pipe", matching Node.js behavior.
@@ -5694,7 +5714,7 @@ type SandboxCreateParams = {
5694
5714
  gpu?: string;
5695
5715
  /** Timeout of the Sandbox container in milliseconds, defaults to 10 minutes. */
5696
5716
  timeoutMs?: number;
5697
- /** The amount of time in milliseconds that a sandbox can be idle before being terminated. */
5717
+ /** The amount of time in milliseconds that a Sandbox can be idle before being terminated. */
5698
5718
  idleTimeoutMs?: number;
5699
5719
  /** Working directory of the Sandbox. */
5700
5720
  workdir?: string;
@@ -5740,7 +5760,7 @@ type SandboxCreateParams = {
5740
5760
  * Normally only ever accessed via the client as:
5741
5761
  * ```typescript
5742
5762
  * const modal = new ModalClient();
5743
- * const sandbox = await modal.sandboxes.create(app, image);
5763
+ * const sb = await modal.sandboxes.create(app, image);
5744
5764
  * ```
5745
5765
  */
5746
5766
  declare class SandboxService {
@@ -5949,11 +5969,12 @@ type ModalGrpcClient = Client<typeof ModalClientDefinition, TimeoutOptions & Ret
5949
5969
  *
5950
5970
  * const app = await modal.apps.fromName("my-app");
5951
5971
  * const image = modal.images.fromRegistry("python:3.13");
5952
- * const sandbox = await modal.sandboxes.create(app, image);
5972
+ * const sb = await modal.sandboxes.create(app, image);
5953
5973
  * ```
5954
5974
  */
5955
5975
  declare class ModalClient {
5956
5976
  readonly apps: AppService;
5977
+ readonly cloudBucketMounts: CloudBucketMountService;
5957
5978
  readonly cls: ClsService;
5958
5979
  readonly functions: FunctionService;
5959
5980
  readonly functionCalls: FunctionCallService;
@@ -6118,4 +6139,4 @@ declare class SandboxTimeoutError extends Error {
6118
6139
 
6119
6140
  declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
6120
6141
 
6121
- export { AlreadyExistsError, App, type AppFromNameParams, AppService, type ClientOptions, CloudBucketMount, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ContainerProcess, type DeleteOptions, type EphemeralOptions, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, FunctionCallService, type FunctionFromNameParams, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, ImageService, InternalFailure, InvalidError, type LogLevel, type Logger, type LookupOptions, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, Retries, Sandbox, type SandboxCreateParams, type SandboxExecParams, SandboxFile, type SandboxFileMode, type SandboxFromNameParams, type SandboxListParams, SandboxService, SandboxTimeoutError, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, VolumeService, checkForRenamedParams, close, initializeClient };
6142
+ export { AlreadyExistsError, App, type AppFromNameParams, AppService, type ClientOptions, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ContainerProcess, type DeleteOptions, type EphemeralOptions, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, FunctionCallService, type FunctionFromNameParams, FunctionService, type FunctionStats, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, ImageService, InternalFailure, InvalidError, type LogLevel, type Logger, type LookupOptions, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, Retries, Sandbox, type SandboxCreateParams, type SandboxExecParams, SandboxFile, type SandboxFileMode, type SandboxFromNameParams, type SandboxListParams, SandboxService, SandboxTimeoutError, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, type StdioBehavior, type StreamMode, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, VolumeService, checkForRenamedParams, close, initializeClient };
package/dist/index.js CHANGED
@@ -43257,6 +43257,89 @@ import {
43257
43257
  Status as Status9
43258
43258
  } from "nice-grpc";
43259
43259
 
43260
+ // src/cloud_bucket_mount.ts
43261
+ var CloudBucketMountService = class {
43262
+ #client;
43263
+ constructor(client2) {
43264
+ this.#client = client2;
43265
+ }
43266
+ create(bucketName, params = {}) {
43267
+ let bucketType = 1 /* S3 */;
43268
+ if (params.bucketEndpointUrl) {
43269
+ const url = new URL(params.bucketEndpointUrl);
43270
+ if (url.hostname.endsWith("r2.cloudflarestorage.com")) {
43271
+ bucketType = 2 /* R2 */;
43272
+ } else if (url.hostname.endsWith("storage.googleapis.com")) {
43273
+ bucketType = 3 /* GCP */;
43274
+ } else {
43275
+ bucketType = 1 /* S3 */;
43276
+ this.#client.logger.debug(
43277
+ "CloudBucketMount received unrecognized bucket endpoint URL. Assuming AWS S3 configuration as fallback.",
43278
+ "bucketEndpointUrl",
43279
+ params.bucketEndpointUrl
43280
+ );
43281
+ }
43282
+ }
43283
+ if (params.requesterPays && !params.secret) {
43284
+ throw new Error("Credentials required in order to use Requester Pays.");
43285
+ }
43286
+ if (params.keyPrefix && !params.keyPrefix.endsWith("/")) {
43287
+ throw new Error(
43288
+ "keyPrefix will be prefixed to all object paths, so it must end in a '/'"
43289
+ );
43290
+ }
43291
+ return new CloudBucketMount2(
43292
+ bucketName,
43293
+ params.secret,
43294
+ params.readOnly ?? false,
43295
+ params.requesterPays ?? false,
43296
+ params.bucketEndpointUrl,
43297
+ params.keyPrefix,
43298
+ params.oidcAuthRoleArn,
43299
+ bucketType
43300
+ );
43301
+ }
43302
+ };
43303
+ var CloudBucketMount2 = class {
43304
+ bucketName;
43305
+ secret;
43306
+ readOnly;
43307
+ requesterPays;
43308
+ bucketEndpointUrl;
43309
+ keyPrefix;
43310
+ oidcAuthRoleArn;
43311
+ #bucketType;
43312
+ constructor(bucketName, secretOrParams, readOnly, requesterPays, bucketEndpointUrl, keyPrefix, oidcAuthRoleArn, bucketType) {
43313
+ if (bucketType !== void 0) {
43314
+ this.bucketName = bucketName;
43315
+ this.secret = secretOrParams;
43316
+ this.readOnly = readOnly;
43317
+ this.requesterPays = requesterPays;
43318
+ this.bucketEndpointUrl = bucketEndpointUrl;
43319
+ this.keyPrefix = keyPrefix;
43320
+ this.oidcAuthRoleArn = oidcAuthRoleArn;
43321
+ this.#bucketType = bucketType;
43322
+ } else {
43323
+ const params = secretOrParams === void 0 ? {} : secretOrParams;
43324
+ return getDefaultClient().cloudBucketMounts.create(bucketName, params);
43325
+ }
43326
+ }
43327
+ /** @ignore */
43328
+ toProto(mountPath) {
43329
+ return {
43330
+ bucketName: this.bucketName,
43331
+ mountPath,
43332
+ credentialsSecretId: this.secret?.secretId ?? "",
43333
+ readOnly: this.readOnly,
43334
+ bucketType: this.#bucketType,
43335
+ requesterPays: this.requesterPays,
43336
+ bucketEndpointUrl: this.bucketEndpointUrl,
43337
+ keyPrefix: this.keyPrefix,
43338
+ oidcAuthRoleArn: this.oidcAuthRoleArn
43339
+ };
43340
+ }
43341
+ };
43342
+
43260
43343
  // src/cls.ts
43261
43344
  import { ClientError as ClientError3, Status as Status3 } from "nice-grpc";
43262
43345
 
@@ -44157,7 +44240,8 @@ var Cls = class _Cls {
44157
44240
  const bindResp = await this.#client.cpClient.functionBindParams({
44158
44241
  functionId: this.#serviceFunctionId,
44159
44242
  serializedParams,
44160
- functionOptions
44243
+ functionOptions,
44244
+ environmentName: this.#client.environmentName()
44161
44245
  });
44162
44246
  return bindResp.boundFunctionId;
44163
44247
  }
@@ -45580,68 +45664,6 @@ async function consumeIterator(iter) {
45580
45664
  }
45581
45665
  }
45582
45666
 
45583
- // src/cloud_bucket_mount.ts
45584
- var CloudBucketMount2 = class {
45585
- bucketName;
45586
- secret;
45587
- readOnly;
45588
- requesterPays;
45589
- bucketEndpointUrl;
45590
- keyPrefix;
45591
- oidcAuthRoleArn;
45592
- constructor(bucketName, params = {}) {
45593
- this.bucketName = bucketName;
45594
- this.secret = params.secret;
45595
- this.readOnly = params.readOnly ?? false;
45596
- this.requesterPays = params.requesterPays ?? false;
45597
- this.bucketEndpointUrl = params.bucketEndpointUrl;
45598
- this.keyPrefix = params.keyPrefix;
45599
- this.oidcAuthRoleArn = params.oidcAuthRoleArn;
45600
- if (this.bucketEndpointUrl) {
45601
- const url = new URL(this.bucketEndpointUrl);
45602
- if (!url.hostname.endsWith("r2.cloudflarestorage.com") && !url.hostname.endsWith("storage.googleapis.com")) {
45603
- console.warn(
45604
- "CloudBucketMount received unrecognized bucket endpoint URL. Assuming AWS S3 configuration as fallback."
45605
- );
45606
- }
45607
- }
45608
- if (this.requesterPays && !this.secret) {
45609
- throw new Error("Credentials required in order to use Requester Pays.");
45610
- }
45611
- if (this.keyPrefix && !this.keyPrefix.endsWith("/")) {
45612
- throw new Error(
45613
- "keyPrefix will be prefixed to all object paths, so it must end in a '/'"
45614
- );
45615
- }
45616
- }
45617
- };
45618
- function endpointUrlToBucketType(bucketEndpointUrl) {
45619
- if (!bucketEndpointUrl) {
45620
- return 1 /* S3 */;
45621
- }
45622
- const url = new URL(bucketEndpointUrl);
45623
- if (url.hostname.endsWith("r2.cloudflarestorage.com")) {
45624
- return 2 /* R2 */;
45625
- } else if (url.hostname.endsWith("storage.googleapis.com")) {
45626
- return 3 /* GCP */;
45627
- } else {
45628
- return 1 /* S3 */;
45629
- }
45630
- }
45631
- function cloudBucketMountToProto(mount, mountPath) {
45632
- return {
45633
- bucketName: mount.bucketName,
45634
- mountPath,
45635
- credentialsSecretId: mount.secret?.secretId ?? "",
45636
- readOnly: mount.readOnly,
45637
- bucketType: endpointUrlToBucketType(mount.bucketEndpointUrl),
45638
- requesterPays: mount.requesterPays,
45639
- bucketEndpointUrl: mount.bucketEndpointUrl,
45640
- keyPrefix: mount.keyPrefix,
45641
- oidcAuthRoleArn: mount.oidcAuthRoleArn
45642
- };
45643
- }
45644
-
45645
45667
  // src/sandbox.ts
45646
45668
  async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45647
45669
  checkForRenamedParams(params, {
@@ -45671,32 +45693,38 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45671
45693
  readOnly: volume.isReadOnly
45672
45694
  })) : [];
45673
45695
  const cloudBucketMounts = params.cloudBucketMounts ? Object.entries(params.cloudBucketMounts).map(
45674
- ([mountPath, mount]) => cloudBucketMountToProto(mount, mountPath)
45696
+ ([mountPath, mount]) => mount.toProto(mountPath)
45675
45697
  ) : [];
45676
45698
  const openPorts = [];
45677
45699
  if (params.encryptedPorts) {
45678
45700
  openPorts.push(
45679
- ...params.encryptedPorts.map((port) => ({
45680
- port,
45681
- unencrypted: false
45682
- }))
45701
+ ...params.encryptedPorts.map(
45702
+ (port) => PortSpec.create({
45703
+ port,
45704
+ unencrypted: false
45705
+ })
45706
+ )
45683
45707
  );
45684
45708
  }
45685
45709
  if (params.h2Ports) {
45686
45710
  openPorts.push(
45687
- ...params.h2Ports.map((port) => ({
45688
- port,
45689
- unencrypted: false,
45690
- tunnelType: 1 /* TUNNEL_TYPE_H2 */
45691
- }))
45711
+ ...params.h2Ports.map(
45712
+ (port) => PortSpec.create({
45713
+ port,
45714
+ unencrypted: false,
45715
+ tunnelType: 1 /* TUNNEL_TYPE_H2 */
45716
+ })
45717
+ )
45692
45718
  );
45693
45719
  }
45694
45720
  if (params.unencryptedPorts) {
45695
45721
  openPorts.push(
45696
- ...params.unencryptedPorts.map((port) => ({
45697
- port,
45698
- unencrypted: true
45699
- }))
45722
+ ...params.unencryptedPorts.map(
45723
+ (port) => PortSpec.create({
45724
+ port,
45725
+ unencrypted: true
45726
+ })
45727
+ )
45700
45728
  );
45701
45729
  }
45702
45730
  const secretIds = (params.secrets || []).map((secret) => secret.secretId);
@@ -45722,9 +45750,9 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45722
45750
  allowedCidrs: []
45723
45751
  };
45724
45752
  }
45725
- const schedulerPlacement = SchedulerPlacement.create({
45726
- regions: params.regions ?? []
45727
- });
45753
+ const schedulerPlacement = params.regions?.length ? SchedulerPlacement.create({
45754
+ regions: params.regions
45755
+ }) : void 0;
45728
45756
  let ptyInfo;
45729
45757
  if (params.pty) {
45730
45758
  ptyInfo = defaultSandboxPTYInfo();
@@ -45781,18 +45809,18 @@ async function buildSandboxCreateRequestProto(appId, imageId, params = {}) {
45781
45809
  idleTimeoutSecs: params.idleTimeoutMs != void 0 ? params.idleTimeoutMs / 1e3 : void 0,
45782
45810
  workdir: params.workdir ?? void 0,
45783
45811
  networkAccess,
45784
- resources: {
45812
+ resources: Resources.create({
45785
45813
  milliCpu,
45786
45814
  milliCpuMax,
45787
45815
  memoryMb,
45788
45816
  memoryMbMax,
45789
45817
  gpuConfig
45790
- },
45818
+ }),
45791
45819
  volumeMounts,
45792
45820
  cloudBucketMounts,
45793
45821
  ptyInfo,
45794
45822
  secretIds,
45795
- openPorts: openPorts.length > 0 ? { ports: openPorts } : void 0,
45823
+ openPorts: PortSpecs.create({ ports: openPorts }),
45796
45824
  cloudProviderStr: params.cloud ?? "",
45797
45825
  schedulerPlacement,
45798
45826
  verbose: params.verbose ?? false,
@@ -46708,7 +46736,7 @@ var AuthTokenManager = class {
46708
46736
 
46709
46737
  // src/version.ts
46710
46738
  function getSDKVersion() {
46711
- return true ? "0.5.4" : "0.0.0";
46739
+ return true ? "0.5.5" : "0.0.0";
46712
46740
  }
46713
46741
 
46714
46742
  // src/logger.ts
@@ -46818,8 +46846,9 @@ function createLogger(logger, logLevel = "") {
46818
46846
  }
46819
46847
 
46820
46848
  // src/client.ts
46821
- var ModalClient = class {
46849
+ var ModalClient2 = class {
46822
46850
  apps;
46851
+ cloudBucketMounts;
46823
46852
  cls;
46824
46853
  functions;
46825
46854
  functionCalls;
@@ -46859,6 +46888,7 @@ var ModalClient = class {
46859
46888
  this.cpClient = params?.cpClient ?? this.createClient(this.profile);
46860
46889
  this.logger.debug("Modal client initialized successfully");
46861
46890
  this.apps = new AppService(this);
46891
+ this.cloudBucketMounts = new CloudBucketMountService(this);
46862
46892
  this.cls = new ClsService(this);
46863
46893
  this.functions = new FunctionService(this);
46864
46894
  this.functionCalls = new FunctionCallService(this);
@@ -47092,7 +47122,7 @@ var defaultClient;
47092
47122
  var defaultClientOptions;
47093
47123
  function getDefaultClient() {
47094
47124
  if (!defaultClient) {
47095
- defaultClient = new ModalClient(defaultClientOptions);
47125
+ defaultClient = new ModalClient2(defaultClientOptions);
47096
47126
  }
47097
47127
  return defaultClient;
47098
47128
  }
@@ -47107,7 +47137,7 @@ function initializeClient(options) {
47107
47137
  tokenSecret: options.tokenSecret,
47108
47138
  environment: options.environment
47109
47139
  };
47110
- defaultClient = new ModalClient(defaultClientOptions);
47140
+ defaultClient = new ModalClient2(defaultClientOptions);
47111
47141
  }
47112
47142
  function close() {
47113
47143
  if (defaultClient) {
@@ -47148,7 +47178,7 @@ var AppService = class {
47148
47178
  };
47149
47179
  function parseGpuConfig(gpu) {
47150
47180
  if (!gpu) {
47151
- return void 0;
47181
+ return GPUConfig.create({});
47152
47182
  }
47153
47183
  let gpuType = gpu;
47154
47184
  let count = 1;
@@ -47162,12 +47192,10 @@ function parseGpuConfig(gpu) {
47162
47192
  );
47163
47193
  }
47164
47194
  }
47165
- return {
47166
- type: 0,
47167
- // Deprecated field, but required by proto
47195
+ return GPUConfig.create({
47168
47196
  count,
47169
47197
  gpuType: gpuType.toUpperCase()
47170
- };
47198
+ });
47171
47199
  }
47172
47200
  var App2 = class {
47173
47201
  appId;
@@ -47180,6 +47208,7 @@ var App2 = class {
47180
47208
  /**
47181
47209
  * @deprecated Use {@link AppService#fromName client.apps.fromName()} instead.
47182
47210
  */
47211
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
47183
47212
  static async lookup(name, options = {}) {
47184
47213
  return getDefaultClient().apps.fromName(name, options);
47185
47214
  }
@@ -47213,6 +47242,7 @@ export {
47213
47242
  App2 as App,
47214
47243
  AppService,
47215
47244
  CloudBucketMount2 as CloudBucketMount,
47245
+ CloudBucketMountService,
47216
47246
  Cls,
47217
47247
  ClsInstance,
47218
47248
  ClsService,
@@ -47226,7 +47256,7 @@ export {
47226
47256
  ImageService,
47227
47257
  InternalFailure,
47228
47258
  InvalidError,
47229
- ModalClient,
47259
+ ModalClient2 as ModalClient,
47230
47260
  NotFoundError,
47231
47261
  Proxy3 as Proxy,
47232
47262
  ProxyService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modal",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Modal SDK for JavaScript/TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://modal.com/docs/guide/sdk-javascript-go",