@dagger.io/dagger 0.15.2 → 0.15.3
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/src/api/client.gen.d.ts +8 -5
- package/dist/src/api/client.gen.d.ts.map +1 -1
- package/dist/src/api/client.gen.js +30 -164
- package/dist/src/common/context.d.ts +1 -1
- package/dist/src/common/context.d.ts.map +1 -1
- package/dist/src/common/context.js +2 -2
- package/dist/src/module/entrypoint/invoke.d.ts.map +1 -1
- package/dist/src/module/entrypoint/invoke.js +10 -0
- package/dist/src/module/entrypoint/load.d.ts.map +1 -1
- package/dist/src/module/entrypoint/load.js +6 -1
- package/dist/src/module/entrypoint/register.d.ts.map +1 -1
- package/dist/src/module/entrypoint/register.js +13 -0
- package/dist/src/module/executor.d.ts +5 -0
- package/dist/src/module/executor.d.ts.map +1 -1
- package/dist/src/module/executor.js +110 -1
- package/dist/src/module/introspector/case_convertor.d.ts.map +1 -1
- package/dist/src/module/introspector/case_convertor.js +7 -9
- package/dist/src/module/introspector/dagger_module/index.d.ts +1 -0
- package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -1
- package/dist/src/module/introspector/dagger_module/index.js +1 -0
- package/dist/src/module/introspector/dagger_module/interface.d.ts +25 -0
- package/dist/src/module/introspector/dagger_module/interface.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/interface.js +56 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts +32 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.js +87 -0
- package/dist/src/module/introspector/dagger_module/module.d.ts +16 -1
- package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -1
- package/dist/src/module/introspector/dagger_module/module.js +36 -2
- package/dist/src/module/introspector/dagger_module/reference.d.ts +1 -1
- package/dist/src/module/introspector/dagger_module/reference.d.ts.map +1 -1
- package/dist/src/module/introspector/typedef.d.ts +8 -1
- package/dist/src/module/introspector/typedef.d.ts.map +1 -1
- package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -1
- package/dist/src/module/introspector/typescript_module/ast.js +9 -2
- package/dist/src/provisioning/bin.js +1 -1
- package/dist/src/provisioning/default.d.ts +1 -1
- package/dist/src/provisioning/default.js +1 -1
- package/package.json +15 -15
|
@@ -97,6 +97,10 @@ export var TypeDefKind;
|
|
|
97
97
|
* Always paired with an EnumTypeDef.
|
|
98
98
|
*/
|
|
99
99
|
TypeDefKind["EnumKind"] = "ENUM_KIND";
|
|
100
|
+
/**
|
|
101
|
+
* A float value.
|
|
102
|
+
*/
|
|
103
|
+
TypeDefKind["FloatKind"] = "FLOAT_KIND";
|
|
100
104
|
/**
|
|
101
105
|
* A graphql input type, used only when representing the core API via TypeDefs.
|
|
102
106
|
*/
|
|
@@ -313,12 +317,7 @@ export class Container extends BaseClient {
|
|
|
313
317
|
envVariables = async () => {
|
|
314
318
|
const ctx = this._ctx.select("envVariables").select("id");
|
|
315
319
|
const response = await ctx.execute();
|
|
316
|
-
return response.map((r) => new
|
|
317
|
-
{
|
|
318
|
-
operation: "loadEnvVariableFromID",
|
|
319
|
-
args: { id: r.id },
|
|
320
|
-
},
|
|
321
|
-
], this._ctx.getConnection()), r.id));
|
|
320
|
+
return response.map((r) => new Client(ctx.copy()).loadEnvVariableFromID(r.id));
|
|
322
321
|
};
|
|
323
322
|
/**
|
|
324
323
|
* The exit code of the last executed command.
|
|
@@ -398,12 +397,7 @@ export class Container extends BaseClient {
|
|
|
398
397
|
exposedPorts = async () => {
|
|
399
398
|
const ctx = this._ctx.select("exposedPorts").select("id");
|
|
400
399
|
const response = await ctx.execute();
|
|
401
|
-
return response.map((r) => new
|
|
402
|
-
{
|
|
403
|
-
operation: "loadPortFromID",
|
|
404
|
-
args: { id: r.id },
|
|
405
|
-
},
|
|
406
|
-
], this._ctx.getConnection()), r.id));
|
|
400
|
+
return response.map((r) => new Client(ctx.copy()).loadPortFromID(r.id));
|
|
407
401
|
};
|
|
408
402
|
/**
|
|
409
403
|
* Retrieves a file at the given path.
|
|
@@ -464,12 +458,7 @@ export class Container extends BaseClient {
|
|
|
464
458
|
labels = async () => {
|
|
465
459
|
const ctx = this._ctx.select("labels").select("id");
|
|
466
460
|
const response = await ctx.execute();
|
|
467
|
-
return response.map((r) => new
|
|
468
|
-
{
|
|
469
|
-
operation: "loadLabelFromID",
|
|
470
|
-
args: { id: r.id },
|
|
471
|
-
},
|
|
472
|
-
], this._ctx.getConnection()), r.id));
|
|
461
|
+
return response.map((r) => new Client(ctx.copy()).loadLabelFromID(r.id));
|
|
473
462
|
};
|
|
474
463
|
/**
|
|
475
464
|
* Retrieves the list of paths where a directory is mounted.
|
|
@@ -566,12 +555,7 @@ export class Container extends BaseClient {
|
|
|
566
555
|
sync = async () => {
|
|
567
556
|
const ctx = this._ctx.select("sync");
|
|
568
557
|
const response = await ctx.execute();
|
|
569
|
-
return new
|
|
570
|
-
{
|
|
571
|
-
operation: "loadContainerFromID",
|
|
572
|
-
args: { id: response },
|
|
573
|
-
},
|
|
574
|
-
], this._ctx.getConnection()));
|
|
558
|
+
return new Client(ctx.copy()).loadContainerFromID(response);
|
|
575
559
|
};
|
|
576
560
|
/**
|
|
577
561
|
* Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).
|
|
@@ -1315,12 +1299,7 @@ export class Directory extends BaseClient {
|
|
|
1315
1299
|
sync = async () => {
|
|
1316
1300
|
const ctx = this._ctx.select("sync");
|
|
1317
1301
|
const response = await ctx.execute();
|
|
1318
|
-
return new
|
|
1319
|
-
{
|
|
1320
|
-
operation: "loadDirectoryFromID",
|
|
1321
|
-
args: { id: response },
|
|
1322
|
-
},
|
|
1323
|
-
], this._ctx.getConnection()));
|
|
1302
|
+
return new Client(ctx.copy()).loadDirectoryFromID(response);
|
|
1324
1303
|
};
|
|
1325
1304
|
/**
|
|
1326
1305
|
* Opens an interactive terminal in new container with this directory mounted inside.
|
|
@@ -1685,12 +1664,7 @@ export class EngineCacheEntrySet extends BaseClient {
|
|
|
1685
1664
|
entries = async () => {
|
|
1686
1665
|
const ctx = this._ctx.select("entries").select("id");
|
|
1687
1666
|
const response = await ctx.execute();
|
|
1688
|
-
return response.map((r) => new
|
|
1689
|
-
{
|
|
1690
|
-
operation: "loadEngineCacheEntryFromID",
|
|
1691
|
-
args: { id: r.id },
|
|
1692
|
-
},
|
|
1693
|
-
], this._ctx.getConnection()), r.id));
|
|
1667
|
+
return response.map((r) => new Client(ctx.copy()).loadEngineCacheEntryFromID(r.id));
|
|
1694
1668
|
};
|
|
1695
1669
|
/**
|
|
1696
1670
|
* The number of cache entries in this set.
|
|
@@ -1779,12 +1753,7 @@ export class EnumTypeDef extends BaseClient {
|
|
|
1779
1753
|
values = async () => {
|
|
1780
1754
|
const ctx = this._ctx.select("values").select("id");
|
|
1781
1755
|
const response = await ctx.execute();
|
|
1782
|
-
return response.map((r) => new
|
|
1783
|
-
{
|
|
1784
|
-
operation: "loadEnumValueTypeDefFromID",
|
|
1785
|
-
args: { id: r.id },
|
|
1786
|
-
},
|
|
1787
|
-
], this._ctx.getConnection()), r.id));
|
|
1756
|
+
return response.map((r) => new Client(ctx.copy()).loadEnumValueTypeDefFromID(r.id));
|
|
1788
1757
|
};
|
|
1789
1758
|
}
|
|
1790
1759
|
/**
|
|
@@ -2093,12 +2062,7 @@ export class File extends BaseClient {
|
|
|
2093
2062
|
sync = async () => {
|
|
2094
2063
|
const ctx = this._ctx.select("sync");
|
|
2095
2064
|
const response = await ctx.execute();
|
|
2096
|
-
return new
|
|
2097
|
-
{
|
|
2098
|
-
operation: "loadFileFromID",
|
|
2099
|
-
args: { id: response },
|
|
2100
|
-
},
|
|
2101
|
-
], this._ctx.getConnection()));
|
|
2065
|
+
return new Client(ctx.copy()).loadFileFromID(response);
|
|
2102
2066
|
};
|
|
2103
2067
|
/**
|
|
2104
2068
|
* Retrieves this file with its name set to the given name.
|
|
@@ -2162,12 +2126,7 @@ export class Function_ extends BaseClient {
|
|
|
2162
2126
|
args = async () => {
|
|
2163
2127
|
const ctx = this._ctx.select("args").select("id");
|
|
2164
2128
|
const response = await ctx.execute();
|
|
2165
|
-
return response.map((r) => new
|
|
2166
|
-
{
|
|
2167
|
-
operation: "loadFunctionArgFromID",
|
|
2168
|
-
args: { id: r.id },
|
|
2169
|
-
},
|
|
2170
|
-
], this._ctx.getConnection()), r.id));
|
|
2129
|
+
return response.map((r) => new Client(ctx.copy()).loadFunctionArgFromID(r.id));
|
|
2171
2130
|
};
|
|
2172
2131
|
/**
|
|
2173
2132
|
* A doc string for the function, if any.
|
|
@@ -2382,12 +2341,7 @@ export class FunctionCall extends BaseClient {
|
|
|
2382
2341
|
inputArgs = async () => {
|
|
2383
2342
|
const ctx = this._ctx.select("inputArgs").select("id");
|
|
2384
2343
|
const response = await ctx.execute();
|
|
2385
|
-
return response.map((r) => new
|
|
2386
|
-
{
|
|
2387
|
-
operation: "loadFunctionCallArgValueFromID",
|
|
2388
|
-
args: { id: r.id },
|
|
2389
|
-
},
|
|
2390
|
-
], this._ctx.getConnection()), r.id));
|
|
2344
|
+
return response.map((r) => new Client(ctx.copy()).loadFunctionCallArgValueFromID(r.id));
|
|
2391
2345
|
};
|
|
2392
2346
|
/**
|
|
2393
2347
|
* The name of the function being called.
|
|
@@ -2953,12 +2907,7 @@ export class InputTypeDef extends BaseClient {
|
|
|
2953
2907
|
fields = async () => {
|
|
2954
2908
|
const ctx = this._ctx.select("fields").select("id");
|
|
2955
2909
|
const response = await ctx.execute();
|
|
2956
|
-
return response.map((r) => new
|
|
2957
|
-
{
|
|
2958
|
-
operation: "loadFieldTypeDefFromID",
|
|
2959
|
-
args: { id: r.id },
|
|
2960
|
-
},
|
|
2961
|
-
], this._ctx.getConnection()), r.id));
|
|
2910
|
+
return response.map((r) => new Client(ctx.copy()).loadFieldTypeDefFromID(r.id));
|
|
2962
2911
|
};
|
|
2963
2912
|
/**
|
|
2964
2913
|
* The name of the input object.
|
|
@@ -3018,12 +2967,7 @@ export class InterfaceTypeDef extends BaseClient {
|
|
|
3018
2967
|
functions = async () => {
|
|
3019
2968
|
const ctx = this._ctx.select("functions").select("id");
|
|
3020
2969
|
const response = await ctx.execute();
|
|
3021
|
-
return response.map((r) => new
|
|
3022
|
-
{
|
|
3023
|
-
operation: "loadFunction_FromID",
|
|
3024
|
-
args: { id: r.id },
|
|
3025
|
-
},
|
|
3026
|
-
], this._ctx.getConnection()), r.id));
|
|
2970
|
+
return response.map((r) => new Client(ctx.copy()).loadFunctionFromID(r.id));
|
|
3027
2971
|
};
|
|
3028
2972
|
/**
|
|
3029
2973
|
* The name of the interface.
|
|
@@ -3230,12 +3174,7 @@ export class Module_ extends BaseClient {
|
|
|
3230
3174
|
dependencies = async () => {
|
|
3231
3175
|
const ctx = this._ctx.select("dependencies").select("id");
|
|
3232
3176
|
const response = await ctx.execute();
|
|
3233
|
-
return response.map((r) => new
|
|
3234
|
-
{
|
|
3235
|
-
operation: "loadModule_FromID",
|
|
3236
|
-
args: { id: r.id },
|
|
3237
|
-
},
|
|
3238
|
-
], this._ctx.getConnection()), r.id));
|
|
3177
|
+
return response.map((r) => new Client(ctx.copy()).loadModuleFromID(r.id));
|
|
3239
3178
|
};
|
|
3240
3179
|
/**
|
|
3241
3180
|
* The dependencies as configured by the module.
|
|
@@ -3243,12 +3182,7 @@ export class Module_ extends BaseClient {
|
|
|
3243
3182
|
dependencyConfig = async () => {
|
|
3244
3183
|
const ctx = this._ctx.select("dependencyConfig").select("id");
|
|
3245
3184
|
const response = await ctx.execute();
|
|
3246
|
-
return response.map((r) => new
|
|
3247
|
-
{
|
|
3248
|
-
operation: "loadModuleDependencyFromID",
|
|
3249
|
-
args: { id: r.id },
|
|
3250
|
-
},
|
|
3251
|
-
], this._ctx.getConnection()), r.id));
|
|
3185
|
+
return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
|
|
3252
3186
|
};
|
|
3253
3187
|
/**
|
|
3254
3188
|
* The doc string of the module, if any
|
|
@@ -3267,12 +3201,7 @@ export class Module_ extends BaseClient {
|
|
|
3267
3201
|
enums = async () => {
|
|
3268
3202
|
const ctx = this._ctx.select("enums").select("id");
|
|
3269
3203
|
const response = await ctx.execute();
|
|
3270
|
-
return response.map((r) => new
|
|
3271
|
-
{
|
|
3272
|
-
operation: "loadTypeDefFromID",
|
|
3273
|
-
args: { id: r.id },
|
|
3274
|
-
},
|
|
3275
|
-
], this._ctx.getConnection()), r.id));
|
|
3204
|
+
return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
|
|
3276
3205
|
};
|
|
3277
3206
|
/**
|
|
3278
3207
|
* The generated files and directories made on top of the module source's context directory.
|
|
@@ -3301,12 +3230,7 @@ export class Module_ extends BaseClient {
|
|
|
3301
3230
|
interfaces = async () => {
|
|
3302
3231
|
const ctx = this._ctx.select("interfaces").select("id");
|
|
3303
3232
|
const response = await ctx.execute();
|
|
3304
|
-
return response.map((r) => new
|
|
3305
|
-
{
|
|
3306
|
-
operation: "loadTypeDefFromID",
|
|
3307
|
-
args: { id: r.id },
|
|
3308
|
-
},
|
|
3309
|
-
], this._ctx.getConnection()), r.id));
|
|
3233
|
+
return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
|
|
3310
3234
|
};
|
|
3311
3235
|
/**
|
|
3312
3236
|
* The name of the module
|
|
@@ -3325,12 +3249,7 @@ export class Module_ extends BaseClient {
|
|
|
3325
3249
|
objects = async () => {
|
|
3326
3250
|
const ctx = this._ctx.select("objects").select("id");
|
|
3327
3251
|
const response = await ctx.execute();
|
|
3328
|
-
return response.map((r) => new
|
|
3329
|
-
{
|
|
3330
|
-
operation: "loadTypeDefFromID",
|
|
3331
|
-
args: { id: r.id },
|
|
3332
|
-
},
|
|
3333
|
-
], this._ctx.getConnection()), r.id));
|
|
3252
|
+
return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
|
|
3334
3253
|
};
|
|
3335
3254
|
/**
|
|
3336
3255
|
* The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile.
|
|
@@ -3562,12 +3481,7 @@ export class ModuleSource extends BaseClient {
|
|
|
3562
3481
|
dependencies = async () => {
|
|
3563
3482
|
const ctx = this._ctx.select("dependencies").select("id");
|
|
3564
3483
|
const response = await ctx.execute();
|
|
3565
|
-
return response.map((r) => new
|
|
3566
|
-
{
|
|
3567
|
-
operation: "loadModuleDependencyFromID",
|
|
3568
|
-
args: { id: r.id },
|
|
3569
|
-
},
|
|
3570
|
-
], this._ctx.getConnection()), r.id));
|
|
3484
|
+
return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
|
|
3571
3485
|
};
|
|
3572
3486
|
/**
|
|
3573
3487
|
* Return the module source's content digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
|
|
@@ -3707,12 +3621,7 @@ export class ModuleSource extends BaseClient {
|
|
|
3707
3621
|
views = async () => {
|
|
3708
3622
|
const ctx = this._ctx.select("views").select("id");
|
|
3709
3623
|
const response = await ctx.execute();
|
|
3710
|
-
return response.map((r) => new
|
|
3711
|
-
{
|
|
3712
|
-
operation: "loadModuleSourceViewFromID",
|
|
3713
|
-
args: { id: r.id },
|
|
3714
|
-
},
|
|
3715
|
-
], this._ctx.getConnection()), r.id));
|
|
3624
|
+
return response.map((r) => new Client(ctx.copy()).loadModuleSourceViewFromID(r.id));
|
|
3716
3625
|
};
|
|
3717
3626
|
/**
|
|
3718
3627
|
* Update the module source with a new context directory. Only valid for local sources.
|
|
@@ -3894,12 +3803,7 @@ export class ObjectTypeDef extends BaseClient {
|
|
|
3894
3803
|
fields = async () => {
|
|
3895
3804
|
const ctx = this._ctx.select("fields").select("id");
|
|
3896
3805
|
const response = await ctx.execute();
|
|
3897
|
-
return response.map((r) => new
|
|
3898
|
-
{
|
|
3899
|
-
operation: "loadFieldTypeDefFromID",
|
|
3900
|
-
args: { id: r.id },
|
|
3901
|
-
},
|
|
3902
|
-
], this._ctx.getConnection()), r.id));
|
|
3806
|
+
return response.map((r) => new Client(ctx.copy()).loadFieldTypeDefFromID(r.id));
|
|
3903
3807
|
};
|
|
3904
3808
|
/**
|
|
3905
3809
|
* Functions defined on this object, if any.
|
|
@@ -3907,12 +3811,7 @@ export class ObjectTypeDef extends BaseClient {
|
|
|
3907
3811
|
functions = async () => {
|
|
3908
3812
|
const ctx = this._ctx.select("functions").select("id");
|
|
3909
3813
|
const response = await ctx.execute();
|
|
3910
|
-
return response.map((r) => new
|
|
3911
|
-
{
|
|
3912
|
-
operation: "loadFunction_FromID",
|
|
3913
|
-
args: { id: r.id },
|
|
3914
|
-
},
|
|
3915
|
-
], this._ctx.getConnection()), r.id));
|
|
3814
|
+
return response.map((r) => new Client(ctx.copy()).loadFunctionFromID(r.id));
|
|
3916
3815
|
};
|
|
3917
3816
|
/**
|
|
3918
3817
|
* The name of the object.
|
|
@@ -4040,14 +3939,6 @@ export class Client extends BaseClient {
|
|
|
4040
3939
|
getGQLClient() {
|
|
4041
3940
|
return this._ctx.getGQLClient();
|
|
4042
3941
|
}
|
|
4043
|
-
/**
|
|
4044
|
-
* Retrieves a content-addressed blob.
|
|
4045
|
-
* @param digest Digest of the blob
|
|
4046
|
-
*/
|
|
4047
|
-
blob = (digest) => {
|
|
4048
|
-
const ctx = this._ctx.select("blob", { digest });
|
|
4049
|
-
return new Directory(ctx);
|
|
4050
|
-
};
|
|
4051
3942
|
/**
|
|
4052
3943
|
* Retrieves a container builtin to the engine.
|
|
4053
3944
|
* @param digest Digest of the image manifest
|
|
@@ -4096,12 +3987,7 @@ export class Client extends BaseClient {
|
|
|
4096
3987
|
currentTypeDefs = async () => {
|
|
4097
3988
|
const ctx = this._ctx.select("currentTypeDefs").select("id");
|
|
4098
3989
|
const response = await ctx.execute();
|
|
4099
|
-
return response.map((r) => new
|
|
4100
|
-
{
|
|
4101
|
-
operation: "loadTypeDefFromID",
|
|
4102
|
-
args: { id: r.id },
|
|
4103
|
-
},
|
|
4104
|
-
], this._ctx.getConnection()), r.id));
|
|
3990
|
+
return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
|
|
4105
3991
|
};
|
|
4106
3992
|
/**
|
|
4107
3993
|
* The default platform of the engine.
|
|
@@ -4719,12 +4605,7 @@ export class Service extends BaseClient {
|
|
|
4719
4605
|
ports = async () => {
|
|
4720
4606
|
const ctx = this._ctx.select("ports").select("id");
|
|
4721
4607
|
const response = await ctx.execute();
|
|
4722
|
-
return response.map((r) => new
|
|
4723
|
-
{
|
|
4724
|
-
operation: "loadPortFromID",
|
|
4725
|
-
args: { id: r.id },
|
|
4726
|
-
},
|
|
4727
|
-
], this._ctx.getConnection()), r.id));
|
|
4608
|
+
return response.map((r) => new Client(ctx.copy()).loadPortFromID(r.id));
|
|
4728
4609
|
};
|
|
4729
4610
|
/**
|
|
4730
4611
|
* Start the service and wait for its health checks to succeed.
|
|
@@ -4734,12 +4615,7 @@ export class Service extends BaseClient {
|
|
|
4734
4615
|
start = async () => {
|
|
4735
4616
|
const ctx = this._ctx.select("start");
|
|
4736
4617
|
const response = await ctx.execute();
|
|
4737
|
-
return new
|
|
4738
|
-
{
|
|
4739
|
-
operation: "loadServiceFromID",
|
|
4740
|
-
args: { id: response },
|
|
4741
|
-
},
|
|
4742
|
-
], this._ctx.getConnection()));
|
|
4618
|
+
return new Client(ctx.copy()).loadServiceFromID(response);
|
|
4743
4619
|
};
|
|
4744
4620
|
/**
|
|
4745
4621
|
* Stop the service.
|
|
@@ -4748,12 +4624,7 @@ export class Service extends BaseClient {
|
|
|
4748
4624
|
stop = async (opts) => {
|
|
4749
4625
|
const ctx = this._ctx.select("stop", { ...opts });
|
|
4750
4626
|
const response = await ctx.execute();
|
|
4751
|
-
return new
|
|
4752
|
-
{
|
|
4753
|
-
operation: "loadServiceFromID",
|
|
4754
|
-
args: { id: response },
|
|
4755
|
-
},
|
|
4756
|
-
], this._ctx.getConnection()));
|
|
4627
|
+
return new Client(ctx.copy()).loadServiceFromID(response);
|
|
4757
4628
|
};
|
|
4758
4629
|
/**
|
|
4759
4630
|
* Creates a tunnel that forwards traffic from the caller's network to this service.
|
|
@@ -4919,12 +4790,7 @@ export class Terminal extends BaseClient {
|
|
|
4919
4790
|
sync = async () => {
|
|
4920
4791
|
const ctx = this._ctx.select("sync");
|
|
4921
4792
|
const response = await ctx.execute();
|
|
4922
|
-
return new
|
|
4923
|
-
{
|
|
4924
|
-
operation: "loadTerminalFromID",
|
|
4925
|
-
args: { id: response },
|
|
4926
|
-
},
|
|
4927
|
-
], this._ctx.getConnection()));
|
|
4793
|
+
return new Client(ctx.copy()).loadTerminalFromID(response);
|
|
4928
4794
|
};
|
|
4929
4795
|
}
|
|
4930
4796
|
/**
|
|
@@ -5,7 +5,7 @@ export declare class Context {
|
|
|
5
5
|
private _connection;
|
|
6
6
|
constructor(_queryTree?: QueryTree[], _connection?: import("./graphql/connection.js").Connection);
|
|
7
7
|
getGQLClient(): GraphQLClient;
|
|
8
|
-
|
|
8
|
+
copy(): Context;
|
|
9
9
|
select(operation: string, args?: Record<string, unknown>): Context;
|
|
10
10
|
execute<T>(): Promise<T>;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/common/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAgB,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAGpE,qBAAa,OAAO;IAEhB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;gBADX,UAAU,GAAE,SAAS,EAAO,EAC5B,WAAW,+CAAmB;IAGxC,YAAY,IAAI,aAAa;IAI7B,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/common/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAgB,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAGpE,qBAAa,OAAO;IAEhB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;gBADX,UAAU,GAAE,SAAS,EAAO,EAC5B,WAAW,+CAAmB;IAGxC,YAAY,IAAI,aAAa;IAI7B,IAAI,IAAI,OAAO;IAIf,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;IAOlE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;CAGzB"}
|
|
@@ -10,8 +10,8 @@ export class Context {
|
|
|
10
10
|
getGQLClient() {
|
|
11
11
|
return this._connection.getGQLClient();
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
return this._connection;
|
|
13
|
+
copy() {
|
|
14
|
+
return new Context([], this._connection);
|
|
15
15
|
}
|
|
16
16
|
select(operation, args) {
|
|
17
17
|
return new Context([...this._queryTree, { operation, args }], this._connection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/invoke.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/invoke.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAIL,YAAY,EAEb,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAkBxC;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,gBAmEf"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../api/client.gen.js";
|
|
1
2
|
import { FunctionNotFound } from "../../common/errors/index.js";
|
|
2
3
|
import { registry } from "../registry.js";
|
|
3
4
|
import { loadResult, loadInvokedMethod, loadInvokedObject, loadArgs, loadParentState, loadObjectReturnType, } from "./load.js";
|
|
4
5
|
function isConstructor(method) {
|
|
5
6
|
return method.name === "";
|
|
6
7
|
}
|
|
8
|
+
function isFloat(num) {
|
|
9
|
+
return num % 1 !== 0;
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
12
|
* A wrapper around the registry to invoke a function.
|
|
9
13
|
*
|
|
@@ -45,6 +49,12 @@ export async function invoke(executor, module, ctx) {
|
|
|
45
49
|
// Handle alias serialization by getting the return type to load
|
|
46
50
|
// if the function called isn't a constructor.
|
|
47
51
|
if (!isConstructor(method)) {
|
|
52
|
+
// Guard to catch if a user returned a float number but the function's return
|
|
53
|
+
// type is set to `number` (integer).
|
|
54
|
+
if (method.returnType.kind === TypeDefKind.IntegerKind &&
|
|
55
|
+
isFloat(result)) {
|
|
56
|
+
throw new Error(`cannot return float '${result}' if return type is 'number' (integer), please use 'float' as return type instead`);
|
|
57
|
+
}
|
|
48
58
|
returnType = loadObjectReturnType(module, object, method);
|
|
49
59
|
}
|
|
50
60
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/load.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAO,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EACL,iBAAiB,IAAI,WAAW,EAChC,cAAc,IAAI,MAAM,EAExB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAEjB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAEd;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,SAAS,CAMpC;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GAAG,WAAW,EAC5B,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CA6Cf;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,GAAG,EACV,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/load.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAO,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EACL,iBAAiB,IAAI,WAAW,EAChC,cAAc,IAAI,MAAM,EAExB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAEjB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAEd;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,SAAS,CAMpC;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GAAG,WAAW,EAC5B,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CA6Cf;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,GAAG,EACV,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,OAAO,CAAC,GAAG,CAAC,CAiDd;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,GACb,gBAAgB,GAAG,cAAc,CAwBnC;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,gBAAgB,GAAG,cAAc,GACxC,OAAO,CAAC,GAAG,CAAC,CAiFd"}
|
|
@@ -107,10 +107,15 @@ export async function loadValue(executor, value, type) {
|
|
|
107
107
|
}
|
|
108
108
|
return executor.buildClass(objectType, value);
|
|
109
109
|
}
|
|
110
|
+
case TypeDefKind.InterfaceKind: {
|
|
111
|
+
const interfaceType = type.name;
|
|
112
|
+
return executor.buildInterface(interfaceType, value);
|
|
113
|
+
}
|
|
110
114
|
// Cannot use `,` to specify multiple matching case so instead we use fallthrough.
|
|
111
115
|
case TypeDefKind.StringKind:
|
|
112
116
|
case TypeDefKind.IntegerKind:
|
|
113
117
|
case TypeDefKind.BooleanKind:
|
|
118
|
+
case TypeDefKind.FloatKind:
|
|
114
119
|
case TypeDefKind.VoidKind:
|
|
115
120
|
case TypeDefKind.ScalarKind:
|
|
116
121
|
case TypeDefKind.EnumKind:
|
|
@@ -154,7 +159,7 @@ export function loadObjectReturnType(module, object, method) {
|
|
|
154
159
|
export async function loadResult(result, module, object) {
|
|
155
160
|
// Handle IDable objects
|
|
156
161
|
if (result && typeof result?.id === "function") {
|
|
157
|
-
|
|
162
|
+
return await result.id();
|
|
158
163
|
}
|
|
159
164
|
// Handle arrays
|
|
160
165
|
if (Array.isArray(result)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAIT,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAIL,YAAY,EAEb,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAIT,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAIL,YAAY,EAEb,MAAM,wCAAwC,CAAA;AAW/C;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,QAAQ,CAAC,CA8EnB"}
|
|
@@ -49,6 +49,16 @@ export async function register(files, module) {
|
|
|
49
49
|
});
|
|
50
50
|
mod = mod.withEnum(typeDef);
|
|
51
51
|
});
|
|
52
|
+
// Register all interfaces defined by this module
|
|
53
|
+
Object.values(module.interfaces).forEach((interface_) => {
|
|
54
|
+
let typeDef = dag.typeDef().withInterface(interface_.name, {
|
|
55
|
+
description: interface_.description,
|
|
56
|
+
});
|
|
57
|
+
Object.values(interface_.functions).forEach((function_) => {
|
|
58
|
+
typeDef = typeDef.withFunction(addFunction(function_));
|
|
59
|
+
});
|
|
60
|
+
mod = mod.withInterface(typeDef);
|
|
61
|
+
});
|
|
52
62
|
// Call ID to actually execute the registration
|
|
53
63
|
return await mod.id();
|
|
54
64
|
}
|
|
@@ -133,6 +143,8 @@ function addTypeDef(type) {
|
|
|
133
143
|
return dag.typeDef().withKind(type.kind).withOptional(true);
|
|
134
144
|
case TypeDefKind.EnumKind:
|
|
135
145
|
return dag.typeDef().withEnum(type.name);
|
|
146
|
+
case TypeDefKind.InterfaceKind:
|
|
147
|
+
return dag.typeDef().withInterface(type.name);
|
|
136
148
|
default:
|
|
137
149
|
return dag.typeDef().withKind(type.kind);
|
|
138
150
|
}
|
|
@@ -145,5 +157,6 @@ function isPrimitiveType(type) {
|
|
|
145
157
|
return (type.kind === TypeDefKind.BooleanKind ||
|
|
146
158
|
type.kind === TypeDefKind.IntegerKind ||
|
|
147
159
|
type.kind === TypeDefKind.StringKind ||
|
|
160
|
+
type.kind === TypeDefKind.FloatKind ||
|
|
148
161
|
type.kind === TypeDefKind.EnumKind);
|
|
149
162
|
}
|
|
@@ -10,6 +10,11 @@ export declare class Executor {
|
|
|
10
10
|
constructor(modules: Module[], daggerModule: DaggerModule);
|
|
11
11
|
private getExportedObject;
|
|
12
12
|
buildClass(object: string, state: State): any;
|
|
13
|
+
/**
|
|
14
|
+
* Transform a Dagger interface identifier into an implementation of this
|
|
15
|
+
* interface serves as module call binding to reach the true implementation.
|
|
16
|
+
*/
|
|
17
|
+
buildInterface(iface: string, id: string): any;
|
|
13
18
|
getResult(object: string, method: string, state: State, inputs: Args): Promise<any>;
|
|
14
19
|
}
|
|
15
20
|
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/module/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/module/executor.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,aAAa,CAAA;AAMhC,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAIpE,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAE/C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE1C,qBAAa,QAAQ;aAED,OAAO,EAAE,MAAM,EAAE;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADb,OAAO,EAAE,MAAM,EAAE,EAChB,YAAY,EAAE,YAAY;IAG7C,OAAO,CAAC,iBAAiB;IAUzB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG;IAqB7C;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,GAAG;IAiBxC,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,GAAG,CAAC;CAchB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { dag, TypeDefKind } from "../api/client.gen.js";
|
|
2
|
+
import { Context } from "../common/context.js";
|
|
1
3
|
import { FunctionNotFound } from "../common/errors/index.js";
|
|
4
|
+
import { Connection } from "../common/graphql/connection.js";
|
|
2
5
|
export class Executor {
|
|
3
6
|
modules;
|
|
4
7
|
daggerModule;
|
|
@@ -17,7 +20,7 @@ export class Executor {
|
|
|
17
20
|
buildClass(object, state) {
|
|
18
21
|
const daggerObject = this.daggerModule.objects[object];
|
|
19
22
|
if (!daggerObject) {
|
|
20
|
-
throw new FunctionNotFound(`Object ${object} not found in the
|
|
23
|
+
throw new FunctionNotFound(`Object ${object} not found in the module`);
|
|
21
24
|
}
|
|
22
25
|
switch (daggerObject.kind()) {
|
|
23
26
|
case "class": {
|
|
@@ -31,6 +34,18 @@ export class Executor {
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Transform a Dagger interface identifier into an implementation of this
|
|
39
|
+
* interface serves as module call binding to reach the true implementation.
|
|
40
|
+
*/
|
|
41
|
+
buildInterface(iface, id) {
|
|
42
|
+
const interfaceObject = this.daggerModule.interfaces[iface];
|
|
43
|
+
if (!interfaceObject) {
|
|
44
|
+
throw new Error(`Interface ${iface} not found in the module`);
|
|
45
|
+
}
|
|
46
|
+
const ifaceImpl = new InterfaceWrapper(this, this.daggerModule, `${this.daggerModule.name}${iface}`, id, interfaceObject.functions);
|
|
47
|
+
return ifaceImpl;
|
|
48
|
+
}
|
|
34
49
|
async getResult(object, method, state, inputs) {
|
|
35
50
|
const obj = this.getExportedObject(object);
|
|
36
51
|
if (method === "") {
|
|
@@ -43,3 +58,97 @@ export class Executor {
|
|
|
43
58
|
return await builtObj[method](...Object.values(inputs));
|
|
44
59
|
}
|
|
45
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Interface Wrapper serves as dynaminc module binding so the module can
|
|
63
|
+
* call function of this interface.
|
|
64
|
+
* Because the actual interface implementation can come from any external modules,
|
|
65
|
+
* all resolution are done by API Call.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* interface Example {
|
|
70
|
+
* foo: () => Promise<string>
|
|
71
|
+
* }
|
|
72
|
+
*
|
|
73
|
+
* class Test {
|
|
74
|
+
* @func()
|
|
75
|
+
* async callFoo(example: Example): Promise<string> {
|
|
76
|
+
* // <- This example argument here is actually the Interface Wrapper, and `foo` will,
|
|
77
|
+
* // directly execute the API call to reach the given implementation.
|
|
78
|
+
* return example.foo()
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
class InterfaceWrapper {
|
|
84
|
+
executor;
|
|
85
|
+
module;
|
|
86
|
+
ifaceName;
|
|
87
|
+
ifaceId;
|
|
88
|
+
fcts;
|
|
89
|
+
_ctx;
|
|
90
|
+
constructor(executor, module, ifaceName, ifaceId, fcts) {
|
|
91
|
+
this.executor = executor;
|
|
92
|
+
this.module = module;
|
|
93
|
+
this.ifaceName = ifaceName;
|
|
94
|
+
this.ifaceId = ifaceId;
|
|
95
|
+
this.fcts = fcts;
|
|
96
|
+
this._ctx = new Context([], new Connection(dag.getGQLClient()));
|
|
97
|
+
// Load the interface by its identifier
|
|
98
|
+
this._ctx = this._ctx.select(`load${ifaceName}FromID`, { id: ifaceId });
|
|
99
|
+
Object.entries(fcts).forEach(([name, fct]) => {
|
|
100
|
+
const argKeys = Object.keys(fct.arguments);
|
|
101
|
+
// Dynamically adding functions of the interface and it's resolvers.
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
this[name] = async (...args) => {
|
|
104
|
+
// Fill up arguments of that function.
|
|
105
|
+
const argsPayload = {};
|
|
106
|
+
for (let i = 0; i < argKeys.length; i++) {
|
|
107
|
+
if (args[i] !== undefined) {
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
argsPayload[argKeys[i]] = args[i];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this._ctx = this._ctx.select(name, argsPayload);
|
|
113
|
+
// If the function is returning an IDable, we don't need to execute it
|
|
114
|
+
// since it will be resolved later.
|
|
115
|
+
if (fct.returnType.kind === TypeDefKind.InterfaceKind ||
|
|
116
|
+
fct.returnType.kind === TypeDefKind.ObjectKind) {
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
// If the function is returning a list, we may need to load the sub-objects
|
|
120
|
+
if (fct.returnType.kind === TypeDefKind.ListKind) {
|
|
121
|
+
const listTypeDef = fct.returnType
|
|
122
|
+
.typeDef;
|
|
123
|
+
// If the list is an object or an interface, then we need to load the sub-objects.
|
|
124
|
+
if (listTypeDef.kind === TypeDefKind.ObjectKind ||
|
|
125
|
+
listTypeDef.kind === TypeDefKind.InterfaceKind) {
|
|
126
|
+
const typedef = listTypeDef;
|
|
127
|
+
// Resolves the call to get the list of IDs to load
|
|
128
|
+
const ids = await this._ctx
|
|
129
|
+
.select("id")
|
|
130
|
+
.execute();
|
|
131
|
+
// If the return type is an interface defined by that module, we need to load it through
|
|
132
|
+
// the interface wrapper
|
|
133
|
+
if (this.module.interfaces[typedef.name]) {
|
|
134
|
+
return await Promise.all(ids.map(({ id }) => new InterfaceWrapper(this.executor, module, `${this.module.name}${typedef.name}`, id, this.module.interfaces[typedef.name].functions)));
|
|
135
|
+
}
|
|
136
|
+
// Otherwise, we can just load the objects from the API
|
|
137
|
+
return await Promise.all(
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
ids.map(({ id }) => dag[`load${listTypeDef.name}FromID`](id)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return await this._ctx.execute();
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* ID function to make the interface IDeable when serialized as return value to the
|
|
148
|
+
* Dagger API.
|
|
149
|
+
*/
|
|
150
|
+
async id() {
|
|
151
|
+
const ctx = this._ctx.select("id");
|
|
152
|
+
return await ctx.execute();
|
|
153
|
+
}
|
|
154
|
+
}
|