@dagger.io/dagger 0.6.3 → 0.8.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.
@@ -54,7 +54,7 @@ export var CacheSharingMode;
54
54
  CacheSharingMode[CacheSharingMode["Shared"] = 2] = "Shared";
55
55
  })(CacheSharingMode || (CacheSharingMode = {}));
56
56
  /**
57
- * Compression algorithm to use for image layers
57
+ * Compression algorithm to use for image layers.
58
58
  */
59
59
  export var ImageLayerCompression;
60
60
  (function (ImageLayerCompression) {
@@ -63,6 +63,14 @@ export var ImageLayerCompression;
63
63
  ImageLayerCompression[ImageLayerCompression["Uncompressed"] = 2] = "Uncompressed";
64
64
  ImageLayerCompression[ImageLayerCompression["Zstd"] = 3] = "Zstd";
65
65
  })(ImageLayerCompression || (ImageLayerCompression = {}));
66
+ /**
67
+ * Mediatypes to use in published or exported image metadata.
68
+ */
69
+ export var ImageMediaTypes;
70
+ (function (ImageMediaTypes) {
71
+ ImageMediaTypes[ImageMediaTypes["Dockermediatypes"] = 0] = "Dockermediatypes";
72
+ ImageMediaTypes[ImageMediaTypes["Ocimediatypes"] = 1] = "Ocimediatypes";
73
+ })(ImageMediaTypes || (ImageMediaTypes = {}));
66
74
  /**
67
75
  * Transport layer network protocol associated to a port.
68
76
  */
@@ -81,8 +89,19 @@ export var NetworkProtocol;
81
89
  * A directory whose contents persist across runs.
82
90
  */
