@dagger.io/dagger 0.19.10 → 0.20.0

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 (30) hide show
  1. package/dist/src/api/client.gen.d.ts +452 -8
  2. package/dist/src/api/client.gen.d.ts.map +1 -1
  3. package/dist/src/api/client.gen.js +677 -11
  4. package/dist/src/common/graphql/connect.d.ts.map +1 -1
  5. package/dist/src/common/graphql/connect.js +1 -1
  6. package/dist/src/module/decorators.d.ts +5 -0
  7. package/dist/src/module/decorators.d.ts.map +1 -1
  8. package/dist/src/module/decorators.js +5 -0
  9. package/dist/src/module/entrypoint/introspection_entrypoint.js +1 -1
  10. package/dist/src/module/entrypoint/invoke.js +1 -1
  11. package/dist/src/module/entrypoint/register.d.ts.map +1 -1
  12. package/dist/src/module/entrypoint/register.js +7 -1
  13. package/dist/src/module/introspector/dagger_module/argument.d.ts +2 -0
  14. package/dist/src/module/introspector/dagger_module/argument.d.ts.map +1 -1
  15. package/dist/src/module/introspector/dagger_module/argument.js +7 -0
  16. package/dist/src/module/introspector/dagger_module/decorator.d.ts +2 -1
  17. package/dist/src/module/introspector/dagger_module/decorator.d.ts.map +1 -1
  18. package/dist/src/module/introspector/dagger_module/decorator.js +2 -1
  19. package/dist/src/module/introspector/dagger_module/function.d.ts +1 -0
  20. package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -1
  21. package/dist/src/module/introspector/dagger_module/function.js +6 -1
  22. package/dist/src/module/registry.d.ts +12 -0
  23. package/dist/src/module/registry.d.ts.map +1 -1
  24. package/dist/src/module/registry.js +6 -0
  25. package/dist/src/provisioning/bin.d.ts.map +1 -1
  26. package/dist/src/provisioning/bin.js +1 -1
  27. package/dist/src/provisioning/default.d.ts +1 -1
  28. package/dist/src/provisioning/default.d.ts.map +1 -1
  29. package/dist/src/provisioning/default.js +1 -1
  30. package/package.json +20 -20
@@ -62,6 +62,114 @@ function CacheSharingModeNameToValue(name) {
62
62
  return name;
63
63
  }
64
64
  }
65
+ /**
66
+ * Strategy to use when merging changesets with conflicting changes.
67
+ */
68
+ export var ChangesetMergeConflict;
69
+ (function (ChangesetMergeConflict) {
70
+ /**
71
+ * Attempt the merge and fail if git merge fails due to conflicts
72
+ */
73
+ ChangesetMergeConflict["Fail"] = "FAIL";
74
+ /**
75
+ * Fail before attempting merge if file-level conflicts are detected
76
+ */
77
+ ChangesetMergeConflict["FailEarly"] = "FAIL_EARLY";
78
+ /**
79
+ * Let git create conflict markers in files. For modify/delete conflicts, keeps the modified version. Fails on binary conflicts.
80
+ */
81
+ ChangesetMergeConflict["LeaveConflictMarkers"] = "LEAVE_CONFLICT_MARKERS";
82
+ /**
83
+ * The conflict is resolved by applying the version of the calling changeset
84
+ */
85
+ ChangesetMergeConflict["PreferOurs"] = "PREFER_OURS";
86
+ /**
87
+ * The conflict is resolved by applying the version of the other changeset
88
+ */
89
+ ChangesetMergeConflict["PreferTheirs"] = "PREFER_THEIRS";
90
+ })(ChangesetMergeConflict || (ChangesetMergeConflict = {}));
91
+ /**
92
+ * Utility function to convert a ChangesetMergeConflict value to its name so
93
+ * it can be uses as argument to call a exposed function.
94
+ */
95
+ function ChangesetMergeConflictValueToName(value) {
96
+ switch (value) {
97
+ case ChangesetMergeConflict.Fail:
98
+ return "FAIL";
99
+ case ChangesetMergeConflict.FailEarly:
100
+ return "FAIL_EARLY";
101
+ case ChangesetMergeConflict.LeaveConflictMarkers:
102
+ return "LEAVE_CONFLICT_MARKERS";
103
+ case ChangesetMergeConflict.PreferOurs:
104
+ return "PREFER_OURS";
105
+ case ChangesetMergeConflict.PreferTheirs:
106
+ return "PREFER_THEIRS";
107
+ default:
108
+ return value;
109
+ }
110
+ }
111
+ /**
112
+ * Utility function to convert a ChangesetMergeConflict name to its value so
113
+ * it can be properly used inside the module runtime.
114
+ */
115
+ function ChangesetMergeConflictNameToValue(name) {
116
+ switch (name) {
117
+ case "FAIL":
118
+ return ChangesetMergeConflict.Fail;
119
+ case "FAIL_EARLY":
120
+ return ChangesetMergeConflict.FailEarly;
121
+ case "LEAVE_CONFLICT_MARKERS":
122
+ return ChangesetMergeConflict.LeaveConflictMarkers;
123
+ case "PREFER_OURS":
124
+ return ChangesetMergeConflict.PreferOurs;
125
+ case "PREFER_THEIRS":
126
+ return ChangesetMergeConflict.PreferTheirs;
127
+ default:
128
+ return name;
129
+ }
130
+ }
131
+ /**
132
+ * Strategy to use when merging multiple changesets with git octopus merge.
133
+ */
134
+ export var ChangesetsMergeConflict;
135
+ (function (ChangesetsMergeConflict) {
136
+ /**
137
+ * Attempt the octopus merge and fail if git merge fails due to conflicts
138
+ */
139
+ ChangesetsMergeConflict["Fail"] = "FAIL";
140
+ /**
141
+ * Fail before attempting merge if file-level conflicts are detected between any changesets
142
+ */
143
+ ChangesetsMergeConflict["FailEarly"] = "FAIL_EARLY";
144
+ })(ChangesetsMergeConflict || (ChangesetsMergeConflict = {}));
145
+ /**
146
+ * Utility function to convert a ChangesetsMergeConflict value to its name so
147
+ * it can be uses as argument to call a exposed function.
148
+ */
149
+ function ChangesetsMergeConflictValueToName(value) {
150
+ switch (value) {
151
+ case ChangesetsMergeConflict.Fail:
152
+ return "FAIL";
153
+ case ChangesetsMergeConflict.FailEarly:
154
+ return "FAIL_EARLY";
155
+ default:
156
+ return value;
157
+ }
158
+ }
159
+ /**
160
+ * Utility function to convert a ChangesetsMergeConflict name to its value so
161
+ * it can be properly used inside the module runtime.
162
+ */
163
+ function ChangesetsMergeConflictNameToValue(name) {
164
+ switch (name) {
165
+ case "FAIL":
166
+ return ChangesetsMergeConflict.Fail;
167
+ case "FAIL_EARLY":
168
+ return ChangesetsMergeConflict.FailEarly;
169
+ default:
170
+ return name;
171
+ }
172
+ }
65
173
  /**
66
174
  * File type.
67
175
  */
