@dagger.io/dagger 0.15.2 → 0.15.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.
Files changed (39) hide show
  1. package/dist/src/api/client.gen.d.ts +58 -17
  2. package/dist/src/api/client.gen.d.ts.map +1 -1
  3. package/dist/src/api/client.gen.js +106 -181
  4. package/dist/src/common/context.d.ts +1 -1
  5. package/dist/src/common/context.d.ts.map +1 -1
  6. package/dist/src/common/context.js +2 -2
  7. package/dist/src/module/entrypoint/invoke.d.ts.map +1 -1
  8. package/dist/src/module/entrypoint/invoke.js +10 -0
  9. package/dist/src/module/entrypoint/load.d.ts.map +1 -1
  10. package/dist/src/module/entrypoint/load.js +6 -1
  11. package/dist/src/module/entrypoint/register.d.ts.map +1 -1
  12. package/dist/src/module/entrypoint/register.js +13 -0
  13. package/dist/src/module/executor.d.ts +5 -0
  14. package/dist/src/module/executor.d.ts.map +1 -1
  15. package/dist/src/module/executor.js +110 -1
  16. package/dist/src/module/introspector/case_convertor.d.ts.map +1 -1
  17. package/dist/src/module/introspector/case_convertor.js +7 -9
  18. package/dist/src/module/introspector/dagger_module/index.d.ts +1 -0
  19. package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -1
  20. package/dist/src/module/introspector/dagger_module/index.js +1 -0
  21. package/dist/src/module/introspector/dagger_module/interface.d.ts +25 -0
  22. package/dist/src/module/introspector/dagger_module/interface.d.ts.map +1 -0
  23. package/dist/src/module/introspector/dagger_module/interface.js +56 -0
  24. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts +32 -0
  25. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts.map +1 -0
  26. package/dist/src/module/introspector/dagger_module/interfaceFunction.js +87 -0
  27. package/dist/src/module/introspector/dagger_module/module.d.ts +16 -1
  28. package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -1
  29. package/dist/src/module/introspector/dagger_module/module.js +36 -2
  30. package/dist/src/module/introspector/dagger_module/reference.d.ts +1 -1
  31. package/dist/src/module/introspector/dagger_module/reference.d.ts.map +1 -1
  32. package/dist/src/module/introspector/typedef.d.ts +8 -1
  33. package/dist/src/module/introspector/typedef.d.ts.map +1 -1
  34. package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -1
  35. package/dist/src/module/introspector/typescript_module/ast.js +9 -2
  36. package/dist/src/provisioning/bin.js +1 -1
  37. package/dist/src/provisioning/default.d.ts +1 -1
  38. package/dist/src/provisioning/default.js +1 -1
  39. 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 EnvVariable(new Context([
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 Port(new Context([
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 Label(new Context([
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 Container(new Context([
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 Directory(new Context([
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 EngineCacheEntry(new Context([
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 EnumValueTypeDef(new Context([
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 File(new Context([
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 FunctionArg(new Context([
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 FunctionCallArgValue(new Context([
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 FieldTypeDef(new Context([
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 Function_(new Context([
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.
@@ -3200,17 +3144,15 @@ export class Module_ extends BaseClient {
3200
3144
  _id = undefined;
3201
3145
  _description = undefined;
3202
3146
  _name = undefined;
3203
- _sdk = undefined;
3204
3147
  _serve = undefined;
3205
3148
  /**
3206
3149
  * Constructor is used for internal usage only, do not create object from it.
3207
3150
  */
3208
- constructor(ctx, _id, _description, _name, _sdk, _serve) {
3151
+ constructor(ctx, _id, _description, _name, _serve) {
3209
3152
  super(ctx);
3210
3153
  this._id = _id;
3211
3154
  this._description = _description;
3212
3155
  this._name = _name;
3213
- this._sdk = _sdk;
3214
3156
  this._serve = _serve;
3215
3157
  }
3216
3158
  /**
@@ -3230,12 +3172,7 @@ export class Module_ extends BaseClient {
3230
3172
  dependencies = async () => {
3231
3173
  const ctx = this._ctx.select("dependencies").select("id");
3232
3174
  const response = await ctx.execute();
3233
- return response.map((r) => new Module_(new Context([
3234
- {
3235
- operation: "loadModule_FromID",
3236
- args: { id: r.id },
3237
- },
3238
- ], this._ctx.getConnection()), r.id));
3175
+ return response.map((r) => new Client(ctx.copy()).loadModuleFromID(r.id));
3239
3176
  };
3240
3177
  /**
3241
3178
  * The dependencies as configured by the module.
@@ -3243,12 +3180,7 @@ export class Module_ extends BaseClient {
3243
3180
  dependencyConfig = async () => {
3244
3181
  const ctx = this._ctx.select("dependencyConfig").select("id");
3245
3182
  const response = await ctx.execute();
3246
- return response.map((r) => new ModuleDependency(new Context([
3247
- {
3248
- operation: "loadModuleDependencyFromID",
3249
- args: { id: r.id },
3250
- },
3251
- ], this._ctx.getConnection()), r.id));
3183
+ return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
3252
3184
  };
3253
3185
  /**
3254
3186
  * The doc string of the module, if any
@@ -3267,12 +3199,7 @@ export class Module_ extends BaseClient {
3267
3199
  enums = async () => {
3268
3200
  const ctx = this._ctx.select("enums").select("id");
3269
3201
  const response = await ctx.execute();
3270
- return response.map((r) => new TypeDef(new Context([
3271
- {
3272
- operation: "loadTypeDefFromID",
3273
- args: { id: r.id },
3274
- },
3275
- ], this._ctx.getConnection()), r.id));
3202
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3276
3203
  };
3277
3204
  /**
3278
3205
  * The generated files and directories made on top of the module source's context directory.
@@ -3301,12 +3228,7 @@ export class Module_ extends BaseClient {
3301
3228
  interfaces = async () => {
3302
3229
  const ctx = this._ctx.select("interfaces").select("id");
3303
3230
  const response = await ctx.execute();
3304
- return response.map((r) => new TypeDef(new Context([
3305
- {
3306
- operation: "loadTypeDefFromID",
3307
- args: { id: r.id },
3308
- },
3309
- ], this._ctx.getConnection()), r.id));
3231
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3310
3232
  };
3311
3233
  /**
3312
3234
  * The name of the module
@@ -3325,12 +3247,7 @@ export class Module_ extends BaseClient {
3325
3247
  objects = async () => {
3326
3248
  const ctx = this._ctx.select("objects").select("id");
3327
3249
  const response = await ctx.execute();
3328
- return response.map((r) => new TypeDef(new Context([
3329
- {
3330
- operation: "loadTypeDefFromID",
3331
- args: { id: r.id },
3332
- },
3333
- ], this._ctx.getConnection()), r.id));
3250
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3334
3251
  };
3335
3252
  /**
3336
3253
  * The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile.
@@ -3340,15 +3257,11 @@ export class Module_ extends BaseClient {
3340
3257
  return new Container(ctx);
3341
3258
  };
3342
3259
  /**
3343
- * The SDK used by this module. Either a name of a builtin SDK or a module source ref string pointing to the SDK's implementation.
3260
+ * The SDK config used by this module.
3344
3261
  */
3345
- sdk = async () => {
3346
- if (this._sdk) {
3347
- return this._sdk;
3348
- }
3262
+ sdk = () => {
3349
3263
  const ctx = this._ctx.select("sdk");
3350
- const response = await ctx.execute();
3351
- return response;
3264
+ return new SDKConfig(ctx);
3352
3265
  };
3353
3266
  /**
3354
3267
  * Serve a module's API in the current session.
@@ -3562,12 +3475,7 @@ export class ModuleSource extends BaseClient {
3562
3475
  dependencies = async () => {
3563
3476
  const ctx = this._ctx.select("dependencies").select("id");
3564
3477
  const response = await ctx.execute();
3565
- return response.map((r) => new ModuleDependency(new Context([
3566
- {
3567
- operation: "loadModuleDependencyFromID",
3568
- args: { id: r.id },
3569
- },
3570
- ], this._ctx.getConnection()), r.id));
3478
+ return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
3571
3479
  };
3572
3480
  /**
3573
3481
  * 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 +3615,7 @@ export class ModuleSource extends BaseClient {
3707
3615
  views = async () => {
3708
3616
  const ctx = this._ctx.select("views").select("id");
3709
3617
  const response = await ctx.execute();
3710
- return response.map((r) => new ModuleSourceView(new Context([
3711
- {
3712
- operation: "loadModuleSourceViewFromID",
3713
- args: { id: r.id },
3714
- },
3715
- ], this._ctx.getConnection()), r.id));
3618
+ return response.map((r) => new Client(ctx.copy()).loadModuleSourceViewFromID(r.id));
3716
3619
  };
3717
3620
  /**
3718
3621
  * Update the module source with a new context directory. Only valid for local sources.
@@ -3748,10 +3651,10 @@ export class ModuleSource extends BaseClient {
3748
3651
  };
3749
3652
  /**
3750
3653
  * Update the module source with a new SDK.
3751
- * @param sdk The SDK to set.
3654
+ * @param source The SDK source to set.
3752
3655
  */
3753
- withSDK = (sdk) => {
3754
- const ctx = this._ctx.select("withSDK", { sdk });
3656
+ withSDK = (source) => {
3657
+ const ctx = this._ctx.select("withSDK", { source });
3755
3658
  return new ModuleSource(ctx);
3756
3659
  };
3757
3660
  /**
@@ -3894,12 +3797,7 @@ export class ObjectTypeDef extends BaseClient {
3894
3797
  fields = async () => {
3895
3798
  const ctx = this._ctx.select("fields").select("id");
3896
3799
  const response = await ctx.execute();
3897
- return response.map((r) => new FieldTypeDef(new Context([
3898
- {
3899
- operation: "loadFieldTypeDefFromID",
3900
- args: { id: r.id },
3901
- },
3902
- ], this._ctx.getConnection()), r.id));
3800
+ return response.map((r) => new Client(ctx.copy()).loadFieldTypeDefFromID(r.id));
3903
3801
  };
3904
3802
  /**
3905
3803
  * Functions defined on this object, if any.
@@ -3907,12 +3805,7 @@ export class ObjectTypeDef extends BaseClient {
3907
3805
  functions = async () => {
3908
3806
  const ctx = this._ctx.select("functions").select("id");
3909
3807
  const response = await ctx.execute();
3910
- return response.map((r) => new Function_(new Context([
3911
- {
3912
- operation: "loadFunction_FromID",
3913
- args: { id: r.id },
3914
- },
3915
- ], this._ctx.getConnection()), r.id));
3808
+ return response.map((r) => new Client(ctx.copy()).loadFunctionFromID(r.id));
3916
3809
  };
3917
3810
  /**
3918
3811
  * The name of the object.
@@ -4040,14 +3933,6 @@ export class Client extends BaseClient {
4040
3933
  getGQLClient() {
4041
3934
  return this._ctx.getGQLClient();
4042
3935
  }
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
3936
  /**
4052
3937
  * Retrieves a container builtin to the engine.
4053
3938
  * @param digest Digest of the image manifest
@@ -4096,12 +3981,7 @@ export class Client extends BaseClient {
4096
3981
  currentTypeDefs = async () => {
4097
3982
  const ctx = this._ctx.select("currentTypeDefs").select("id");
4098
3983
  const response = await ctx.execute();
4099
- return response.map((r) => new TypeDef(new Context([
4100
- {
4101
- operation: "loadTypeDefFromID",
4102
- args: { id: r.id },
4103
- },
4104
- ], this._ctx.getConnection()), r.id));
3984
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
4105
3985
  };
4106
3986
  /**
4107
3987
  * The default platform of the engine.
@@ -4419,6 +4299,13 @@ export class Client extends BaseClient {
4419
4299
  const ctx = this._ctx.select("loadPortFromID", { id });
4420
4300
  return new Port(ctx);
4421
4301
  };
4302
+ /**
4303
+ * Load a SDKConfig from its ID.
4304
+ */
4305
+ loadSDKConfigFromID = (id) => {
4306
+ const ctx = this._ctx.select("loadSDKConfigFromID", { id });
4307
+ return new SDKConfig(ctx);
4308
+ };
4422
4309
  /**
4423
4310
  * Load a ScalarTypeDef from its ID.
4424
4311
  */
@@ -4433,6 +4320,13 @@ export class Client extends BaseClient {
4433
4320
  const ctx = this._ctx.select("loadSecretFromID", { id });
4434
4321
  return new Secret(ctx);
4435
4322
  };
4323
+ /**
4324
+ * Load a Secret from its Name.
4325
+ */
4326
+ loadSecretFromName = (name, opts) => {
4327
+ const ctx = this._ctx.select("loadSecretFromName", { name, ...opts });
4328
+ return new Secret(ctx);
4329
+ };
4436
4330
  /**
4437
4331
  * Load a Service from its ID.
4438
4332
  */
@@ -4496,10 +4390,11 @@ export class Client extends BaseClient {
4496
4390
  return new ModuleSource(ctx);
4497
4391
  };
4498
4392
  /**
4499
- * Reference a secret by name.
4393
+ * Creates a new secret.
4394
+ * @param uri The URI of the secret store
4500
4395
  */
4501
- secret = (name, opts) => {
4502
- const ctx = this._ctx.select("secret", { name, ...opts });
4396
+ secret = (uri) => {
4397
+ const ctx = this._ctx.select("secret", { uri });
4503
4398
  return new Secret(ctx);
4504
4399
  };
4505
4400
  /**
@@ -4539,6 +4434,43 @@ export class Client extends BaseClient {
4539
4434
  return response;
4540
4435
  };
4541
4436
  }
4437
+ /**
4438
+ * The SDK config of the module.
4439
+ */
4440
+ export class SDKConfig extends BaseClient {
4441
+ _id = undefined;
4442
+ _source = undefined;
4443
+ /**
4444
+ * Constructor is used for internal usage only, do not create object from it.
4445
+ */
4446
+ constructor(ctx, _id, _source) {
4447
+ super(ctx);
4448
+ this._id = _id;
4449
+ this._source = _source;
4450
+ }
4451
+ /**
4452
+ * A unique identifier for this SDKConfig.
4453
+ */
4454
+ id = async () => {
4455
+ if (this._id) {
4456
+ return this._id;
4457
+ }
4458
+ const ctx = this._ctx.select("id");
4459
+ const response = await ctx.execute();
4460
+ return response;
4461
+ };
4462
+ /**
4463
+ * Source of the SDK. Either a name of a builtin SDK or a module source ref string pointing to the SDK's implementation.
4464
+ */
4465
+ source = async () => {
4466
+ if (this._source) {
4467
+ return this._source;
4468
+ }
4469
+ const ctx = this._ctx.select("source");
4470
+ const response = await ctx.execute();
4471
+ return response;
4472
+ };
4473
+ }
4542
4474
  /**
4543
4475
  * A definition of a custom scalar defined in a Module.
4544
4476
  */
@@ -4609,14 +4541,16 @@ export class Secret extends BaseClient {
4609
4541
  _id = undefined;
4610
4542
  _name = undefined;
4611
4543
  _plaintext = undefined;
4544
+ _uri = undefined;
4612
4545
  /**
4613
4546
  * Constructor is used for internal usage only, do not create object from it.
4614
4547
  */
4615
- constructor(ctx, _id, _name, _plaintext) {
4548
+ constructor(ctx, _id, _name, _plaintext, _uri) {
4616
4549
  super(ctx);
4617
4550
  this._id = _id;
4618
4551
  this._name = _name;
4619
4552
  this._plaintext = _plaintext;
4553
+ this._uri = _uri;
4620
4554
  }
4621
4555
  /**
4622
4556
  * A unique identifier for this Secret.
@@ -4651,6 +4585,17 @@ export class Secret extends BaseClient {
4651
4585
  const response = await ctx.execute();
4652
4586
  return response;
4653
4587
  };
4588
+ /**
4589
+ * The URI of this secret.
4590
+ */
4591
+ uri = async () => {
4592
+ if (this._uri) {
4593
+ return this._uri;
4594
+ }
4595
+ const ctx = this._ctx.select("uri");
4596
+ const response = await ctx.execute();
4597
+ return response;
4598
+ };
4654
4599
  }
4655
4600
  /**
4656
4601
  * A content-addressed service providing TCP connectivity.
@@ -4719,12 +4664,7 @@ export class Service extends BaseClient {
4719
4664
  ports = async () => {
4720
4665
  const ctx = this._ctx.select("ports").select("id");
4721
4666
  const response = await ctx.execute();
4722
- return response.map((r) => new Port(new Context([
4723
- {
4724
- operation: "loadPortFromID",
4725
- args: { id: r.id },
4726
- },
4727
- ], this._ctx.getConnection()), r.id));
4667
+ return response.map((r) => new Client(ctx.copy()).loadPortFromID(r.id));
4728
4668
  };
4729
4669
  /**
4730
4670
  * Start the service and wait for its health checks to succeed.
@@ -4734,12 +4674,7 @@ export class Service extends BaseClient {
4734
4674
  start = async () => {
4735
4675
  const ctx = this._ctx.select("start");
4736
4676
  const response = await ctx.execute();
4737
- return new Service(new Context([
4738
- {
4739
- operation: "loadServiceFromID",
4740
- args: { id: response },
4741
- },
4742
- ], this._ctx.getConnection()));
4677
+ return new Client(ctx.copy()).loadServiceFromID(response);
4743
4678
  };
4744
4679
  /**
4745
4680
  * Stop the service.
@@ -4748,12 +4683,7 @@ export class Service extends BaseClient {
4748
4683
  stop = async (opts) => {
4749
4684
  const ctx = this._ctx.select("stop", { ...opts });
4750
4685
  const response = await ctx.execute();
4751
- return new Service(new Context([
4752
- {
4753
- operation: "loadServiceFromID",
4754
- args: { id: response },
4755
- },
4756
- ], this._ctx.getConnection()));
4686
+ return new Client(ctx.copy()).loadServiceFromID(response);
4757
4687
  };
4758
4688
  /**
4759
4689
  * Creates a tunnel that forwards traffic from the caller's network to this service.
@@ -4919,12 +4849,7 @@ export class Terminal extends BaseClient {
4919
4849
  sync = async () => {
4920
4850
  const ctx = this._ctx.select("sync");
4921
4851
  const response = await ctx.execute();
4922
- return new Terminal(new Context([
4923
- {
4924
- operation: "loadTerminalFromID",
4925
- args: { id: response },
4926
- },
4927
- ], this._ctx.getConnection()));
4852
+ return new Client(ctx.copy()).loadTerminalFromID(response);
4928
4853
  };
4929
4854
  }
4930
4855
  /**
@@ -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
- getConnection(): import("./graphql/connection.js").Connection;
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,aAAa;IAIb,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"}
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
- getConnection() {
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":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAIL,YAAY,EAEb,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAcxC;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,gBAwDf"}
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/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,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
- result = await result.id();
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;AAS/C;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,QAAQ,CAAC,CAiEnB"}
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"}