83
91
  export class CacheVolume extends BaseClient {
92
+ /**
93
+ * Constructor is used for internal usage only, do not create object from it.
94
+ */
95
+ constructor(parent, _id) {
96
+ super(parent);
97
+ this._id = undefined;
98
+ this._id = _id;
99
+ }
84
100
  id() {
85
101
  return __awaiter(this, void 0, void 0, function* () {
102
+ if (this._id) {
103
+ return this._id;
104
+ }
86
105
  const response = yield computeQuery([
87
106
  ...this._queryTree,
88
107
  {
@@ -92,35 +111,45 @@ export class CacheVolume extends BaseClient {
92
111
  return response;
93
112
  });
94
113
  }
95
- /**
96
- * Chain objects together
97
- * @example
98
- * ```ts
99
- * function AddAFewMounts(c) {
100
- * return c
101
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
102
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
103
- * }
104
- *
105
- * connect(async (client) => {
106
- * const tree = await client
107
- * .container()
108
- * .from("alpine")
109
- * .withWorkdir("/foo")
110
- * .with(AddAFewMounts)
111
- * .withExec(["ls", "-lh"])
112
- * .stdout()
113
- * })
114
- *```
115
- */
116
- with(arg) {
117
- return arg(this);
118
- }
119
114
  }
120
115
  /**
121
116
  * An OCI-compatible container, also known as a docker container.
122
117
  */
123
118
  export class Container extends BaseClient {
119
+ /**
120
+ * Constructor is used for internal usage only, do not create object from it.
121
+ */
122
+ constructor(parent, _endpoint, _envVariable, _export, _hostname, _id, _imageRef, _label, _platform, _publish, _stderr, _stdout, _sync, _user, _workdir) {
123
+ super(parent);
124
+ this._endpoint = undefined;
125
+ this._envVariable = undefined;
126
+ this._export = undefined;
127
+ this._hostname = undefined;
128
+ this._id = undefined;
129
+ this._imageRef = undefined;
130
+ this._label = undefined;
131
+ this._platform = undefined;
132
+ this._publish = undefined;
133
+ this._stderr = undefined;
134
+ this._stdout = undefined;
135
+ this._sync = undefined;
136
+ this._user = undefined;
137
+ this._workdir = undefined;
138
+ this._endpoint = _endpoint;
139
+ this._envVariable = _envVariable;
140
+ this._export = _export;
141
+ this._hostname = _hostname;
142
+ this._id = _id;
143
+ this._imageRef = _imageRef;
144
+ this._label = _label;
145
+ this._platform = _platform;
146
+ this._publish = _publish;
147
+ this._stderr = _stderr;
148
+ this._stdout = _stdout;
149
+ this._sync = _sync;
150
+ this._user = _user;
151
+ this._workdir = _workdir;
152
+ }
124
153
  /**
125
154
  * Initializes this container from a Dockerfile build.
126
155
  * @param context Directory context used by the Dockerfile.
@@ -192,6 +221,9 @@ export class Container extends BaseClient {
192
221
  */
193
222
  endpoint(opts) {
194
223
  return __awaiter(this, void 0, void 0, function* () {
224
+ if (this._endpoint) {
225
+ return this._endpoint;
226
+ }
195
227
  const response = yield computeQuery([
196
228
  ...this._queryTree,
197
229
  {
@@ -222,6 +254,9 @@ export class Container extends BaseClient {
222
254
  */
223
255
  envVariable(name) {
224
256
  return __awaiter(this, void 0, void 0, function* () {
257
+ if (this._envVariable) {
258
+ return this._envVariable;
259
+ }
225
260
  const response = yield computeQuery([
226
261
  ...this._queryTree,
227
262
  {
@@ -242,48 +277,15 @@ export class Container extends BaseClient {
242
277
  {
243
278
  operation: "envVariables",
244
279
  },
245
- ], this.client);
246
- return response;
247
- });
248
- }
249
- /**
250
- * Retrieves this container after executing the specified command inside it.
251
- * @param opts.args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
252
- * @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
253
- * @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
254
- * @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
255
- * @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
256
- * Do not use this option unless you trust the command being executed.
257
- * The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
258
- * @deprecated Replaced by withExec.
259
- */
260
- exec(opts) {
261
- return new Container({
262
- queryTree: [
263
- ...this._queryTree,
264
- {
265
- operation: "exec",
266
- args: Object.assign({}, opts),
267
- },
268
- ],
269
- host: this.clientHost,
270
- sessionToken: this.sessionToken,
271
- });
272
- }
273
- /**
274
- * Exit code of the last executed command. Zero means success.
275
- *
276
- * Will execute default command if none is set, or error if there's no default.
277
- */
278
- exitCode() {
279
- return __awaiter(this, void 0, void 0, function* () {
280
- const response = yield computeQuery([
281
- ...this._queryTree,
282
280
  {
283
- operation: "exitCode",
281
+ operation: "name value",
284
282
  },
285
283
  ], this.client);
286
- return response;
284
+ return response.map((r) => new EnvVariable({
285
+ queryTree: this.queryTree,
286
+ host: this.clientHost,
287
+ sessionToken: this.sessionToken,
288
+ }, r.name, r.value));
287
289
  });
288
290
  }
289
291
  /**
@@ -300,9 +302,15 @@ export class Container extends BaseClient {
300
302
  * cache, that will be used (this can result in a mix of compression algorithms for
301
303
  * different layers). If this is unset and a layer has no compressed blob in the
302
304
  * engine's cache, then it will be compressed using Gzip.
305
+ * @param opts.mediaTypes Use the specified media types for the exported image's layers. Defaults to OCI, which
306
+ * is largely compatible with most recent container runtimes, but Docker may be needed
307
+ * for older runtimes without OCI support.
303
308
  */
304
309
  export(path, opts) {
305
310
  return __awaiter(this, void 0, void 0, function* () {
311
+ if (this._export) {
312
+ return this._export;
313
+ }
306
314
  const response = yield computeQuery([
307
315
  ...this._queryTree,
308
316
  {
@@ -328,8 +336,15 @@ export class Container extends BaseClient {
328
336
  {
329
337
  operation: "exposedPorts",
330
338
  },
339
+ {
340
+ operation: "description port protocol",
341
+ },
331
342
  ], this.client);
332
- return response;
343
+ return response.map((r) => new Port({
344
+ queryTree: this.queryTree,
345
+ host: this.clientHost,
346
+ sessionToken: this.sessionToken,
347
+ }, r.description, r.port, r.protocol));
333
348
  });
334
349
  }
335
350
  /**
@@ -370,22 +385,6 @@ export class Container extends BaseClient {
370
385
  sessionToken: this.sessionToken,
371
386
  });
372
387
  }
373
- /**
374
- * Retrieves this container's root filesystem. Mounts are not included.
375
- * @deprecated Replaced by rootfs.
376
- */
377
- fs() {
378
- return new Directory({
379
- queryTree: [
380
- ...this._queryTree,
381
- {
382
- operation: "fs",
383
- },
384
- ],
385
- host: this.clientHost,
386
- sessionToken: this.sessionToken,
387
- });
388
- }
389
388
  /**
390
389
  * Retrieves a hostname which can be used by clients to reach this container.
391
390
  *
@@ -393,6 +392,9 @@ export class Container extends BaseClient {
393
392
  */
394
393
  hostname() {
395
394
  return __awaiter(this, void 0, void 0, function* () {
395
+ if (this._hostname) {
396
+ return this._hostname;
397
+ }
396
398
  const response = yield computeQuery([
397
399
  ...this._queryTree,
398
400
  {
@@ -407,6 +409,9 @@ export class Container extends BaseClient {
407
409
  */
408
410
  id() {
409
411
  return __awaiter(this, void 0, void 0, function* () {
412
+ if (this._id) {
413
+ return this._id;
414
+ }
410
415
  const response = yield computeQuery([
411
416
  ...this._queryTree,
412
417
  {
@@ -421,6 +426,9 @@ export class Container extends BaseClient {
421
426
  */
422
427
  imageRef() {
423
428
  return __awaiter(this, void 0, void 0, function* () {
429
+ if (this._imageRef) {
430
+ return this._imageRef;
431
+ }
424
432
  const response = yield computeQuery([
425
433
  ...this._queryTree,
426
434
  {
@@ -457,6 +465,9 @@ export class Container extends BaseClient {
457
465
  */
458
466
  label(name) {
459
467
  return __awaiter(this, void 0, void 0, function* () {
468
+ if (this._label) {
469
+ return this._label;
470
+ }
460
471
  const response = yield computeQuery([
461
472
  ...this._queryTree,
462
473
  {
@@ -477,8 +488,15 @@ export class Container extends BaseClient {
477
488
  {
478
489
  operation: "labels",
479
490
  },
491
+ {
492
+ operation: "name value",
493
+ },
480
494
  ], this.client);
481
- return response;
495
+ return response.map((r) => new Label({
496
+ queryTree: this.queryTree,
497
+ host: this.clientHost,
498
+ sessionToken: this.sessionToken,
499
+ }, r.name, r.value));
482
500
  });
483
501
  }
484
502
  /**
@@ -519,6 +537,9 @@ export class Container extends BaseClient {
519
537
  */
520
538
  platform() {
521
539
  return __awaiter(this, void 0, void 0, function* () {
540
+ if (this._platform) {
541
+ return this._platform;
542
+ }
522
543
  const response = yield computeQuery([
523
544
  ...this._queryTree,
524
545
  {
@@ -543,9 +564,15 @@ export class Container extends BaseClient {
543
564
  * cache, that will be used (this can result in a mix of compression algorithms for
544
565
  * different layers). If this is unset and a layer has no compressed blob in the
545
566
  * engine's cache, then it will be compressed using Gzip.
567
+ * @param opts.mediaTypes Use the specified media types for the published image's layers. Defaults to OCI, which
568
+ * is largely compatible with most recent registries, but Docker may be needed for older
569
+ * registries without OCI support.
546
570
  */
547
571
  publish(address, opts) {
548
572
  return __awaiter(this, void 0, void 0, function* () {
573
+ if (this._publish) {
574
+ return this._publish;
575
+ }
549
576
  const response = yield computeQuery([
550
577
  ...this._queryTree,
551
578
  {
@@ -578,6 +605,9 @@ export class Container extends BaseClient {
578
605
  */
579
606
  stderr() {
580
607
  return __awaiter(this, void 0, void 0, function* () {
608
+ if (this._stderr) {
609
+ return this._stderr;
610
+ }
581
611
  const response = yield computeQuery([
582
612
  ...this._queryTree,
583
613
  {
@@ -594,6 +624,9 @@ export class Container extends BaseClient {
594
624
  */
595
625
  stdout() {
596
626
  return __awaiter(this, void 0, void 0, function* () {
627
+ if (this._stdout) {
628
+ return this._stdout;
629
+ }
597
630
  const response = yield computeQuery([
598
631
  ...this._queryTree,
599
632
  {
@@ -624,6 +657,9 @@ export class Container extends BaseClient {
624
657
  */
625
658
  user() {
626
659
  return __awaiter(this, void 0, void 0, function* () {
660
+ if (this._user) {
661
+ return this._user;
662
+ }
627
663
  const response = yield computeQuery([
628
664
  ...this._queryTree,
629
665
  {
@@ -768,23 +804,6 @@ export class Container extends BaseClient {
768
804
  sessionToken: this.sessionToken,
769
805
  });
770
806
  }
771
- /**
772
- * Initializes this container from this DirectoryID.
773
- * @deprecated Replaced by withRootfs.
774
- */
775
- withFS(id) {
776
- return new Container({
777
- queryTree: [
778
- ...this._queryTree,
779
- {
780
- operation: "withFS",
781
- args: { id },
782
- },
783
- ],
784
- host: this.clientHost,
785
- sessionToken: this.sessionToken,
786
- });
787
- }
788
807
  /**
789
808
  * Retrieves this container plus the contents of the given file copied to the given path.
790
809
  * @param path Location of the copied file (e.g., "/tmp/file.txt").
@@ -811,6 +830,22 @@ export class Container extends BaseClient {
811
830
  sessionToken: this.sessionToken,
812
831
  });
813
832
  }
833
+ /**
834
+ * Indicate that subsequent operations should be featured more prominently in
835
+ * the UI.
836
+ */
837
+ withFocus() {
838
+ return new Container({
839
+ queryTree: [
840
+ ...this._queryTree,
841
+ {
842
+ operation: "withFocus",
843
+ },
844
+ ],
845
+ host: this.clientHost,
846
+ sessionToken: this.sessionToken,
847
+ });
848
+ }
814
849
  /**
815
850
  * Retrieves this container plus the given label.
816
851
  * @param name The name of the label (e.g., "org.opencontainers.artifact.created").
@@ -993,13 +1028,13 @@ export class Container extends BaseClient {
993
1028
  /**
994
1029
  * Initializes this container from this DirectoryID.
995
1030
  */
996
- withRootfs(id) {
1031
+ withRootfs(directory) {
997
1032
  return new Container({
998
1033
  queryTree: [
999
1034
  ...this._queryTree,
1000
1035
  {
1001
1036
  operation: "withRootfs",
1002
- args: { id },
1037
+ args: { directory },
1003
1038
  },
1004
1039
  ],
1005
1040
  host: this.clientHost,
@@ -1145,6 +1180,24 @@ export class Container extends BaseClient {
1145
1180
  sessionToken: this.sessionToken,
1146
1181
  });
1147
1182
  }
1183
+ /**
1184
+ * Indicate that subsequent operations should not be featured more prominently
1185
+ * in the UI.
1186
+ *
1187
+ * This is the initial state of all containers.
1188
+ */
1189
+ withoutFocus() {
1190
+ return new Container({
1191
+ queryTree: [
1192
+ ...this._queryTree,
1193
+ {
1194
+ operation: "withoutFocus",
1195
+ },
1196
+ ],
1197
+ host: this.clientHost,
1198
+ sessionToken: this.sessionToken,
1199
+ });
1200
+ }
1148
1201
  /**
1149
1202
  * Retrieves this container minus the given environment label.
1150
1203
  * @param name The name of the label to remove (e.g., "org.opencontainers.artifact.created").
@@ -1219,6 +1272,9 @@ export class Container extends BaseClient {
1219
1272
  */
1220
1273
  workdir() {
1221
1274
  return __awaiter(this, void 0, void 0, function* () {
1275
+ if (this._workdir) {
1276
+ return this._workdir;
1277
+ }
1222
1278
  const response = yield computeQuery([
1223
1279
  ...this._queryTree,
1224
1280
  {
@@ -1229,25 +1285,9 @@ export class Container extends BaseClient {
1229
1285
  });
1230
1286
  }
1231
1287
  /**
1232
- * Chain objects together
1233
- * @example
1234
- * ```ts
1235
- * function AddAFewMounts(c) {
1236
- * return c
1237
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1238
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1239
- * }
1288
+ * Call the provided function with current Container.
1240
1289
  *
1241
- * connect(async (client) => {
1242
- * const tree = await client
1243
- * .container()
1244
- * .from("alpine")
1245
- * .withWorkdir("/foo")
1246
- * .with(AddAFewMounts)
1247
- * .withExec(["ls", "-lh"])
1248
- * .stdout()
1249
- * })
1250
- *```
1290
+ * This is useful for reusability and readability by not breaking the calling chain.
1251
1291
  */
1252
1292
  with(arg) {
1253
1293
  return arg(this);
@@ -1257,6 +1297,18 @@ export class Container extends BaseClient {
1257
1297
  * A directory.
1258
1298
  */
1259
1299
  export class Directory extends BaseClient {
1300
+ /**
1301
+ * Constructor is used for internal usage only, do not create object from it.
1302
+ */
1303
+ constructor(parent, _export, _id, _sync) {
1304
+ super(parent);
1305
+ this._export = undefined;
1306
+ this._id = undefined;
1307
+ this._sync = undefined;
1308
+ this._export = _export;
1309
+ this._id = _id;
1310
+ this._sync = _sync;
1311
+ }
1260
1312
  /**
1261
1313
  * Gets the difference between this directory and an another directory.
1262
1314
  * @param other Identifier of the directory to compare.
@@ -1338,6 +1390,9 @@ export class Directory extends BaseClient {
1338
1390
  */
1339
1391
  export(path) {
1340
1392
  return __awaiter(this, void 0, void 0, function* () {
1393
+ if (this._export) {
1394
+ return this._export;
1395
+ }
1341
1396
  const response = yield computeQuery([
1342
1397
  ...this._queryTree,
1343
1398
  {
@@ -1370,6 +1425,9 @@ export class Directory extends BaseClient {
1370
1425
  */
1371
1426
  id() {
1372
1427
  return __awaiter(this, void 0, void 0, function* () {
1428
+ if (this._id) {
1429
+ return this._id;
1430
+ }
1373
1431
  const response = yield computeQuery([
1374
1432
  ...this._queryTree,
1375
1433
  {
@@ -1398,6 +1456,20 @@ export class Directory extends BaseClient {
1398
1456
  sessionToken: this.sessionToken,
1399
1457
  });
1400
1458
  }
1459
+ /**
1460
+ * Force evaluation in the engine.
1461
+ */
1462
+ sync() {
1463
+ return __awaiter(this, void 0, void 0, function* () {
1464
+ yield computeQuery([
1465
+ ...this._queryTree,
1466
+ {
1467
+ operation: "sync",
1468
+ },
1469
+ ], this.client);
1470
+ return this;
1471
+ });
1472
+ }
1401
1473
  /**
1402
1474
  * Retrieves this directory plus a directory written at the given path.
1403
1475
  * @param path Location of the written directory (e.g., "/src/").
@@ -1534,25 +1606,9 @@ export class Directory extends BaseClient {
1534
1606
  });
1535
1607
  }
1536
1608
  /**
1537
- * Chain objects together
1538
- * @example
1539
- * ```ts
1540
- * function AddAFewMounts(c) {
1541
- * return c
1542
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1543
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1544
- * }
1609
+ * Call the provided function with current Directory.
1545
1610
  *
1546
- * connect(async (client) => {
1547
- * const tree = await client
1548
- * .container()
1549
- * .from("alpine")
1550
- * .withWorkdir("/foo")
1551
- * .with(AddAFewMounts)
1552
- * .withExec(["ls", "-lh"])
1553
- * .stdout()
1554
- * })
1555
- *```
1611
+ * This is useful for reusability and readability by not breaking the calling chain.
1556
1612
  */
1557
1613
  with(arg) {
1558
1614
  return arg(this);
@@ -1562,11 +1618,24 @@ export class Directory extends BaseClient {
1562
1618
  * A simple key value object that represents an environment variable.
1563
1619
  */
1564
1620
  export class EnvVariable extends BaseClient {
1621
+ /**
1622
+ * Constructor is used for internal usage only, do not create object from it.
1623
+ */
1624
+ constructor(parent, _name, _value) {
1625
+ super(parent);
1626
+ this._name = undefined;
1627
+ this._value = undefined;
1628
+ this._name = _name;
1629
+ this._value = _value;
1630
+ }
1565
1631
  /**
1566
1632
  * The environment variable name.
1567
1633
  */
1568
1634
  name() {
1569
1635
  return __awaiter(this, void 0, void 0, function* () {
1636
+ if (this._name) {
1637
+ return this._name;
1638
+ }
1570
1639
  const response = yield computeQuery([
1571
1640
  ...this._queryTree,
1572
1641
  {
@@ -1581,6 +1650,9 @@ export class EnvVariable extends BaseClient {
1581
1650
  */
1582
1651
  value() {
1583
1652
  return __awaiter(this, void 0, void 0, function* () {
1653
+ if (this._value) {
1654
+ return this._value;
1655
+ }
1584
1656
  const response = yield computeQuery([
1585
1657
  ...this._queryTree,
1586
1658
  {
@@ -1590,40 +1662,35 @@ export class EnvVariable extends BaseClient {
1590
1662
  return response;
1591
1663
  });
1592
1664
  }
1593
- /**
1594
- * Chain objects together
1595
- * @example
1596
- * ```ts
1597
- * function AddAFewMounts(c) {
1598
- * return c
1599
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1600
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1601
- * }
1602
- *
1603
- * connect(async (client) => {
1604
- * const tree = await client
1605
- * .container()
1606
- * .from("alpine")
1607
- * .withWorkdir("/foo")
1608
- * .with(AddAFewMounts)
1609
- * .withExec(["ls", "-lh"])
1610
- * .stdout()
1611
- * })
1612
- *```
1613
- */
1614
- with(arg) {
1615
- return arg(this);
1616
- }
1617
1665
  }
1618
1666
  /**
1619
1667
  * A file.
1620
1668
  */
1621
1669
  export class File extends BaseClient {
1670
+ /**
1671
+ * Constructor is used for internal usage only, do not create object from it.
1672
+ */
1673
+ constructor(parent, _contents, _export, _id, _size, _sync) {
1674
+ super(parent);
1675
+ this._contents = undefined;
1676
+ this._export = undefined;
1677
+ this._id = undefined;
1678
+ this._size = undefined;
1679
+ this._sync = undefined;
1680
+ this._contents = _contents;
1681
+ this._export = _export;
1682
+ this._id = _id;
1683
+ this._size = _size;
1684
+ this._sync = _sync;
1685
+ }
1622
1686
  /**
1623
1687
  * Retrieves the contents of the file.
1624
1688
  */
1625
1689
  contents() {
1626
1690
  return __awaiter(this, void 0, void 0, function* () {
1691
+ if (this._contents) {
1692
+ return this._contents;
1693
+ }
1627
1694
  const response = yield computeQuery([
1628
1695
  ...this._queryTree,
1629
1696
  {
@@ -1641,6 +1708,9 @@ export class File extends BaseClient {
1641
1708
  */
1642
1709
  export(path, opts) {
1643
1710
  return __awaiter(this, void 0, void 0, function* () {
1711
+ if (this._export) {
1712
+ return this._export;
1713
+ }
1644
1714
  const response = yield computeQuery([
1645
1715
  ...this._queryTree,
1646
1716
  {
@@ -1656,6 +1726,9 @@ export class File extends BaseClient {
1656
1726
  */
1657
1727
  id() {
1658
1728
  return __awaiter(this, void 0, void 0, function* () {
1729
+ if (this._id) {
1730
+ return this._id;
1731
+ }
1659
1732
  const response = yield computeQuery([
1660
1733
  ...this._queryTree,
1661
1734
  {
@@ -1666,33 +1739,34 @@ export class File extends BaseClient {
1666
1739
  });
1667
1740
  }
1668
1741
  /**
1669
- * Retrieves a secret referencing the contents of this file.
1670
- * @deprecated insecure, leaves secret in cache. Superseded by setSecret
1742
+ * Gets the size of the file, in bytes.
1671
1743
  */
1672
- secret() {
1673
- return new Secret({
1674
- queryTree: [
1744
+ size() {
1745
+ return __awaiter(this, void 0, void 0, function* () {
1746
+ if (this._size) {
1747
+ return this._size;
1748
+ }
1749
+ const response = yield computeQuery([
1675
1750
  ...this._queryTree,
1676
1751
  {
1677
- operation: "secret",
1752
+ operation: "size",
1678
1753
  },
1679
- ],
1680
- host: this.clientHost,
1681
- sessionToken: this.sessionToken,
1754
+ ], this.client);
1755
+ return response;
1682
1756
  });
1683
1757
  }
1684
1758
  /**
1685
- * Gets the size of the file, in bytes.
1759
+ * Force evaluation in the engine.
1686
1760
  */
1687
- size() {
1761
+ sync() {
1688
1762
  return __awaiter(this, void 0, void 0, function* () {
1689
- const response = yield computeQuery([
1763
+ yield computeQuery([
1690
1764
  ...this._queryTree,
1691
1765
  {
1692
- operation: "size",
1766
+ operation: "sync",
1693
1767
  },
1694
1768
  ], this.client);
1695
- return response;
1769
+ return this;
1696
1770
  });
1697
1771
  }
1698
1772
  /**
@@ -1715,25 +1789,9 @@ export class File extends BaseClient {
1715
1789
  });
1716
1790
  }
1717
1791
  /**
1718
- * Chain objects together
1719
- * @example
1720
- * ```ts
1721
- * function AddAFewMounts(c) {
1722
- * return c
1723
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1724
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1725
- * }
1792
+ * Call the provided function with current File.
1726
1793
  *
1727
- * connect(async (client) => {
1728
- * const tree = await client
1729
- * .container()
1730
- * .from("alpine")
1731
- * .withWorkdir("/foo")
1732
- * .with(AddAFewMounts)
1733
- * .withExec(["ls", "-lh"])
1734
- * .stdout()
1735
- * })
1736
- *```
1794
+ * This is useful for reusability and readability by not breaking the calling chain.
1737
1795
  */
1738
1796
  with(arg) {
1739
1797
  return arg(this);
@@ -1744,18 +1802,10 @@ export class File extends BaseClient {
1744
1802
  */
1745
1803
  export class GitRef extends BaseClient {
1746
1804
  /**
1747
- * The digest of the current value of this ref.
1805
+ * Constructor is used for internal usage only, do not create object from it.
1748
1806
  */
1749
- digest() {
1750
- return __awaiter(this, void 0, void 0, function* () {
1751
- const response = yield computeQuery([
1752
- ...this._queryTree,
1753
- {
1754
- operation: "digest",
1755
- },
1756
- ], this.client);
1757
- return response;
1758
- });
1807
+ constructor(parent) {
1808
+ super(parent);
1759
1809
  }
1760
1810
  /**
1761
1811
  * The filesystem tree at this ref.
@@ -1773,35 +1823,17 @@ export class GitRef extends BaseClient {
1773
1823
  sessionToken: this.sessionToken,
1774
1824
  });
1775
1825
  }
1776
- /**
1777
- * Chain objects together
1778
- * @example
1779
- * ```ts
1780
- * function AddAFewMounts(c) {
1781
- * return c
1782
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1783
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1784
- * }
1785
- *
1786
- * connect(async (client) => {
1787
- * const tree = await client
1788
- * .container()
1789
- * .from("alpine")
1790
- * .withWorkdir("/foo")
1791
- * .with(AddAFewMounts)
1792
- * .withExec(["ls", "-lh"])
1793
- * .stdout()
1794
- * })
1795
- *```
1796
- */
1797
- with(arg) {
1798
- return arg(this);
1799
- }
1800
1826
  }
1801
1827
  /**
1802
1828
  * A git repository.
1803
1829
  */
1804
1830
  export class GitRepository extends BaseClient {
1831
+ /**
1832
+ * Constructor is used for internal usage only, do not create object from it.
1833
+ */
1834
+ constructor(parent) {
1835
+ super(parent);
1836
+ }
1805
1837
  /**
1806
1838
  * Returns details on one branch.
1807
1839
  * @param name Branch's name (e.g., "main").
@@ -1819,20 +1851,6 @@ export class GitRepository extends BaseClient {
1819
1851
  sessionToken: this.sessionToken,
1820
1852
  });
1821
1853
  }
1822
- /**
1823
- * Lists of branches on the repository.
1824
- */
1825
- branches() {
1826
- return __awaiter(this, void 0, void 0, function* () {
1827
- const response = yield computeQuery([
1828
- ...this._queryTree,
1829
- {
1830
- operation: "branches",
1831
- },
1832
- ], this.client);
1833
- return response;
1834
- });
1835
- }
1836
1854
  /**
1837
1855
  * Returns details on one commit.
1838
1856
  * @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
@@ -1867,49 +1885,17 @@ export class GitRepository extends BaseClient {
1867
1885
  sessionToken: this.sessionToken,
1868
1886
  });
1869
1887
  }
1870
- /**
1871
- * Lists of tags on the repository.
1872
- */
1873
- tags() {
1874
- return __awaiter(this, void 0, void 0, function* () {
1875
- const response = yield computeQuery([
1876
- ...this._queryTree,
1877
- {
1878
- operation: "tags",
1879
- },
1880
- ], this.client);
1881
- return response;
1882
- });
1883
- }
1884
- /**
1885
- * Chain objects together
1886
- * @example
1887
- * ```ts
1888
- * function AddAFewMounts(c) {
1889
- * return c
1890
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
1891
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
1892
- * }
1893
- *
1894
- * connect(async (client) => {
1895
- * const tree = await client
1896
- * .container()
1897
- * .from("alpine")
1898
- * .withWorkdir("/foo")
1899
- * .with(AddAFewMounts)
1900
- * .withExec(["ls", "-lh"])
1901
- * .stdout()
1902
- * })
1903
- *```
1904
- */
1905
- with(arg) {
1906
- return arg(this);
1907
- }
1908
1888
  }
1909
1889
  /**
1910
1890
  * Information about the host execution environment.
1911
1891
  */
1912
1892
  export class Host extends BaseClient {
1893
+ /**
1894
+ * Constructor is used for internal usage only, do not create object from it.
1895
+ */
1896
+ constructor(parent) {
1897
+ super(parent);
1898
+ }
1913
1899
  /**
1914
1900
  * Accesses a directory on the host.
1915
1901
  * @param path Location of the directory to access (e.g., ".").
@@ -1929,23 +1915,6 @@ export class Host extends BaseClient {
1929
1915
  sessionToken: this.sessionToken,
1930
1916
  });
1931
1917
  }
1932
- /**
1933
- * Accesses an environment variable on the host.
1934
- * @param name Name of the environment variable (e.g., "PATH").
1935
- */
1936
- envVariable(name) {
1937
- return new HostVariable({
1938
- queryTree: [
1939
- ...this._queryTree,
1940
- {
1941
- operation: "envVariable",
1942
- args: { name },
1943
- },
1944
- ],
1945
- host: this.clientHost,
1946
- sessionToken: this.sessionToken,
1947
- });
1948
- }
1949
1918
  /**
1950
1919
  * Accesses a file on the host.
1951
1920
  * @param path Location of the file to retrieve (e.g., "README.md").
@@ -1964,16 +1933,18 @@ export class Host extends BaseClient {
1964
1933
  });
1965
1934
  }
1966
1935
  /**
1967
- * Accesses a Unix socket on the host.
1968
- * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
1936
+ * Sets a secret given a user-defined name and the file path on the host, and returns the secret.
1937
+ * The file is limited to a size of 512000 bytes.
1938
+ * @param name The user defined name for this secret.
1939
+ * @param path Location of the file to set as a secret.
1969
1940
  */
1970
- unixSocket(path) {
1971
- return new Socket({
1941
+ setSecretFile(name, path) {
1942
+ return new Secret({
1972
1943
  queryTree: [
1973
1944
  ...this._queryTree,
1974
1945
  {
1975
- operation: "unixSocket",
1976
- args: { path },
1946
+ operation: "setSecretFile",
1947
+ args: { name, path },
1977
1948
  },
1978
1949
  ],
1979
1950
  host: this.clientHost,
@@ -1981,117 +1952,45 @@ export class Host extends BaseClient {
1981
1952
  });
1982
1953
  }
1983
1954
  /**
1984
- * Retrieves the current working directory on the host.
1985
- * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1986
- * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
1987
- * @deprecated Use directory with path set to '.' instead.
1955
+ * Accesses a Unix socket on the host.
1956
+ * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
1988
1957
  */
1989
- workdir(opts) {
1990
- return new Directory({
1958
+ unixSocket(path) {
1959
+ return new Socket({
1991
1960
  queryTree: [
1992
1961
  ...this._queryTree,
1993
1962
  {
1994
- operation: "workdir",
1995
- args: Object.assign({}, opts),
1963
+ operation: "unixSocket",
1964
+ args: { path },
1996
1965
  },
1997
1966
  ],
1998
1967
  host: this.clientHost,
1999
1968
  sessionToken: this.sessionToken,
2000
1969
  });
2001
1970
  }
2002
- /**
2003
- * Chain objects together
2004
- * @example
2005
- * ```ts
2006
- * function AddAFewMounts(c) {
2007
- * return c
2008
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2009
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2010
- * }
2011
- *
2012
- * connect(async (client) => {
2013
- * const tree = await client
2014
- * .container()
2015
- * .from("alpine")
2016
- * .withWorkdir("/foo")
2017
- * .with(AddAFewMounts)
2018
- * .withExec(["ls", "-lh"])
2019
- * .stdout()
2020
- * })
2021
- *```
2022
- */
2023
- with(arg) {
2024
- return arg(this);
2025
- }
2026
1971
  }
2027
1972
  /**
2028
- * An environment variable on the host environment.
1973
+ * A simple key value object that represents a label.
2029
1974
  */
2030
- export class HostVariable extends BaseClient {
2031
- /**
2032
- * A secret referencing the value of this variable.
2033
- * @deprecated been superseded by setSecret
2034
- */
2035
- secret() {
2036
- return new Secret({
2037
- queryTree: [
2038
- ...this._queryTree,
2039
- {
2040
- operation: "secret",
2041
- },
2042
- ],
2043
- host: this.clientHost,
2044
- sessionToken: this.sessionToken,
2045
- });
2046
- }
2047
- /**
2048
- * The value of this variable.
2049
- */
2050
- value() {
2051
- return __awaiter(this, void 0, void 0, function* () {
2052
- const response = yield computeQuery([
2053
- ...this._queryTree,
2054
- {
2055
- operation: "value",
2056
- },
2057
- ], this.client);
2058
- return response;
2059
- });
2060
- }
1975
+ export class Label extends BaseClient {
2061
1976
  /**
2062
- * Chain objects together
2063
- * @example
2064
- * ```ts
2065
- * function AddAFewMounts(c) {
2066
- * return c
2067
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2068
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2069
- * }
2070
- *
2071
- * connect(async (client) => {
2072
- * const tree = await client
2073
- * .container()
2074
- * .from("alpine")
2075
- * .withWorkdir("/foo")
2076
- * .with(AddAFewMounts)
2077
- * .withExec(["ls", "-lh"])
2078
- * .stdout()
2079
- * })
2080
- *```
1977
+ * Constructor is used for internal usage only, do not create object from it.
2081
1978
  */
2082
- with(arg) {
2083
- return arg(this);
1979
+ constructor(parent, _name, _value) {
1980
+ super(parent);
1981
+ this._name = undefined;
1982
+ this._value = undefined;
1983
+ this._name = _name;
1984
+ this._value = _value;
2084
1985
  }
2085
- }
2086
- /**
2087
- * A simple key value object that represents a label.
2088
- */
2089
- export class Label extends BaseClient {
2090
1986
  /**
2091
1987
  * The label name.
2092
1988
  */
2093
1989
  name() {
2094
1990
  return __awaiter(this, void 0, void 0, function* () {
1991
+ if (this._name) {
1992
+ return this._name;
1993
+ }
2095
1994
  const response = yield computeQuery([
2096
1995
  ...this._queryTree,
2097
1996
  {
@@ -2106,6 +2005,9 @@ export class Label extends BaseClient {
2106
2005
  */
2107
2006
  value() {
2108
2007
  return __awaiter(this, void 0, void 0, function* () {
2008
+ if (this._value) {
2009
+ return this._value;
2010
+ }
2109
2011
  const response = yield computeQuery([
2110
2012
  ...this._queryTree,
2111
2013
  {
@@ -2115,40 +2017,31 @@ export class Label extends BaseClient {
2115
2017
  return response;
2116
2018
  });
2117
2019
  }
2118
- /**
2119
- * Chain objects together
2120
- * @example
2121
- * ```ts
2122
- * function AddAFewMounts(c) {
2123
- * return c
2124
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2125
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2126
- * }
2127
- *
2128
- * connect(async (client) => {
2129
- * const tree = await client
2130
- * .container()
2131
- * .from("alpine")
2132
- * .withWorkdir("/foo")
2133
- * .with(AddAFewMounts)
2134
- * .withExec(["ls", "-lh"])
2135
- * .stdout()
2136
- * })
2137
- *```
2138
- */
2139
- with(arg) {
2140
- return arg(this);
2141
- }
2142
2020
  }
2143
2021
  /**
2144
2022
  * A port exposed by a container.
2145
2023
  */
2146
2024
  export class Port extends BaseClient {
2025
+ /**
2026
+ * Constructor is used for internal usage only, do not create object from it.
2027
+ */
2028
+ constructor(parent, _description, _port, _protocol) {
2029
+ super(parent);
2030
+ this._description = undefined;
2031
+ this._port = undefined;
2032
+ this._protocol = undefined;
2033
+ this._description = _description;
2034
+ this._port = _port;
2035
+ this._protocol = _protocol;
2036
+ }
2147
2037
  /**
2148
2038
  * The port description.
2149
2039
  */
2150
2040
  description() {
2151
2041
  return __awaiter(this, void 0, void 0, function* () {
2042
+ if (this._description) {
2043
+ return this._description;
2044
+ }
2152
2045
  const response = yield computeQuery([
2153
2046
  ...this._queryTree,
2154
2047
  {
@@ -2163,6 +2056,9 @@ export class Port extends BaseClient {
2163
2056
  */
2164
2057
  port() {
2165
2058
  return __awaiter(this, void 0, void 0, function* () {
2059
+ if (this._port) {
2060
+ return this._port;
2061
+ }
2166
2062
  const response = yield computeQuery([
2167
2063
  ...this._queryTree,
2168
2064
  {
@@ -2177,6 +2073,9 @@ export class Port extends BaseClient {
2177
2073
  */
2178
2074
  protocol() {
2179
2075
  return __awaiter(this, void 0, void 0, function* () {
2076
+ if (this._protocol) {
2077
+ return this._protocol;
2078
+ }
2180
2079
  const response = yield computeQuery([
2181
2080
  ...this._queryTree,
2182
2081
  {
@@ -2186,35 +2085,21 @@ export class Port extends BaseClient {
2186
2085
  return response;
2187
2086
  });
2188
2087
  }
2189
- /**
2190
- * Chain objects together
2191
- * @example
2192
- * ```ts
2193
- * function AddAFewMounts(c) {
2194
- * return c
2195
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2196
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2197
- * }
2198
- *
2199
- * connect(async (client) => {
2200
- * const tree = await client
2201
- * .container()
2202
- * .from("alpine")
2203
- * .withWorkdir("/foo")
2204
- * .with(AddAFewMounts)
2205
- * .withExec(["ls", "-lh"])
2206
- * .stdout()
2207
- * })
2208
- *```
2209
- */
2210
- with(arg) {
2211
- return arg(this);
2212
- }
2213
2088
  }
2214
2089
  /**
2215
2090
  * A collection of Dagger resources that can be queried and invoked.
2216
2091
  */
2217
2092
  export class Project extends BaseClient {
2093
+ /**
2094
+ * Constructor is used for internal usage only, do not create object from it.
2095
+ */
2096
+ constructor(parent, _id, _name) {
2097
+ super(parent);
2098
+ this._id = undefined;
2099
+ this._name = undefined;
2100
+ this._id = _id;
2101
+ this._name = _name;
2102
+ }
2218
2103
  /**
2219
2104
  * Commands provided by this project
2220
2105
  */
@@ -2225,8 +2110,15 @@ export class Project extends BaseClient {
2225
2110
  {
2226
2111
  operation: "commands",
2227
2112
  },
2113
+ {
2114
+ operation: "description id name resultType",
2115
+ },
2228
2116
  ], this.client);
2229
- return response;
2117
+ return response.map((r) => new ProjectCommand({
2118
+ queryTree: this.queryTree,
2119
+ host: this.clientHost,
2120
+ sessionToken: this.sessionToken,
2121
+ }, r.description, r.id, r.name, r.resultType));
2230
2122
  });
2231
2123
  }
2232
2124
  /**
@@ -2234,6 +2126,9 @@ export class Project extends BaseClient {
2234
2126
  */
2235
2127
  id() {
2236
2128
  return __awaiter(this, void 0, void 0, function* () {
2129
+ if (this._id) {
2130
+ return this._id;
2131
+ }
2237
2132
  const response = yield computeQuery([
2238
2133
  ...this._queryTree,
2239
2134
  {
@@ -2264,6 +2159,9 @@ export class Project extends BaseClient {
2264
2159
  */
2265
2160
  name() {
2266
2161
  return __awaiter(this, void 0, void 0, function* () {
2162
+ if (this._name) {
2163
+ return this._name;
2164
+ }
2267
2165
  const response = yield computeQuery([
2268
2166
  ...this._queryTree,
2269
2167
  {
@@ -2274,25 +2172,9 @@ export class Project extends BaseClient {
2274
2172
  });
2275
2173
  }
2276
2174
  /**
2277
- * Chain objects together
2278
- * @example
2279
- * ```ts
2280
- * function AddAFewMounts(c) {
2281
- * return c
2282
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2283
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2284
- * }
2175
+ * Call the provided function with current Project.
2285
2176
  *
2286
- * connect(async (client) => {
2287
- * const tree = await client
2288
- * .container()
2289
- * .from("alpine")
2290
- * .withWorkdir("/foo")
2291
- * .with(AddAFewMounts)
2292
- * .withExec(["ls", "-lh"])
2293
- * .stdout()
2294
- * })
2295
- *```
2177
+ * This is useful for reusability and readability by not breaking the calling chain.
2296
2178
  */
2297
2179
  with(arg) {
2298
2180
  return arg(this);
@@ -2302,11 +2184,28 @@ export class Project extends BaseClient {
2302
2184
  * A command defined in a project that can be invoked from the CLI.
2303
2185
  */
2304
2186
  export class ProjectCommand extends BaseClient {
2187
+ /**
2188
+ * Constructor is used for internal usage only, do not create object from it.
2189
+ */
2190
+ constructor(parent, _description, _id, _name, _resultType) {
2191
+ super(parent);
2192
+ this._description = undefined;
2193
+ this._id = undefined;
2194
+ this._name = undefined;
2195
+ this._resultType = undefined;
2196
+ this._description = _description;
2197
+ this._id = _id;
2198
+ this._name = _name;
2199
+ this._resultType = _resultType;
2200
+ }
2305
2201
  /**
2306
2202
  * Documentation for what this command does.
2307
2203
  */
2308
2204
  description() {
2309
2205
  return __awaiter(this, void 0, void 0, function* () {
2206
+ if (this._description) {
2207
+ return this._description;
2208
+ }
2310
2209
  const response = yield computeQuery([
2311
2210
  ...this._queryTree,
2312
2211
  {
@@ -2326,8 +2225,15 @@ export class ProjectCommand extends BaseClient {
2326
2225
  {
2327
2226
  operation: "flags",
2328
2227
  },
2228
+ {
2229
+ operation: "description name",
2230
+ },
2329
2231
  ], this.client);
2330
- return response;
2232
+ return response.map((r) => new ProjectCommandFlag({
2233
+ queryTree: this.queryTree,
2234
+ host: this.clientHost,
2235
+ sessionToken: this.sessionToken,
2236
+ }, r.description, r.name));
2331
2237
  });
2332
2238
  }
2333
2239
  /**
@@ -2335,6 +2241,9 @@ export class ProjectCommand extends BaseClient {
2335
2241
  */
2336
2242
  id() {
2337
2243
  return __awaiter(this, void 0, void 0, function* () {
2244
+ if (this._id) {
2245
+ return this._id;
2246
+ }
2338
2247
  const response = yield computeQuery([
2339
2248
  ...this._queryTree,
2340
2249
  {
@@ -2349,6 +2258,9 @@ export class ProjectCommand extends BaseClient {
2349
2258
  */
2350
2259
  name() {
2351
2260
  return __awaiter(this, void 0, void 0, function* () {
2261
+ if (this._name) {
2262
+ return this._name;
2263
+ }
2352
2264
  const response = yield computeQuery([
2353
2265
  ...this._queryTree,
2354
2266
  {
@@ -2363,6 +2275,9 @@ export class ProjectCommand extends BaseClient {
2363
2275
  */
2364
2276
  resultType() {
2365
2277
  return __awaiter(this, void 0, void 0, function* () {
2278
+ if (this._resultType) {
2279
+ return this._resultType;
2280
+ }
2366
2281
  const response = yield computeQuery([
2367
2282
  ...this._queryTree,
2368
2283
  {
@@ -2382,44 +2297,40 @@ export class ProjectCommand extends BaseClient {
2382
2297
  {
2383
2298
  operation: "subcommands",
2384
2299
  },
2300
+ {
2301
+ operation: "description id name resultType",
2302
+ },
2385
2303
  ], this.client);
2386
- return response;
2304
+ return response.map((r) => new ProjectCommand({
2305
+ queryTree: this.queryTree,
2306
+ host: this.clientHost,
2307
+ sessionToken: this.sessionToken,
2308
+ }, r.description, r.id, r.name, r.resultType));
2387
2309
  });
2388
2310
  }
2389
- /**
2390
- * Chain objects together
2391
- * @example
2392
- * ```ts
2393
- * function AddAFewMounts(c) {
2394
- * return c
2395
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2396
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2397
- * }
2398
- *
2399
- * connect(async (client) => {
2400
- * const tree = await client
2401
- * .container()
2402
- * .from("alpine")
2403
- * .withWorkdir("/foo")
2404
- * .with(AddAFewMounts)
2405
- * .withExec(["ls", "-lh"])
2406
- * .stdout()
2407
- * })
2408
- *```
2409
- */
2410
- with(arg) {
2411
- return arg(this);
2412
- }
2413
2311
  }
2414
2312
  /**
2415
2313
  * A flag accepted by a project command.
2416
2314
  */
2417
2315
  export class ProjectCommandFlag extends BaseClient {
2316
+ /**
2317
+ * Constructor is used for internal usage only, do not create object from it.
2318
+ */
2319
+ constructor(parent, _description, _name) {
2320
+ super(parent);
2321
+ this._description = undefined;
2322
+ this._name = undefined;
2323
+ this._description = _description;
2324
+ this._name = _name;
2325
+ }
2418
2326
  /**
2419
2327
  * Documentation for what this flag sets.
2420
2328
  */
2421
2329
  description() {
2422
2330
  return __awaiter(this, void 0, void 0, function* () {
2331
+ if (this._description) {
2332
+ return this._description;
2333
+ }
2423
2334
  const response = yield computeQuery([
2424
2335
  ...this._queryTree,
2425
2336
  {
@@ -2434,6 +2345,9 @@ export class ProjectCommandFlag extends BaseClient {
2434
2345
  */
2435
2346
  name() {
2436
2347
  return __awaiter(this, void 0, void 0, function* () {
2348
+ if (this._name) {
2349
+ return this._name;
2350
+ }
2437
2351
  const response = yield computeQuery([
2438
2352
  ...this._queryTree,
2439
2353
  {
@@ -2443,32 +2357,18 @@ export class ProjectCommandFlag extends BaseClient {
2443
2357
  return response;
2444
2358
  });
2445
2359
  }
2360
+ }
2361
+ export class Client extends BaseClient {
2446
2362
  /**
2447
- * Chain objects together
2448
- * @example
2449
- * ```ts
2450
- * function AddAFewMounts(c) {
2451
- * return c
2452
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2453
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2454
- * }
2455
- *
2456
- * connect(async (client) => {
2457
- * const tree = await client
2458
- * .container()
2459
- * .from("alpine")
2460
- * .withWorkdir("/foo")
2461
- * .with(AddAFewMounts)
2462
- * .withExec(["ls", "-lh"])
2463
- * .stdout()
2464
- * })
2465
- *```
2363
+ * Constructor is used for internal usage only, do not create object from it.
2466
2364
  */
2467
- with(arg) {
2468
- return arg(this);
2365
+ constructor(parent, _checkVersionCompatibility, _defaultPlatform) {
2366
+ super(parent);
2367
+ this._checkVersionCompatibility = undefined;
2368
+ this._defaultPlatform = undefined;
2369
+ this._checkVersionCompatibility = _checkVersionCompatibility;
2370
+ this._defaultPlatform = _defaultPlatform;
2469
2371
  }
2470
- }
2471
- export default class Client extends BaseClient {
2472
2372
  /**
2473
2373
  * Constructs a cache volume for a given cache key.
2474
2374
  * @param key A string identifier to target this cache volume (e.g., "modules-cache").
@@ -2486,6 +2386,22 @@ export default class Client extends BaseClient {
2486
2386
  sessionToken: this.sessionToken,
2487
2387
  });
2488
2388
  }
2389
+ /**
2390
+ * Checks if the current Dagger Engine is compatible with an SDK's required version.
2391
+ * @param version The SDK's required version.
2392
+ */
2393
+ checkVersionCompatibility(version) {
2394
+ return __awaiter(this, void 0, void 0, function* () {
2395
+ const response = yield computeQuery([
2396
+ ...this._queryTree,
2397
+ {
2398
+ operation: "checkVersionCompatibility",
2399
+ args: { version },
2400
+ },
2401
+ ], this.client);
2402
+ return response;
2403
+ });
2404
+ }
2489
2405
  /**
2490
2406
  * Loads a container from ID.
2491
2407
  *
@@ -2708,16 +2624,37 @@ export default class Client extends BaseClient {
2708
2624
  sessionToken: this.sessionToken,
2709
2625
  });
2710
2626
  }
2627
+ /**
2628
+ * Call the provided function with current Client.
2629
+ *
2630
+ * This is useful for reusability and readability by not breaking the calling chain.
2631
+ */
2632
+ with(arg) {
2633
+ return arg(this);
2634
+ }
2711
2635
  }
2712
2636
  /**
2713
2637
  * A reference to a secret value, which can be handled more safely than the value itself.
2714
2638
  */
2715
2639
  export class Secret extends BaseClient {
2640
+ /**
2641
+ * Constructor is used for internal usage only, do not create object from it.
2642
+ */
2643
+ constructor(parent, _id, _plaintext) {
2644
+ super(parent);
2645
+ this._id = undefined;
2646
+ this._plaintext = undefined;
2647
+ this._id = _id;
2648
+ this._plaintext = _plaintext;
2649
+ }
2716
2650
  /**
2717
2651
  * The identifier for this secret.
2718
2652
  */
2719
2653
  id() {
2720
2654
  return __awaiter(this, void 0, void 0, function* () {
2655
+ if (this._id) {
2656
+ return this._id;
2657
+ }
2721
2658
  const response = yield computeQuery([
2722
2659
  ...this._queryTree,
2723
2660
  {
@@ -2732,6 +2669,9 @@ export class Secret extends BaseClient {
2732
2669
  */
2733
2670
  plaintext() {
2734
2671
  return __awaiter(this, void 0, void 0, function* () {
2672
+ if (this._plaintext) {
2673
+ return this._plaintext;
2674
+ }
2735
2675
  const response = yield computeQuery([
2736
2676
  ...this._queryTree,
2737
2677
  {
@@ -2741,37 +2681,24 @@ export class Secret extends BaseClient {
2741
2681
  return response;
2742
2682
  });
2743
2683
  }
2684
+ }
2685
+ export class Socket extends BaseClient {
2744
2686
  /**
2745
- * Chain objects together
2746
- * @example
2747
- * ```ts
2748
- * function AddAFewMounts(c) {
2749
- * return c
2750
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2751
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2752
- * }
2753
- *
2754
- * connect(async (client) => {
2755
- * const tree = await client
2756
- * .container()
2757
- * .from("alpine")
2758
- * .withWorkdir("/foo")
2759
- * .with(AddAFewMounts)
2760
- * .withExec(["ls", "-lh"])
2761
- * .stdout()
2762
- * })
2763
- *```
2687
+ * Constructor is used for internal usage only, do not create object from it.
2764
2688
  */
2765
- with(arg) {
2766
- return arg(this);
2689
+ constructor(parent, _id) {
2690
+ super(parent);
2691
+ this._id = undefined;
2692
+ this._id = _id;
2767
2693
  }
2768
- }
2769
- export class Socket extends BaseClient {
2770
2694
  /**
2771
2695
  * The content-addressed identifier of the socket.
2772
2696
  */
2773
2697
  id() {
2774
2698
  return __awaiter(this, void 0, void 0, function* () {
2699
+ if (this._id) {
2700
+ return this._id;
2701
+ }
2775
2702
  const response = yield computeQuery([
2776
2703
  ...this._queryTree,
2777
2704
  {
@@ -2781,28 +2708,4 @@ export class Socket extends BaseClient {
2781
2708
  return response;
2782
2709
  });
2783
2710
  }
2784
- /**
2785
- * Chain objects together
2786
- * @example
2787
- * ```ts
2788
- * function AddAFewMounts(c) {
2789
- * return c
2790
- * .withMountedDirectory("/foo", new Client().host().directory("/Users/slumbering/forks/dagger"))
2791
- * .withMountedDirectory("/bar", new Client().host().directory("/Users/slumbering/forks/dagger/sdk/nodejs"))
2792
- * }
2793
- *
2794
- * connect(async (client) => {
2795
- * const tree = await client
2796
- * .container()
2797
- * .from("alpine")
2798
- * .withWorkdir("/foo")
2799
- * .with(AddAFewMounts)
2800
- * .withExec(["ls", "-lh"])
2801
- * .stdout()
2802
- * })
2803
- *```
2804
- */
2805
- with(arg) {
2806
- return arg(this);
2807
- }
2808
2711
  }