@dagger.io/dagger 0.15.1 → 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.
Files changed (80) hide show
  1. package/dist/src/api/client.gen.d.ts +59 -6
  2. package/dist/src/api/client.gen.d.ts.map +1 -1
  3. package/dist/src/api/client.gen.js +52 -166
  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/common/utils.d.ts +14 -14
  8. package/dist/src/module/decorators.d.ts.map +1 -1
  9. package/dist/src/module/entrypoint/invoke.d.ts.map +1 -1
  10. package/dist/src/module/entrypoint/invoke.js +10 -0
  11. package/dist/src/module/entrypoint/load.d.ts.map +1 -1
  12. package/dist/src/module/entrypoint/load.js +9 -3
  13. package/dist/src/module/entrypoint/register.d.ts.map +1 -1
  14. package/dist/src/module/entrypoint/register.js +23 -0
  15. package/dist/src/module/executor.d.ts +5 -0
  16. package/dist/src/module/executor.d.ts.map +1 -1
  17. package/dist/src/module/executor.js +110 -1
  18. package/dist/src/module/introspector/case_convertor.d.ts.map +1 -1
  19. package/dist/src/module/introspector/case_convertor.js +7 -9
  20. package/dist/src/module/introspector/dagger_module/argument.d.ts +2 -1
  21. package/dist/src/module/introspector/dagger_module/argument.d.ts.map +1 -1
  22. package/dist/src/module/introspector/dagger_module/argument.js +3 -1
  23. package/dist/src/module/introspector/dagger_module/enum.d.ts +3 -2
  24. package/dist/src/module/introspector/dagger_module/enum.d.ts.map +1 -1
  25. package/dist/src/module/introspector/dagger_module/enum.js +5 -2
  26. package/dist/src/module/introspector/dagger_module/enumBase.d.ts +3 -2
  27. package/dist/src/module/introspector/dagger_module/enumBase.d.ts.map +1 -1
  28. package/dist/src/module/introspector/dagger_module/enumClass.d.ts +3 -2
  29. package/dist/src/module/introspector/dagger_module/enumClass.d.ts.map +1 -1
  30. package/dist/src/module/introspector/dagger_module/enumClass.js +5 -2
  31. package/dist/src/module/introspector/dagger_module/function.d.ts +2 -1
  32. package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -1
  33. package/dist/src/module/introspector/dagger_module/function.js +3 -1
  34. package/dist/src/module/introspector/dagger_module/index.d.ts +2 -0
  35. package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -1
  36. package/dist/src/module/introspector/dagger_module/index.js +2 -0
  37. package/dist/src/module/introspector/dagger_module/interface.d.ts +25 -0
  38. package/dist/src/module/introspector/dagger_module/interface.d.ts.map +1 -0
  39. package/dist/src/module/introspector/dagger_module/interface.js +56 -0
  40. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts +32 -0
  41. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts.map +1 -0
  42. package/dist/src/module/introspector/dagger_module/interfaceFunction.js +87 -0
  43. package/dist/src/module/introspector/dagger_module/locatable.d.ts +12 -0
  44. package/dist/src/module/introspector/dagger_module/locatable.d.ts.map +1 -0
  45. package/dist/src/module/introspector/dagger_module/locatable.js +14 -0
  46. package/dist/src/module/introspector/dagger_module/module.d.ts +16 -1
  47. package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -1
  48. package/dist/src/module/introspector/dagger_module/module.js +36 -2
  49. package/dist/src/module/introspector/dagger_module/object.d.ts +17 -2
  50. package/dist/src/module/introspector/dagger_module/object.d.ts.map +1 -1
  51. package/dist/src/module/introspector/dagger_module/object.js +19 -1
  52. package/dist/src/module/introspector/dagger_module/objectBase.d.ts +3 -2
  53. package/dist/src/module/introspector/dagger_module/objectBase.d.ts.map +1 -1
  54. package/dist/src/module/introspector/dagger_module/property.d.ts +2 -1
  55. package/dist/src/module/introspector/dagger_module/property.d.ts.map +1 -1
  56. package/dist/src/module/introspector/dagger_module/property.js +3 -1
  57. package/dist/src/module/introspector/dagger_module/reference.d.ts +1 -1
  58. package/dist/src/module/introspector/dagger_module/reference.d.ts.map +1 -1
  59. package/dist/src/module/introspector/dagger_module/typeObject.d.ts +24 -2
  60. package/dist/src/module/introspector/dagger_module/typeObject.d.ts.map +1 -1
  61. package/dist/src/module/introspector/dagger_module/typeObject.js +26 -1
  62. package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts +2 -1
  63. package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts.map +1 -1
  64. package/dist/src/module/introspector/dagger_module/typeObjectProperty.js +3 -1
  65. package/dist/src/module/introspector/typedef.d.ts +8 -1
  66. package/dist/src/module/introspector/typedef.d.ts.map +1 -1
  67. package/dist/src/module/introspector/typescript_module/ast.d.ts +14 -0
  68. package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -1
  69. package/dist/src/module/introspector/typescript_module/ast.js +37 -2
  70. package/dist/src/module/introspector/typescript_module/index.d.ts +1 -0
  71. package/dist/src/module/introspector/typescript_module/index.d.ts.map +1 -1
  72. package/dist/src/module/introspector/typescript_module/index.js +1 -0
  73. package/dist/src/module/introspector/typescript_module/location.d.ts +6 -0
  74. package/dist/src/module/introspector/typescript_module/location.d.ts.map +1 -0
  75. package/dist/src/module/introspector/typescript_module/location.js +1 -0
  76. package/dist/src/module/registry.d.ts.map +1 -1
  77. package/dist/src/provisioning/bin.js +1 -1
  78. package/dist/src/provisioning/default.d.ts +1 -1
  79. package/dist/src/provisioning/default.js +1 -1
  80. package/package.json +21 -21
