modal 0.3.3 → 0.3.4
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.d.ts +80 -8
- package/dist/index.js +485 -114
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
|
+
|
|
1
3
|
declare class Image {
|
|
2
4
|
readonly imageId: string;
|
|
3
5
|
constructor(imageId: string);
|
|
@@ -93,6 +95,80 @@ declare class App {
|
|
|
93
95
|
imageFromRegistry(tag: string): Promise<Image>;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
declare enum ParameterType {
|
|
99
|
+
PARAM_TYPE_UNSPECIFIED = 0,
|
|
100
|
+
PARAM_TYPE_STRING = 1,
|
|
101
|
+
PARAM_TYPE_INT = 2,
|
|
102
|
+
/** PARAM_TYPE_PICKLE - currently unused */
|
|
103
|
+
PARAM_TYPE_PICKLE = 3,
|
|
104
|
+
PARAM_TYPE_BYTES = 4,
|
|
105
|
+
/** PARAM_TYPE_UNKNOWN - used in schemas to signify unrecognized or un-annotated types */
|
|
106
|
+
PARAM_TYPE_UNKNOWN = 5,
|
|
107
|
+
PARAM_TYPE_LIST = 6,
|
|
108
|
+
PARAM_TYPE_DICT = 7,
|
|
109
|
+
PARAM_TYPE_NONE = 8,
|
|
110
|
+
PARAM_TYPE_BOOL = 9,
|
|
111
|
+
UNRECOGNIZED = -1
|
|
112
|
+
}
|
|
113
|
+
/** TODO: rename into NamedPayloadType or similar */
|
|
114
|
+
interface ClassParameterSpec {
|
|
115
|
+
name: string;
|
|
116
|
+
/** TODO: deprecate - use full_type instead */
|
|
117
|
+
type: ParameterType;
|
|
118
|
+
hasDefault: boolean;
|
|
119
|
+
/** Default *values* are only registered for class parameters */
|
|
120
|
+
stringDefault?: string | undefined;
|
|
121
|
+
intDefault?: number | undefined;
|
|
122
|
+
pickleDefault?: Uint8Array | undefined;
|
|
123
|
+
bytesDefault?: Uint8Array | undefined;
|
|
124
|
+
boolDefault?: boolean | undefined;
|
|
125
|
+
/** supersedes `type` */
|
|
126
|
+
fullType: GenericPayloadType | undefined;
|
|
127
|
+
}
|
|
128
|
+
declare const ClassParameterSpec: MessageFns<ClassParameterSpec>;
|
|
129
|
+
interface GenericPayloadType {
|
|
130
|
+
baseType: ParameterType;
|
|
131
|
+
/** sub-type for generic types like lists */
|
|
132
|
+
subTypes: GenericPayloadType[];
|
|
133
|
+
}
|
|
134
|
+
declare const GenericPayloadType: MessageFns<GenericPayloadType>;
|
|
135
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
136
|
+
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
137
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
138
|
+
} : Partial<T>;
|
|
139
|
+
interface MessageFns<T> {
|
|
140
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
141
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
142
|
+
fromJSON(object: any): T;
|
|
143
|
+
toJSON(message: T): unknown;
|
|
144
|
+
create(base?: DeepPartial<T>): T;
|
|
145
|
+
fromPartial(object: DeepPartial<T>): T;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Represents a deployed Modal Function, which can be invoked remotely. */
|
|
149
|
+
declare class Function_ {
|
|
150
|
+
readonly functionId: string;
|
|
151
|
+
readonly methodName: string | undefined;
|
|
152
|
+
constructor(functionId: string, methodName?: string);
|
|
153
|
+
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
154
|
+
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Represents a deployed Modal Cls. */
|
|
158
|
+
declare class Cls {
|
|
159
|
+
#private;
|
|
160
|
+
constructor(serviceFunctionId: string, schema: ClassParameterSpec[], methodNames: string[]);
|
|
161
|
+
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Cls>;
|
|
162
|
+
/** Create a new instance of the Cls with parameters. */
|
|
163
|
+
instance(params?: Record<string, any>): Promise<ClsInstance>;
|
|
164
|
+
}
|
|
165
|
+
/** Represents an instance of a deployed Modal Cls, optionally with parameters. */
|
|
166
|
+
declare class ClsInstance {
|
|
167
|
+
#private;
|
|
168
|
+
constructor(methods: Map<string, Function_>);
|
|
169
|
+
method(name: string): Function_;
|
|
170
|
+
}
|
|
171
|
+
|
|
96
172
|
/** Function execution exceeds the allowed time limit. */
|
|
97
173
|
declare class TimeoutError extends Error {
|
|
98
174
|
constructor(message: string);
|
|
@@ -105,13 +181,9 @@ declare class RemoteError extends Error {
|
|
|
105
181
|
declare class InternalFailure extends Error {
|
|
106
182
|
constructor(message: string);
|
|
107
183
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
readonly functionId: string;
|
|
112
|
-
constructor(functionId: string);
|
|
113
|
-
static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
|
|
114
|
-
remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
|
|
184
|
+
/** Some resource was not found. */
|
|
185
|
+
declare class NotFoundError extends Error {
|
|
186
|
+
constructor(message: string);
|
|
115
187
|
}
|
|
116
188
|
|
|
117
|
-
export { App, Function_, Image, InternalFailure, type LookupOptions, RemoteError, Sandbox, type SandboxCreateOptions, type StdioBehavior, type StreamMode, TimeoutError };
|
|
189
|
+
export { App, Cls, ClsInstance, Function_, Image, InternalFailure, type LookupOptions, NotFoundError, RemoteError, Sandbox, type SandboxCreateOptions, type StdioBehavior, type StreamMode, TimeoutError };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/app.ts
|
|
2
|
+
import { ClientError as ClientError2, Status as Status2 } from "nice-grpc";
|
|
3
|
+
|
|
1
4
|
// node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js
|
|
2
5
|
function varint64read() {
|
|
3
6
|
let lowBits = 0;
|
|
@@ -3858,7 +3861,7 @@ var AppGetObjectsItem = {
|
|
|
3858
3861
|
writer.uint32(10).string(message.tag);
|
|
3859
3862
|
}
|
|
3860
3863
|
if (message.object !== void 0) {
|
|
3861
|
-
|
|
3864
|
+
Object_.encode(message.object, writer.uint32(50).fork()).join();
|
|
3862
3865
|
}
|
|
3863
3866
|
return writer;
|
|
3864
3867
|
},
|
|
@@ -3880,7 +3883,7 @@ var AppGetObjectsItem = {
|
|
|
3880
3883
|
if (tag !== 50) {
|
|
3881
3884
|
break;
|
|
3882
3885
|
}
|
|
3883
|
-
message.object =
|
|
3886
|
+
message.object = Object_.decode(reader, reader.uint32());
|
|
3884
3887
|
continue;
|
|
3885
3888
|
}
|
|
3886
3889
|
}
|
|
@@ -3894,7 +3897,7 @@ var AppGetObjectsItem = {
|
|
|
3894
3897
|
fromJSON(object) {
|
|
3895
3898
|
return {
|
|
3896
3899
|
tag: isSet3(object.tag) ? globalThis.String(object.tag) : "",
|
|
3897
|
-
object: isSet3(object.object) ?
|
|
3900
|
+
object: isSet3(object.object) ? Object_.fromJSON(object.object) : void 0
|
|
3898
3901
|
};
|
|
3899
3902
|
},
|
|
3900
3903
|
toJSON(message) {
|
|
@@ -3903,7 +3906,7 @@ var AppGetObjectsItem = {
|
|
|
3903
3906
|
obj.tag = message.tag;
|
|
3904
3907
|
}
|
|
3905
3908
|
if (message.object !== void 0) {
|
|
3906
|
-
obj.object =
|
|
3909
|
+
obj.object = Object_.toJSON(message.object);
|
|
3907
3910
|
}
|
|
3908
3911
|
return obj;
|
|
3909
3912
|
},
|
|
@@ -3913,7 +3916,7 @@ var AppGetObjectsItem = {
|
|
|
3913
3916
|
fromPartial(object) {
|
|
3914
3917
|
const message = createBaseAppGetObjectsItem();
|
|
3915
3918
|
message.tag = object.tag ?? "";
|
|
3916
|
-
message.object = object.object !== void 0 && object.object !== null ?
|
|
3919
|
+
message.object = object.object !== void 0 && object.object !== null ? Object_.fromPartial(object.object) : void 0;
|
|
3917
3920
|
return message;
|
|
3918
3921
|
}
|
|
3919
3922
|
};
|
|
@@ -4244,12 +4247,12 @@ function createBaseAppLayout() {
|
|
|
4244
4247
|
var AppLayout = {
|
|
4245
4248
|
encode(message, writer = new BinaryWriter()) {
|
|
4246
4249
|
for (const v of message.objects) {
|
|
4247
|
-
|
|
4250
|
+
Object_.encode(v, writer.uint32(10).fork()).join();
|
|
4248
4251
|
}
|
|
4249
|
-
|
|
4252
|
+
Object.entries(message.functionIds).forEach(([key, value]) => {
|
|
4250
4253
|
AppLayout_FunctionIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
|
|
4251
4254
|
});
|
|
4252
|
-
|
|
4255
|
+
Object.entries(message.classIds).forEach(([key, value]) => {
|
|
4253
4256
|
AppLayout_ClassIdsEntry.encode({ key, value }, writer.uint32(26).fork()).join();
|
|
4254
4257
|
});
|
|
4255
4258
|
return writer;
|
|
@@ -4265,7 +4268,7 @@ var AppLayout = {
|
|
|
4265
4268
|
if (tag !== 10) {
|
|
4266
4269
|
break;
|
|
4267
4270
|
}
|
|
4268
|
-
message.objects.push(
|
|
4271
|
+
message.objects.push(Object_.decode(reader, reader.uint32()));
|
|
4269
4272
|
continue;
|
|
4270
4273
|
}
|
|
4271
4274
|
case 2: {
|
|
@@ -4298,12 +4301,12 @@ var AppLayout = {
|
|
|
4298
4301
|
},
|
|
4299
4302
|
fromJSON(object) {
|
|
4300
4303
|
return {
|
|
4301
|
-
objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) =>
|
|
4302
|
-
functionIds: isObject2(object.functionIds) ?
|
|
4304
|
+
objects: globalThis.Array.isArray(object?.objects) ? object.objects.map((e) => Object_.fromJSON(e)) : [],
|
|
4305
|
+
functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
|
|
4303
4306
|
acc[key] = String(value);
|
|
4304
4307
|
return acc;
|
|
4305
4308
|
}, {}) : {},
|
|
4306
|
-
classIds: isObject2(object.classIds) ?
|
|
4309
|
+
classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
|
|
4307
4310
|
acc[key] = String(value);
|
|
4308
4311
|
return acc;
|
|
4309
4312
|
}, {}) : {}
|
|
@@ -4312,10 +4315,10 @@ var AppLayout = {
|
|
|
4312
4315
|
toJSON(message) {
|
|
4313
4316
|
const obj = {};
|
|
4314
4317
|
if (message.objects?.length) {
|
|
4315
|
-
obj.objects = message.objects.map((e) =>
|
|
4318
|
+
obj.objects = message.objects.map((e) => Object_.toJSON(e));
|
|
4316
4319
|
}
|
|
4317
4320
|
if (message.functionIds) {
|
|
4318
|
-
const entries =
|
|
4321
|
+
const entries = Object.entries(message.functionIds);
|
|
4319
4322
|
if (entries.length > 0) {
|
|
4320
4323
|
obj.functionIds = {};
|
|
4321
4324
|
entries.forEach(([k, v]) => {
|
|
@@ -4324,7 +4327,7 @@ var AppLayout = {
|
|
|
4324
4327
|
}
|
|
4325
4328
|
}
|
|
4326
4329
|
if (message.classIds) {
|
|
4327
|
-
const entries =
|
|
4330
|
+
const entries = Object.entries(message.classIds);
|
|
4328
4331
|
if (entries.length > 0) {
|
|
4329
4332
|
obj.classIds = {};
|
|
4330
4333
|
entries.forEach(([k, v]) => {
|
|
@@ -4339,8 +4342,8 @@ var AppLayout = {
|
|
|
4339
4342
|
},
|
|
4340
4343
|
fromPartial(object) {
|
|
4341
4344
|
const message = createBaseAppLayout();
|
|
4342
|
-
message.objects = object.objects?.map((e) =>
|
|
4343
|
-
message.functionIds =
|
|
4345
|
+
message.objects = object.objects?.map((e) => Object_.fromPartial(e)) || [];
|
|
4346
|
+
message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
|
|
4344
4347
|
(acc, [key, value]) => {
|
|
4345
4348
|
if (value !== void 0) {
|
|
4346
4349
|
acc[key] = globalThis.String(value);
|
|
@@ -4349,7 +4352,7 @@ var AppLayout = {
|
|
|
4349
4352
|
},
|
|
4350
4353
|
{}
|
|
4351
4354
|
);
|
|
4352
|
-
message.classIds =
|
|
4355
|
+
message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
|
|
4353
4356
|
if (value !== void 0) {
|
|
4354
4357
|
acc[key] = globalThis.String(value);
|
|
4355
4358
|
}
|
|
@@ -4888,13 +4891,13 @@ var AppPublishRequest = {
|
|
|
4888
4891
|
if (message.appState !== 0) {
|
|
4889
4892
|
writer.uint32(32).int32(message.appState);
|
|
4890
4893
|
}
|
|
4891
|
-
|
|
4894
|
+
Object.entries(message.functionIds).forEach(([key, value]) => {
|
|
4892
4895
|
AppPublishRequest_FunctionIdsEntry.encode({ key, value }, writer.uint32(42).fork()).join();
|
|
4893
4896
|
});
|
|
4894
|
-
|
|
4897
|
+
Object.entries(message.classIds).forEach(([key, value]) => {
|
|
4895
4898
|
AppPublishRequest_ClassIdsEntry.encode({ key, value }, writer.uint32(50).fork()).join();
|
|
4896
4899
|
});
|
|
4897
|
-
|
|
4900
|
+
Object.entries(message.definitionIds).forEach(([key, value]) => {
|
|
4898
4901
|
AppPublishRequest_DefinitionIdsEntry.encode({ key, value }, writer.uint32(58).fork()).join();
|
|
4899
4902
|
});
|
|
4900
4903
|
if (message.rollbackVersion !== 0) {
|
|
@@ -5008,15 +5011,15 @@ var AppPublishRequest = {
|
|
|
5008
5011
|
name: isSet3(object.name) ? globalThis.String(object.name) : "",
|
|
5009
5012
|
deploymentTag: isSet3(object.deploymentTag) ? globalThis.String(object.deploymentTag) : "",
|
|
5010
5013
|
appState: isSet3(object.appState) ? appStateFromJSON(object.appState) : 0,
|
|
5011
|
-
functionIds: isObject2(object.functionIds) ?
|
|
5014
|
+
functionIds: isObject2(object.functionIds) ? Object.entries(object.functionIds).reduce((acc, [key, value]) => {
|
|
5012
5015
|
acc[key] = String(value);
|
|
5013
5016
|
return acc;
|
|
5014
5017
|
}, {}) : {},
|
|
5015
|
-
classIds: isObject2(object.classIds) ?
|
|
5018
|
+
classIds: isObject2(object.classIds) ? Object.entries(object.classIds).reduce((acc, [key, value]) => {
|
|
5016
5019
|
acc[key] = String(value);
|
|
5017
5020
|
return acc;
|
|
5018
5021
|
}, {}) : {},
|
|
5019
|
-
definitionIds: isObject2(object.definitionIds) ?
|
|
5022
|
+
definitionIds: isObject2(object.definitionIds) ? Object.entries(object.definitionIds).reduce((acc, [key, value]) => {
|
|
5020
5023
|
acc[key] = String(value);
|
|
5021
5024
|
return acc;
|
|
5022
5025
|
}, {}) : {},
|
|
@@ -5040,7 +5043,7 @@ var AppPublishRequest = {
|
|
|
5040
5043
|
obj.appState = appStateToJSON(message.appState);
|
|
5041
5044
|
}
|
|
5042
5045
|
if (message.functionIds) {
|
|
5043
|
-
const entries =
|
|
5046
|
+
const entries = Object.entries(message.functionIds);
|
|
5044
5047
|
if (entries.length > 0) {
|
|
5045
5048
|
obj.functionIds = {};
|
|
5046
5049
|
entries.forEach(([k, v]) => {
|
|
@@ -5049,7 +5052,7 @@ var AppPublishRequest = {
|
|
|
5049
5052
|
}
|
|
5050
5053
|
}
|
|
5051
5054
|
if (message.classIds) {
|
|
5052
|
-
const entries =
|
|
5055
|
+
const entries = Object.entries(message.classIds);
|
|
5053
5056
|
if (entries.length > 0) {
|
|
5054
5057
|
obj.classIds = {};
|
|
5055
5058
|
entries.forEach(([k, v]) => {
|
|
@@ -5058,7 +5061,7 @@ var AppPublishRequest = {
|
|
|
5058
5061
|
}
|
|
5059
5062
|
}
|
|
5060
5063
|
if (message.definitionIds) {
|
|
5061
|
-
const entries =
|
|
5064
|
+
const entries = Object.entries(message.definitionIds);
|
|
5062
5065
|
if (entries.length > 0) {
|
|
5063
5066
|
obj.definitionIds = {};
|
|
5064
5067
|
entries.forEach(([k, v]) => {
|
|
@@ -5086,7 +5089,7 @@ var AppPublishRequest = {
|
|
|
5086
5089
|
message.name = object.name ?? "";
|
|
5087
5090
|
message.deploymentTag = object.deploymentTag ?? "";
|
|
5088
5091
|
message.appState = object.appState ?? 0;
|
|
5089
|
-
message.functionIds =
|
|
5092
|
+
message.functionIds = Object.entries(object.functionIds ?? {}).reduce(
|
|
5090
5093
|
(acc, [key, value]) => {
|
|
5091
5094
|
if (value !== void 0) {
|
|
5092
5095
|
acc[key] = globalThis.String(value);
|
|
@@ -5095,13 +5098,13 @@ var AppPublishRequest = {
|
|
|
5095
5098
|
},
|
|
5096
5099
|
{}
|
|
5097
5100
|
);
|
|
5098
|
-
message.classIds =
|
|
5101
|
+
message.classIds = Object.entries(object.classIds ?? {}).reduce((acc, [key, value]) => {
|
|
5099
5102
|
if (value !== void 0) {
|
|
5100
5103
|
acc[key] = globalThis.String(value);
|
|
5101
5104
|
}
|
|
5102
5105
|
return acc;
|
|
5103
5106
|
}, {});
|
|
5104
|
-
message.definitionIds =
|
|
5107
|
+
message.definitionIds = Object.entries(object.definitionIds ?? {}).reduce(
|
|
5105
5108
|
(acc, [key, value]) => {
|
|
5106
5109
|
if (value !== void 0) {
|
|
5107
5110
|
acc[key] = globalThis.String(value);
|
|
@@ -5464,7 +5467,7 @@ var AppSetObjectsRequest = {
|
|
|
5464
5467
|
if (message.appId !== "") {
|
|
5465
5468
|
writer.uint32(10).string(message.appId);
|
|
5466
5469
|
}
|
|
5467
|
-
|
|
5470
|
+
Object.entries(message.indexedObjectIds).forEach(([key, value]) => {
|
|
5468
5471
|
AppSetObjectsRequest_IndexedObjectIdsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
|
|
5469
5472
|
});
|
|
5470
5473
|
if (message.clientId !== "") {
|
|
@@ -5534,7 +5537,7 @@ var AppSetObjectsRequest = {
|
|
|
5534
5537
|
fromJSON(object) {
|
|
5535
5538
|
return {
|
|
5536
5539
|
appId: isSet3(object.appId) ? globalThis.String(object.appId) : "",
|
|
5537
|
-
indexedObjectIds: isObject2(object.indexedObjectIds) ?
|
|
5540
|
+
indexedObjectIds: isObject2(object.indexedObjectIds) ? Object.entries(object.indexedObjectIds).reduce((acc, [key, value]) => {
|
|
5538
5541
|
acc[key] = String(value);
|
|
5539
5542
|
return acc;
|
|
5540
5543
|
}, {}) : {},
|
|
@@ -5549,7 +5552,7 @@ var AppSetObjectsRequest = {
|
|
|
5549
5552
|
obj.appId = message.appId;
|
|
5550
5553
|
}
|
|
5551
5554
|
if (message.indexedObjectIds) {
|
|
5552
|
-
const entries =
|
|
5555
|
+
const entries = Object.entries(message.indexedObjectIds);
|
|
5553
5556
|
if (entries.length > 0) {
|
|
5554
5557
|
obj.indexedObjectIds = {};
|
|
5555
5558
|
entries.forEach(([k, v]) => {
|
|
@@ -5574,7 +5577,7 @@ var AppSetObjectsRequest = {
|
|
|
5574
5577
|
fromPartial(object) {
|
|
5575
5578
|
const message = createBaseAppSetObjectsRequest();
|
|
5576
5579
|
message.appId = object.appId ?? "";
|
|
5577
|
-
message.indexedObjectIds =
|
|
5580
|
+
message.indexedObjectIds = Object.entries(object.indexedObjectIds ?? {}).reduce(
|
|
5578
5581
|
(acc, [key, value]) => {
|
|
5579
5582
|
if (value !== void 0) {
|
|
5580
5583
|
acc[key] = globalThis.String(value);
|
|
@@ -7401,6 +7404,59 @@ var ClassParameterInfo = {
|
|
|
7401
7404
|
return message;
|
|
7402
7405
|
}
|
|
7403
7406
|
};
|
|
7407
|
+
function createBaseClassParameterSet() {
|
|
7408
|
+
return { parameters: [] };
|
|
7409
|
+
}
|
|
7410
|
+
var ClassParameterSet = {
|
|
7411
|
+
encode(message, writer = new BinaryWriter()) {
|
|
7412
|
+
for (const v of message.parameters) {
|
|
7413
|
+
ClassParameterValue.encode(v, writer.uint32(10).fork()).join();
|
|
7414
|
+
}
|
|
7415
|
+
return writer;
|
|
7416
|
+
},
|
|
7417
|
+
decode(input, length) {
|
|
7418
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
7419
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
7420
|
+
const message = createBaseClassParameterSet();
|
|
7421
|
+
while (reader.pos < end) {
|
|
7422
|
+
const tag = reader.uint32();
|
|
7423
|
+
switch (tag >>> 3) {
|
|
7424
|
+
case 1: {
|
|
7425
|
+
if (tag !== 10) {
|
|
7426
|
+
break;
|
|
7427
|
+
}
|
|
7428
|
+
message.parameters.push(ClassParameterValue.decode(reader, reader.uint32()));
|
|
7429
|
+
continue;
|
|
7430
|
+
}
|
|
7431
|
+
}
|
|
7432
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7433
|
+
break;
|
|
7434
|
+
}
|
|
7435
|
+
reader.skip(tag & 7);
|
|
7436
|
+
}
|
|
7437
|
+
return message;
|
|
7438
|
+
},
|
|
7439
|
+
fromJSON(object) {
|
|
7440
|
+
return {
|
|
7441
|
+
parameters: globalThis.Array.isArray(object?.parameters) ? object.parameters.map((e) => ClassParameterValue.fromJSON(e)) : []
|
|
7442
|
+
};
|
|
7443
|
+
},
|
|
7444
|
+
toJSON(message) {
|
|
7445
|
+
const obj = {};
|
|
7446
|
+
if (message.parameters?.length) {
|
|
7447
|
+
obj.parameters = message.parameters.map((e) => ClassParameterValue.toJSON(e));
|
|
7448
|
+
}
|
|
7449
|
+
return obj;
|
|
7450
|
+
},
|
|
7451
|
+
create(base) {
|
|
7452
|
+
return ClassParameterSet.fromPartial(base ?? {});
|
|
7453
|
+
},
|
|
7454
|
+
fromPartial(object) {
|
|
7455
|
+
const message = createBaseClassParameterSet();
|
|
7456
|
+
message.parameters = object.parameters?.map((e) => ClassParameterValue.fromPartial(e)) || [];
|
|
7457
|
+
return message;
|
|
7458
|
+
}
|
|
7459
|
+
};
|
|
7404
7460
|
function createBaseClassParameterSpec() {
|
|
7405
7461
|
return {
|
|
7406
7462
|
name: "",
|
|
@@ -7584,6 +7640,157 @@ var ClassParameterSpec = {
|
|
|
7584
7640
|
return message;
|
|
7585
7641
|
}
|
|
7586
7642
|
};
|
|
7643
|
+
function createBaseClassParameterValue() {
|
|
7644
|
+
return {
|
|
7645
|
+
name: "",
|
|
7646
|
+
type: 0,
|
|
7647
|
+
stringValue: void 0,
|
|
7648
|
+
intValue: void 0,
|
|
7649
|
+
pickleValue: void 0,
|
|
7650
|
+
bytesValue: void 0,
|
|
7651
|
+
boolValue: void 0
|
|
7652
|
+
};
|
|
7653
|
+
}
|
|
7654
|
+
var ClassParameterValue = {
|
|
7655
|
+
encode(message, writer = new BinaryWriter()) {
|
|
7656
|
+
if (message.name !== "") {
|
|
7657
|
+
writer.uint32(10).string(message.name);
|
|
7658
|
+
}
|
|
7659
|
+
if (message.type !== 0) {
|
|
7660
|
+
writer.uint32(16).int32(message.type);
|
|
7661
|
+
}
|
|
7662
|
+
if (message.stringValue !== void 0) {
|
|
7663
|
+
writer.uint32(26).string(message.stringValue);
|
|
7664
|
+
}
|
|
7665
|
+
if (message.intValue !== void 0) {
|
|
7666
|
+
writer.uint32(32).int64(message.intValue);
|
|
7667
|
+
}
|
|
7668
|
+
if (message.pickleValue !== void 0) {
|
|
7669
|
+
writer.uint32(42).bytes(message.pickleValue);
|
|
7670
|
+
}
|
|
7671
|
+
if (message.bytesValue !== void 0) {
|
|
7672
|
+
writer.uint32(50).bytes(message.bytesValue);
|
|
7673
|
+
}
|
|
7674
|
+
if (message.boolValue !== void 0) {
|
|
7675
|
+
writer.uint32(56).bool(message.boolValue);
|
|
7676
|
+
}
|
|
7677
|
+
return writer;
|
|
7678
|
+
},
|
|
7679
|
+
decode(input, length) {
|
|
7680
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
7681
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
7682
|
+
const message = createBaseClassParameterValue();
|
|
7683
|
+
while (reader.pos < end) {
|
|
7684
|
+
const tag = reader.uint32();
|
|
7685
|
+
switch (tag >>> 3) {
|
|
7686
|
+
case 1: {
|
|
7687
|
+
if (tag !== 10) {
|
|
7688
|
+
break;
|
|
7689
|
+
}
|
|
7690
|
+
message.name = reader.string();
|
|
7691
|
+
continue;
|
|
7692
|
+
}
|
|
7693
|
+
case 2: {
|
|
7694
|
+
if (tag !== 16) {
|
|
7695
|
+
break;
|
|
7696
|
+
}
|
|
7697
|
+
message.type = reader.int32();
|
|
7698
|
+
continue;
|
|
7699
|
+
}
|
|
7700
|
+
case 3: {
|
|
7701
|
+
if (tag !== 26) {
|
|
7702
|
+
break;
|
|
7703
|
+
}
|
|
7704
|
+
message.stringValue = reader.string();
|
|
7705
|
+
continue;
|
|
7706
|
+
}
|
|
7707
|
+
case 4: {
|
|
7708
|
+
if (tag !== 32) {
|
|
7709
|
+
break;
|
|
7710
|
+
}
|
|
7711
|
+
message.intValue = longToNumber(reader.int64());
|
|
7712
|
+
continue;
|
|
7713
|
+
}
|
|
7714
|
+
case 5: {
|
|
7715
|
+
if (tag !== 42) {
|
|
7716
|
+
break;
|
|
7717
|
+
}
|
|
7718
|
+
message.pickleValue = reader.bytes();
|
|
7719
|
+
continue;
|
|
7720
|
+
}
|
|
7721
|
+
case 6: {
|
|
7722
|
+
if (tag !== 50) {
|
|
7723
|
+
break;
|
|
7724
|
+
}
|
|
7725
|
+
message.bytesValue = reader.bytes();
|
|
7726
|
+
continue;
|
|
7727
|
+
}
|
|
7728
|
+
case 7: {
|
|
7729
|
+
if (tag !== 56) {
|
|
7730
|
+
break;
|
|
7731
|
+
}
|
|
7732
|
+
message.boolValue = reader.bool();
|
|
7733
|
+
continue;
|
|
7734
|
+
}
|
|
7735
|
+
}
|
|
7736
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7737
|
+
break;
|
|
7738
|
+
}
|
|
7739
|
+
reader.skip(tag & 7);
|
|
7740
|
+
}
|
|
7741
|
+
return message;
|
|
7742
|
+
},
|
|
7743
|
+
fromJSON(object) {
|
|
7744
|
+
return {
|
|
7745
|
+
name: isSet3(object.name) ? globalThis.String(object.name) : "",
|
|
7746
|
+
type: isSet3(object.type) ? parameterTypeFromJSON(object.type) : 0,
|
|
7747
|
+
stringValue: isSet3(object.stringValue) ? globalThis.String(object.stringValue) : void 0,
|
|
7748
|
+
intValue: isSet3(object.intValue) ? globalThis.Number(object.intValue) : void 0,
|
|
7749
|
+
pickleValue: isSet3(object.pickleValue) ? bytesFromBase64(object.pickleValue) : void 0,
|
|
7750
|
+
bytesValue: isSet3(object.bytesValue) ? bytesFromBase64(object.bytesValue) : void 0,
|
|
7751
|
+
boolValue: isSet3(object.boolValue) ? globalThis.Boolean(object.boolValue) : void 0
|
|
7752
|
+
};
|
|
7753
|
+
},
|
|
7754
|
+
toJSON(message) {
|
|
7755
|
+
const obj = {};
|
|
7756
|
+
if (message.name !== "") {
|
|
7757
|
+
obj.name = message.name;
|
|
7758
|
+
}
|
|
7759
|
+
if (message.type !== 0) {
|
|
7760
|
+
obj.type = parameterTypeToJSON(message.type);
|
|
7761
|
+
}
|
|
7762
|
+
if (message.stringValue !== void 0) {
|
|
7763
|
+
obj.stringValue = message.stringValue;
|
|
7764
|
+
}
|
|
7765
|
+
if (message.intValue !== void 0) {
|
|
7766
|
+
obj.intValue = Math.round(message.intValue);
|
|
7767
|
+
}
|
|
7768
|
+
if (message.pickleValue !== void 0) {
|
|
7769
|
+
obj.pickleValue = base64FromBytes(message.pickleValue);
|
|
7770
|
+
}
|
|
7771
|
+
if (message.bytesValue !== void 0) {
|
|
7772
|
+
obj.bytesValue = base64FromBytes(message.bytesValue);
|
|
7773
|
+
}
|
|
7774
|
+
if (message.boolValue !== void 0) {
|
|
7775
|
+
obj.boolValue = message.boolValue;
|
|
7776
|
+
}
|
|
7777
|
+
return obj;
|
|
7778
|
+
},
|
|
7779
|
+
create(base) {
|
|
7780
|
+
return ClassParameterValue.fromPartial(base ?? {});
|
|
7781
|
+
},
|
|
7782
|
+
fromPartial(object) {
|
|
7783
|
+
const message = createBaseClassParameterValue();
|
|
7784
|
+
message.name = object.name ?? "";
|
|
7785
|
+
message.type = object.type ?? 0;
|
|
7786
|
+
message.stringValue = object.stringValue ?? void 0;
|
|
7787
|
+
message.intValue = object.intValue ?? void 0;
|
|
7788
|
+
message.pickleValue = object.pickleValue ?? void 0;
|
|
7789
|
+
message.bytesValue = object.bytesValue ?? void 0;
|
|
7790
|
+
message.boolValue = object.boolValue ?? void 0;
|
|
7791
|
+
return message;
|
|
7792
|
+
}
|
|
7793
|
+
};
|
|
7587
7794
|
function createBaseClientHelloResponse() {
|
|
7588
7795
|
return { warning: "", imageBuilderVersion: "", serverWarnings: [] };
|
|
7589
7796
|
}
|
|
@@ -13509,7 +13716,7 @@ var FunctionMessage = {
|
|
|
13509
13716
|
if (message.snapshotDebug !== false) {
|
|
13510
13717
|
writer.uint32(584).bool(message.snapshotDebug);
|
|
13511
13718
|
}
|
|
13512
|
-
|
|
13719
|
+
Object.entries(message.methodDefinitions).forEach(([key, value]) => {
|
|
13513
13720
|
Function_MethodDefinitionsEntry.encode({ key, value }, writer.uint32(594).fork()).join();
|
|
13514
13721
|
});
|
|
13515
13722
|
if (message.methodDefinitionsSet !== false) {
|
|
@@ -13530,7 +13737,7 @@ var FunctionMessage = {
|
|
|
13530
13737
|
if (message.functionSchema !== void 0) {
|
|
13531
13738
|
FunctionSchema.encode(message.functionSchema, writer.uint32(642).fork()).join();
|
|
13532
13739
|
}
|
|
13533
|
-
|
|
13740
|
+
Object.entries(message.experimentalOptions).forEach(([key, value]) => {
|
|
13534
13741
|
Function_ExperimentalOptionsEntry.encode({ key, value }, writer.uint32(650).fork()).join();
|
|
13535
13742
|
});
|
|
13536
13743
|
return writer;
|
|
@@ -14094,7 +14301,7 @@ var FunctionMessage = {
|
|
|
14094
14301
|
runtimePerfRecord: isSet3(object.runtimePerfRecord) ? globalThis.Boolean(object.runtimePerfRecord) : false,
|
|
14095
14302
|
schedule: isSet3(object.schedule) ? Schedule.fromJSON(object.schedule) : void 0,
|
|
14096
14303
|
snapshotDebug: isSet3(object.snapshotDebug) ? globalThis.Boolean(object.snapshotDebug) : false,
|
|
14097
|
-
methodDefinitions: isObject2(object.methodDefinitions) ?
|
|
14304
|
+
methodDefinitions: isObject2(object.methodDefinitions) ? Object.entries(object.methodDefinitions).reduce((acc, [key, value]) => {
|
|
14098
14305
|
acc[key] = MethodDefinition.fromJSON(value);
|
|
14099
14306
|
return acc;
|
|
14100
14307
|
}, {}) : {},
|
|
@@ -14104,7 +14311,7 @@ var FunctionMessage = {
|
|
|
14104
14311
|
ExperimentalEnableGpuSnapshot: isSet3(object.ExperimentalEnableGpuSnapshot) ? globalThis.Boolean(object.ExperimentalEnableGpuSnapshot) : false,
|
|
14105
14312
|
autoscalerSettings: isSet3(object.autoscalerSettings) ? AutoscalerSettings.fromJSON(object.autoscalerSettings) : void 0,
|
|
14106
14313
|
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0,
|
|
14107
|
-
experimentalOptions: isObject2(object.experimentalOptions) ?
|
|
14314
|
+
experimentalOptions: isObject2(object.experimentalOptions) ? Object.entries(object.experimentalOptions).reduce((acc, [key, value]) => {
|
|
14108
14315
|
acc[key] = String(value);
|
|
14109
14316
|
return acc;
|
|
14110
14317
|
}, {}) : {}
|
|
@@ -14293,7 +14500,7 @@ var FunctionMessage = {
|
|
|
14293
14500
|
obj.snapshotDebug = message.snapshotDebug;
|
|
14294
14501
|
}
|
|
14295
14502
|
if (message.methodDefinitions) {
|
|
14296
|
-
const entries =
|
|
14503
|
+
const entries = Object.entries(message.methodDefinitions);
|
|
14297
14504
|
if (entries.length > 0) {
|
|
14298
14505
|
obj.methodDefinitions = {};
|
|
14299
14506
|
entries.forEach(([k, v]) => {
|
|
@@ -14320,7 +14527,7 @@ var FunctionMessage = {
|
|
|
14320
14527
|
obj.functionSchema = FunctionSchema.toJSON(message.functionSchema);
|
|
14321
14528
|
}
|
|
14322
14529
|
if (message.experimentalOptions) {
|
|
14323
|
-
const entries =
|
|
14530
|
+
const entries = Object.entries(message.experimentalOptions);
|
|
14324
14531
|
if (entries.length > 0) {
|
|
14325
14532
|
obj.experimentalOptions = {};
|
|
14326
14533
|
entries.forEach(([k, v]) => {
|
|
@@ -14395,7 +14602,7 @@ var FunctionMessage = {
|
|
|
14395
14602
|
message.runtimePerfRecord = object.runtimePerfRecord ?? false;
|
|
14396
14603
|
message.schedule = object.schedule !== void 0 && object.schedule !== null ? Schedule.fromPartial(object.schedule) : void 0;
|
|
14397
14604
|
message.snapshotDebug = object.snapshotDebug ?? false;
|
|
14398
|
-
message.methodDefinitions =
|
|
14605
|
+
message.methodDefinitions = Object.entries(object.methodDefinitions ?? {}).reduce((acc, [key, value]) => {
|
|
14399
14606
|
if (value !== void 0) {
|
|
14400
14607
|
acc[key] = MethodDefinition.fromPartial(value);
|
|
14401
14608
|
}
|
|
@@ -14407,7 +14614,7 @@ var FunctionMessage = {
|
|
|
14407
14614
|
message.ExperimentalEnableGpuSnapshot = object.ExperimentalEnableGpuSnapshot ?? false;
|
|
14408
14615
|
message.autoscalerSettings = object.autoscalerSettings !== void 0 && object.autoscalerSettings !== null ? AutoscalerSettings.fromPartial(object.autoscalerSettings) : void 0;
|
|
14409
14616
|
message.functionSchema = object.functionSchema !== void 0 && object.functionSchema !== null ? FunctionSchema.fromPartial(object.functionSchema) : void 0;
|
|
14410
|
-
message.experimentalOptions =
|
|
14617
|
+
message.experimentalOptions = Object.entries(object.experimentalOptions ?? {}).reduce(
|
|
14411
14618
|
(acc, [key, value]) => {
|
|
14412
14619
|
if (value !== void 0) {
|
|
14413
14620
|
acc[key] = globalThis.String(value);
|
|
@@ -15792,7 +15999,7 @@ var FunctionData = {
|
|
|
15792
15999
|
if (message.ExperimentalProxyIp !== void 0) {
|
|
15793
16000
|
writer.uint32(194).string(message.ExperimentalProxyIp);
|
|
15794
16001
|
}
|
|
15795
|
-
|
|
16002
|
+
Object.entries(message.methodDefinitions).forEach(([key, value]) => {
|
|
15796
16003
|
FunctionData_MethodDefinitionsEntry.encode({ key, value }, writer.uint32(202).fork()).join();
|
|
15797
16004
|
});
|
|
15798
16005
|
if (message.methodDefinitionsSet !== false) {
|
|
@@ -15834,7 +16041,7 @@ var FunctionData = {
|
|
|
15834
16041
|
if (message.functionSchema !== void 0) {
|
|
15835
16042
|
FunctionSchema.encode(message.functionSchema, writer.uint32(258).fork()).join();
|
|
15836
16043
|
}
|
|
15837
|
-
|
|
16044
|
+
Object.entries(message.experimentalOptions).forEach(([key, value]) => {
|
|
15838
16045
|
FunctionData_ExperimentalOptionsEntry.encode({ key, value }, writer.uint32(266).fork()).join();
|
|
15839
16046
|
});
|
|
15840
16047
|
return writer;
|
|
@@ -16103,7 +16310,7 @@ var FunctionData = {
|
|
|
16103
16310
|
webhookConfig: isSet3(object.webhookConfig) ? WebhookConfig.fromJSON(object.webhookConfig) : void 0,
|
|
16104
16311
|
customDomainInfo: globalThis.Array.isArray(object?.customDomainInfo) ? object.customDomainInfo.map((e) => CustomDomainInfo.fromJSON(e)) : [],
|
|
16105
16312
|
ExperimentalProxyIp: isSet3(object.ExperimentalProxyIp) ? globalThis.String(object.ExperimentalProxyIp) : void 0,
|
|
16106
|
-
methodDefinitions: isObject2(object.methodDefinitions) ?
|
|
16313
|
+
methodDefinitions: isObject2(object.methodDefinitions) ? Object.entries(object.methodDefinitions).reduce((acc, [key, value]) => {
|
|
16107
16314
|
acc[key] = MethodDefinition.fromJSON(value);
|
|
16108
16315
|
return acc;
|
|
16109
16316
|
}, {}) : {},
|
|
@@ -16120,7 +16327,7 @@ var FunctionData = {
|
|
|
16120
16327
|
runtimePerfRecord: isSet3(object.runtimePerfRecord) ? globalThis.Boolean(object.runtimePerfRecord) : false,
|
|
16121
16328
|
autoscalerSettings: isSet3(object.autoscalerSettings) ? AutoscalerSettings.fromJSON(object.autoscalerSettings) : void 0,
|
|
16122
16329
|
functionSchema: isSet3(object.functionSchema) ? FunctionSchema.fromJSON(object.functionSchema) : void 0,
|
|
16123
|
-
experimentalOptions: isObject2(object.experimentalOptions) ?
|
|
16330
|
+
experimentalOptions: isObject2(object.experimentalOptions) ? Object.entries(object.experimentalOptions).reduce((acc, [key, value]) => {
|
|
16124
16331
|
acc[key] = String(value);
|
|
16125
16332
|
return acc;
|
|
16126
16333
|
}, {}) : {}
|
|
@@ -16180,7 +16387,7 @@ var FunctionData = {
|
|
|
16180
16387
|
obj.ExperimentalProxyIp = message.ExperimentalProxyIp;
|
|
16181
16388
|
}
|
|
16182
16389
|
if (message.methodDefinitions) {
|
|
16183
|
-
const entries =
|
|
16390
|
+
const entries = Object.entries(message.methodDefinitions);
|
|
16184
16391
|
if (entries.length > 0) {
|
|
16185
16392
|
obj.methodDefinitions = {};
|
|
16186
16393
|
entries.forEach(([k, v]) => {
|
|
@@ -16228,7 +16435,7 @@ var FunctionData = {
|
|
|
16228
16435
|
obj.functionSchema = FunctionSchema.toJSON(message.functionSchema);
|
|
16229
16436
|
}
|
|
16230
16437
|
if (message.experimentalOptions) {
|
|
16231
|
-
const entries =
|
|
16438
|
+
const entries = Object.entries(message.experimentalOptions);
|
|
16232
16439
|
if (entries.length > 0) {
|
|
16233
16440
|
obj.experimentalOptions = {};
|
|
16234
16441
|
entries.forEach(([k, v]) => {
|
|
@@ -16260,7 +16467,7 @@ var FunctionData = {
|
|
|
16260
16467
|
message.webhookConfig = object.webhookConfig !== void 0 && object.webhookConfig !== null ? WebhookConfig.fromPartial(object.webhookConfig) : void 0;
|
|
16261
16468
|
message.customDomainInfo = object.customDomainInfo?.map((e) => CustomDomainInfo.fromPartial(e)) || [];
|
|
16262
16469
|
message.ExperimentalProxyIp = object.ExperimentalProxyIp ?? void 0;
|
|
16263
|
-
message.methodDefinitions =
|
|
16470
|
+
message.methodDefinitions = Object.entries(object.methodDefinitions ?? {}).reduce((acc, [key, value]) => {
|
|
16264
16471
|
if (value !== void 0) {
|
|
16265
16472
|
acc[key] = MethodDefinition.fromPartial(value);
|
|
16266
16473
|
}
|
|
@@ -16279,7 +16486,7 @@ var FunctionData = {
|
|
|
16279
16486
|
message.runtimePerfRecord = object.runtimePerfRecord ?? false;
|
|
16280
16487
|
message.autoscalerSettings = object.autoscalerSettings !== void 0 && object.autoscalerSettings !== null ? AutoscalerSettings.fromPartial(object.autoscalerSettings) : void 0;
|
|
16281
16488
|
message.functionSchema = object.functionSchema !== void 0 && object.functionSchema !== null ? FunctionSchema.fromPartial(object.functionSchema) : void 0;
|
|
16282
|
-
message.experimentalOptions =
|
|
16489
|
+
message.experimentalOptions = Object.entries(object.experimentalOptions ?? {}).reduce(
|
|
16283
16490
|
(acc, [key, value]) => {
|
|
16284
16491
|
if (value !== void 0) {
|
|
16285
16492
|
acc[key] = globalThis.String(value);
|
|
@@ -17911,7 +18118,7 @@ var FunctionHandleMetadata = {
|
|
|
17911
18118
|
if (message.classParameterInfo !== void 0) {
|
|
17912
18119
|
ClassParameterInfo.encode(message.classParameterInfo, writer.uint32(346).fork()).join();
|
|
17913
18120
|
}
|
|
17914
|
-
|
|
18121
|
+
Object.entries(message.methodHandleMetadata).forEach(([key, value]) => {
|
|
17915
18122
|
FunctionHandleMetadata_MethodHandleMetadataEntry.encode({ key, value }, writer.uint32(354).fork()).join();
|
|
17916
18123
|
});
|
|
17917
18124
|
if (message.functionSchema !== void 0) {
|
|
@@ -18017,7 +18224,7 @@ var FunctionHandleMetadata = {
|
|
|
18017
18224
|
useMethodName: isSet3(object.useMethodName) ? globalThis.String(object.useMethodName) : "",
|
|
18018
18225
|
definitionId: isSet3(object.definitionId) ? globalThis.String(object.definitionId) : "",
|
|
18019
18226
|
classParameterInfo: isSet3(object.classParameterInfo) ? ClassParameterInfo.fromJSON(object.classParameterInfo) : void 0,
|
|
18020
|
-
methodHandleMetadata: isObject2(object.methodHandleMetadata) ?
|
|
18227
|
+
methodHandleMetadata: isObject2(object.methodHandleMetadata) ? Object.entries(object.methodHandleMetadata).reduce(
|
|
18021
18228
|
(acc, [key, value]) => {
|
|
18022
18229
|
acc[key] = FunctionHandleMetadata.fromJSON(value);
|
|
18023
18230
|
return acc;
|
|
@@ -18054,7 +18261,7 @@ var FunctionHandleMetadata = {
|
|
|
18054
18261
|
obj.classParameterInfo = ClassParameterInfo.toJSON(message.classParameterInfo);
|
|
18055
18262
|
}
|
|
18056
18263
|
if (message.methodHandleMetadata) {
|
|
18057
|
-
const entries =
|
|
18264
|
+
const entries = Object.entries(message.methodHandleMetadata);
|
|
18058
18265
|
if (entries.length > 0) {
|
|
18059
18266
|
obj.methodHandleMetadata = {};
|
|
18060
18267
|
entries.forEach(([k, v]) => {
|
|
@@ -18080,7 +18287,7 @@ var FunctionHandleMetadata = {
|
|
|
18080
18287
|
message.useMethodName = object.useMethodName ?? "";
|
|
18081
18288
|
message.definitionId = object.definitionId ?? "";
|
|
18082
18289
|
message.classParameterInfo = object.classParameterInfo !== void 0 && object.classParameterInfo !== null ? ClassParameterInfo.fromPartial(object.classParameterInfo) : void 0;
|
|
18083
|
-
message.methodHandleMetadata =
|
|
18290
|
+
message.methodHandleMetadata = Object.entries(object.methodHandleMetadata ?? {}).reduce((acc, [key, value]) => {
|
|
18084
18291
|
if (value !== void 0) {
|
|
18085
18292
|
acc[key] = FunctionHandleMetadata.fromPartial(value);
|
|
18086
18293
|
}
|
|
@@ -18808,7 +19015,7 @@ var FunctionPrecreateRequest = {
|
|
|
18808
19015
|
if (message.useMethodName !== "") {
|
|
18809
19016
|
writer.uint32(58).string(message.useMethodName);
|
|
18810
19017
|
}
|
|
18811
|
-
|
|
19018
|
+
Object.entries(message.methodDefinitions).forEach(([key, value]) => {
|
|
18812
19019
|
FunctionPrecreateRequest_MethodDefinitionsEntry.encode({ key, value }, writer.uint32(66).fork()).join();
|
|
18813
19020
|
});
|
|
18814
19021
|
if (message.functionSchema !== void 0) {
|
|
@@ -18906,7 +19113,7 @@ var FunctionPrecreateRequest = {
|
|
|
18906
19113
|
webhookConfig: isSet3(object.webhookConfig) ? WebhookConfig.fromJSON(object.webhookConfig) : void 0,
|
|
18907
19114
|
useFunctionId: isSet3(object.useFunctionId) ? globalThis.String(object.useFunctionId) : "",
|
|
18908
19115
|
useMethodName: isSet3(object.useMethodName) ? globalThis.String(object.useMethodName) : "",
|
|
18909
|
-
methodDefinitions: isObject2(object.methodDefinitions) ?
|
|
19116
|
+
methodDefinitions: isObject2(object.methodDefinitions) ? Object.entries(object.methodDefinitions).reduce((acc, [key, value]) => {
|
|
18910
19117
|
acc[key] = MethodDefinition.fromJSON(value);
|
|
18911
19118
|
return acc;
|
|
18912
19119
|
}, {}) : {},
|
|
@@ -18937,7 +19144,7 @@ var FunctionPrecreateRequest = {
|
|
|
18937
19144
|
obj.useMethodName = message.useMethodName;
|
|
18938
19145
|
}
|
|
18939
19146
|
if (message.methodDefinitions) {
|
|
18940
|
-
const entries =
|
|
19147
|
+
const entries = Object.entries(message.methodDefinitions);
|
|
18941
19148
|
if (entries.length > 0) {
|
|
18942
19149
|
obj.methodDefinitions = {};
|
|
18943
19150
|
entries.forEach(([k, v]) => {
|
|
@@ -18962,7 +19169,7 @@ var FunctionPrecreateRequest = {
|
|
|
18962
19169
|
message.webhookConfig = object.webhookConfig !== void 0 && object.webhookConfig !== null ? WebhookConfig.fromPartial(object.webhookConfig) : void 0;
|
|
18963
19170
|
message.useFunctionId = object.useFunctionId ?? "";
|
|
18964
19171
|
message.useMethodName = object.useMethodName ?? "";
|
|
18965
|
-
message.methodDefinitions =
|
|
19172
|
+
message.methodDefinitions = Object.entries(object.methodDefinitions ?? {}).reduce((acc, [key, value]) => {
|
|
18966
19173
|
if (value !== void 0) {
|
|
18967
19174
|
acc[key] = MethodDefinition.fromPartial(value);
|
|
18968
19175
|
}
|
|
@@ -21468,7 +21675,7 @@ var ImageMetadata = {
|
|
|
21468
21675
|
if (message.pythonVersionInfo !== void 0) {
|
|
21469
21676
|
writer.uint32(10).string(message.pythonVersionInfo);
|
|
21470
21677
|
}
|
|
21471
|
-
|
|
21678
|
+
Object.entries(message.pythonPackages).forEach(([key, value]) => {
|
|
21472
21679
|
ImageMetadata_PythonPackagesEntry.encode({ key, value }, writer.uint32(18).fork()).join();
|
|
21473
21680
|
});
|
|
21474
21681
|
if (message.workdir !== void 0) {
|
|
@@ -21518,7 +21725,7 @@ var ImageMetadata = {
|
|
|
21518
21725
|
fromJSON(object) {
|
|
21519
21726
|
return {
|
|
21520
21727
|
pythonVersionInfo: isSet3(object.pythonVersionInfo) ? globalThis.String(object.pythonVersionInfo) : void 0,
|
|
21521
|
-
pythonPackages: isObject2(object.pythonPackages) ?
|
|
21728
|
+
pythonPackages: isObject2(object.pythonPackages) ? Object.entries(object.pythonPackages).reduce((acc, [key, value]) => {
|
|
21522
21729
|
acc[key] = String(value);
|
|
21523
21730
|
return acc;
|
|
21524
21731
|
}, {}) : {},
|
|
@@ -21531,7 +21738,7 @@ var ImageMetadata = {
|
|
|
21531
21738
|
obj.pythonVersionInfo = message.pythonVersionInfo;
|
|
21532
21739
|
}
|
|
21533
21740
|
if (message.pythonPackages) {
|
|
21534
|
-
const entries =
|
|
21741
|
+
const entries = Object.entries(message.pythonPackages);
|
|
21535
21742
|
if (entries.length > 0) {
|
|
21536
21743
|
obj.pythonPackages = {};
|
|
21537
21744
|
entries.forEach(([k, v]) => {
|
|
@@ -21550,7 +21757,7 @@ var ImageMetadata = {
|
|
|
21550
21757
|
fromPartial(object) {
|
|
21551
21758
|
const message = createBaseImageMetadata();
|
|
21552
21759
|
message.pythonVersionInfo = object.pythonVersionInfo ?? void 0;
|
|
21553
|
-
message.pythonPackages =
|
|
21760
|
+
message.pythonPackages = Object.entries(object.pythonPackages ?? {}).reduce(
|
|
21554
21761
|
(acc, [key, value]) => {
|
|
21555
21762
|
if (value !== void 0) {
|
|
21556
21763
|
acc[key] = globalThis.String(value);
|
|
@@ -23465,7 +23672,7 @@ function createBaseObject() {
|
|
|
23465
23672
|
volumeMetadata: void 0
|
|
23466
23673
|
};
|
|
23467
23674
|
}
|
|
23468
|
-
var
|
|
23675
|
+
var Object_ = {
|
|
23469
23676
|
encode(message, writer = new BinaryWriter()) {
|
|
23470
23677
|
if (message.objectId !== "") {
|
|
23471
23678
|
writer.uint32(10).string(message.objectId);
|
|
@@ -23577,7 +23784,7 @@ var Object2 = {
|
|
|
23577
23784
|
return obj;
|
|
23578
23785
|
},
|
|
23579
23786
|
create(base) {
|
|
23580
|
-
return
|
|
23787
|
+
return Object_.fromPartial(base ?? {});
|
|
23581
23788
|
},
|
|
23582
23789
|
fromPartial(object) {
|
|
23583
23790
|
const message = createBaseObject();
|
|
@@ -29481,7 +29688,7 @@ var SecretGetOrCreateRequest = {
|
|
|
29481
29688
|
if (message.objectCreationType !== 0) {
|
|
29482
29689
|
writer.uint32(32).int32(message.objectCreationType);
|
|
29483
29690
|
}
|
|
29484
|
-
|
|
29691
|
+
Object.entries(message.envDict).forEach(([key, value]) => {
|
|
29485
29692
|
SecretGetOrCreateRequest_EnvDictEntry.encode({ key, value }, writer.uint32(42).fork()).join();
|
|
29486
29693
|
});
|
|
29487
29694
|
if (message.appId !== "") {
|
|
@@ -29565,7 +29772,7 @@ var SecretGetOrCreateRequest = {
|
|
|
29565
29772
|
namespace: isSet3(object.namespace) ? deploymentNamespaceFromJSON(object.namespace) : 0,
|
|
29566
29773
|
environmentName: isSet3(object.environmentName) ? globalThis.String(object.environmentName) : "",
|
|
29567
29774
|
objectCreationType: isSet3(object.objectCreationType) ? objectCreationTypeFromJSON(object.objectCreationType) : 0,
|
|
29568
|
-
envDict: isObject2(object.envDict) ?
|
|
29775
|
+
envDict: isObject2(object.envDict) ? Object.entries(object.envDict).reduce((acc, [key, value]) => {
|
|
29569
29776
|
acc[key] = String(value);
|
|
29570
29777
|
return acc;
|
|
29571
29778
|
}, {}) : {},
|
|
@@ -29588,7 +29795,7 @@ var SecretGetOrCreateRequest = {
|
|
|
29588
29795
|
obj.objectCreationType = objectCreationTypeToJSON(message.objectCreationType);
|
|
29589
29796
|
}
|
|
29590
29797
|
if (message.envDict) {
|
|
29591
|
-
const entries =
|
|
29798
|
+
const entries = Object.entries(message.envDict);
|
|
29592
29799
|
if (entries.length > 0) {
|
|
29593
29800
|
obj.envDict = {};
|
|
29594
29801
|
entries.forEach(([k, v]) => {
|
|
@@ -29613,7 +29820,7 @@ var SecretGetOrCreateRequest = {
|
|
|
29613
29820
|
message.namespace = object.namespace ?? 0;
|
|
29614
29821
|
message.environmentName = object.environmentName ?? "";
|
|
29615
29822
|
message.objectCreationType = object.objectCreationType ?? 0;
|
|
29616
|
-
message.envDict =
|
|
29823
|
+
message.envDict = Object.entries(object.envDict ?? {}).reduce((acc, [key, value]) => {
|
|
29617
29824
|
if (value !== void 0) {
|
|
29618
29825
|
acc[key] = globalThis.String(value);
|
|
29619
29826
|
}
|
|
@@ -36630,11 +36837,11 @@ async function readConfigFile() {
|
|
|
36630
36837
|
encoding: "utf-8"
|
|
36631
36838
|
});
|
|
36632
36839
|
return parseToml(configContent);
|
|
36633
|
-
} catch (
|
|
36634
|
-
if (
|
|
36840
|
+
} catch (err) {
|
|
36841
|
+
if (err.code === "ENOENT") {
|
|
36635
36842
|
return {};
|
|
36636
36843
|
}
|
|
36637
|
-
throw new Error(`Failed to read or parse .modal.toml: ${
|
|
36844
|
+
throw new Error(`Failed to read or parse .modal.toml: ${err.message}`);
|
|
36638
36845
|
}
|
|
36639
36846
|
}
|
|
36640
36847
|
var config = await readConfigFile();
|
|
@@ -36723,9 +36930,9 @@ var retryableGrpcStatusCodes = /* @__PURE__ */ new Set([
|
|
|
36723
36930
|
Status.INTERNAL,
|
|
36724
36931
|
Status.UNKNOWN
|
|
36725
36932
|
]);
|
|
36726
|
-
function isRetryableGrpc(
|
|
36727
|
-
if (
|
|
36728
|
-
return retryableGrpcStatusCodes.has(
|
|
36933
|
+
function isRetryableGrpc(err) {
|
|
36934
|
+
if (err instanceof ClientError) {
|
|
36935
|
+
return retryableGrpcStatusCodes.has(err.code);
|
|
36729
36936
|
}
|
|
36730
36937
|
return false;
|
|
36731
36938
|
}
|
|
@@ -37098,9 +37305,9 @@ async function* outputStreamSb(sandboxId, fileDescriptor) {
|
|
|
37098
37305
|
break;
|
|
37099
37306
|
}
|
|
37100
37307
|
}
|
|
37101
|
-
} catch (
|
|
37102
|
-
if (isRetryableGrpc(
|
|
37103
|
-
else throw
|
|
37308
|
+
} catch (err) {
|
|
37309
|
+
if (isRetryableGrpc(err) && retries > 0) retries--;
|
|
37310
|
+
else throw err;
|
|
37104
37311
|
}
|
|
37105
37312
|
}
|
|
37106
37313
|
}
|
|
@@ -37125,9 +37332,9 @@ async function* outputStreamCp(execId, fileDescriptor) {
|
|
|
37125
37332
|
break;
|
|
37126
37333
|
}
|
|
37127
37334
|
}
|
|
37128
|
-
} catch (
|
|
37129
|
-
if (isRetryableGrpc(
|
|
37130
|
-
else throw
|
|
37335
|
+
} catch (err) {
|
|
37336
|
+
if (isRetryableGrpc(err) && retries > 0) retries--;
|
|
37337
|
+
else throw err;
|
|
37131
37338
|
}
|
|
37132
37339
|
}
|
|
37133
37340
|
}
|
|
@@ -37179,6 +37386,32 @@ function encodeIfString(chunk) {
|
|
|
37179
37386
|
return typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
37180
37387
|
}
|
|
37181
37388
|
|
|
37389
|
+
// src/errors.ts
|
|
37390
|
+
var TimeoutError = class extends Error {
|
|
37391
|
+
constructor(message) {
|
|
37392
|
+
super(message);
|
|
37393
|
+
this.name = "TimeoutError";
|
|
37394
|
+
}
|
|
37395
|
+
};
|
|
37396
|
+
var RemoteError = class extends Error {
|
|
37397
|
+
constructor(message) {
|
|
37398
|
+
super(message);
|
|
37399
|
+
this.name = "RemoteError";
|
|
37400
|
+
}
|
|
37401
|
+
};
|
|
37402
|
+
var InternalFailure = class extends Error {
|
|
37403
|
+
constructor(message) {
|
|
37404
|
+
super(message);
|
|
37405
|
+
this.name = "InternalFailure";
|
|
37406
|
+
}
|
|
37407
|
+
};
|
|
37408
|
+
var NotFoundError = class extends Error {
|
|
37409
|
+
constructor(message) {
|
|
37410
|
+
super(message);
|
|
37411
|
+
this.name = "NotFoundError";
|
|
37412
|
+
}
|
|
37413
|
+
};
|
|
37414
|
+
|
|
37182
37415
|
// src/app.ts
|
|
37183
37416
|
var App = class _App {
|
|
37184
37417
|
appId;
|
|
@@ -37187,12 +37420,18 @@ var App = class _App {
|
|
|
37187
37420
|
}
|
|
37188
37421
|
/** Lookup a deployed app by name, or create if it does not exist. */
|
|
37189
37422
|
static async lookup(name, options = {}) {
|
|
37190
|
-
|
|
37191
|
-
|
|
37192
|
-
|
|
37193
|
-
|
|
37194
|
-
|
|
37195
|
-
|
|
37423
|
+
try {
|
|
37424
|
+
const resp = await client.appGetOrCreate({
|
|
37425
|
+
appName: name,
|
|
37426
|
+
environmentName: environmentName(options.environment),
|
|
37427
|
+
objectCreationType: options.createIfMissing ? 1 /* OBJECT_CREATION_TYPE_CREATE_IF_MISSING */ : 0 /* OBJECT_CREATION_TYPE_UNSPECIFIED */
|
|
37428
|
+
});
|
|
37429
|
+
return new _App(resp.appId);
|
|
37430
|
+
} catch (err) {
|
|
37431
|
+
if (err instanceof ClientError2 && err.code === Status2.NOT_FOUND)
|
|
37432
|
+
throw new NotFoundError(`App '${name}' not found`);
|
|
37433
|
+
throw err;
|
|
37434
|
+
}
|
|
37196
37435
|
}
|
|
37197
37436
|
async createSandbox(image, options = {}) {
|
|
37198
37437
|
const createResp = await client.sandboxCreate({
|
|
@@ -37219,25 +37458,8 @@ var App = class _App {
|
|
|
37219
37458
|
}
|
|
37220
37459
|
};
|
|
37221
37460
|
|
|
37222
|
-
// src/
|
|
37223
|
-
|
|
37224
|
-
constructor(message) {
|
|
37225
|
-
super(message);
|
|
37226
|
-
this.name = "TimeoutError";
|
|
37227
|
-
}
|
|
37228
|
-
};
|
|
37229
|
-
var RemoteError = class extends Error {
|
|
37230
|
-
constructor(message) {
|
|
37231
|
-
super(message);
|
|
37232
|
-
this.name = "RemoteError";
|
|
37233
|
-
}
|
|
37234
|
-
};
|
|
37235
|
-
var InternalFailure = class extends Error {
|
|
37236
|
-
constructor(message) {
|
|
37237
|
-
super(message);
|
|
37238
|
-
this.name = "InternalFailure";
|
|
37239
|
-
}
|
|
37240
|
-
};
|
|
37461
|
+
// src/cls.ts
|
|
37462
|
+
import { ClientError as ClientError4, Status as Status4 } from "nice-grpc";
|
|
37241
37463
|
|
|
37242
37464
|
// src/function.ts
|
|
37243
37465
|
import { createHash } from "node:crypto";
|
|
@@ -37544,23 +37766,32 @@ function loads(buf) {
|
|
|
37544
37766
|
}
|
|
37545
37767
|
|
|
37546
37768
|
// src/function.ts
|
|
37769
|
+
import { ClientError as ClientError3, Status as Status3 } from "nice-grpc";
|
|
37547
37770
|
var maxObjectSizeBytes = 2 * 1024 * 1024;
|
|
37548
37771
|
function timeNow() {
|
|
37549
37772
|
return Date.now() / 1e3;
|
|
37550
37773
|
}
|
|
37551
37774
|
var Function_ = class _Function_ {
|
|
37552
37775
|
functionId;
|
|
37553
|
-
|
|
37776
|
+
methodName;
|
|
37777
|
+
constructor(functionId, methodName) {
|
|
37554
37778
|
this.functionId = functionId;
|
|
37779
|
+
this.methodName = methodName;
|
|
37555
37780
|
}
|
|
37556
37781
|
static async lookup(appName, name, options = {}) {
|
|
37557
|
-
|
|
37558
|
-
|
|
37559
|
-
|
|
37560
|
-
|
|
37561
|
-
|
|
37562
|
-
|
|
37563
|
-
|
|
37782
|
+
try {
|
|
37783
|
+
const resp = await client.functionGet({
|
|
37784
|
+
appName,
|
|
37785
|
+
objectTag: name,
|
|
37786
|
+
namespace: 1 /* DEPLOYMENT_NAMESPACE_WORKSPACE */,
|
|
37787
|
+
environmentName: environmentName(options.environment)
|
|
37788
|
+
});
|
|
37789
|
+
return new _Function_(resp.functionId);
|
|
37790
|
+
} catch (err) {
|
|
37791
|
+
if (err instanceof ClientError3 && err.code === Status3.NOT_FOUND)
|
|
37792
|
+
throw new NotFoundError(`Function '${appName}/${name}' not found`);
|
|
37793
|
+
throw err;
|
|
37794
|
+
}
|
|
37564
37795
|
}
|
|
37565
37796
|
// Execute a single input into a remote Function.
|
|
37566
37797
|
async remote(args = [], kwargs = {}) {
|
|
@@ -37579,7 +37810,8 @@ var Function_ = class _Function_ {
|
|
|
37579
37810
|
input: {
|
|
37580
37811
|
args: argsBlobId ? void 0 : payload,
|
|
37581
37812
|
argsBlobId,
|
|
37582
|
-
dataFormat: 1 /* DATA_FORMAT_PICKLE
|
|
37813
|
+
dataFormat: 1 /* DATA_FORMAT_PICKLE */,
|
|
37814
|
+
methodName: this.methodName
|
|
37583
37815
|
}
|
|
37584
37816
|
}
|
|
37585
37817
|
]
|
|
@@ -37675,11 +37907,150 @@ function deserializeDataFormat(data, dataFormat) {
|
|
|
37675
37907
|
throw new Error(`Unsupported data format: ${dataFormat}`);
|
|
37676
37908
|
}
|
|
37677
37909
|
}
|
|
37910
|
+
|
|
37911
|
+
// src/cls.ts
|
|
37912
|
+
var Cls = class _Cls {
|
|
37913
|
+
#serviceFunctionId;
|
|
37914
|
+
#schema;
|
|
37915
|
+
#methodNames;
|
|
37916
|
+
constructor(serviceFunctionId, schema, methodNames) {
|
|
37917
|
+
this.#serviceFunctionId = serviceFunctionId;
|
|
37918
|
+
this.#schema = schema;
|
|
37919
|
+
this.#methodNames = methodNames;
|
|
37920
|
+
}
|
|
37921
|
+
static async lookup(appName, name, options = {}) {
|
|
37922
|
+
try {
|
|
37923
|
+
const serviceFunctionName = `${name}.*`;
|
|
37924
|
+
const serviceFunction = await client.functionGet({
|
|
37925
|
+
appName,
|
|
37926
|
+
objectTag: serviceFunctionName,
|
|
37927
|
+
namespace: 1 /* DEPLOYMENT_NAMESPACE_WORKSPACE */,
|
|
37928
|
+
environmentName: environmentName(options.environment)
|
|
37929
|
+
});
|
|
37930
|
+
const parameterInfo = serviceFunction.handleMetadata?.classParameterInfo;
|
|
37931
|
+
const schema = parameterInfo?.schema ?? [];
|
|
37932
|
+
if (schema.length > 0 && parameterInfo?.format !== 2 /* PARAM_SERIALIZATION_FORMAT_PROTO */) {
|
|
37933
|
+
throw new Error(
|
|
37934
|
+
`Unsupported parameter format: ${parameterInfo?.format}`
|
|
37935
|
+
);
|
|
37936
|
+
}
|
|
37937
|
+
let methodNames;
|
|
37938
|
+
if (serviceFunction.handleMetadata?.methodHandleMetadata) {
|
|
37939
|
+
methodNames = Object.keys(
|
|
37940
|
+
serviceFunction.handleMetadata.methodHandleMetadata
|
|
37941
|
+
);
|
|
37942
|
+
} else {
|
|
37943
|
+
throw new Error(
|
|
37944
|
+
"Cls requires Modal deployments using client v0.67 or later."
|
|
37945
|
+
);
|
|
37946
|
+
}
|
|
37947
|
+
return new _Cls(serviceFunction.functionId, schema, methodNames);
|
|
37948
|
+
} catch (err) {
|
|
37949
|
+
if (err instanceof ClientError4 && err.code === Status4.NOT_FOUND)
|
|
37950
|
+
throw new NotFoundError(`Class '${appName}/${name}' not found`);
|
|
37951
|
+
throw err;
|
|
37952
|
+
}
|
|
37953
|
+
}
|
|
37954
|
+
/** Create a new instance of the Cls with parameters. */
|
|
37955
|
+
async instance(params = {}) {
|
|
37956
|
+
let functionId;
|
|
37957
|
+
if (this.#schema.length === 0) {
|
|
37958
|
+
functionId = this.#serviceFunctionId;
|
|
37959
|
+
} else {
|
|
37960
|
+
functionId = await this.#bindParameters(params);
|
|
37961
|
+
}
|
|
37962
|
+
const methods = /* @__PURE__ */ new Map();
|
|
37963
|
+
for (const name of this.#methodNames) {
|
|
37964
|
+
methods.set(name, new Function_(functionId, name));
|
|
37965
|
+
}
|
|
37966
|
+
return new ClsInstance(methods);
|
|
37967
|
+
}
|
|
37968
|
+
/** Bind parameters to the Cls function. */
|
|
37969
|
+
async #bindParameters(params) {
|
|
37970
|
+
const serializedParams = encodeParameterSet(this.#schema, params);
|
|
37971
|
+
const bindResp = await client.functionBindParams({
|
|
37972
|
+
functionId: this.#serviceFunctionId,
|
|
37973
|
+
serializedParams
|
|
37974
|
+
});
|
|
37975
|
+
return bindResp.boundFunctionId;
|
|
37976
|
+
}
|
|
37977
|
+
};
|
|
37978
|
+
function encodeParameterSet(schema, params) {
|
|
37979
|
+
const encoded = [];
|
|
37980
|
+
for (const paramSpec of schema) {
|
|
37981
|
+
const paramValue = encodeParameter(paramSpec, params[paramSpec.name]);
|
|
37982
|
+
encoded.push(paramValue);
|
|
37983
|
+
}
|
|
37984
|
+
encoded.sort((a, b) => a.name.localeCompare(b.name));
|
|
37985
|
+
return ClassParameterSet.encode({ parameters: encoded }).finish();
|
|
37986
|
+
}
|
|
37987
|
+
function encodeParameter(paramSpec, value) {
|
|
37988
|
+
const name = paramSpec.name;
|
|
37989
|
+
const paramType = paramSpec.type;
|
|
37990
|
+
const paramValue = { name, type: paramType };
|
|
37991
|
+
switch (paramType) {
|
|
37992
|
+
case 1 /* PARAM_TYPE_STRING */:
|
|
37993
|
+
if (value == null && paramSpec.hasDefault) {
|
|
37994
|
+
value = paramSpec.stringDefault ?? "";
|
|
37995
|
+
}
|
|
37996
|
+
if (typeof value !== "string") {
|
|
37997
|
+
throw new Error(`Parameter '${name}' must be a string`);
|
|
37998
|
+
}
|
|
37999
|
+
paramValue.stringValue = value;
|
|
38000
|
+
break;
|
|
38001
|
+
case 2 /* PARAM_TYPE_INT */:
|
|
38002
|
+
if (value == null && paramSpec.hasDefault) {
|
|
38003
|
+
value = paramSpec.intDefault ?? 0;
|
|
38004
|
+
}
|
|
38005
|
+
if (typeof value !== "number") {
|
|
38006
|
+
throw new Error(`Parameter '${name}' must be an integer`);
|
|
38007
|
+
}
|
|
38008
|
+
paramValue.intValue = value;
|
|
38009
|
+
break;
|
|
38010
|
+
case 9 /* PARAM_TYPE_BOOL */:
|
|
38011
|
+
if (value == null && paramSpec.hasDefault) {
|
|
38012
|
+
value = paramSpec.boolDefault ?? false;
|
|
38013
|
+
}
|
|
38014
|
+
if (typeof value !== "boolean") {
|
|
38015
|
+
throw new Error(`Parameter '${name}' must be a boolean`);
|
|
38016
|
+
}
|
|
38017
|
+
paramValue.boolValue = value;
|
|
38018
|
+
break;
|
|
38019
|
+
case 4 /* PARAM_TYPE_BYTES */:
|
|
38020
|
+
if (value == null && paramSpec.hasDefault) {
|
|
38021
|
+
value = paramSpec.bytesDefault ?? new Uint8Array();
|
|
38022
|
+
}
|
|
38023
|
+
if (!(value instanceof Uint8Array)) {
|
|
38024
|
+
throw new Error(`Parameter '${name}' must be a byte array`);
|
|
38025
|
+
}
|
|
38026
|
+
paramValue.bytesValue = value;
|
|
38027
|
+
break;
|
|
38028
|
+
default:
|
|
38029
|
+
throw new Error(`Unsupported parameter type: ${paramType}`);
|
|
38030
|
+
}
|
|
38031
|
+
return paramValue;
|
|
38032
|
+
}
|
|
38033
|
+
var ClsInstance = class {
|
|
38034
|
+
#methods;
|
|
38035
|
+
constructor(methods) {
|
|
38036
|
+
this.#methods = methods;
|
|
38037
|
+
}
|
|
38038
|
+
method(name) {
|
|
38039
|
+
const method = this.#methods.get(name);
|
|
38040
|
+
if (!method) {
|
|
38041
|
+
throw new NotFoundError(`Method '${name}' not found on class`);
|
|
38042
|
+
}
|
|
38043
|
+
return method;
|
|
38044
|
+
}
|
|
38045
|
+
};
|
|
37678
38046
|
export {
|
|
37679
38047
|
App,
|
|
38048
|
+
Cls,
|
|
38049
|
+
ClsInstance,
|
|
37680
38050
|
Function_,
|
|
37681
38051
|
Image2 as Image,
|
|
37682
38052
|
InternalFailure,
|
|
38053
|
+
NotFoundError,
|
|
37683
38054
|
RemoteError,
|
|
37684
38055
|
Sandbox2 as Sandbox,
|
|
37685
38056
|
TimeoutError
|