@@ -428,11 +536,11 @@ function NetworkProtocolNameToValue(name) {
428
536
  export var ReturnType;
429
537
  (function (ReturnType) {
430
538
  /**
431
- * Any execution (exit codes 0-127)
539
+ * Any execution (exit codes 0-127 and 192-255)
432
540
  */
433
541
  ReturnType["Any"] = "ANY";
434
542
  /**
435
- * A failed execution (exit codes 1-127)
543
+ * A failed execution (exit codes 1-127 and 192-255)
436
544
  */
437
545
  ReturnType["Failure"] = "FAILURE";
438
546
  /**
@@ -850,6 +958,20 @@ export class Binding extends BaseClient {
850
958
  const ctx = this._ctx.select("asFile");
851
959
  return new File(ctx);
852
960
  };
961
+ /**
962
+ * Retrieve the binding value, as type Generator
963
+ */
964
+ asGenerator = () => {
965
+ const ctx = this._ctx.select("asGenerator");
966
+ return new Generator(ctx);
967
+ };
968
+ /**
969
+ * Retrieve the binding value, as type GeneratorGroup
970
+ */
971
+ asGeneratorGroup = () => {
972
+ const ctx = this._ctx.select("asGeneratorGroup");
973
+ return new GeneratorGroup(ctx);
974
+ };
853
975
  /**
854
976
  * Retrieve the binding value, as type GitRef
855
977
  */
@@ -945,6 +1067,13 @@ export class Binding extends BaseClient {
945
1067
  const response = await ctx.execute();
946
1068
  return response;
947
1069
  };
1070
+ /**
1071
+ * Retrieve the binding value, as type Workspace
1072
+ */
1073
+ asWorkspace = () => {
1074
+ const ctx = this._ctx.select("asWorkspace");
1075
+ return new Workspace(ctx);
1076
+ };
948
1077
  /**
949
1078
  * Returns the digest of the binding value
950
1079
  */
@@ -1126,6 +1255,58 @@ export class Changeset extends BaseClient {
1126
1255
  const response = await ctx.execute();
1127
1256
  return new Client(ctx.copy()).loadChangesetFromID(response);
1128
1257
  };
1258
+ /**
1259
+ * Add changes to an existing changeset
1260
+ *
1261
+ * By default the operation will fail in case of conflicts, for instance a file modified in both changesets. The behavior can be adjusted using onConflict argument
1262
+ * @param changes Changes to merge into the actual changeset
1263
+ * @param opts.onConflict What to do on a merge conflict
1264
+ */
1265
+ withChangeset = (changes, opts) => {
1266
+ const metadata = {
1267
+ onConflict: {
1268
+ is_enum: true,
1269
+ value_to_name: ChangesetMergeConflictValueToName,
1270
+ },
1271
+ };
1272
+ const ctx = this._ctx.select("withChangeset", {
1273
+ changes,
1274
+ ...opts,
1275
+ __metadata: metadata,
1276
+ });
1277
+ return new Changeset(ctx);
1278
+ };
1279
+ /**
1280
+ * Add changes from multiple changesets using git octopus merge strategy
1281
+ *
1282
+ * This is more efficient than chaining multiple withChangeset calls when merging many changesets.
1283
+ *
1284
+ * Only FAIL and FAIL_EARLY conflict strategies are supported (octopus merge cannot use -X ours/theirs).
1285
+ * @param changes List of changesets to merge into the actual changeset
1286
+ * @param opts.onConflict What to do on a merge conflict
1287
+ */
1288
+ withChangesets = (changes, opts) => {
1289
+ const metadata = {
1290
+ onConflict: {
1291
+ is_enum: true,
1292
+ value_to_name: ChangesetsMergeConflictValueToName,
1293
+ },
1294
+ };
1295
+ const ctx = this._ctx.select("withChangesets", {
1296
+ changes,
1297
+ ...opts,
1298
+ __metadata: metadata,
1299
+ });
1300
+ return new Changeset(ctx);
1301
+ };
1302
+ /**
1303
+ * Call the provided function with current Changeset.
1304
+ *
1305
+ * This is useful for reusability and readability by not breaking the calling chain.
1306
+ */
1307
+ with = (arg) => {
1308
+ return arg(this);
1309
+ };
1129
1310
  }
1130
1311
  export class Check extends BaseClient {
1131
1312
  _id = undefined;
@@ -1179,6 +1360,13 @@ export class Check extends BaseClient {
1179
1360
  const response = await ctx.execute();
1180
1361
  return response;
1181
1362
  };
1363
+ /**
1364
+ * If the check failed, this is the error
1365
+ */
1366
+ error = () => {
1367
+ const ctx = this._ctx.select("error");
1368
+ return new Error(ctx);
1369
+ };
1182
1370
  /**
1183
1371
  * Return the fully qualified name of the check
1184
1372
  */
@@ -1190,6 +1378,13 @@ export class Check extends BaseClient {
1190
1378
  const response = await ctx.execute();
1191
1379
  return response;
1192
1380
  };
1381
+ /**
1382
+ * The original module in which the check has been defined
1383
+ */
1384
+ originalModule = () => {
1385
+ const ctx = this._ctx.select("originalModule");
1386
+ return new Module_(ctx);
1387
+ };
1193
1388
  /**
1194
1389
  * Whether the check passed
1195
1390
  */
@@ -1227,13 +1422,6 @@ export class Check extends BaseClient {
1227
1422
  const ctx = this._ctx.select("run");
1228
1423
  return new Check(ctx);
1229
1424
  };
1230
- /**
1231
- * The module source where the check is defined (i.e., toolchains)
1232
- */
1233
- source = () => {
1234
- const ctx = this._ctx.select("source");
1235
- return new ModuleSource(ctx);
1236
- };
1237
1425
  /**
1238
1426
  * Call the provided function with current Check.
1239
1427
  *
@@ -2403,6 +2591,15 @@ export class CurrentModule extends BaseClient {
2403
2591
  const ctx = this._ctx.select("generatedContextDirectory");
2404
2592
  return new Directory(ctx);
2405
2593
  };
2594
+ /**
2595
+ * Return all generators defined by the module
2596
+ * @param opts.include Only include generators matching the specified patterns
2597
+ * @experimental
2598
+ */
2599
+ generators = (opts) => {
2600
+ const ctx = this._ctx.select("generators", { ...opts });
2601
+ return new GeneratorGroup(ctx);
2602
+ };
2406
2603
  /**
2407
2604
  * The name of the module being executed in
2408
2605
  */
@@ -2565,6 +2762,11 @@ export class Directory extends BaseClient {
2565
2762
  * @param opts.noInit If set, skip the automatic init process injected into containers created by RUN statements.
2566
2763
  *
2567
2764
  * This should only be used if the user requires that their exec processes be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
2765
+ * @param opts.ssh A socket to use for SSH authentication during the build
2766
+ *
2767
+ * (e.g., for Dockerfile RUN --mount=type=ssh instructions).
2768
+ *
2769
+ * Typically obtained via host.unixSocket() pointing to the SSH_AUTH_SOCK.
2568
2770
  */
2569
2771
  dockerBuild = (opts) => {
2570
2772
  const ctx = this._ctx.select("dockerBuild", { ...opts });
@@ -2977,6 +3179,10 @@ export class EngineCache extends BaseClient {
2977
3179
  /**
2978
3180
  * Prune the cache of releaseable entries
2979
3181
  * @param opts.useDefaultPolicy Use the engine-wide default pruning policy if true, otherwise prune the whole cache of any releasable entries.
3182
+ * @param opts.maxUsedSpace Override the maximum disk space to keep before pruning (e.g. "200GB" or "80%").
3183
+ * @param opts.reservedSpace Override the minimum disk space to retain during pruning (e.g. "500GB" or "10%").
3184
+ * @param opts.minFreeSpace Override the minimum free disk space target during pruning (e.g. "20GB" or "20%").
3185
+ * @param opts.targetSpace Override the target disk space to keep after pruning (e.g. "200GB" or "50%").
2980
3186
  */
2981
3187
  prune = async (opts) => {
2982
3188
  if (this._prune) {
@@ -3018,10 +3224,11 @@ export class EngineCacheEntry extends BaseClient {
3018
3224
  _description = undefined;
3019
3225
  _diskSpaceBytes = undefined;
3020
3226
  _mostRecentUseTimeUnixNano = undefined;
3227
+ _recordType = undefined;
3021
3228
  /**
3022
3229
  * Constructor is used for internal usage only, do not create object from it.
3023
3230
  */
3024
- constructor(ctx, _id, _activelyUsed, _createdTimeUnixNano, _description, _diskSpaceBytes, _mostRecentUseTimeUnixNano) {
3231
+ constructor(ctx, _id, _activelyUsed, _createdTimeUnixNano, _description, _diskSpaceBytes, _mostRecentUseTimeUnixNano, _recordType) {
3025
3232
  super(ctx);
3026
3233
  this._id = _id;
3027
3234
  this._activelyUsed = _activelyUsed;
@@ -3029,6 +3236,7 @@ export class EngineCacheEntry extends BaseClient {
3029
3236
  this._description = _description;
3030
3237
  this._diskSpaceBytes = _diskSpaceBytes;
3031
3238
  this._mostRecentUseTimeUnixNano = _mostRecentUseTimeUnixNano;
3239
+ this._recordType = _recordType;
3032
3240
  }
3033
3241
  /**
3034
3242
  * A unique identifier for this EngineCacheEntry.
@@ -3096,6 +3304,17 @@ export class EngineCacheEntry extends BaseClient {
3096
3304
  const response = await ctx.execute();
3097
3305
  return response;
3098
3306
  };
3307
+ /**
3308
+ * The type of the cache record (e.g. regular, internal, frontend, source.local, source.git.checkout, exec.cachemount).
3309
+ */
3310
+ recordType = async () => {
3311
+ if (this._recordType) {
3312
+ return this._recordType;
3313
+ }
3314
+ const ctx = this._ctx.select("recordType");
3315
+ const response = await ctx.execute();
3316
+ return response;
3317
+ };
3099
3318
  }
3100
3319
  /**
3101
3320
  * A set of cache entries returned by a query to a cache
@@ -3344,6 +3563,24 @@ export class Env extends BaseClient {
3344
3563
  const response = await ctx.execute();
3345
3564
  return response;
3346
3565
  };
3566
+ /**
3567
+ * Return the check with the given name from the installed modules. Must match exactly one check.
3568
+ * @param name The name of the check to retrieve
3569
+ * @experimental
3570
+ */
3571
+ check = (name) => {
3572
+ const ctx = this._ctx.select("check", { name });
3573
+ return new Check(ctx);
3574
+ };
3575
+ /**
3576
+ * Return all checks defined by the installed modules
3577
+ * @param opts.include Only include checks matching the specified patterns
3578
+ * @experimental
3579
+ */
3580
+ checks = (opts) => {
3581
+ const ctx = this._ctx.select("checks", { ...opts });
3582
+ return new CheckGroup(ctx);
3583
+ };
3347
3584
  /**
3348
3585
  * Retrieves an input binding by name
3349
3586
  */
@@ -3620,6 +3857,55 @@ export class Env extends BaseClient {
3620
3857
  const ctx = this._ctx.select("withFileOutput", { name, description });
3621
3858
  return new Env(ctx);
3622
3859
  };
3860
+ /**
3861
+ * Create or update a binding of type GeneratorGroup in the environment
3862
+ * @param name The name of the binding
3863
+ * @param value The GeneratorGroup value to assign to the binding
3864
+ * @param description The purpose of the input
3865
+ */
3866
+ withGeneratorGroupInput = (name, value, description) => {
3867
+ const ctx = this._ctx.select("withGeneratorGroupInput", {
3868
+ name,
3869
+ value,
3870
+ description,
3871
+ });
3872
+ return new Env(ctx);
3873
+ };
3874
+ /**
3875
+ * Declare a desired GeneratorGroup output to be assigned in the environment
3876
+ * @param name The name of the binding
3877
+ * @param description A description of the desired value of the binding
3878
+ */
3879
+ withGeneratorGroupOutput = (name, description) => {
3880
+ const ctx = this._ctx.select("withGeneratorGroupOutput", {
3881
+ name,
3882
+ description,
3883
+ });
3884
+ return new Env(ctx);
3885
+ };
3886
+ /**
3887
+ * Create or update a binding of type Generator in the environment
3888
+ * @param name The name of the binding
3889
+ * @param value The Generator value to assign to the binding
3890
+ * @param description The purpose of the input
3891
+ */
3892
+ withGeneratorInput = (name, value, description) => {
3893
+ const ctx = this._ctx.select("withGeneratorInput", {
3894
+ name,
3895
+ value,
3896
+ description,
3897
+ });
3898
+ return new Env(ctx);
3899
+ };
3900
+ /**
3901
+ * Declare a desired Generator output to be assigned in the environment
3902
+ * @param name The name of the binding
3903
+ * @param description A description of the desired value of the binding
3904
+ */
3905
+ withGeneratorOutput = (name, description) => {
3906
+ const ctx = this._ctx.select("withGeneratorOutput", { name, description });
3907
+ return new Env(ctx);
3908
+ };
3623
3909
  /**
3624
3910
  * Create or update a binding of type GitRef in the environment
3625
3911
  * @param name The name of the binding
@@ -3692,10 +3978,22 @@ export class Env extends BaseClient {
3692
3978
  const ctx = this._ctx.select("withJSONValueOutput", { name, description });
3693
3979
  return new Env(ctx);
3694
3980
  };
3981
+ /**
3982
+ * Sets the main module for this environment (the project being worked on)
3983
+ *
3984
+ * Contextual path arguments will be populated using the environment's workspace.
3985
+ */
3986
+ withMainModule = (module_) => {
3987
+ const ctx = this._ctx.select("withMainModule", {
3988
+ module: module_,
3989
+ });
3990
+ return new Env(ctx);
3991
+ };
3695
3992
  /**
3696
3993
  * Installs a module into the environment, exposing its functions to the model
3697
3994
  *
3698
3995
  * Contextual path arguments will be populated using the environment's workspace.
3996
+ * @deprecated Use withMainModule instead
3699
3997
  */
3700
3998
  withModule = (module_) => {
3701
3999
  const ctx = this._ctx.select("withModule", {
@@ -3949,6 +4247,29 @@ export class Env extends BaseClient {
3949
4247
  const ctx = this._ctx.select("withWorkspace", { workspace });
3950
4248
  return new Env(ctx);
3951
4249
  };
4250
+ /**
4251
+ * Create or update a binding of type Workspace in the environment
4252
+ * @param name The name of the binding
4253
+ * @param value The Workspace value to assign to the binding
4254
+ * @param description The purpose of the input
4255
+ */
4256
+ withWorkspaceInput = (name, value, description) => {
4257
+ const ctx = this._ctx.select("withWorkspaceInput", {
4258
+ name,
4259
+ value,
4260
+ description,
4261
+ });
4262
+ return new Env(ctx);
4263
+ };
4264
+ /**
4265
+ * Declare a desired Workspace output to be assigned in the environment
4266
+ * @param name The name of the binding
4267
+ * @param description A description of the desired value of the binding
4268
+ */
4269
+ withWorkspaceOutput = (name, description) => {
4270
+ const ctx = this._ctx.select("withWorkspaceOutput", { name, description });
4271
+ return new Env(ctx);
4272
+ };
3952
4273
  /**
3953
4274
  * Returns a new environment without any outputs
3954
4275
  */
@@ -4652,6 +4973,13 @@ export class Function_ extends BaseClient {
4652
4973
  const ctx = this._ctx.select("withDescription", { description });
4653
4974
  return new Function_(ctx);
4654
4975
  };
4976
+ /**
4977
+ * Returns the function with a flag indicating it's a generator.
4978
+ */
4979
+ withGenerator = () => {
4980
+ const ctx = this._ctx.select("withGenerator");
4981
+ return new Function_(ctx);
4982
+ };
4655
4983
  /**
4656
4984
  * Returns the function with the given source map.
4657
4985
  * @param sourceMap The source map for the function definition.
@@ -4676,6 +5004,7 @@ export class Function_ extends BaseClient {
4676
5004
  */
4677
5005
  export class FunctionArg extends BaseClient {
4678
5006
  _id = undefined;
5007
+ _defaultAddress = undefined;
4679
5008
  _defaultPath = undefined;
4680
5009
  _defaultValue = undefined;
4681
5010
  _deprecated = undefined;
@@ -4684,9 +5013,10 @@ export class FunctionArg extends BaseClient {
4684
5013
  /**
4685
5014
  * Constructor is used for internal usage only, do not create object from it.
4686
5015
  */
4687
- constructor(ctx, _id, _defaultPath, _defaultValue, _deprecated, _description, _name) {
5016
+ constructor(ctx, _id, _defaultAddress, _defaultPath, _defaultValue, _deprecated, _description, _name) {
4688
5017
  super(ctx);
4689
5018
  this._id = _id;
5019
+ this._defaultAddress = _defaultAddress;
4690
5020
  this._defaultPath = _defaultPath;
4691
5021
  this._defaultValue = _defaultValue;
4692
5022
  this._deprecated = _deprecated;
@@ -4704,6 +5034,17 @@ export class FunctionArg extends BaseClient {
4704
5034
  const response = await ctx.execute();
4705
5035
  return response;
4706
5036
  };
5037
+ /**
5038
+ * Only applies to arguments of type Container. If the argument is not set, load it from the given address (e.g. alpine:latest)
5039
+ */
5040
+ defaultAddress = async () => {
5041
+ if (this._defaultAddress) {
5042
+ return this._defaultAddress;
5043
+ }
5044
+ const ctx = this._ctx.select("defaultAddress");
5045
+ const response = await ctx.execute();
5046
+ return response;
5047
+ };
4707
5048
  /**
4708
5049
  * Only applies to arguments of type File or Directory. If the argument is not set, load it from the given path in the context directory
4709
5050
  */
@@ -4998,6 +5339,191 @@ export class GeneratedCode extends BaseClient {
4998
5339
  return arg(this);
4999
5340
  };
5000
5341
  }
5342
+ export class Generator extends BaseClient {
5343
+ _id = undefined;
5344
+ _completed = undefined;
5345
+ _description = undefined;
5346
+ _isEmpty = undefined;
5347
+ _name = undefined;
5348
+ /**
5349
+ * Constructor is used for internal usage only, do not create object from it.
5350
+ */
5351
+ constructor(ctx, _id, _completed, _description, _isEmpty, _name) {
5352
+ super(ctx);
5353
+ this._id = _id;
5354
+ this._completed = _completed;
5355
+ this._description = _description;
5356
+ this._isEmpty = _isEmpty;
5357
+ this._name = _name;
5358
+ }
5359
+ /**
5360
+ * A unique identifier for this Generator.
5361
+ */
5362
+ id = async () => {
5363
+ if (this._id) {
5364
+ return this._id;
5365
+ }
5366
+ const ctx = this._ctx.select("id");
5367
+ const response = await ctx.execute();
5368
+ return response;
5369
+ };
5370
+ /**
5371
+ * The generated changeset
5372
+ */
5373
+ changes = () => {
5374
+ const ctx = this._ctx.select("changes");
5375
+ return new Changeset(ctx);
5376
+ };
5377
+ /**
5378
+ * Whether the generator complete
5379
+ */
5380
+ completed = async () => {
5381
+ if (this._completed) {
5382
+ return this._completed;
5383
+ }
5384
+ const ctx = this._ctx.select("completed");
5385
+ const response = await ctx.execute();
5386
+ return response;
5387
+ };
5388
+ /**
5389
+ * Return the description of the generator
5390
+ */
5391
+ description = async () => {
5392
+ if (this._description) {
5393
+ return this._description;
5394
+ }
5395
+ const ctx = this._ctx.select("description");
5396
+ const response = await ctx.execute();
5397
+ return response;
5398
+ };
5399
+ /**
5400
+ * Wether changeset from the generator execution is empty or not
5401
+ */
5402
+ isEmpty = async () => {
5403
+ if (this._isEmpty) {
5404
+ return this._isEmpty;
5405
+ }
5406
+ const ctx = this._ctx.select("isEmpty");
5407
+ const response = await ctx.execute();
5408
+ return response;
5409
+ };
5410
+ /**
5411
+ * Return the fully qualified name of the generator
5412
+ */
5413
+ name = async () => {
5414
+ if (this._name) {
5415
+ return this._name;
5416
+ }
5417
+ const ctx = this._ctx.select("name");
5418
+ const response = await ctx.execute();
5419
+ return response;
5420
+ };
5421
+ /**
5422
+ * The original module in which the generator has been defined
5423
+ */
5424
+ originalModule = () => {
5425
+ const ctx = this._ctx.select("originalModule");
5426
+ return new Module_(ctx);
5427
+ };
5428
+ /**
5429
+ * The path of the generator within its module
5430
+ */
5431
+ path = async () => {
5432
+ const ctx = this._ctx.select("path");
5433
+ const response = await ctx.execute();
5434
+ return response;
5435
+ };
5436
+ /**
5437
+ * Execute the generator
5438
+ */
5439
+ run = () => {
5440
+ const ctx = this._ctx.select("run");
5441
+ return new Generator(ctx);
5442
+ };
5443
+ /**
5444
+ * Call the provided function with current Generator.
5445
+ *
5446
+ * This is useful for reusability and readability by not breaking the calling chain.
5447
+ */
5448
+ with = (arg) => {
5449
+ return arg(this);
5450
+ };
5451
+ }
5452
+ export class GeneratorGroup extends BaseClient {
5453
+ _id = undefined;
5454
+ _isEmpty = undefined;
5455
+ /**
5456
+ * Constructor is used for internal usage only, do not create object from it.
5457
+ */
5458
+ constructor(ctx, _id, _isEmpty) {
5459
+ super(ctx);
5460
+ this._id = _id;
5461
+ this._isEmpty = _isEmpty;
5462
+ }
5463
+ /**
5464
+ * A unique identifier for this GeneratorGroup.
5465
+ */
5466
+ id = async () => {
5467
+ if (this._id) {
5468
+ return this._id;
5469
+ }
5470
+ const ctx = this._ctx.select("id");
5471
+ const response = await ctx.execute();
5472
+ return response;
5473
+ };
5474
+ /**
5475
+ * The combined changes from the generators execution
5476
+ *
5477
+ * If any conflict occurs, for instance if the same file is modified by multiple generators, or if a file is both modified and deleted, an error is raised and the merge of the changesets will failed.
5478
+ *
5479
+ * Set 'continueOnConflicts' flag to force to merge the changes in a 'last write wins' strategy.
5480
+ * @param opts.onConflict Strategy to apply on conflicts between generators
5481
+ */
5482
+ changes = (opts) => {
5483
+ const metadata = {
5484
+ onConflict: {
5485
+ is_enum: true,
5486
+ value_to_name: ChangesetsMergeConflictValueToName,
5487
+ },
5488
+ };
5489
+ const ctx = this._ctx.select("changes", { ...opts, __metadata: metadata });
5490
+ return new Changeset(ctx);
5491
+ };
5492
+ /**
5493
+ * Whether the generated changeset is empty or not
5494
+ */
5495
+ isEmpty = async () => {
5496
+ if (this._isEmpty) {
5497
+ return this._isEmpty;
5498
+ }
5499
+ const ctx = this._ctx.select("isEmpty");
5500
+ const response = await ctx.execute();
5501
+ return response;
5502
+ };
5503
+ /**
5504
+ * Return a list of individual generators and their details
5505
+ */
5506
+ list = async () => {
5507
+ const ctx = this._ctx.select("list").select("id");
5508
+ const response = await ctx.execute();
5509
+ return response.map((r) => new Client(ctx.copy()).loadGeneratorFromID(r.id));
5510
+ };
5511
+ /**
5512
+ * Execute all selected generators
5513
+ */
5514
+ run = () => {
5515
+ const ctx = this._ctx.select("run");
5516
+ return new GeneratorGroup(ctx);
5517
+ };
5518
+ /**
5519
+ * Call the provided function with current GeneratorGroup.
5520
+ *
5521
+ * This is useful for reusability and readability by not breaking the calling chain.
5522
+ */
5523
+ with = (arg) => {
5524
+ return arg(this);
5525
+ };
5526
+ }
5001
5527
  /**
5002
5528
  * A git ref (tag, branch, or commit).
5003
5529
  */
@@ -6058,6 +6584,24 @@ export class Module_ extends BaseClient {
6058
6584
  const ctx = this._ctx.select("generatedContextDirectory");
6059
6585
  return new Directory(ctx);
6060
6586
  };
6587
+ /**
6588
+ * Return the generator defined by the module with the given name. Must match to exactly one generator.
6589
+ * @param name The name of the generator to retrieve
6590
+ * @experimental
6591
+ */
6592
+ generator = (name) => {
6593
+ const ctx = this._ctx.select("generator", { name });
6594
+ return new Generator(ctx);
6595
+ };
6596
+ /**
6597
+ * Return all generators defined by the module
6598
+ * @param opts.include Only include generators matching the specified patterns
6599
+ * @experimental
6600
+ */
6601
+ generators = (opts) => {
6602
+ const ctx = this._ctx.select("generators", { ...opts });
6603
+ return new GeneratorGroup(ctx);
6604
+ };
6061
6605
  /**
6062
6606
  * Interfaces served by this module.
6063
6607
  */
@@ -7017,6 +7561,15 @@ export class Client extends BaseClient {
7017
7561
  const response = await ctx.execute();
7018
7562
  return response.map((r) => new Client(ctx.copy()).loadTypeDefFromID(r.id));
7019
7563
  };
7564
+ /**
7565
+ * Detect and return the current workspace.
7566
+ * @param opts.skipMigrationCheck If true, skip legacy dagger.json migration checks.
7567
+ * @experimental
7568
+ */
7569
+ currentWorkspace = (opts) => {
7570
+ const ctx = this._ctx.select("currentWorkspace", { ...opts });
7571
+ return new Workspace(ctx);
7572
+ };
7020
7573
  /**
7021
7574
  * The default platform of the engine.
7022
7575
  */
@@ -7342,6 +7895,20 @@ export class Client extends BaseClient {
7342
7895
  const ctx = this._ctx.select("loadGeneratedCodeFromID", { id });
7343
7896
  return new GeneratedCode(ctx);
7344
7897
  };
7898
+ /**
7899
+ * Load a Generator from its ID.
7900
+ */
7901
+ loadGeneratorFromID = (id) => {
7902
+ const ctx = this._ctx.select("loadGeneratorFromID", { id });
7903
+ return new Generator(ctx);
7904
+ };
7905
+ /**
7906
+ * Load a GeneratorGroup from its ID.
7907
+ */
7908
+ loadGeneratorGroupFromID = (id) => {
7909
+ const ctx = this._ctx.select("loadGeneratorGroupFromID", { id });
7910
+ return new GeneratorGroup(ctx);
7911
+ };
7345
7912
  /**
7346
7913
  * Load a GitRef from its ID.
7347
7914
  */
@@ -7524,6 +8091,13 @@ export class Client extends BaseClient {
7524
8091
  const ctx = this._ctx.select("loadTypeDefFromID", { id });
7525
8092
  return new TypeDef(ctx);
7526
8093
  };
8094
+ /**
8095
+ * Load a Workspace from its ID.
8096
+ */
8097
+ loadWorkspaceFromID = (id) => {
8098
+ const ctx = this._ctx.select("loadWorkspaceFromID", { id });
8099
+ return new Workspace(ctx);
8100
+ };
7527
8101
  /**
7528
8102
  * Create a new module.
7529
8103
  */
@@ -8491,4 +9065,96 @@ export class TypeDef extends BaseClient {
8491
9065
  return arg(this);
8492
9066
  };
8493
9067
  }
9068
+ /**
9069
+ * A Dagger workspace detected from the current working directory.
9070
+ */
9071
+ export class Workspace extends BaseClient {
9072
+ _id = undefined;
9073
+ _clientId = undefined;
9074
+ _findUp = undefined;
9075
+ _root = undefined;
9076
+ /**
9077
+ * Constructor is used for internal usage only, do not create object from it.
9078
+ */
9079
+ constructor(ctx, _id, _clientId, _findUp, _root) {
9080
+ super(ctx);
9081
+ this._id = _id;
9082
+ this._clientId = _clientId;
9083
+ this._findUp = _findUp;
9084
+ this._root = _root;
9085
+ }
9086
+ /**
9087
+ * A unique identifier for this Workspace.
9088
+ */
9089
+ id = async () => {
9090
+ if (this._id) {
9091
+ return this._id;
9092
+ }
9093
+ const ctx = this._ctx.select("id");
9094
+ const response = await ctx.execute();
9095
+ return response;
9096
+ };
9097
+ /**
9098
+ * The client ID that owns this workspace's host filesystem.
9099
+ */
9100
+ clientId = async () => {
9101
+ if (this._clientId) {
9102
+ return this._clientId;
9103
+ }
9104
+ const ctx = this._ctx.select("clientId");
9105
+ const response = await ctx.execute();
9106
+ return response;
9107
+ };
9108
+ /**
9109
+ * Returns a Directory from the workspace.
9110
+ *
9111
+ * Path is relative to workspace root. Use "." for the root directory.
9112
+ * @param path Location of the directory to retrieve, relative to the workspace root (e.g., "src", ".").
9113
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
9114
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
9115
+ * @param opts.gitignore Apply .gitignore filter rules inside the directory.
9116
+ */
9117
+ directory = (path, opts) => {
9118
+ const ctx = this._ctx.select("directory", { path, ...opts });
9119
+ return new Directory(ctx);
9120
+ };
9121
+ /**
9122
+ * Returns a File from the workspace.
9123
+ *
9124
+ * Path is relative to workspace root.
9125
+ * @param path Location of the file to retrieve, relative to the workspace root (e.g., "go.mod").
9126
+ */
9127
+ file = (path) => {
9128
+ const ctx = this._ctx.select("file", { path });
9129
+ return new File(ctx);
9130
+ };
9131
+ /**
9132
+ * Search for a file or directory by walking up from the start path within the workspace.
9133
+ *
9134
+ * Returns the path relative to the workspace root if found, or null if not found.
9135
+ *
9136
+ * The search stops at the workspace root and will not traverse above it.
9137
+ * @param name The name of the file or directory to search for.
9138
+ * @param opts.from Path to start the search from, relative to the workspace root.
9139
+ */
9140
+ findUp = async (name, opts) => {
9141
+ if (this._findUp) {
9142
+ return this._findUp;
9143
+ }
9144
+ const ctx = this._ctx.select("findUp", { name, ...opts });
9145
+ const response = await ctx.execute();
9146
+ return response;
9147
+ };
9148
+ /**
9149
+ * Absolute path to the workspace root directory.
9150
+ */
9151
+ root = async () => {
9152
+ if (this._root) {
9153
+ return this._root;
9154
+ }
9155
+ const ctx = this._ctx.select("root");
9156
+ const response = await ctx.execute();
9157
+ return response;
9158
+ };
9159
+ }
8494
9160
  export const dag = new Client();