modal 0.3.23 → 0.3.25
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 +556 -39
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +556 -39
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1632,6 +1632,9 @@ function dataFormatFromJSON(object) {
|
|
|
1632
1632
|
case 3:
|
|
1633
1633
|
case "DATA_FORMAT_GENERATOR_DONE":
|
|
1634
1634
|
return 3 /* DATA_FORMAT_GENERATOR_DONE */;
|
|
1635
|
+
case 4:
|
|
1636
|
+
case "DATA_FORMAT_CBOR":
|
|
1637
|
+
return 4 /* DATA_FORMAT_CBOR */;
|
|
1635
1638
|
case -1:
|
|
1636
1639
|
case "UNRECOGNIZED":
|
|
1637
1640
|
default:
|
|
@@ -1648,6 +1651,8 @@ function dataFormatToJSON(object) {
|
|
|
1648
1651
|
return "DATA_FORMAT_ASGI";
|
|
1649
1652
|
case 3 /* DATA_FORMAT_GENERATOR_DONE */:
|
|
1650
1653
|
return "DATA_FORMAT_GENERATOR_DONE";
|
|
1654
|
+
case 4 /* DATA_FORMAT_CBOR */:
|
|
1655
|
+
return "DATA_FORMAT_CBOR";
|
|
1651
1656
|
case -1 /* UNRECOGNIZED */:
|
|
1652
1657
|
default:
|
|
1653
1658
|
return "UNRECOGNIZED";
|
|
@@ -14786,7 +14791,9 @@ function createBaseFunctionMessage() {
|
|
|
14786
14791
|
flashServiceUrls: [],
|
|
14787
14792
|
flashServiceLabel: "",
|
|
14788
14793
|
enableGpuSnapshot: false,
|
|
14789
|
-
startupTimeoutSecs: 0
|
|
14794
|
+
startupTimeoutSecs: 0,
|
|
14795
|
+
supportedInputFormats: [],
|
|
14796
|
+
supportedOutputFormats: []
|
|
14790
14797
|
};
|
|
14791
14798
|
}
|
|
14792
14799
|
var FunctionMessage = {
|
|
@@ -15010,6 +15017,16 @@ var FunctionMessage = {
|
|
|
15010
15017
|
if (message.startupTimeoutSecs !== 0) {
|
|
15011
15018
|
writer.uint32(688).uint32(message.startupTimeoutSecs);
|
|
15012
15019
|
}
|
|
15020
|
+
writer.uint32(698).fork();
|
|
15021
|
+
for (const v of message.supportedInputFormats) {
|
|
15022
|
+
writer.int32(v);
|
|
15023
|
+
}
|
|
15024
|
+
writer.join();
|
|
15025
|
+
writer.uint32(706).fork();
|
|
15026
|
+
for (const v of message.supportedOutputFormats) {
|
|
15027
|
+
writer.int32(v);
|
|
15028
|
+
}
|
|
15029
|
+
writer.join();
|
|
15013
15030
|
return writer;
|
|
15014
15031
|
},
|
|
15015
15032
|
decode(input, length) {
|
|
@@ -15536,6 +15553,34 @@ var FunctionMessage = {
|
|
|
15536
15553
|
message.startupTimeoutSecs = reader.uint32();
|
|
15537
15554
|
continue;
|
|
15538
15555
|
}
|
|
15556
|
+
case 87: {
|
|
15557
|
+
if (tag === 696) {
|
|
15558
|
+
message.supportedInputFormats.push(reader.int32());
|
|
15559
|
+
continue;
|
|
15560
|
+
}
|
|
15561
|
+
if (tag === 698) {
|
|
15562
|
+
const end2 = reader.uint32() + reader.pos;
|
|
15563
|
+
while (reader.pos < end2) {
|
|
15564
|
+
message.supportedInputFormats.push(reader.int32());
|
|
15565
|
+
}
|
|
15566
|
+
continue;
|
|
15567
|
+
}
|
|
15568
|
+
break;
|
|
15569
|
+
}
|
|
15570
|
+
case 88: {
|
|
15571
|
+
if (tag === 704) {
|
|
15572
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
15573
|
+
continue;
|
|
15574
|
+
}
|
|
15575
|
+
if (tag === 706) {
|
|
15576
|
+
const end2 = reader.uint32() + reader.pos;
|
|
15577
|
+
while (reader.pos < end2) {
|
|
15578
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
15579
|
+
}
|
|
15580
|
+
continue;
|
|
15581
|
+
}
|
|
15582
|
+
break;
|
|
15583
|
+
}
|
|
15539
15584
|
}
|
|
15540
15585
|
if ((tag & 7) === 4 || tag === 0) {
|
|
15541
15586
|
break;
|
|
@@ -15624,7 +15669,9 @@ var FunctionMessage = {
|
|
|
15624
15669
|
flashServiceUrls: globalThis.Array.isArray(object?.flashServiceUrls) ? object.flashServiceUrls.map((e) => globalThis.String(e)) : [],
|
|
15625
15670
|
flashServiceLabel: isSet3(object.flashServiceLabel) ? globalThis.String(object.flashServiceLabel) : "",
|
|
15626
15671
|
enableGpuSnapshot: isSet3(object.enableGpuSnapshot) ? globalThis.Boolean(object.enableGpuSnapshot) : false,
|
|
15627
|
-
startupTimeoutSecs: isSet3(object.startupTimeoutSecs) ? globalThis.Number(object.startupTimeoutSecs) : 0
|
|
15672
|
+
startupTimeoutSecs: isSet3(object.startupTimeoutSecs) ? globalThis.Number(object.startupTimeoutSecs) : 0,
|
|
15673
|
+
supportedInputFormats: globalThis.Array.isArray(object?.supportedInputFormats) ? object.supportedInputFormats.map((e) => dataFormatFromJSON(e)) : [],
|
|
15674
|
+
supportedOutputFormats: globalThis.Array.isArray(object?.supportedOutputFormats) ? object.supportedOutputFormats.map((e) => dataFormatFromJSON(e)) : []
|
|
15628
15675
|
};
|
|
15629
15676
|
},
|
|
15630
15677
|
toJSON(message) {
|
|
@@ -15860,6 +15907,12 @@ var FunctionMessage = {
|
|
|
15860
15907
|
if (message.startupTimeoutSecs !== 0) {
|
|
15861
15908
|
obj.startupTimeoutSecs = Math.round(message.startupTimeoutSecs);
|
|
15862
15909
|
}
|
|
15910
|
+
if (message.supportedInputFormats?.length) {
|
|
15911
|
+
obj.supportedInputFormats = message.supportedInputFormats.map((e) => dataFormatToJSON(e));
|
|
15912
|
+
}
|
|
15913
|
+
if (message.supportedOutputFormats?.length) {
|
|
15914
|
+
obj.supportedOutputFormats = message.supportedOutputFormats.map((e) => dataFormatToJSON(e));
|
|
15915
|
+
}
|
|
15863
15916
|
return obj;
|
|
15864
15917
|
},
|
|
15865
15918
|
create(base) {
|
|
@@ -15953,6 +16006,8 @@ var FunctionMessage = {
|
|
|
15953
16006
|
message.flashServiceLabel = object.flashServiceLabel ?? "";
|
|
15954
16007
|
message.enableGpuSnapshot = object.enableGpuSnapshot ?? false;
|
|
15955
16008
|
message.startupTimeoutSecs = object.startupTimeoutSecs ?? 0;
|
|
16009
|
+
message.supportedInputFormats = object.supportedInputFormats?.map((e) => e) || [];
|
|
16010
|
+
message.supportedOutputFormats = object.supportedOutputFormats?.map((e) => e) || [];
|
|
15956
16011
|
return message;
|
|
15957
16012
|
}
|
|
15958
16013
|
};
|
|
@@ -17461,7 +17516,9 @@ function createBaseFunctionData() {
|
|
|
17461
17516
|
experimentalOptions: {},
|
|
17462
17517
|
flashServiceUrls: [],
|
|
17463
17518
|
flashServiceLabel: "",
|
|
17464
|
-
startupTimeoutSecs: 0
|
|
17519
|
+
startupTimeoutSecs: 0,
|
|
17520
|
+
supportedInputFormats: [],
|
|
17521
|
+
supportedOutputFormats: []
|
|
17465
17522
|
};
|
|
17466
17523
|
}
|
|
17467
17524
|
var FunctionData = {
|
|
@@ -17571,6 +17628,16 @@ var FunctionData = {
|
|
|
17571
17628
|
if (message.startupTimeoutSecs !== 0) {
|
|
17572
17629
|
writer.uint32(288).uint32(message.startupTimeoutSecs);
|
|
17573
17630
|
}
|
|
17631
|
+
writer.uint32(298).fork();
|
|
17632
|
+
for (const v of message.supportedInputFormats) {
|
|
17633
|
+
writer.int32(v);
|
|
17634
|
+
}
|
|
17635
|
+
writer.join();
|
|
17636
|
+
writer.uint32(306).fork();
|
|
17637
|
+
for (const v of message.supportedOutputFormats) {
|
|
17638
|
+
writer.int32(v);
|
|
17639
|
+
}
|
|
17640
|
+
writer.join();
|
|
17574
17641
|
return writer;
|
|
17575
17642
|
},
|
|
17576
17643
|
decode(input, length) {
|
|
@@ -17831,6 +17898,34 @@ var FunctionData = {
|
|
|
17831
17898
|
message.startupTimeoutSecs = reader.uint32();
|
|
17832
17899
|
continue;
|
|
17833
17900
|
}
|
|
17901
|
+
case 37: {
|
|
17902
|
+
if (tag === 296) {
|
|
17903
|
+
message.supportedInputFormats.push(reader.int32());
|
|
17904
|
+
continue;
|
|
17905
|
+
}
|
|
17906
|
+
if (tag === 298) {
|
|
17907
|
+
const end2 = reader.uint32() + reader.pos;
|
|
17908
|
+
while (reader.pos < end2) {
|
|
17909
|
+
message.supportedInputFormats.push(reader.int32());
|
|
17910
|
+
}
|
|
17911
|
+
continue;
|
|
17912
|
+
}
|
|
17913
|
+
break;
|
|
17914
|
+
}
|
|
17915
|
+
case 38: {
|
|
17916
|
+
if (tag === 304) {
|
|
17917
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
17918
|
+
continue;
|
|
17919
|
+
}
|
|
17920
|
+
if (tag === 306) {
|
|
17921
|
+
const end2 = reader.uint32() + reader.pos;
|
|
17922
|
+
while (reader.pos < end2) {
|
|
17923
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
17924
|
+
}
|
|
17925
|
+
continue;
|
|
17926
|
+
}
|
|
17927
|
+
break;
|
|
17928
|
+
}
|
|
17834
17929
|
}
|
|
17835
17930
|
if ((tag & 7) === 4 || tag === 0) {
|
|
17836
17931
|
break;
|
|
@@ -17881,7 +17976,9 @@ var FunctionData = {
|
|
|
17881
17976
|
}, {}) : {},
|
|
17882
17977
|
flashServiceUrls: globalThis.Array.isArray(object?.flashServiceUrls) ? object.flashServiceUrls.map((e) => globalThis.String(e)) : [],
|
|
17883
17978
|
flashServiceLabel: isSet3(object.flashServiceLabel) ? globalThis.String(object.flashServiceLabel) : "",
|
|
17884
|
-
startupTimeoutSecs: isSet3(object.startupTimeoutSecs) ? globalThis.Number(object.startupTimeoutSecs) : 0
|
|
17979
|
+
startupTimeoutSecs: isSet3(object.startupTimeoutSecs) ? globalThis.Number(object.startupTimeoutSecs) : 0,
|
|
17980
|
+
supportedInputFormats: globalThis.Array.isArray(object?.supportedInputFormats) ? object.supportedInputFormats.map((e) => dataFormatFromJSON(e)) : [],
|
|
17981
|
+
supportedOutputFormats: globalThis.Array.isArray(object?.supportedOutputFormats) ? object.supportedOutputFormats.map((e) => dataFormatFromJSON(e)) : []
|
|
17885
17982
|
};
|
|
17886
17983
|
},
|
|
17887
17984
|
toJSON(message) {
|
|
@@ -18003,6 +18100,12 @@ var FunctionData = {
|
|
|
18003
18100
|
if (message.startupTimeoutSecs !== 0) {
|
|
18004
18101
|
obj.startupTimeoutSecs = Math.round(message.startupTimeoutSecs);
|
|
18005
18102
|
}
|
|
18103
|
+
if (message.supportedInputFormats?.length) {
|
|
18104
|
+
obj.supportedInputFormats = message.supportedInputFormats.map((e) => dataFormatToJSON(e));
|
|
18105
|
+
}
|
|
18106
|
+
if (message.supportedOutputFormats?.length) {
|
|
18107
|
+
obj.supportedOutputFormats = message.supportedOutputFormats.map((e) => dataFormatToJSON(e));
|
|
18108
|
+
}
|
|
18006
18109
|
return obj;
|
|
18007
18110
|
},
|
|
18008
18111
|
create(base) {
|
|
@@ -18058,6 +18161,8 @@ var FunctionData = {
|
|
|
18058
18161
|
message.flashServiceUrls = object.flashServiceUrls?.map((e) => e) || [];
|
|
18059
18162
|
message.flashServiceLabel = object.flashServiceLabel ?? "";
|
|
18060
18163
|
message.startupTimeoutSecs = object.startupTimeoutSecs ?? 0;
|
|
18164
|
+
message.supportedInputFormats = object.supportedInputFormats?.map((e) => e) || [];
|
|
18165
|
+
message.supportedOutputFormats = object.supportedOutputFormats?.map((e) => e) || [];
|
|
18061
18166
|
return message;
|
|
18062
18167
|
}
|
|
18063
18168
|
};
|
|
@@ -19788,7 +19893,9 @@ function createBaseFunctionHandleMetadata() {
|
|
|
19788
19893
|
inputPlaneUrl: void 0,
|
|
19789
19894
|
inputPlaneRegion: void 0,
|
|
19790
19895
|
maxObjectSizeBytes: void 0,
|
|
19791
|
-
ExperimentalFlashUrls: []
|
|
19896
|
+
ExperimentalFlashUrls: [],
|
|
19897
|
+
supportedInputFormats: [],
|
|
19898
|
+
supportedOutputFormats: []
|
|
19792
19899
|
};
|
|
19793
19900
|
}
|
|
19794
19901
|
var FunctionHandleMetadata = {
|
|
@@ -19835,6 +19942,16 @@ var FunctionHandleMetadata = {
|
|
|
19835
19942
|
for (const v of message.ExperimentalFlashUrls) {
|
|
19836
19943
|
writer.uint32(394).string(v);
|
|
19837
19944
|
}
|
|
19945
|
+
writer.uint32(402).fork();
|
|
19946
|
+
for (const v of message.supportedInputFormats) {
|
|
19947
|
+
writer.int32(v);
|
|
19948
|
+
}
|
|
19949
|
+
writer.join();
|
|
19950
|
+
writer.uint32(410).fork();
|
|
19951
|
+
for (const v of message.supportedOutputFormats) {
|
|
19952
|
+
writer.int32(v);
|
|
19953
|
+
}
|
|
19954
|
+
writer.join();
|
|
19838
19955
|
return writer;
|
|
19839
19956
|
},
|
|
19840
19957
|
decode(input, length) {
|
|
@@ -19945,6 +20062,34 @@ var FunctionHandleMetadata = {
|
|
|
19945
20062
|
message.ExperimentalFlashUrls.push(reader.string());
|
|
19946
20063
|
continue;
|
|
19947
20064
|
}
|
|
20065
|
+
case 50: {
|
|
20066
|
+
if (tag === 400) {
|
|
20067
|
+
message.supportedInputFormats.push(reader.int32());
|
|
20068
|
+
continue;
|
|
20069
|
+
}
|
|
20070
|
+
if (tag === 402) {
|
|
20071
|
+
const end2 = reader.uint32() + reader.pos;
|
|
20072
|
+
while (reader.pos < end2) {
|
|
20073
|
+
message.supportedInputFormats.push(reader.int32());
|
|
20074
|
+
}
|
|
20075
|
+
continue;
|
|
20076
|
+
}
|
|
20077
|
+
break;
|
|
20078
|
+
}
|
|
20079
|
+
case 51: {
|
|
20080
|
+
if (tag === 408) {
|
|
20081
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
20082
|
+
continue;
|
|
20083
|
+
}
|
|
20084
|
+
if (tag === 410) {
|
|
20085
|
+
const end2 = reader.uint32() + reader.pos;
|
|
20086
|
+
while (reader.pos < end2) {
|
|
20087
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
20088
|
+
}
|
|
20089
|
+
continue;
|
|
20090
|
+
}
|
|
20091
|
+
break;
|
|
20092
|
+
}
|
|
19948
20093
|
}
|
|
19949
20094
|
if ((tag & 7) === 4 || tag === 0) {
|
|
19950
20095
|
break;
|
|
@@ -19974,7 +20119,9 @@ var FunctionHandleMetadata = {
|
|
|
19974
20119
|
inputPlaneUrl: isSet3(object.inputPlaneUrl) ? globalThis.String(object.inputPlaneUrl) : void 0,
|
|
19975
20120
|
inputPlaneRegion: isSet3(object.inputPlaneRegion) ? globalThis.String(object.inputPlaneRegion) : void 0,
|
|
19976
20121
|
maxObjectSizeBytes: isSet3(object.maxObjectSizeBytes) ? globalThis.Number(object.maxObjectSizeBytes) : void 0,
|
|
19977
|
-
ExperimentalFlashUrls: globalThis.Array.isArray(object?.ExperimentalFlashUrls) ? object.ExperimentalFlashUrls.map((e) => globalThis.String(e)) : []
|
|
20122
|
+
ExperimentalFlashUrls: globalThis.Array.isArray(object?.ExperimentalFlashUrls) ? object.ExperimentalFlashUrls.map((e) => globalThis.String(e)) : [],
|
|
20123
|
+
supportedInputFormats: globalThis.Array.isArray(object?.supportedInputFormats) ? object.supportedInputFormats.map((e) => dataFormatFromJSON(e)) : [],
|
|
20124
|
+
supportedOutputFormats: globalThis.Array.isArray(object?.supportedOutputFormats) ? object.supportedOutputFormats.map((e) => dataFormatFromJSON(e)) : []
|
|
19978
20125
|
};
|
|
19979
20126
|
},
|
|
19980
20127
|
toJSON(message) {
|
|
@@ -20027,6 +20174,12 @@ var FunctionHandleMetadata = {
|
|
|
20027
20174
|
if (message.ExperimentalFlashUrls?.length) {
|
|
20028
20175
|
obj.ExperimentalFlashUrls = message.ExperimentalFlashUrls;
|
|
20029
20176
|
}
|
|
20177
|
+
if (message.supportedInputFormats?.length) {
|
|
20178
|
+
obj.supportedInputFormats = message.supportedInputFormats.map((e) => dataFormatToJSON(e));
|
|
20179
|
+
}
|
|
20180
|
+
if (message.supportedOutputFormats?.length) {
|
|
20181
|
+
obj.supportedOutputFormats = message.supportedOutputFormats.map((e) => dataFormatToJSON(e));
|
|
20182
|
+
}
|
|
20030
20183
|
return obj;
|
|
20031
20184
|
},
|
|
20032
20185
|
create(base) {
|
|
@@ -20053,6 +20206,8 @@ var FunctionHandleMetadata = {
|
|
|
20053
20206
|
message.inputPlaneRegion = object.inputPlaneRegion ?? void 0;
|
|
20054
20207
|
message.maxObjectSizeBytes = object.maxObjectSizeBytes ?? void 0;
|
|
20055
20208
|
message.ExperimentalFlashUrls = object.ExperimentalFlashUrls?.map((e) => e) || [];
|
|
20209
|
+
message.supportedInputFormats = object.supportedInputFormats?.map((e) => e) || [];
|
|
20210
|
+
message.supportedOutputFormats = object.supportedOutputFormats?.map((e) => e) || [];
|
|
20056
20211
|
return message;
|
|
20057
20212
|
}
|
|
20058
20213
|
};
|
|
@@ -20860,7 +21015,9 @@ function createBaseFunctionPrecreateRequest() {
|
|
|
20860
21015
|
useFunctionId: "",
|
|
20861
21016
|
useMethodName: "",
|
|
20862
21017
|
methodDefinitions: {},
|
|
20863
|
-
functionSchema: void 0
|
|
21018
|
+
functionSchema: void 0,
|
|
21019
|
+
supportedInputFormats: [],
|
|
21020
|
+
supportedOutputFormats: []
|
|
20864
21021
|
};
|
|
20865
21022
|
}
|
|
20866
21023
|
var FunctionPrecreateRequest = {
|
|
@@ -20892,6 +21049,16 @@ var FunctionPrecreateRequest = {
|
|
|
20892
21049
|
if (message.functionSchema !== void 0) {
|
|
20893
21050
|
FunctionSchema.encode(message.functionSchema, writer.uint32(74).fork()).join();
|
|
20894
21051
|
}
|
|
21052
|
+
writer.uint32(82).fork();
|
|
21053
|
+
for (const v of message.supportedInputFormats) {
|
|
21054
|
+
writer.int32(v);
|
|
21055
|
+
}
|
|
21056
|
+
writer.join();
|
|
21057
|
+
writer.uint32(90).fork();
|
|
21058
|
+
for (const v of message.supportedOutputFormats) {
|
|
21059
|
+
writer.int32(v);
|
|
21060
|
+
}
|
|
21061
|
+
writer.join();
|
|
20895
21062
|
return writer;
|
|
20896
21063
|
},
|
|
20897
21064
|
decode(input, length) {
|
|
@@ -20967,6 +21134,34 @@ var FunctionPrecreateRequest = {
|
|
|
20967
21134
|
message.functionSchema = FunctionSchema.decode(reader, reader.uint32());
|
|
20968
21135
|
continue;
|
|
20969
21136
|
}
|
|
21137
|
+
case 10: {
|
|
21138
|
+
if (tag === 80) {
|
|
21139
|
+
message.supportedInputFormats.push(reader.int32());
|
|
21140
|
+
continue;
|
|
21141
|
+
}
|
|
21142
|
+
if (tag === 82) {
|
|
21143
|
+
const end2 = reader.uint32() + reader.pos;
|
|
21144
|
+
while (reader.pos < end2) {
|
|
21145
|
+
message.supportedInputFormats.push(reader.int32());
|
|
21146
|
+
}
|
|
21147
|
+
continue;
|
|
21148
|
+
}
|
|
21149
|
+
break;
|
|
21150
|
+
}
|
|
21151
|
+
case 11: {
|
|
21152
|
+
if (tag === 88) {
|
|
21153
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
21154
|
+
continue;
|
|
21155
|
+
}
|
|
21156
|
+
if (tag === 90) {
|
|
21157
|
+
const end2 = reader.uint32() + reader.pos;
|
|
21158
|
+
while (reader.pos < end2) {
|
|
21159
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
21160
|
+
}
|
|
21161
|
+
continue;
|
|
21162
|
+
}
|
|
21163
|
+
break;
|
|
21164
|
+
}
|
|
20970
21165
|
}
|
|
20971
21166
|
if ((tag & 7) === 4 || tag === 0) {
|
|
20972
21167
|
break;
|
|
@@ -20988,7 +21183,9 @@ var FunctionPrecreateRequest = {
|
|
|
20988
21183
|
acc[key] = MethodDefinition.fromJSON(value);
|
|
20989
21184
|
return acc;
|
|
20990
21185
|
}, {}) : {},
|
|
20991
|
-
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0
|
|
21186
|
+
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0,
|
|
21187
|
+
supportedInputFormats: globalThis.Array.isArray(object?.supportedInputFormats) ? object.supportedInputFormats.map((e) => dataFormatFromJSON(e)) : [],
|
|
21188
|
+
supportedOutputFormats: globalThis.Array.isArray(object?.supportedOutputFormats) ? object.supportedOutputFormats.map((e) => dataFormatFromJSON(e)) : []
|
|
20992
21189
|
};
|
|
20993
21190
|
},
|
|
20994
21191
|
toJSON(message) {
|
|
@@ -21026,6 +21223,12 @@ var FunctionPrecreateRequest = {
|
|
|
21026
21223
|
if (message.functionSchema !== void 0) {
|
|
21027
21224
|
obj.functionSchema = FunctionSchema.toJSON(message.functionSchema);
|
|
21028
21225
|
}
|
|
21226
|
+
if (message.supportedInputFormats?.length) {
|
|
21227
|
+
obj.supportedInputFormats = message.supportedInputFormats.map((e) => dataFormatToJSON(e));
|
|
21228
|
+
}
|
|
21229
|
+
if (message.supportedOutputFormats?.length) {
|
|
21230
|
+
obj.supportedOutputFormats = message.supportedOutputFormats.map((e) => dataFormatToJSON(e));
|
|
21231
|
+
}
|
|
21029
21232
|
return obj;
|
|
21030
21233
|
},
|
|
21031
21234
|
create(base) {
|
|
@@ -21047,6 +21250,8 @@ var FunctionPrecreateRequest = {
|
|
|
21047
21250
|
return acc;
|
|
21048
21251
|
}, {});
|
|
21049
21252
|
message.functionSchema = object.functionSchema !== void 0 && object.functionSchema !== null ? FunctionSchema.fromPartial(object.functionSchema) : void 0;
|
|
21253
|
+
message.supportedInputFormats = object.supportedInputFormats?.map((e) => e) || [];
|
|
21254
|
+
message.supportedOutputFormats = object.supportedOutputFormats?.map((e) => e) || [];
|
|
21050
21255
|
return message;
|
|
21051
21256
|
}
|
|
21052
21257
|
};
|
|
@@ -25062,7 +25267,9 @@ function createBaseMethodDefinition() {
|
|
|
25062
25267
|
webUrl: "",
|
|
25063
25268
|
webUrlInfo: void 0,
|
|
25064
25269
|
customDomainInfo: [],
|
|
25065
|
-
functionSchema: void 0
|
|
25270
|
+
functionSchema: void 0,
|
|
25271
|
+
supportedInputFormats: [],
|
|
25272
|
+
supportedOutputFormats: []
|
|
25066
25273
|
};
|
|
25067
25274
|
}
|
|
25068
25275
|
var MethodDefinition = {
|
|
@@ -25088,6 +25295,16 @@ var MethodDefinition = {
|
|
|
25088
25295
|
if (message.functionSchema !== void 0) {
|
|
25089
25296
|
FunctionSchema.encode(message.functionSchema, writer.uint32(58).fork()).join();
|
|
25090
25297
|
}
|
|
25298
|
+
writer.uint32(66).fork();
|
|
25299
|
+
for (const v of message.supportedInputFormats) {
|
|
25300
|
+
writer.int32(v);
|
|
25301
|
+
}
|
|
25302
|
+
writer.join();
|
|
25303
|
+
writer.uint32(74).fork();
|
|
25304
|
+
for (const v of message.supportedOutputFormats) {
|
|
25305
|
+
writer.int32(v);
|
|
25306
|
+
}
|
|
25307
|
+
writer.join();
|
|
25091
25308
|
return writer;
|
|
25092
25309
|
},
|
|
25093
25310
|
decode(input, length) {
|
|
@@ -25146,6 +25363,34 @@ var MethodDefinition = {
|
|
|
25146
25363
|
message.functionSchema = FunctionSchema.decode(reader, reader.uint32());
|
|
25147
25364
|
continue;
|
|
25148
25365
|
}
|
|
25366
|
+
case 8: {
|
|
25367
|
+
if (tag === 64) {
|
|
25368
|
+
message.supportedInputFormats.push(reader.int32());
|
|
25369
|
+
continue;
|
|
25370
|
+
}
|
|
25371
|
+
if (tag === 66) {
|
|
25372
|
+
const end2 = reader.uint32() + reader.pos;
|
|
25373
|
+
while (reader.pos < end2) {
|
|
25374
|
+
message.supportedInputFormats.push(reader.int32());
|
|
25375
|
+
}
|
|
25376
|
+
continue;
|
|
25377
|
+
}
|
|
25378
|
+
break;
|
|
25379
|
+
}
|
|
25380
|
+
case 9: {
|
|
25381
|
+
if (tag === 72) {
|
|
25382
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
25383
|
+
continue;
|
|
25384
|
+
}
|
|
25385
|
+
if (tag === 74) {
|
|
25386
|
+
const end2 = reader.uint32() + reader.pos;
|
|
25387
|
+
while (reader.pos < end2) {
|
|
25388
|
+
message.supportedOutputFormats.push(reader.int32());
|
|
25389
|
+
}
|
|
25390
|
+
continue;
|
|
25391
|
+
}
|
|
25392
|
+
break;
|
|
25393
|
+
}
|
|
25149
25394
|
}
|
|
25150
25395
|
if ((tag & 7) === 4 || tag === 0) {
|
|
25151
25396
|
break;
|
|
@@ -25162,7 +25407,9 @@ var MethodDefinition = {
|
|
|
25162
25407
|
webUrl: isSet3(object.webUrl) ? globalThis.String(object.webUrl) : "",
|
|
25163
25408
|
webUrlInfo: isSet3(object.webUrlInfo) ? WebUrlInfo.fromJSON(object.webUrlInfo) : void 0,
|
|
25164
25409
|
customDomainInfo: globalThis.Array.isArray(object?.customDomainInfo) ? object.customDomainInfo.map((e) => CustomDomainInfo.fromJSON(e)) : [],
|
|
25165
|
-
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0
|
|
25410
|
+
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0,
|
|
25411
|
+
supportedInputFormats: globalThis.Array.isArray(object?.supportedInputFormats) ? object.supportedInputFormats.map((e) => dataFormatFromJSON(e)) : [],
|
|
25412
|
+
supportedOutputFormats: globalThis.Array.isArray(object?.supportedOutputFormats) ? object.supportedOutputFormats.map((e) => dataFormatFromJSON(e)) : []
|
|
25166
25413
|
};
|
|
25167
25414
|
},
|
|
25168
25415
|
toJSON(message) {
|
|
@@ -25188,6 +25435,12 @@ var MethodDefinition = {
|
|
|
25188
25435
|
if (message.functionSchema !== void 0) {
|
|
25189
25436
|
obj.functionSchema = FunctionSchema.toJSON(message.functionSchema);
|
|
25190
25437
|
}
|
|
25438
|
+
if (message.supportedInputFormats?.length) {
|
|
25439
|
+
obj.supportedInputFormats = message.supportedInputFormats.map((e) => dataFormatToJSON(e));
|
|
25440
|
+
}
|
|
25441
|
+
if (message.supportedOutputFormats?.length) {
|
|
25442
|
+
obj.supportedOutputFormats = message.supportedOutputFormats.map((e) => dataFormatToJSON(e));
|
|
25443
|
+
}
|
|
25191
25444
|
return obj;
|
|
25192
25445
|
},
|
|
25193
25446
|
create(base) {
|
|
@@ -25202,6 +25455,8 @@ var MethodDefinition = {
|
|
|
25202
25455
|
message.webUrlInfo = object.webUrlInfo !== void 0 && object.webUrlInfo !== null ? WebUrlInfo.fromPartial(object.webUrlInfo) : void 0;
|
|
25203
25456
|
message.customDomainInfo = object.customDomainInfo?.map((e) => CustomDomainInfo.fromPartial(e)) || [];
|
|
25204
25457
|
message.functionSchema = object.functionSchema !== void 0 && object.functionSchema !== null ? FunctionSchema.fromPartial(object.functionSchema) : void 0;
|
|
25458
|
+
message.supportedInputFormats = object.supportedInputFormats?.map((e) => e) || [];
|
|
25459
|
+
message.supportedOutputFormats = object.supportedOutputFormats?.map((e) => e) || [];
|
|
25205
25460
|
return message;
|
|
25206
25461
|
}
|
|
25207
25462
|
};
|
|
@@ -32666,6 +32921,108 @@ var SandboxTag = {
|
|
|
32666
32921
|
return message;
|
|
32667
32922
|
}
|
|
32668
32923
|
};
|
|
32924
|
+
function createBaseSandboxTagsGetRequest() {
|
|
32925
|
+
return { sandboxId: "" };
|
|
32926
|
+
}
|
|
32927
|
+
var SandboxTagsGetRequest = {
|
|
32928
|
+
encode(message, writer = new BinaryWriter()) {
|
|
32929
|
+
if (message.sandboxId !== "") {
|
|
32930
|
+
writer.uint32(10).string(message.sandboxId);
|
|
32931
|
+
}
|
|
32932
|
+
return writer;
|
|
32933
|
+
},
|
|
32934
|
+
decode(input, length) {
|
|
32935
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
32936
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
32937
|
+
const message = createBaseSandboxTagsGetRequest();
|
|
32938
|
+
while (reader.pos < end) {
|
|
32939
|
+
const tag = reader.uint32();
|
|
32940
|
+
switch (tag >>> 3) {
|
|
32941
|
+
case 1: {
|
|
32942
|
+
if (tag !== 10) {
|
|
32943
|
+
break;
|
|
32944
|
+
}
|
|
32945
|
+
message.sandboxId = reader.string();
|
|
32946
|
+
continue;
|
|
32947
|
+
}
|
|
32948
|
+
}
|
|
32949
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
32950
|
+
break;
|
|
32951
|
+
}
|
|
32952
|
+
reader.skip(tag & 7);
|
|
32953
|
+
}
|
|
32954
|
+
return message;
|
|
32955
|
+
},
|
|
32956
|
+
fromJSON(object) {
|
|
32957
|
+
return { sandboxId: isSet3(object.sandboxId) ? globalThis.String(object.sandboxId) : "" };
|
|
32958
|
+
},
|
|
32959
|
+
toJSON(message) {
|
|
32960
|
+
const obj = {};
|
|
32961
|
+
if (message.sandboxId !== "") {
|
|
32962
|
+
obj.sandboxId = message.sandboxId;
|
|
32963
|
+
}
|
|
32964
|
+
return obj;
|
|
32965
|
+
},
|
|
32966
|
+
create(base) {
|
|
32967
|
+
return SandboxTagsGetRequest.fromPartial(base ?? {});
|
|
32968
|
+
},
|
|
32969
|
+
fromPartial(object) {
|
|
32970
|
+
const message = createBaseSandboxTagsGetRequest();
|
|
32971
|
+
message.sandboxId = object.sandboxId ?? "";
|
|
32972
|
+
return message;
|
|
32973
|
+
}
|
|
32974
|
+
};
|
|
32975
|
+
function createBaseSandboxTagsGetResponse() {
|
|
32976
|
+
return { tags: [] };
|
|
32977
|
+
}
|
|
32978
|
+
var SandboxTagsGetResponse = {
|
|
32979
|
+
encode(message, writer = new BinaryWriter()) {
|
|
32980
|
+
for (const v of message.tags) {
|
|
32981
|
+
SandboxTag.encode(v, writer.uint32(10).fork()).join();
|
|
32982
|
+
}
|
|
32983
|
+
return writer;
|
|
32984
|
+
},
|
|
32985
|
+
decode(input, length) {
|
|
32986
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
32987
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
32988
|
+
const message = createBaseSandboxTagsGetResponse();
|
|
32989
|
+
while (reader.pos < end) {
|
|
32990
|
+
const tag = reader.uint32();
|
|
32991
|
+
switch (tag >>> 3) {
|
|
32992
|
+
case 1: {
|
|
32993
|
+
if (tag !== 10) {
|
|
32994
|
+
break;
|
|
32995
|
+
}
|
|
32996
|
+
message.tags.push(SandboxTag.decode(reader, reader.uint32()));
|
|
32997
|
+
continue;
|
|
32998
|
+
}
|
|
32999
|
+
}
|
|
33000
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
33001
|
+
break;
|
|
33002
|
+
}
|
|
33003
|
+
reader.skip(tag & 7);
|
|
33004
|
+
}
|
|
33005
|
+
return message;
|
|
33006
|
+
},
|
|
33007
|
+
fromJSON(object) {
|
|
33008
|
+
return { tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e) => SandboxTag.fromJSON(e)) : [] };
|
|
33009
|
+
},
|
|
33010
|
+
toJSON(message) {
|
|
33011
|
+
const obj = {};
|
|
33012
|
+
if (message.tags?.length) {
|
|
33013
|
+
obj.tags = message.tags.map((e) => SandboxTag.toJSON(e));
|
|
33014
|
+
}
|
|
33015
|
+
return obj;
|
|
33016
|
+
},
|
|
33017
|
+
create(base) {
|
|
33018
|
+
return SandboxTagsGetResponse.fromPartial(base ?? {});
|
|
33019
|
+
},
|
|
33020
|
+
fromPartial(object) {
|
|
33021
|
+
const message = createBaseSandboxTagsGetResponse();
|
|
33022
|
+
message.tags = object.tags?.map((e) => SandboxTag.fromPartial(e)) || [];
|
|
33023
|
+
return message;
|
|
33024
|
+
}
|
|
33025
|
+
};
|
|
32669
33026
|
function createBaseSandboxTagsSetRequest() {
|
|
32670
33027
|
return { environmentName: "", sandboxId: "", tags: [] };
|
|
32671
33028
|
}
|
|
@@ -41260,6 +41617,14 @@ var ModalClientDefinition = {
|
|
|
41260
41617
|
responseStream: false,
|
|
41261
41618
|
options: {}
|
|
41262
41619
|
},
|
|
41620
|
+
sandboxTagsGet: {
|
|
41621
|
+
name: "SandboxTagsGet",
|
|
41622
|
+
requestType: SandboxTagsGetRequest,
|
|
41623
|
+
requestStream: false,
|
|
41624
|
+
responseType: SandboxTagsGetResponse,
|
|
41625
|
+
responseStream: false,
|
|
41626
|
+
options: {}
|
|
41627
|
+
},
|
|
41263
41628
|
sandboxTagsSet: {
|
|
41264
41629
|
name: "SandboxTagsSet",
|
|
41265
41630
|
requestType: SandboxTagsSetRequest,
|
|
@@ -41695,9 +42060,135 @@ function imageBuilderVersion(version) {
|
|
|
41695
42060
|
return version || clientProfile.imageBuilderVersion || "2024.10";
|
|
41696
42061
|
}
|
|
41697
42062
|
|
|
42063
|
+
// src/auth_token_manager.ts
|
|
42064
|
+
var REFRESH_WINDOW = 5 * 60;
|
|
42065
|
+
var DEFAULT_EXPIRY_OFFSET = 20 * 60;
|
|
42066
|
+
var AuthTokenManager = class {
|
|
42067
|
+
client;
|
|
42068
|
+
currentToken = "";
|
|
42069
|
+
tokenExpiry = 0;
|
|
42070
|
+
stopped = false;
|
|
42071
|
+
timeoutId = null;
|
|
42072
|
+
initialTokenPromise = null;
|
|
42073
|
+
constructor(client2) {
|
|
42074
|
+
this.client = client2;
|
|
42075
|
+
}
|
|
42076
|
+
/**
|
|
42077
|
+
* Returns the current cached token.
|
|
42078
|
+
* If the initial token fetch is still in progress, waits for it to complete.
|
|
42079
|
+
*/
|
|
42080
|
+
async getToken() {
|
|
42081
|
+
if (this.initialTokenPromise) {
|
|
42082
|
+
await this.initialTokenPromise;
|
|
42083
|
+
}
|
|
42084
|
+
if (this.currentToken && !this.isExpired()) {
|
|
42085
|
+
return this.currentToken;
|
|
42086
|
+
}
|
|
42087
|
+
throw new Error("No valid auth token available");
|
|
42088
|
+
}
|
|
42089
|
+
/**
|
|
42090
|
+
* Fetches a new auth token from the server and stores it.
|
|
42091
|
+
*/
|
|
42092
|
+
async fetchToken() {
|
|
42093
|
+
const response = await this.client.authTokenGet({});
|
|
42094
|
+
const token = response.token;
|
|
42095
|
+
if (!token) {
|
|
42096
|
+
throw new Error(
|
|
42097
|
+
"Internal error: did not receive auth token from server, please contact Modal support"
|
|
42098
|
+
);
|
|
42099
|
+
}
|
|
42100
|
+
this.currentToken = token;
|
|
42101
|
+
const exp = this.decodeJWT(token);
|
|
42102
|
+
if (exp > 0) {
|
|
42103
|
+
this.tokenExpiry = exp;
|
|
42104
|
+
} else {
|
|
42105
|
+
console.warn("Failed to decode x-modal-auth-token exp field");
|
|
42106
|
+
this.tokenExpiry = Math.floor(Date.now() / 1e3) + DEFAULT_EXPIRY_OFFSET;
|
|
42107
|
+
}
|
|
42108
|
+
}
|
|
42109
|
+
/**
|
|
42110
|
+
* Background loop that refreshes tokens REFRESH_WINDOW seconds before they expire.
|
|
42111
|
+
*/
|
|
42112
|
+
async backgroundRefresh() {
|
|
42113
|
+
while (!this.stopped) {
|
|
42114
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
42115
|
+
const refreshTime = this.tokenExpiry - REFRESH_WINDOW;
|
|
42116
|
+
const delay = Math.max(0, refreshTime - now) * 1e3;
|
|
42117
|
+
await new Promise((resolve) => {
|
|
42118
|
+
this.timeoutId = setTimeout(resolve, delay);
|
|
42119
|
+
this.timeoutId.unref();
|
|
42120
|
+
});
|
|
42121
|
+
if (this.stopped) {
|
|
42122
|
+
return;
|
|
42123
|
+
}
|
|
42124
|
+
try {
|
|
42125
|
+
await this.fetchToken();
|
|
42126
|
+
} catch (error) {
|
|
42127
|
+
console.error("Failed to refresh auth token:", error);
|
|
42128
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
42129
|
+
}
|
|
42130
|
+
}
|
|
42131
|
+
}
|
|
42132
|
+
/**
|
|
42133
|
+
* Fetches the initial token and starts the refresh loop.
|
|
42134
|
+
* Throws an error if the initial token fetch fails.
|
|
42135
|
+
*/
|
|
42136
|
+
async start() {
|
|
42137
|
+
this.initialTokenPromise = this.fetchToken();
|
|
42138
|
+
try {
|
|
42139
|
+
await this.initialTokenPromise;
|
|
42140
|
+
} finally {
|
|
42141
|
+
this.initialTokenPromise = null;
|
|
42142
|
+
}
|
|
42143
|
+
this.stopped = false;
|
|
42144
|
+
this.backgroundRefresh();
|
|
42145
|
+
}
|
|
42146
|
+
/**
|
|
42147
|
+
* Stops the background refresh.
|
|
42148
|
+
*/
|
|
42149
|
+
stop() {
|
|
42150
|
+
this.stopped = true;
|
|
42151
|
+
if (this.timeoutId) {
|
|
42152
|
+
clearTimeout(this.timeoutId);
|
|
42153
|
+
this.timeoutId = null;
|
|
42154
|
+
}
|
|
42155
|
+
}
|
|
42156
|
+
/**
|
|
42157
|
+
* Extracts the exp claim from a JWT token.
|
|
42158
|
+
*/
|
|
42159
|
+
decodeJWT(token) {
|
|
42160
|
+
try {
|
|
42161
|
+
const parts = token.split(".");
|
|
42162
|
+
if (parts.length !== 3) {
|
|
42163
|
+
return 0;
|
|
42164
|
+
}
|
|
42165
|
+
let payload = parts[1];
|
|
42166
|
+
while (payload.length % 4 !== 0) {
|
|
42167
|
+
payload += "=";
|
|
42168
|
+
}
|
|
42169
|
+
const decoded = atob(payload);
|
|
42170
|
+
const claims = JSON.parse(decoded);
|
|
42171
|
+
return claims.exp || 0;
|
|
42172
|
+
} catch {
|
|
42173
|
+
return 0;
|
|
42174
|
+
}
|
|
42175
|
+
}
|
|
42176
|
+
isExpired() {
|
|
42177
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
42178
|
+
return now >= this.tokenExpiry;
|
|
42179
|
+
}
|
|
42180
|
+
getCurrentToken() {
|
|
42181
|
+
return this.currentToken;
|
|
42182
|
+
}
|
|
42183
|
+
setToken(token, expiry) {
|
|
42184
|
+
this.currentToken = token;
|
|
42185
|
+
this.tokenExpiry = expiry;
|
|
42186
|
+
}
|
|
42187
|
+
};
|
|
42188
|
+
|
|
41698
42189
|
// src/client.ts
|
|
41699
42190
|
var defaultProfile = getProfile(process.env["MODAL_PROFILE"]);
|
|
41700
|
-
var
|
|
42191
|
+
var authTokenManager = null;
|
|
41701
42192
|
function authMiddleware(profile) {
|
|
41702
42193
|
return async function* authMiddleware2(call, options) {
|
|
41703
42194
|
if (!profile.tokenId || !profile.tokenSecret) {
|
|
@@ -41714,25 +42205,16 @@ function authMiddleware(profile) {
|
|
|
41714
42205
|
options.metadata.set("x-modal-client-version", "1.0.0");
|
|
41715
42206
|
options.metadata.set("x-modal-token-id", tokenId);
|
|
41716
42207
|
options.metadata.set("x-modal-token-secret", tokenSecret);
|
|
41717
|
-
if (
|
|
41718
|
-
|
|
41719
|
-
|
|
41720
|
-
|
|
41721
|
-
options.onHeader = (header) => {
|
|
41722
|
-
const token = header.get("x-modal-auth-token");
|
|
41723
|
-
if (token) {
|
|
41724
|
-
modalAuthToken = token;
|
|
42208
|
+
if (call.method.path !== "/modal.client.ModalClient/AuthTokenGet") {
|
|
42209
|
+
if (!authTokenManager) {
|
|
42210
|
+
authTokenManager = new AuthTokenManager(client);
|
|
42211
|
+
authTokenManager.start();
|
|
41725
42212
|
}
|
|
41726
|
-
|
|
41727
|
-
};
|
|
41728
|
-
const prevOnTrailer = options.onTrailer;
|
|
41729
|
-
options.onTrailer = (trailer) => {
|
|
41730
|
-
const token = trailer.get("x-modal-auth-token");
|
|
42213
|
+
const token = await authTokenManager.getToken();
|
|
41731
42214
|
if (token) {
|
|
41732
|
-
|
|
42215
|
+
options.metadata.set("x-modal-auth-token", token);
|
|
41733
42216
|
}
|
|
41734
|
-
|
|
41735
|
-
};
|
|
42217
|
+
}
|
|
41736
42218
|
return yield* call.next(call.request, options);
|
|
41737
42219
|
};
|
|
41738
42220
|
}
|
|
@@ -41868,6 +42350,8 @@ function initializeClient(options) {
|
|
|
41868
42350
|
};
|
|
41869
42351
|
clientProfile = mergedProfile;
|
|
41870
42352
|
client = createClient(mergedProfile);
|
|
42353
|
+
authTokenManager = new AuthTokenManager(client);
|
|
42354
|
+
authTokenManager.start();
|
|
41871
42355
|
}
|
|
41872
42356
|
|
|
41873
42357
|
// src/secret.ts
|
|
@@ -41984,6 +42468,13 @@ var Secret = class _Secret {
|
|
|
41984
42468
|
}
|
|
41985
42469
|
}
|
|
41986
42470
|
};
|
|
42471
|
+
async function mergeEnvAndSecrets(env, secrets) {
|
|
42472
|
+
const result = [...secrets || []];
|
|
42473
|
+
if (env && Object.keys(env).length > 0) {
|
|
42474
|
+
result.push(await Secret.fromObject(env));
|
|
42475
|
+
}
|
|
42476
|
+
return result;
|
|
42477
|
+
}
|
|
41987
42478
|
|
|
41988
42479
|
// src/image.ts
|
|
41989
42480
|
var import_nice_grpc3 = require("nice-grpc");
|
|
@@ -42001,6 +42492,7 @@ var Image2 = class _Image {
|
|
|
42001
42492
|
this.#layers = layers || [
|
|
42002
42493
|
{
|
|
42003
42494
|
commands: [],
|
|
42495
|
+
env: void 0,
|
|
42004
42496
|
secrets: void 0,
|
|
42005
42497
|
gpuConfig: void 0,
|
|
42006
42498
|
forceBuild: false
|
|
@@ -42117,6 +42609,7 @@ var Image2 = class _Image {
|
|
|
42117
42609
|
_Image.validateDockerfileCommands(commands);
|
|
42118
42610
|
const newLayer = {
|
|
42119
42611
|
commands: [...commands],
|
|
42612
|
+
env: options?.env,
|
|
42120
42613
|
secrets: options?.secrets,
|
|
42121
42614
|
gpuConfig: options?.gpu ? parseGpuConfig(options.gpu) : void 0,
|
|
42122
42615
|
forceBuild: options?.forceBuild
|
|
@@ -42138,7 +42631,8 @@ var Image2 = class _Image {
|
|
|
42138
42631
|
let baseImageId;
|
|
42139
42632
|
for (let i = 0; i < this.#layers.length; i++) {
|
|
42140
42633
|
const layer = this.#layers[i];
|
|
42141
|
-
const
|
|
42634
|
+
const mergedSecrets = await mergeEnvAndSecrets(layer.env, layer.secrets);
|
|
42635
|
+
const secretIds = mergedSecrets.map((secret) => secret.secretId);
|
|
42142
42636
|
const gpuConfig = layer.gpuConfig;
|
|
42143
42637
|
let dockerfileCommands;
|
|
42144
42638
|
let baseImages;
|
|
@@ -42469,8 +42963,12 @@ function defaultSandboxPTYInfo() {
|
|
|
42469
42963
|
noTerminateOnIdleStdin: true
|
|
42470
42964
|
});
|
|
42471
42965
|
}
|
|
42472
|
-
function
|
|
42473
|
-
const
|
|
42966
|
+
async function buildContainerExecRequestProto(taskId, command, options) {
|
|
42967
|
+
const mergedSecrets = await mergeEnvAndSecrets(
|
|
42968
|
+
options?.env,
|
|
42969
|
+
options?.secrets
|
|
42970
|
+
);
|
|
42971
|
+
const secretIds = mergedSecrets.map((secret) => secret.secretId);
|
|
42474
42972
|
let ptyInfo;
|
|
42475
42973
|
if (options?.pty) {
|
|
42476
42974
|
ptyInfo = defaultSandboxPTYInfo();
|
|
@@ -42525,6 +43023,23 @@ var Sandbox2 = class _Sandbox {
|
|
|
42525
43023
|
throw err;
|
|
42526
43024
|
}
|
|
42527
43025
|
}
|
|
43026
|
+
/** Get tags (key-value pairs) currently attached to this Sandbox from the server. */
|
|
43027
|
+
async getTags() {
|
|
43028
|
+
let resp;
|
|
43029
|
+
try {
|
|
43030
|
+
resp = await client.sandboxTagsGet({ sandboxId: this.sandboxId });
|
|
43031
|
+
} catch (err) {
|
|
43032
|
+
if (err instanceof import_nice_grpc5.ClientError && err.code === import_nice_grpc5.Status.INVALID_ARGUMENT) {
|
|
43033
|
+
throw new InvalidError(err.details || err.message);
|
|
43034
|
+
}
|
|
43035
|
+
throw err;
|
|
43036
|
+
}
|
|
43037
|
+
const tags = {};
|
|
43038
|
+
for (const tag of resp.tags) {
|
|
43039
|
+
tags[tag.tagName] = tag.tagValue;
|
|
43040
|
+
}
|
|
43041
|
+
return tags;
|
|
43042
|
+
}
|
|
42528
43043
|
/** Returns a running Sandbox object from an ID.
|
|
42529
43044
|
*
|
|
42530
43045
|
* @returns Sandbox with ID
|
|
@@ -42588,7 +43103,7 @@ var Sandbox2 = class _Sandbox {
|
|
|
42588
43103
|
}
|
|
42589
43104
|
async exec(command, options) {
|
|
42590
43105
|
const taskId = await this.#getTaskId();
|
|
42591
|
-
const req =
|
|
43106
|
+
const req = await buildContainerExecRequestProto(taskId, command, options);
|
|
42592
43107
|
const resp = await client.containerExec(req);
|
|
42593
43108
|
return new ContainerProcess(resp.execId, options);
|
|
42594
43109
|
}
|
|
@@ -42976,7 +43491,7 @@ function parseGpuConfig(gpu) {
|
|
|
42976
43491
|
gpuType: gpuType.toUpperCase()
|
|
42977
43492
|
};
|
|
42978
43493
|
}
|
|
42979
|
-
function
|
|
43494
|
+
async function buildSandboxCreateRequestProto(appId, imageId, options = {}) {
|
|
42980
43495
|
const gpuConfig = parseGpuConfig(options.gpu);
|
|
42981
43496
|
if (options.timeout && options.timeout % 1e3 !== 0) {
|
|
42982
43497
|
throw new Error(
|
|
@@ -43028,7 +43543,8 @@ function sandboxCreateRequestProto(appId, imageId, options = {}) {
|
|
|
43028
43543
|
}))
|
|
43029
43544
|
);
|
|
43030
43545
|
}
|
|
43031
|
-
const
|
|
43546
|
+
const mergedSecrets = await mergeEnvAndSecrets(options.env, options.secrets);
|
|
43547
|
+
const secretIds = mergedSecrets.map((secret) => secret.secretId);
|
|
43032
43548
|
let networkAccess;
|
|
43033
43549
|
if (options.blockNetwork) {
|
|
43034
43550
|
if (options.cidrAllowlist) {
|
|
@@ -43112,7 +43628,7 @@ var App2 = class _App {
|
|
|
43112
43628
|
}
|
|
43113
43629
|
async createSandbox(image, options = {}) {
|
|
43114
43630
|
await image.build(this);
|
|
43115
|
-
const createReq =
|
|
43631
|
+
const createReq = await buildSandboxCreateRequestProto(
|
|
43116
43632
|
this.appId,
|
|
43117
43633
|
image.imageId,
|
|
43118
43634
|
options
|
|
@@ -43249,7 +43765,7 @@ function encodeValue(val, w, proto) {
|
|
|
43249
43765
|
if (val >= 0 && val <= 255) {
|
|
43250
43766
|
w.byte(75 /* BININT1 */);
|
|
43251
43767
|
w.byte(val);
|
|
43252
|
-
} else if (val >=
|
|
43768
|
+
} else if (val >= 0 && val <= 65535) {
|
|
43253
43769
|
w.byte(77 /* BININT2 */);
|
|
43254
43770
|
w.byte(val & 255);
|
|
43255
43771
|
w.byte(val >> 8 & 255);
|
|
@@ -43384,7 +43900,7 @@ function loads(buf) {
|
|
|
43384
43900
|
case 77 /* BININT2 */: {
|
|
43385
43901
|
const lo = r.byte(), hi = r.byte();
|
|
43386
43902
|
const n = hi << 8 | lo;
|
|
43387
|
-
push(n
|
|
43903
|
+
push(n);
|
|
43388
43904
|
break;
|
|
43389
43905
|
}
|
|
43390
43906
|
case 74 /* BININT4 */: {
|
|
@@ -44050,7 +44566,7 @@ var Cls = class _Cls {
|
|
|
44050
44566
|
/** Bind parameters to the Cls function. */
|
|
44051
44567
|
async #bindParameters(params) {
|
|
44052
44568
|
const serializedParams = encodeParameterSet(this.#schema, params);
|
|
44053
|
-
const functionOptions = buildFunctionOptionsProto(this.#options);
|
|
44569
|
+
const functionOptions = await buildFunctionOptionsProto(this.#options);
|
|
44054
44570
|
const bindResp = await client.functionBindParams({
|
|
44055
44571
|
functionId: this.#serviceFunctionId,
|
|
44056
44572
|
serializedParams,
|
|
@@ -44075,7 +44591,7 @@ function mergeServiceOptions(base, diff) {
|
|
|
44075
44591
|
const merged = { ...base ?? {}, ...filteredDiff };
|
|
44076
44592
|
return Object.keys(merged).length === 0 ? void 0 : merged;
|
|
44077
44593
|
}
|
|
44078
|
-
function buildFunctionOptionsProto(options) {
|
|
44594
|
+
async function buildFunctionOptionsProto(options) {
|
|
44079
44595
|
if (!options) return void 0;
|
|
44080
44596
|
const o = options ?? {};
|
|
44081
44597
|
const gpuConfig = parseGpuConfig(o.gpu);
|
|
@@ -44084,7 +44600,8 @@ function buildFunctionOptionsProto(options) {
|
|
|
44084
44600
|
memoryMb: o.memory,
|
|
44085
44601
|
gpuConfig
|
|
44086
44602
|
} : void 0;
|
|
44087
|
-
const
|
|
44603
|
+
const mergedSecrets = await mergeEnvAndSecrets(o.env, o.secrets);
|
|
44604
|
+
const secretIds = mergedSecrets.map((s) => s.secretId);
|
|
44088
44605
|
const volumeMounts = o.volumes ? Object.entries(o.volumes).map(([mountPath, volume]) => ({
|
|
44089
44606
|
volumeId: volume.volumeId,
|
|
44090
44607
|
mountPath,
|