modal 0.3.18 → 0.3.20
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 +173 -74
- package/dist/index.d.cts +78 -74
- package/dist/index.d.ts +78 -74
- package/dist/index.js +173 -74
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -59,7 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
module.exports = __toCommonJS(index_exports);
|
|
60
60
|
|
|
61
61
|
// src/app.ts
|
|
62
|
-
var
|
|
62
|
+
var import_nice_grpc6 = require("nice-grpc");
|
|
63
63
|
|
|
64
64
|
// node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js
|
|
65
65
|
function varint64read() {
|
|
@@ -19689,7 +19689,8 @@ function createBaseFunctionHandleMetadata() {
|
|
|
19689
19689
|
functionSchema: void 0,
|
|
19690
19690
|
inputPlaneUrl: void 0,
|
|
19691
19691
|
inputPlaneRegion: void 0,
|
|
19692
|
-
maxObjectSizeBytes: void 0
|
|
19692
|
+
maxObjectSizeBytes: void 0,
|
|
19693
|
+
ExperimentalFlashUrls: []
|
|
19693
19694
|
};
|
|
19694
19695
|
}
|
|
19695
19696
|
var FunctionHandleMetadata = {
|
|
@@ -19733,6 +19734,9 @@ var FunctionHandleMetadata = {
|
|
|
19733
19734
|
if (message.maxObjectSizeBytes !== void 0) {
|
|
19734
19735
|
writer.uint32(384).uint64(message.maxObjectSizeBytes);
|
|
19735
19736
|
}
|
|
19737
|
+
for (const v of message.ExperimentalFlashUrls) {
|
|
19738
|
+
writer.uint32(394).string(v);
|
|
19739
|
+
}
|
|
19736
19740
|
return writer;
|
|
19737
19741
|
},
|
|
19738
19742
|
decode(input, length) {
|
|
@@ -19836,6 +19840,13 @@ var FunctionHandleMetadata = {
|
|
|
19836
19840
|
message.maxObjectSizeBytes = longToNumber(reader.uint64());
|
|
19837
19841
|
continue;
|
|
19838
19842
|
}
|
|
19843
|
+
case 49: {
|
|
19844
|
+
if (tag !== 394) {
|
|
19845
|
+
break;
|
|
19846
|
+
}
|
|
19847
|
+
message.ExperimentalFlashUrls.push(reader.string());
|
|
19848
|
+
continue;
|
|
19849
|
+
}
|
|
19839
19850
|
}
|
|
19840
19851
|
if ((tag & 7) === 4 || tag === 0) {
|
|
19841
19852
|
break;
|
|
@@ -19864,7 +19875,8 @@ var FunctionHandleMetadata = {
|
|
|
19864
19875
|
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0,
|
|
19865
19876
|
inputPlaneUrl: isSet3(object.inputPlaneUrl) ? globalThis.String(object.inputPlaneUrl) : void 0,
|
|
19866
19877
|
inputPlaneRegion: isSet3(object.inputPlaneRegion) ? globalThis.String(object.inputPlaneRegion) : void 0,
|
|
19867
|
-
maxObjectSizeBytes: isSet3(object.maxObjectSizeBytes) ? globalThis.Number(object.maxObjectSizeBytes) : void 0
|
|
19878
|
+
maxObjectSizeBytes: isSet3(object.maxObjectSizeBytes) ? globalThis.Number(object.maxObjectSizeBytes) : void 0,
|
|
19879
|
+
ExperimentalFlashUrls: globalThis.Array.isArray(object?.ExperimentalFlashUrls) ? object.ExperimentalFlashUrls.map((e) => globalThis.String(e)) : []
|
|
19868
19880
|
};
|
|
19869
19881
|
},
|
|
19870
19882
|
toJSON(message) {
|
|
@@ -19914,6 +19926,9 @@ var FunctionHandleMetadata = {
|
|
|
19914
19926
|
if (message.maxObjectSizeBytes !== void 0) {
|
|
19915
19927
|
obj.maxObjectSizeBytes = Math.round(message.maxObjectSizeBytes);
|
|
19916
19928
|
}
|
|
19929
|
+
if (message.ExperimentalFlashUrls?.length) {
|
|
19930
|
+
obj.ExperimentalFlashUrls = message.ExperimentalFlashUrls;
|
|
19931
|
+
}
|
|
19917
19932
|
return obj;
|
|
19918
19933
|
},
|
|
19919
19934
|
create(base) {
|
|
@@ -19939,6 +19954,7 @@ var FunctionHandleMetadata = {
|
|
|
19939
19954
|
message.inputPlaneUrl = object.inputPlaneUrl ?? void 0;
|
|
19940
19955
|
message.inputPlaneRegion = object.inputPlaneRegion ?? void 0;
|
|
19941
19956
|
message.maxObjectSizeBytes = object.maxObjectSizeBytes ?? void 0;
|
|
19957
|
+
message.ExperimentalFlashUrls = object.ExperimentalFlashUrls?.map((e) => e) || [];
|
|
19942
19958
|
return message;
|
|
19943
19959
|
}
|
|
19944
19960
|
};
|
|
@@ -23001,6 +23017,57 @@ var ImageContextFile = {
|
|
|
23001
23017
|
return message;
|
|
23002
23018
|
}
|
|
23003
23019
|
};
|
|
23020
|
+
function createBaseImageDeleteRequest() {
|
|
23021
|
+
return { imageId: "" };
|
|
23022
|
+
}
|
|
23023
|
+
var ImageDeleteRequest = {
|
|
23024
|
+
encode(message, writer = new BinaryWriter()) {
|
|
23025
|
+
if (message.imageId !== "") {
|
|
23026
|
+
writer.uint32(10).string(message.imageId);
|
|
23027
|
+
}
|
|
23028
|
+
return writer;
|
|
23029
|
+
},
|
|
23030
|
+
decode(input, length) {
|
|
23031
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
23032
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
23033
|
+
const message = createBaseImageDeleteRequest();
|
|
23034
|
+
while (reader.pos < end) {
|
|
23035
|
+
const tag = reader.uint32();
|
|
23036
|
+
switch (tag >>> 3) {
|
|
23037
|
+
case 1: {
|
|
23038
|
+
if (tag !== 10) {
|
|
23039
|
+
break;
|
|
23040
|
+
}
|
|
23041
|
+
message.imageId = reader.string();
|
|
23042
|
+
continue;
|
|
23043
|
+
}
|
|
23044
|
+
}
|
|
23045
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
23046
|
+
break;
|
|
23047
|
+
}
|
|
23048
|
+
reader.skip(tag & 7);
|
|
23049
|
+
}
|
|
23050
|
+
return message;
|
|
23051
|
+
},
|
|
23052
|
+
fromJSON(object) {
|
|
23053
|
+
return { imageId: isSet3(object.imageId) ? globalThis.String(object.imageId) : "" };
|
|
23054
|
+
},
|
|
23055
|
+
toJSON(message) {
|
|
23056
|
+
const obj = {};
|
|
23057
|
+
if (message.imageId !== "") {
|
|
23058
|
+
obj.imageId = message.imageId;
|
|
23059
|
+
}
|
|
23060
|
+
return obj;
|
|
23061
|
+
},
|
|
23062
|
+
create(base) {
|
|
23063
|
+
return ImageDeleteRequest.fromPartial(base ?? {});
|
|
23064
|
+
},
|
|
23065
|
+
fromPartial(object) {
|
|
23066
|
+
const message = createBaseImageDeleteRequest();
|
|
23067
|
+
message.imageId = object.imageId ?? "";
|
|
23068
|
+
return message;
|
|
23069
|
+
}
|
|
23070
|
+
};
|
|
23004
23071
|
function createBaseImageFromIdRequest() {
|
|
23005
23072
|
return { imageId: "" };
|
|
23006
23073
|
}
|
|
@@ -40438,6 +40505,14 @@ var ModalClientDefinition = {
|
|
|
40438
40505
|
options: {}
|
|
40439
40506
|
},
|
|
40440
40507
|
/** Images */
|
|
40508
|
+
imageDelete: {
|
|
40509
|
+
name: "ImageDelete",
|
|
40510
|
+
requestType: ImageDeleteRequest,
|
|
40511
|
+
requestStream: false,
|
|
40512
|
+
responseType: Empty,
|
|
40513
|
+
responseStream: false,
|
|
40514
|
+
options: {}
|
|
40515
|
+
},
|
|
40441
40516
|
imageFromId: {
|
|
40442
40517
|
name: "ImageFromId",
|
|
40443
40518
|
requestType: ImageFromIdRequest,
|
|
@@ -41482,6 +41557,8 @@ var Secret = class _Secret {
|
|
|
41482
41557
|
};
|
|
41483
41558
|
|
|
41484
41559
|
// src/image.ts
|
|
41560
|
+
var import_nice_grpc3 = require("nice-grpc");
|
|
41561
|
+
var import_nice_grpc4 = require("nice-grpc");
|
|
41485
41562
|
var Image2 = class _Image {
|
|
41486
41563
|
#imageId;
|
|
41487
41564
|
#tag;
|
|
@@ -41496,18 +41573,27 @@ var Image2 = class _Image {
|
|
|
41496
41573
|
return this.#imageId;
|
|
41497
41574
|
}
|
|
41498
41575
|
/**
|
|
41499
|
-
* Creates an
|
|
41576
|
+
* Creates an Image from an Image ID
|
|
41500
41577
|
*
|
|
41501
|
-
* @param imageId - Image
|
|
41578
|
+
* @param imageId - Image ID.
|
|
41502
41579
|
*/
|
|
41503
|
-
static fromId(imageId) {
|
|
41504
|
-
|
|
41580
|
+
static async fromId(imageId) {
|
|
41581
|
+
try {
|
|
41582
|
+
const resp = await client.imageFromId({ imageId });
|
|
41583
|
+
return new _Image(resp.imageId, "");
|
|
41584
|
+
} catch (err) {
|
|
41585
|
+
if (err instanceof import_nice_grpc3.ClientError && err.code === import_nice_grpc4.Status.NOT_FOUND)
|
|
41586
|
+
throw new NotFoundError(err.details);
|
|
41587
|
+
if (err instanceof import_nice_grpc3.ClientError && err.code === import_nice_grpc4.Status.FAILED_PRECONDITION && err.details.includes("Could not find image with ID"))
|
|
41588
|
+
throw new NotFoundError(err.details);
|
|
41589
|
+
throw err;
|
|
41590
|
+
}
|
|
41505
41591
|
}
|
|
41506
41592
|
/**
|
|
41507
|
-
* Creates an
|
|
41593
|
+
* Creates an Image from a raw registry tag, optionally using a Secret for authentication.
|
|
41508
41594
|
*
|
|
41509
|
-
* @param tag - The registry tag for the
|
|
41510
|
-
* @param secret - Optional. A
|
|
41595
|
+
* @param tag - The registry tag for the Image.
|
|
41596
|
+
* @param secret - Optional. A Secret containing credentials for registry authentication.
|
|
41511
41597
|
*/
|
|
41512
41598
|
static fromRegistry(tag, secret) {
|
|
41513
41599
|
let imageRegistryConfig;
|
|
@@ -41525,10 +41611,10 @@ var Image2 = class _Image {
|
|
|
41525
41611
|
return new _Image("", tag, imageRegistryConfig);
|
|
41526
41612
|
}
|
|
41527
41613
|
/**
|
|
41528
|
-
* Creates an
|
|
41614
|
+
* Creates an Image from a raw registry tag, optionally using a Secret for authentication.
|
|
41529
41615
|
*
|
|
41530
|
-
* @param tag - The registry tag for the
|
|
41531
|
-
* @param secret - A
|
|
41616
|
+
* @param tag - The registry tag for the Image.
|
|
41617
|
+
* @param secret - A Secret containing credentials for registry authentication.
|
|
41532
41618
|
*/
|
|
41533
41619
|
static fromAwsEcr(tag, secret) {
|
|
41534
41620
|
let imageRegistryConfig;
|
|
@@ -41546,10 +41632,10 @@ var Image2 = class _Image {
|
|
|
41546
41632
|
return new _Image("", tag, imageRegistryConfig);
|
|
41547
41633
|
}
|
|
41548
41634
|
/**
|
|
41549
|
-
* Creates an
|
|
41635
|
+
* Creates an Image from a raw registry tag, optionally using a Secret for authentication.
|
|
41550
41636
|
*
|
|
41551
|
-
* @param tag - The registry tag for the
|
|
41552
|
-
* @param secret - A
|
|
41637
|
+
* @param tag - The registry tag for the Image.
|
|
41638
|
+
* @param secret - A Secret containing credentials for registry authentication.
|
|
41553
41639
|
*/
|
|
41554
41640
|
static fromGcpArtifactRegistry(tag, secret) {
|
|
41555
41641
|
let imageRegistryConfig;
|
|
@@ -41567,9 +41653,9 @@ var Image2 = class _Image {
|
|
|
41567
41653
|
return new _Image("", tag, imageRegistryConfig);
|
|
41568
41654
|
}
|
|
41569
41655
|
/**
|
|
41570
|
-
* Eagerly builds an
|
|
41656
|
+
* Eagerly builds an Image on Modal.
|
|
41571
41657
|
*
|
|
41572
|
-
* @param app - App to use to build
|
|
41658
|
+
* @param app - App to use to build the Image.
|
|
41573
41659
|
*/
|
|
41574
41660
|
async build(app) {
|
|
41575
41661
|
if (this.imageId !== "") {
|
|
@@ -41629,10 +41715,15 @@ ${result.exception}`
|
|
|
41629
41715
|
this.#imageId = resp.imageId;
|
|
41630
41716
|
return this;
|
|
41631
41717
|
}
|
|
41718
|
+
/** Delete an Image by ID. Warning: This removes an *entire Image*, and cannot be undone. */
|
|
41719
|
+
static async delete(imageId, _ = {}) {
|
|
41720
|
+
const image = await _Image.fromId(imageId);
|
|
41721
|
+
await client.imageDelete({ imageId: image.imageId });
|
|
41722
|
+
}
|
|
41632
41723
|
};
|
|
41633
41724
|
|
|
41634
41725
|
// src/sandbox.ts
|
|
41635
|
-
var
|
|
41726
|
+
var import_nice_grpc5 = require("nice-grpc");
|
|
41636
41727
|
|
|
41637
41728
|
// src/sandbox_filesystem.ts
|
|
41638
41729
|
var SandboxFile = class {
|
|
@@ -41910,7 +42001,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
41910
42001
|
tags: tagsList
|
|
41911
42002
|
});
|
|
41912
42003
|
} catch (err) {
|
|
41913
|
-
if (err instanceof
|
|
42004
|
+
if (err instanceof import_nice_grpc5.ClientError && err.code === import_nice_grpc5.Status.INVALID_ARGUMENT) {
|
|
41914
42005
|
throw new InvalidError(err.details || err.message);
|
|
41915
42006
|
}
|
|
41916
42007
|
throw err;
|
|
@@ -41927,7 +42018,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
41927
42018
|
timeout: 0
|
|
41928
42019
|
});
|
|
41929
42020
|
} catch (err) {
|
|
41930
|
-
if (err instanceof
|
|
42021
|
+
if (err instanceof import_nice_grpc5.ClientError && err.code === import_nice_grpc5.Status.NOT_FOUND)
|
|
41931
42022
|
throw new NotFoundError(`Sandbox with id: '${sandboxId}' not found`);
|
|
41932
42023
|
throw err;
|
|
41933
42024
|
}
|
|
@@ -41938,8 +42029,8 @@ var Sandbox2 = class _Sandbox {
|
|
|
41938
42029
|
* Raises a NotFoundError if no running Sandbox is found with the given name.
|
|
41939
42030
|
* A Sandbox's name is the `name` argument passed to `App.createSandbox`.
|
|
41940
42031
|
*
|
|
41941
|
-
* @param appName - Name of the deployed
|
|
41942
|
-
* @param name - Name of the
|
|
42032
|
+
* @param appName - Name of the deployed App
|
|
42033
|
+
* @param name - Name of the Sandbox
|
|
41943
42034
|
* @param environment - Optional override for the environment
|
|
41944
42035
|
* @returns Promise that resolves to a Sandbox
|
|
41945
42036
|
*/
|
|
@@ -41952,15 +42043,15 @@ var Sandbox2 = class _Sandbox {
|
|
|
41952
42043
|
});
|
|
41953
42044
|
return new _Sandbox(resp.sandboxId);
|
|
41954
42045
|
} catch (err) {
|
|
41955
|
-
if (err instanceof
|
|
42046
|
+
if (err instanceof import_nice_grpc5.ClientError && err.code === import_nice_grpc5.Status.NOT_FOUND)
|
|
41956
42047
|
throw new NotFoundError(
|
|
41957
|
-
`Sandbox with name '${name}' not found in
|
|
42048
|
+
`Sandbox with name '${name}' not found in App '${appName}'`
|
|
41958
42049
|
);
|
|
41959
42050
|
throw err;
|
|
41960
42051
|
}
|
|
41961
42052
|
}
|
|
41962
42053
|
/**
|
|
41963
|
-
* Open a file in the
|
|
42054
|
+
* Open a file in the Sandbox filesystem.
|
|
41964
42055
|
* @param path - Path to the file to open
|
|
41965
42056
|
* @param mode - File open mode (r, w, a, r+, w+, a+)
|
|
41966
42057
|
* @returns Promise that resolves to a SandboxFile
|
|
@@ -42023,7 +42114,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
42023
42114
|
}
|
|
42024
42115
|
}
|
|
42025
42116
|
}
|
|
42026
|
-
/** Get Tunnel metadata for the
|
|
42117
|
+
/** Get Tunnel metadata for the Sandbox.
|
|
42027
42118
|
*
|
|
42028
42119
|
* Raises `SandboxTimeoutError` if the tunnels are not available after the timeout.
|
|
42029
42120
|
*
|
|
@@ -42071,7 +42162,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
42071
42162
|
);
|
|
42072
42163
|
}
|
|
42073
42164
|
if (!resp.imageId) {
|
|
42074
|
-
throw new Error("Sandbox snapshot response missing
|
|
42165
|
+
throw new Error("Sandbox snapshot response missing `imageId`");
|
|
42075
42166
|
}
|
|
42076
42167
|
return new Image2(resp.imageId, "");
|
|
42077
42168
|
}
|
|
@@ -42115,7 +42206,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
42115
42206
|
}
|
|
42116
42207
|
beforeTimestamp = resp.sandboxes[resp.sandboxes.length - 1].createdAt;
|
|
42117
42208
|
} catch (err) {
|
|
42118
|
-
if (err instanceof
|
|
42209
|
+
if (err instanceof import_nice_grpc5.ClientError && err.code === import_nice_grpc5.Status.INVALID_ARGUMENT) {
|
|
42119
42210
|
throw new InvalidError(err.details || err.message);
|
|
42120
42211
|
}
|
|
42121
42212
|
throw err;
|
|
@@ -42381,7 +42472,7 @@ var App = class _App {
|
|
|
42381
42472
|
this.appId = appId;
|
|
42382
42473
|
this.name = name;
|
|
42383
42474
|
}
|
|
42384
|
-
/** Lookup a deployed
|
|
42475
|
+
/** Lookup a deployed App by name, or create if it does not exist. */
|
|
42385
42476
|
static async lookup(name, options = {}) {
|
|
42386
42477
|
try {
|
|
42387
42478
|
const resp = await client.appGetOrCreate({
|
|
@@ -42391,7 +42482,7 @@ var App = class _App {
|
|
|
42391
42482
|
});
|
|
42392
42483
|
return new _App(resp.appId, name);
|
|
42393
42484
|
} catch (err) {
|
|
42394
|
-
if (err instanceof
|
|
42485
|
+
if (err instanceof import_nice_grpc6.ClientError && err.code === import_nice_grpc6.Status.NOT_FOUND)
|
|
42395
42486
|
throw new NotFoundError(`App '${name}' not found`);
|
|
42396
42487
|
throw err;
|
|
42397
42488
|
}
|
|
@@ -42499,7 +42590,7 @@ var App = class _App {
|
|
|
42499
42590
|
}
|
|
42500
42591
|
});
|
|
42501
42592
|
} catch (err) {
|
|
42502
|
-
if (err instanceof
|
|
42593
|
+
if (err instanceof import_nice_grpc6.ClientError && err.code === import_nice_grpc6.Status.ALREADY_EXISTS) {
|
|
42503
42594
|
throw new AlreadyExistsError(err.details || err.message);
|
|
42504
42595
|
}
|
|
42505
42596
|
throw err;
|
|
@@ -42527,7 +42618,7 @@ var App = class _App {
|
|
|
42527
42618
|
};
|
|
42528
42619
|
|
|
42529
42620
|
// src/cls.ts
|
|
42530
|
-
var
|
|
42621
|
+
var import_nice_grpc8 = require("nice-grpc");
|
|
42531
42622
|
|
|
42532
42623
|
// src/function.ts
|
|
42533
42624
|
var import_node_crypto = require("crypto");
|
|
@@ -42693,7 +42784,9 @@ function encodeValue(val, w, proto) {
|
|
|
42693
42784
|
}
|
|
42694
42785
|
return;
|
|
42695
42786
|
}
|
|
42696
|
-
throw new PickleError(
|
|
42787
|
+
throw new PickleError(
|
|
42788
|
+
`The JS Modal SDK does not support encoding/pickling data of type ${typeof val}`
|
|
42789
|
+
);
|
|
42697
42790
|
}
|
|
42698
42791
|
function maybeMemoize(w, proto) {
|
|
42699
42792
|
if (proto >= 4) {
|
|
@@ -42702,7 +42795,9 @@ function maybeMemoize(w, proto) {
|
|
|
42702
42795
|
}
|
|
42703
42796
|
function dumps(obj, protocol = 4) {
|
|
42704
42797
|
if (![3, 4, 5].includes(protocol))
|
|
42705
|
-
throw new PickleError(
|
|
42798
|
+
throw new PickleError(
|
|
42799
|
+
`The JS Modal SDK does not support pickle protocol version ${protocol}`
|
|
42800
|
+
);
|
|
42706
42801
|
const w = new Writer();
|
|
42707
42802
|
w.byte(128 /* PROTO */);
|
|
42708
42803
|
w.byte(protocol);
|
|
@@ -42719,8 +42814,10 @@ function loads(buf) {
|
|
|
42719
42814
|
const op0 = r.byte();
|
|
42720
42815
|
if (op0 !== 128 /* PROTO */) throw new PickleError("pickle missing PROTO header");
|
|
42721
42816
|
const proto = r.byte();
|
|
42722
|
-
if (!
|
|
42723
|
-
throw new PickleError(
|
|
42817
|
+
if (![3, 4, 5].includes(proto))
|
|
42818
|
+
throw new PickleError(
|
|
42819
|
+
`The JS Modal SDK does not support pickle protocol version ${proto}`
|
|
42820
|
+
);
|
|
42724
42821
|
const stack = [];
|
|
42725
42822
|
const memo = [];
|
|
42726
42823
|
const tdec = new TextDecoder();
|
|
@@ -42873,7 +42970,9 @@ function loads(buf) {
|
|
|
42873
42970
|
break;
|
|
42874
42971
|
}
|
|
42875
42972
|
default:
|
|
42876
|
-
throw new PickleError(
|
|
42973
|
+
throw new PickleError(
|
|
42974
|
+
`The JS Modal SDK does not support decoding/unpickling this kind of data. Error: unsupported opcode 0x${op.toString(16)}`
|
|
42975
|
+
);
|
|
42877
42976
|
}
|
|
42878
42977
|
}
|
|
42879
42978
|
throw new PickleError("pickle stream ended without STOP");
|
|
@@ -42933,7 +43032,7 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
42933
43032
|
}
|
|
42934
43033
|
async retry(retryCount) {
|
|
42935
43034
|
if (!this.input) {
|
|
42936
|
-
throw new Error("Cannot retry
|
|
43035
|
+
throw new Error("Cannot retry Function invocation - input missing");
|
|
42937
43036
|
}
|
|
42938
43037
|
const retryItem = {
|
|
42939
43038
|
inputJwt: this.inputJwt,
|
|
@@ -43076,11 +43175,11 @@ var FunctionCall = class _FunctionCall {
|
|
|
43076
43175
|
constructor(functionCallId) {
|
|
43077
43176
|
this.functionCallId = functionCallId;
|
|
43078
43177
|
}
|
|
43079
|
-
/** Create a new
|
|
43178
|
+
/** Create a new Function call from ID. */
|
|
43080
43179
|
fromId(functionCallId) {
|
|
43081
43180
|
return new _FunctionCall(functionCallId);
|
|
43082
43181
|
}
|
|
43083
|
-
/** Get the result of a
|
|
43182
|
+
/** Get the result of a Function call, optionally waiting with a timeout. */
|
|
43084
43183
|
async get(options = {}) {
|
|
43085
43184
|
const timeout = options.timeout;
|
|
43086
43185
|
const invocation = ControlPlaneInvocation.fromFunctionCallId(
|
|
@@ -43088,7 +43187,7 @@ var FunctionCall = class _FunctionCall {
|
|
|
43088
43187
|
);
|
|
43089
43188
|
return invocation.awaitOutput(timeout);
|
|
43090
43189
|
}
|
|
43091
|
-
/** Cancel a running
|
|
43190
|
+
/** Cancel a running Function call. */
|
|
43092
43191
|
async cancel(options = {}) {
|
|
43093
43192
|
await client.functionCallCancel({
|
|
43094
43193
|
functionCallId: this.functionCallId,
|
|
@@ -43098,7 +43197,7 @@ var FunctionCall = class _FunctionCall {
|
|
|
43098
43197
|
};
|
|
43099
43198
|
|
|
43100
43199
|
// src/function.ts
|
|
43101
|
-
var
|
|
43200
|
+
var import_nice_grpc7 = require("nice-grpc");
|
|
43102
43201
|
var maxObjectSizeBytes = 2 * 1024 * 1024;
|
|
43103
43202
|
var maxSystemRetries = 8;
|
|
43104
43203
|
var Function_ = class _Function_ {
|
|
@@ -43127,7 +43226,7 @@ var Function_ = class _Function_ {
|
|
|
43127
43226
|
resp.handleMetadata?.webUrl
|
|
43128
43227
|
);
|
|
43129
43228
|
} catch (err) {
|
|
43130
|
-
if (err instanceof
|
|
43229
|
+
if (err instanceof import_nice_grpc7.ClientError && err.code === import_nice_grpc7.Status.NOT_FOUND)
|
|
43131
43230
|
throw new NotFoundError(`Function '${appName}/${name}' not found`);
|
|
43132
43231
|
throw err;
|
|
43133
43232
|
}
|
|
@@ -43164,7 +43263,7 @@ var Function_ = class _Function_ {
|
|
|
43164
43263
|
4 /* FUNCTION_CALL_INVOCATION_TYPE_SYNC */
|
|
43165
43264
|
);
|
|
43166
43265
|
}
|
|
43167
|
-
// Spawn a single input into a remote
|
|
43266
|
+
// Spawn a single input into a remote Function.
|
|
43168
43267
|
async spawn(args = [], kwargs = {}) {
|
|
43169
43268
|
const input = await this.#createInput(args, kwargs);
|
|
43170
43269
|
const invocation = await ControlPlaneInvocation.create(
|
|
@@ -43201,7 +43300,7 @@ var Function_ = class _Function_ {
|
|
|
43201
43300
|
}
|
|
43202
43301
|
/**
|
|
43203
43302
|
* URL of a Function running as a web endpoint.
|
|
43204
|
-
* @returns The web URL if this
|
|
43303
|
+
* @returns The web URL if this Function is a web endpoint, otherwise undefined
|
|
43205
43304
|
*/
|
|
43206
43305
|
async getWebUrl() {
|
|
43207
43306
|
return this.#webUrl || void 0;
|
|
@@ -43359,7 +43458,7 @@ var Cls = class _Cls {
|
|
|
43359
43458
|
void 0
|
|
43360
43459
|
);
|
|
43361
43460
|
} catch (err) {
|
|
43362
|
-
if (err instanceof
|
|
43461
|
+
if (err instanceof import_nice_grpc8.ClientError && err.code === import_nice_grpc8.Status.NOT_FOUND)
|
|
43363
43462
|
throw new NotFoundError(`Class '${appName}/${name}' not found`);
|
|
43364
43463
|
throw err;
|
|
43365
43464
|
}
|
|
@@ -43555,7 +43654,7 @@ var ClsInstance = class {
|
|
|
43555
43654
|
};
|
|
43556
43655
|
|
|
43557
43656
|
// src/queue.ts
|
|
43558
|
-
var
|
|
43657
|
+
var import_nice_grpc9 = require("nice-grpc");
|
|
43559
43658
|
|
|
43560
43659
|
// src/ephemeral.ts
|
|
43561
43660
|
var ephemeralObjectHeartbeatSleep = 3e5;
|
|
@@ -43614,8 +43713,8 @@ var Queue = class _Queue {
|
|
|
43614
43713
|
return new Uint8Array();
|
|
43615
43714
|
}
|
|
43616
43715
|
/**
|
|
43617
|
-
* Create a nameless, temporary
|
|
43618
|
-
* You will need to call `closeEphemeral()` to delete the
|
|
43716
|
+
* Create a nameless, temporary Queue.
|
|
43717
|
+
* You will need to call `closeEphemeral()` to delete the Queue.
|
|
43619
43718
|
*/
|
|
43620
43719
|
static async ephemeral(options = {}) {
|
|
43621
43720
|
const resp = await client.queueGetOrCreate({
|
|
@@ -43627,7 +43726,7 @@ var Queue = class _Queue {
|
|
|
43627
43726
|
);
|
|
43628
43727
|
return new _Queue(resp.queueId, void 0, ephemeralHbManager);
|
|
43629
43728
|
}
|
|
43630
|
-
/** Delete the ephemeral
|
|
43729
|
+
/** Delete the ephemeral Queue. Only usable with `Queue.ephemeral()`. */
|
|
43631
43730
|
closeEphemeral() {
|
|
43632
43731
|
if (this.#ephemeralHbManager) {
|
|
43633
43732
|
this.#ephemeralHbManager.stop();
|
|
@@ -43636,7 +43735,7 @@ var Queue = class _Queue {
|
|
|
43636
43735
|
}
|
|
43637
43736
|
}
|
|
43638
43737
|
/**
|
|
43639
|
-
* Lookup a
|
|
43738
|
+
* Lookup a Queue by name.
|
|
43640
43739
|
*/
|
|
43641
43740
|
static async lookup(name, options = {}) {
|
|
43642
43741
|
const resp = await client.queueGetOrCreate({
|
|
@@ -43646,13 +43745,13 @@ var Queue = class _Queue {
|
|
|
43646
43745
|
});
|
|
43647
43746
|
return new _Queue(resp.queueId, name);
|
|
43648
43747
|
}
|
|
43649
|
-
/** Delete a
|
|
43748
|
+
/** Delete a Queue by name. */
|
|
43650
43749
|
static async delete(name, options = {}) {
|
|
43651
43750
|
const queue = await _Queue.lookup(name, options);
|
|
43652
43751
|
await client.queueDelete({ queueId: queue.queueId });
|
|
43653
43752
|
}
|
|
43654
43753
|
/**
|
|
43655
|
-
* Remove all objects from a
|
|
43754
|
+
* Remove all objects from a Queue partition.
|
|
43656
43755
|
*/
|
|
43657
43756
|
async clear(options = {}) {
|
|
43658
43757
|
if (options.partition && options.all) {
|
|
@@ -43694,9 +43793,9 @@ var Queue = class _Queue {
|
|
|
43694
43793
|
}
|
|
43695
43794
|
}
|
|
43696
43795
|
/**
|
|
43697
|
-
* Remove and return the next object from the
|
|
43796
|
+
* Remove and return the next object from the Queue.
|
|
43698
43797
|
*
|
|
43699
|
-
* By default, this will wait until at least one item is present in the
|
|
43798
|
+
* By default, this will wait until at least one item is present in the Queue.
|
|
43700
43799
|
* If `timeout` is set, raises `QueueEmptyError` if no items are available
|
|
43701
43800
|
* within that timeout in milliseconds.
|
|
43702
43801
|
*/
|
|
@@ -43705,9 +43804,9 @@ var Queue = class _Queue {
|
|
|
43705
43804
|
return values[0];
|
|
43706
43805
|
}
|
|
43707
43806
|
/**
|
|
43708
|
-
* Remove and return up to `n` objects from the
|
|
43807
|
+
* Remove and return up to `n` objects from the Queue.
|
|
43709
43808
|
*
|
|
43710
|
-
* By default, this will wait until at least one item is present in the
|
|
43809
|
+
* By default, this will wait until at least one item is present in the Queue.
|
|
43711
43810
|
* If `timeout` is set, raises `QueueEmptyError` if no items are available
|
|
43712
43811
|
* within that timeout in milliseconds.
|
|
43713
43812
|
*/
|
|
@@ -43729,7 +43828,7 @@ var Queue = class _Queue {
|
|
|
43729
43828
|
});
|
|
43730
43829
|
break;
|
|
43731
43830
|
} catch (e) {
|
|
43732
|
-
if (e instanceof
|
|
43831
|
+
if (e instanceof import_nice_grpc9.ClientError && e.code === import_nice_grpc9.Status.RESOURCE_EXHAUSTED) {
|
|
43733
43832
|
delay = Math.min(delay * 2, 3e4);
|
|
43734
43833
|
if (deadline !== void 0) {
|
|
43735
43834
|
const remaining = deadline - Date.now();
|
|
@@ -43745,11 +43844,11 @@ var Queue = class _Queue {
|
|
|
43745
43844
|
}
|
|
43746
43845
|
}
|
|
43747
43846
|
/**
|
|
43748
|
-
* Add an item to the end of the
|
|
43847
|
+
* Add an item to the end of the Queue.
|
|
43749
43848
|
*
|
|
43750
|
-
* If the
|
|
43849
|
+
* If the Queue is full, this will retry with exponential backoff until the
|
|
43751
43850
|
* provided `timeout` is reached, or indefinitely if `timeout` is not set.
|
|
43752
|
-
* Raises `QueueFullError` if the
|
|
43851
|
+
* Raises `QueueFullError` if the Queue is still full after the timeout.
|
|
43753
43852
|
*/
|
|
43754
43853
|
async put(v, options = {}) {
|
|
43755
43854
|
await this.#put(
|
|
@@ -43760,11 +43859,11 @@ var Queue = class _Queue {
|
|
|
43760
43859
|
);
|
|
43761
43860
|
}
|
|
43762
43861
|
/**
|
|
43763
|
-
* Add several items to the end of the
|
|
43862
|
+
* Add several items to the end of the Queue.
|
|
43764
43863
|
*
|
|
43765
|
-
* If the
|
|
43864
|
+
* If the Queue is full, this will retry with exponential backoff until the
|
|
43766
43865
|
* provided `timeout` is reached, or indefinitely if `timeout` is not set.
|
|
43767
|
-
* Raises `QueueFullError` if the
|
|
43866
|
+
* Raises `QueueFullError` if the Queue is still full after the timeout.
|
|
43768
43867
|
*/
|
|
43769
43868
|
async putMany(values, options = {}) {
|
|
43770
43869
|
await this.#put(
|
|
@@ -43774,7 +43873,7 @@ var Queue = class _Queue {
|
|
|
43774
43873
|
options.partitionTtl
|
|
43775
43874
|
);
|
|
43776
43875
|
}
|
|
43777
|
-
/** Return the number of objects in the
|
|
43876
|
+
/** Return the number of objects in the Queue. */
|
|
43778
43877
|
async len(options = {}) {
|
|
43779
43878
|
if (options.partition && options.total) {
|
|
43780
43879
|
throw new InvalidError(
|
|
@@ -43788,7 +43887,7 @@ var Queue = class _Queue {
|
|
|
43788
43887
|
});
|
|
43789
43888
|
return resp.len;
|
|
43790
43889
|
}
|
|
43791
|
-
/** Iterate through items in a
|
|
43890
|
+
/** Iterate through items in a Queue without mutation. */
|
|
43792
43891
|
async *iterate(options = {}) {
|
|
43793
43892
|
const { partition, itemPollTimeout = 0 } = options;
|
|
43794
43893
|
let lastEntryId = void 0;
|
|
@@ -43821,7 +43920,7 @@ var Queue = class _Queue {
|
|
|
43821
43920
|
};
|
|
43822
43921
|
|
|
43823
43922
|
// src/volume.ts
|
|
43824
|
-
var
|
|
43923
|
+
var import_nice_grpc10 = require("nice-grpc");
|
|
43825
43924
|
var Volume = class _Volume {
|
|
43826
43925
|
volumeId;
|
|
43827
43926
|
name;
|
|
@@ -43843,7 +43942,7 @@ var Volume = class _Volume {
|
|
|
43843
43942
|
});
|
|
43844
43943
|
return new _Volume(resp.volumeId, name);
|
|
43845
43944
|
} catch (err) {
|
|
43846
|
-
if (err instanceof
|
|
43945
|
+
if (err instanceof import_nice_grpc10.ClientError && err.code === import_nice_grpc10.Status.NOT_FOUND)
|
|
43847
43946
|
throw new NotFoundError(err.details);
|
|
43848
43947
|
throw err;
|
|
43849
43948
|
}
|
|
@@ -43856,8 +43955,8 @@ var Volume = class _Volume {
|
|
|
43856
43955
|
return this._readOnly;
|
|
43857
43956
|
}
|
|
43858
43957
|
/**
|
|
43859
|
-
* Create a nameless, temporary
|
|
43860
|
-
* You will need to call `closeEphemeral()` to delete the
|
|
43958
|
+
* Create a nameless, temporary Volume.
|
|
43959
|
+
* You will need to call `closeEphemeral()` to delete the Volume.
|
|
43861
43960
|
*/
|
|
43862
43961
|
static async ephemeral(options = {}) {
|
|
43863
43962
|
const resp = await client.volumeGetOrCreate({
|
|
@@ -43869,7 +43968,7 @@ var Volume = class _Volume {
|
|
|
43869
43968
|
);
|
|
43870
43969
|
return new _Volume(resp.volumeId, void 0, false, ephemeralHbManager);
|
|
43871
43970
|
}
|
|
43872
|
-
/** Delete the ephemeral
|
|
43971
|
+
/** Delete the ephemeral Volume. Only usable with `Volume.ephemeral()`. */
|
|
43873
43972
|
closeEphemeral() {
|
|
43874
43973
|
if (this.#ephemeralHbManager) {
|
|
43875
43974
|
this.#ephemeralHbManager.stop();
|
|
@@ -43880,7 +43979,7 @@ var Volume = class _Volume {
|
|
|
43880
43979
|
};
|
|
43881
43980
|
|
|
43882
43981
|
// src/proxy.ts
|
|
43883
|
-
var
|
|
43982
|
+
var import_nice_grpc11 = require("nice-grpc");
|
|
43884
43983
|
var Proxy3 = class _Proxy {
|
|
43885
43984
|
proxyId;
|
|
43886
43985
|
/** @ignore */
|
|
@@ -43899,7 +43998,7 @@ var Proxy3 = class _Proxy {
|
|
|
43899
43998
|
}
|
|
43900
43999
|
return new _Proxy(resp.proxy.proxyId);
|
|
43901
44000
|
} catch (err) {
|
|
43902
|
-
if (err instanceof
|
|
44001
|
+
if (err instanceof import_nice_grpc11.ClientError && err.code === import_nice_grpc11.Status.NOT_FOUND)
|
|
43903
44002
|
throw new NotFoundError(`Proxy '${name}' not found`);
|
|
43904
44003
|
throw err;
|
|
43905
44004
|
}
|