@@ -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).
@@ -593,6 +577,18 @@ export class Container extends BaseClient {
593
577
  *
594
578
  * Frontend is the port accepting traffic on the host, backend is the service port.
595
579
  * @param opts.random Bind each tunnel port to a random port on the host.
580
+ * @param opts.args Command to run instead of the container's default command (e.g., ["go", "run", "main.go"]).
581
+ *
582
+ * If empty, the container's default command is used.
583
+ * @param opts.useEntrypoint If the container has an entrypoint, prepend it to the args.
584
+ * @param opts.experimentalPrivilegedNesting Provides Dagger access to the executed command.
585
+ *
586
+ * Do not use this option unless you trust the command being executed; the command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
587
+ * @param opts.insecureRootCapabilities Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
588
+ * @param opts.expand Replace "${VAR}" or "$VAR" in the args according to the current environment variables defined in the container (e.g. "/$VAR/foo").
589
+ * @param opts.noInit If set, skip the automatic init process injected into containers by default.
590
+ *
591
+ * This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
596
592
  */
597
593
  up = async (opts) => {
598
594
  if (this._up) {
@@ -1303,12 +1299,7 @@ export class Directory extends BaseClient {
1303
1299
  sync = async () => {
1304
1300
  const ctx = this._ctx.select("sync");
1305
1301
  const response = await ctx.execute();
1306
- return new Directory(new Context([
1307
- {
1308
- operation: "loadDirectoryFromID",
1309
- args: { id: response },
1310
- },
1311
- ], this._ctx.getConnection()));
1302
+ return new Client(ctx.copy()).loadDirectoryFromID(response);
1312
1303
  };
1313
1304
  /**
1314
1305
  * Opens an interactive terminal in new container with this directory mounted inside.
@@ -1673,12 +1664,7 @@ export class EngineCacheEntrySet extends BaseClient {
1673
1664
  entries = async () => {
1674
1665
  const ctx = this._ctx.select("entries").select("id");
1675
1666
  const response = await ctx.execute();
1676
- return response.map((r) => new EngineCacheEntry(new Context([
1677
- {
1678
- operation: "loadEngineCacheEntryFromID",
1679
- args: { id: r.id },
1680
- },
1681
- ], this._ctx.getConnection()), r.id));
1667
+ return response.map((r) => new Client(ctx.copy()).loadEngineCacheEntryFromID(r.id));
1682
1668
  };
1683
1669
  /**
1684
1670
  * The number of cache entries in this set.
@@ -1767,12 +1753,7 @@ export class EnumTypeDef extends BaseClient {
1767
1753
  values = async () => {
1768
1754
  const ctx = this._ctx.select("values").select("id");
1769
1755
  const response = await ctx.execute();
1770
- return response.map((r) => new EnumValueTypeDef(new Context([
1771
- {
1772
- operation: "loadEnumValueTypeDefFromID",
1773
- args: { id: r.id },
1774
- },
1775
- ], this._ctx.getConnection()), r.id));
1756
+ return response.map((r) => new Client(ctx.copy()).loadEnumValueTypeDefFromID(r.id));
1776
1757
  };
1777
1758
  }
1778
1759
  /**
@@ -2081,12 +2062,7 @@ export class File extends BaseClient {
2081
2062
  sync = async () => {
2082
2063
  const ctx = this._ctx.select("sync");
2083
2064
  const response = await ctx.execute();
2084
- return new File(new Context([
2085
- {
2086
- operation: "loadFileFromID",
2087
- args: { id: response },
2088
- },
2089
- ], this._ctx.getConnection()));
2065
+ return new Client(ctx.copy()).loadFileFromID(response);
2090
2066
  };
2091
2067
  /**
2092
2068
  * Retrieves this file with its name set to the given name.
@@ -2150,12 +2126,7 @@ export class Function_ extends BaseClient {
2150
2126
  args = async () => {
2151
2127
  const ctx = this._ctx.select("args").select("id");
2152
2128
  const response = await ctx.execute();
2153
- return response.map((r) => new FunctionArg(new Context([
2154
- {
2155
- operation: "loadFunctionArgFromID",
2156
- args: { id: r.id },
2157
- },
2158
- ], this._ctx.getConnection()), r.id));
2129
+ return response.map((r) => new Client(ctx.copy()).loadFunctionArgFromID(r.id));
2159
2130
  };
2160
2131
  /**
2161
2132
  * A doc string for the function, if any.
@@ -2370,12 +2341,7 @@ export class FunctionCall extends BaseClient {
2370
2341
  inputArgs = async () => {
2371
2342
  const ctx = this._ctx.select("inputArgs").select("id");
2372
2343
  const response = await ctx.execute();
2373
- return response.map((r) => new FunctionCallArgValue(new Context([
2374
- {
2375
- operation: "loadFunctionCallArgValueFromID",
2376
- args: { id: r.id },
2377
- },
2378
- ], this._ctx.getConnection()), r.id));
2344
+ return response.map((r) => new Client(ctx.copy()).loadFunctionCallArgValueFromID(r.id));
2379
2345
  };
2380
2346
  /**
2381
2347
  * The name of the function being called.
@@ -2941,12 +2907,7 @@ export class InputTypeDef extends BaseClient {
2941
2907
  fields = async () => {
2942
2908
  const ctx = this._ctx.select("fields").select("id");
2943
2909
  const response = await ctx.execute();
2944
- return response.map((r) => new FieldTypeDef(new Context([
2945
- {
2946
- operation: "loadFieldTypeDefFromID",
2947
- args: { id: r.id },
2948
- },
2949
- ], this._ctx.getConnection()), r.id));
2910
+ return response.map((r) => new Client(ctx.copy()).loadFieldTypeDefFromID(r.id));
2950
2911
  };
2951
2912
  /**
2952
2913
  * The name of the input object.
@@ -3006,12 +2967,7 @@ export class InterfaceTypeDef extends BaseClient {
3006
2967
  functions = async () => {
3007
2968
  const ctx = this._ctx.select("functions").select("id");
3008
2969
  const response = await ctx.execute();
3009
- return response.map((r) => new Function_(new Context([
3010
- {
3011
- operation: "loadFunction_FromID",
3012
- args: { id: r.id },
3013
- },
3014
- ], this._ctx.getConnection()), r.id));
2970
+ return response.map((r) => new Client(ctx.copy()).loadFunctionFromID(r.id));
3015
2971
  };
3016
2972
  /**
3017
2973
  * The name of the interface.
@@ -3218,12 +3174,7 @@ export class Module_ extends BaseClient {
3218
3174
  dependencies = async () => {
3219
3175
  const ctx = this._ctx.select("dependencies").select("id");
3220
3176
  const response = await ctx.execute();
3221
- return response.map((r) => new Module_(new Context([
3222
- {
3223
- operation: "loadModule_FromID",
3224
- args: { id: r.id },
3225
- },
3226
- ], this._ctx.getConnection()), r.id));
3177
+ return response.map((r) => new Client(ctx.copy()).loadModuleFromID(r.id));
3227
3178
  };
3228
3179
  /**
3229
3180
  * The dependencies as configured by the module.
@@ -3231,12 +3182,7 @@ export class Module_ extends BaseClient {
3231
3182
  dependencyConfig = async () => {
3232
3183
  const ctx = this._ctx.select("dependencyConfig").select("id");
3233
3184
  const response = await ctx.execute();
3234
- return response.map((r) => new ModuleDependency(new Context([
3235
- {
3236
- operation: "loadModuleDependencyFromID",
3237
- args: { id: r.id },
3238
- },
3239
- ], this._ctx.getConnection()), r.id));
3185
+ return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
3240
3186
  };
3241
3187
  /**
3242
3188
  * The doc string of the module, if any
@@ -3255,12 +3201,7 @@ export class Module_ extends BaseClient {
3255
3201
  enums = async () => {
3256
3202
  const ctx = this._ctx.select("enums").select("id");
3257
3203
  const response = await ctx.execute();
3258
- return response.map((r) => new TypeDef(new Context([
3259
- {
3260
- operation: "loadTypeDefFromID",
3261
- args: { id: r.id },
3262
- },
3263
- ], this._ctx.getConnection()), r.id));
3204
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3264
3205
  };
3265
3206
  /**
3266
3207
  * The generated files and directories made on top of the module source's context directory.
@@ -3289,12 +3230,7 @@ export class Module_ extends BaseClient {
3289
3230
  interfaces = async () => {
3290
3231
  const ctx = this._ctx.select("interfaces").select("id");
3291
3232
  const response = await ctx.execute();
3292
- return response.map((r) => new TypeDef(new Context([
3293
- {
3294
- operation: "loadTypeDefFromID",
3295
- args: { id: r.id },
3296
- },
3297
- ], this._ctx.getConnection()), r.id));
3233
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3298
3234
  };
3299
3235
  /**
3300
3236
  * The name of the module
@@ -3313,12 +3249,7 @@ export class Module_ extends BaseClient {
3313
3249
  objects = async () => {
3314
3250
  const ctx = this._ctx.select("objects").select("id");
3315
3251
  const response = await ctx.execute();
3316
- return response.map((r) => new TypeDef(new Context([
3317
- {
3318
- operation: "loadTypeDefFromID",
3319
- args: { id: r.id },
3320
- },
3321
- ], this._ctx.getConnection()), r.id));
3252
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
3322
3253
  };
3323
3254
  /**
3324
3255
  * The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile.
@@ -3550,12 +3481,7 @@ export class ModuleSource extends BaseClient {
3550
3481
  dependencies = async () => {
3551
3482
  const ctx = this._ctx.select("dependencies").select("id");
3552
3483
  const response = await ctx.execute();
3553
- return response.map((r) => new ModuleDependency(new Context([
3554
- {
3555
- operation: "loadModuleDependencyFromID",
3556
- args: { id: r.id },
3557
- },
3558
- ], this._ctx.getConnection()), r.id));
3484
+ return response.map((r) => new Client(ctx.copy()).loadModuleDependencyFromID(r.id));
3559
3485
  };
3560
3486
  /**
3561
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.
@@ -3695,12 +3621,7 @@ export class ModuleSource extends BaseClient {
3695
3621
  views = async () => {
3696
3622
  const ctx = this._ctx.select("views").select("id");
3697
3623
  const response = await ctx.execute();
3698
- return response.map((r) => new ModuleSourceView(new Context([
3699
- {
3700
- operation: "loadModuleSourceViewFromID",
3701
- args: { id: r.id },
3702
- },
3703
- ], this._ctx.getConnection()), r.id));
3624
+ return response.map((r) => new Client(ctx.copy()).loadModuleSourceViewFromID(r.id));
3704
3625
  };
3705
3626
  /**
3706
3627
  * Update the module source with a new context directory. Only valid for local sources.
@@ -3750,6 +3671,14 @@ export class ModuleSource extends BaseClient {
3750
3671
  const ctx = this._ctx.select("withSourceSubpath", { path });
3751
3672
  return new ModuleSource(ctx);
3752
3673
  };
3674
+ /**
3675
+ * Update one or more module dependencies.
3676
+ * @param dependencies The dependencies to update.
3677
+ */
3678
+ withUpdateDependencies = (dependencies) => {
3679
+ const ctx = this._ctx.select("withUpdateDependencies", { dependencies });
3680
+ return new ModuleSource(ctx);
3681
+ };
3753
3682
  /**
3754
3683
  * Update the module source with a new named view.
3755
3684
  * @param name The name of the view to set.
@@ -3874,12 +3803,7 @@ export class ObjectTypeDef extends BaseClient {
3874
3803
  fields = async () => {
3875
3804
  const ctx = this._ctx.select("fields").select("id");
3876
3805
  const response = await ctx.execute();
3877
- return response.map((r) => new FieldTypeDef(new Context([
3878
- {
3879
- operation: "loadFieldTypeDefFromID",
3880
- args: { id: r.id },
3881
- },
3882
- ], this._ctx.getConnection()), r.id));
3806
+ return response.map((r) => new Client(ctx.copy()).loadFieldTypeDefFromID(r.id));
3883
3807
  };
3884
3808
  /**
3885
3809
  * Functions defined on this object, if any.
@@ -3887,12 +3811,7 @@ export class ObjectTypeDef extends BaseClient {
3887
3811
  functions = async () => {
3888
3812
  const ctx = this._ctx.select("functions").select("id");
3889
3813
  const response = await ctx.execute();
3890
- return response.map((r) => new Function_(new Context([
3891
- {
3892
- operation: "loadFunction_FromID",
3893
- args: { id: r.id },
3894
- },
3895
- ], this._ctx.getConnection()), r.id));
3814
+ return response.map((r) => new Client(ctx.copy()).loadFunctionFromID(r.id));
3896
3815
  };
3897
3816
  /**
3898
3817
  * The name of the object.
@@ -4020,14 +3939,6 @@ export class Client extends BaseClient {
4020
3939
  getGQLClient() {
4021
3940
  return this._ctx.getGQLClient();
4022
3941
  }
4023
- /**
4024
- * Retrieves a content-addressed blob.
4025
- * @param digest Digest of the blob
4026
- */
4027
- blob = (digest) => {
4028
- const ctx = this._ctx.select("blob", { digest });
4029
- return new Directory(ctx);
4030
- };
4031
3942
  /**
4032
3943
  * Retrieves a container builtin to the engine.
4033
3944
  * @param digest Digest of the image manifest
@@ -4040,8 +3951,8 @@ export class Client extends BaseClient {
4040
3951
  * Constructs a cache volume for a given cache key.
4041
3952
  * @param key A string identifier to target this cache volume (e.g., "modules-cache").
4042
3953
  */
4043
- cacheVolume = (key) => {
4044
- const ctx = this._ctx.select("cacheVolume", { key });
3954
+ cacheVolume = (key, opts) => {
3955
+ const ctx = this._ctx.select("cacheVolume", { key, ...opts });
4045
3956
  return new CacheVolume(ctx);
4046
3957
  };
4047
3958
  /**
@@ -4076,12 +3987,7 @@ export class Client extends BaseClient {
4076
3987
  currentTypeDefs = async () => {
4077
3988
  const ctx = this._ctx.select("currentTypeDefs").select("id");
4078
3989
  const response = await ctx.execute();
4079
- return response.map((r) => new TypeDef(new Context([
4080
- {
4081
- operation: "loadTypeDefFromID",
4082
- args: { id: r.id },
4083
- },
4084
- ], this._ctx.getConnection()), r.id));
3990
+ return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
4085
3991
  };
4086
3992
  /**
4087
3993
  * The default platform of the engine.
@@ -4699,12 +4605,7 @@ export class Service extends BaseClient {
4699
4605
  ports = async () => {
4700
4606
  const ctx = this._ctx.select("ports").select("id");
4701
4607
  const response = await ctx.execute();
4702
- return response.map((r) => new Port(new Context([
4703
- {
4704
- operation: "loadPortFromID",
4705
- args: { id: r.id },
4706
- },
4707
- ], this._ctx.getConnection()), r.id));
4608
+ return response.map((r) => new Client(ctx.copy()).loadPortFromID(r.id));
4708
4609
  };
4709
4610
  /**
4710
4611
  * Start the service and wait for its health checks to succeed.
@@ -4714,12 +4615,7 @@ export class Service extends BaseClient {
4714
4615
  start = async () => {
4715
4616
  const ctx = this._ctx.select("start");
4716
4617
  const response = await ctx.execute();
4717
- return new Service(new Context([
4718
- {
4719
- operation: "loadServiceFromID",
4720
- args: { id: response },
4721
- },
4722
- ], this._ctx.getConnection()));
4618
+ return new Client(ctx.copy()).loadServiceFromID(response);
4723
4619
  };
4724
4620
  /**
4725
4621
  * Stop the service.
@@ -4728,12 +4624,7 @@ export class Service extends BaseClient {
4728
4624
  stop = async (opts) => {
4729
4625
  const ctx = this._ctx.select("stop", { ...opts });
4730
4626
  const response = await ctx.execute();
4731
- return new Service(new Context([
4732
- {
4733
- operation: "loadServiceFromID",
4734
- args: { id: response },
4735
- },
4736
- ], this._ctx.getConnection()));
4627
+ return new Client(ctx.copy()).loadServiceFromID(response);
4737
4628
  };
4738
4629
  /**
4739
4630
  * Creates a tunnel that forwards traffic from the caller's network to this service.
@@ -4899,12 +4790,7 @@ export class Terminal extends BaseClient {
4899
4790
  sync = async () => {
4900
4791
  const ctx = this._ctx.select("sync");
4901
4792
  const response = await ctx.execute();
4902
- return new Terminal(new Context([
4903
- {
4904
- operation: "loadTerminalFromID",
4905
- args: { id: response },
4906
- },
4907
- ], this._ctx.getConnection()));
4793
+ return new Client(ctx.copy()).loadTerminalFromID(response);
4908
4794
  };
4909
4795
  }
4910
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
- 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);
@@ -4,8 +4,8 @@ export declare const log: (stack?: string) => {
4
4
  level: any;
5
5
  noColor: boolean;
6
6
  setLevel(level: "error" | "debug" | "info" | "warn" | "disable" | "success"): void;
7
- createNamedLogger(name: string): any;
8
- setLogStream(stream: import("stream").Stream): any;
7
+ createNamedLogger(name: string): /*elided*/ any;
8
+ setLogStream(stream: import("stream").Stream): /*elided*/ any;
9
9
  setLevelNoColor(): void;
10
10
  setLevelColor(): void;
11
11
  isLevelValid(level: "error" | "debug" | "info" | "warn" | "disable" | "success"): boolean;
@@ -18,19 +18,19 @@ export declare const log: (stack?: string) => {
18
18
  underscore?: boolean | undefined;
19
19
  strikethrough?: boolean | undefined;
20
20
  }): string;
21
- joint(): any;
22
- append(...args: any[]): any;
23
- reset(): any;
21
+ joint(): /*elided*/ any;
22
+ append(...args: any[]): /*elided*/ any;
23
+ reset(): /*elided*/ any;
24
24
  setDate(callback: Function): void;
25
25
  getDate(): string;
26
- color(ticket: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white"): any;
27
- bgColor(ticket: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white"): any;
28
- bold(): any;
29
- dim(): any;
30
- underscore(): any;
31
- strikethrough(): any;
32
- reverse(): any;
33
- italic(): any;
26
+ color(ticket: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white"): /*elided*/ any;
27
+ bgColor(ticket: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white"): /*elided*/ any;
28
+ bold(): /*elided*/ any;
29
+ dim(): /*elided*/ any;
30
+ underscore(): /*elided*/ any;
31
+ strikethrough(): /*elided*/ any;
32
+ reverse(): /*elided*/ any;
33
+ italic(): /*elided*/ any;
34
34
  fontColorLog(ticket: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white", text: string, setting?: {
35
35
  reverse?: boolean | undefined;
36
36
  bold?: boolean | undefined;
@@ -58,7 +58,7 @@ export declare const log: (stack?: string) => {
58
58
  underscore?: boolean | undefined;
59
59
  strikethrough?: boolean | undefined;
60
60
  }): void;
61
- log(...args: any[]): any;
61
+ log(...args: any[]): /*elided*/ any;
62
62
  error(...args: any[]): void;
63
63
  warn(...args: any[]): void;
64
64
  info(...args: any[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/module/decorators.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,MAAM,wEAAkB,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,gFAkC4rC,CAAC,8BAlC7qC,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,qEAAiB,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,QAAQ,wEAAoB,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,6HAAoB,CAAA"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/module/decorators.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,MAAM,wEAAkB,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,gFAkC2rC,CAAC,8BAlC5qC,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,qEAAiB,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,QAAQ,wEAAoB,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,6HAAoB,CAAA"}
@@ -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,EACjB,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,CA2Cd;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,CA8Ed"}
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"}
@@ -1,5 +1,5 @@
1
1
  import { dag, TypeDefKind } from "../../api/client.gen.js";
2
- import { DaggerEnum, DaggerObject, } from "../introspector/dagger_module/index.js";
2
+ import { DaggerEnum, DaggerObject, DaggerTypeObject, } from "../introspector/dagger_module/index.js";
3
3
  /**
4
4
  * Import all given typescript files so that trigger their decorators
5
5
  * and register their class and functions inside the Registry.
@@ -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)) {
@@ -162,7 +167,8 @@ export async function loadResult(result, module, object) {
162
167
  return result;
163
168
  }
164
169
  // Handle objects
165
- if (typeof result === "object" && object instanceof DaggerObject) {
170
+ if (typeof result === "object" &&
171
+ (object instanceof DaggerObject || object instanceof DaggerTypeObject)) {
166
172
  const state = {};
167
173
  for (const [key, value] of Object.entries(result)) {
168
174
  const property = Object.values(object.properties).find((p) => p.name === key);
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAGT,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAIL,YAAY,EACb,MAAM,wCAAwC,CAAA;AAS/C;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,QAAQ,CAAC,CA6DnB"}
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"}