@dagger.io/dagger 0.8.7 → 0.9.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.
@@ -85,6 +85,44 @@ export var NetworkProtocol;
85
85
  */
86
86
  NetworkProtocol["Udp"] = "UDP";
87
87
  })(NetworkProtocol || (NetworkProtocol = {}));
88
+ /**
89
+ * Distinguishes the different kinds of TypeDefs.
90
+ */
91
+ export var TypeDefKind;
92
+ (function (TypeDefKind) {
93
+ /**
94
+ * A boolean value
95
+ */
96
+ TypeDefKind["Booleankind"] = "BooleanKind";
97
+ /**
98
+ * An integer value
99
+ */
100
+ TypeDefKind["Integerkind"] = "IntegerKind";
101
+ /**
102
+ * A list of values all having the same type.
103
+ *
104
+ * Always paired with a ListTypeDef.
105
+ */
106
+ TypeDefKind["Listkind"] = "ListKind";
107
+ /**
108
+ * A named type defined in the GraphQL schema, with fields and functions.
109
+ *
110
+ * Always paired with an ObjectTypeDef.
111
+ */
112
+ TypeDefKind["Objectkind"] = "ObjectKind";
113
+ /**
114
+ * A string value
115
+ */
116
+ TypeDefKind["Stringkind"] = "StringKind";
117
+ /**
118
+ * A special kind used to signify that no value is returned.
119
+ *
120
+ * This is used for functions that have no return value. The outer TypeDef
121
+ * specifying this Kind is always Optional, as the Void is never actually
122
+ * represented.
123
+ */
124
+ TypeDefKind["Voidkind"] = "VoidKind";
125
+ })(TypeDefKind || (TypeDefKind = {}));
88
126
  /**
89
127
  * A directory whose contents persist across runs.
90
128
  */
@@ -119,37 +157,99 @@ export class Container extends BaseClient {
119
157
  /**
120
158
  * Constructor is used for internal usage only, do not create object from it.
121
159
  */
122
- constructor(parent, _endpoint, _envVariable, _export, _hostname, _id, _imageRef, _label, _platform, _publish, _stderr, _stdout, _sync, _user, _workdir) {
160
+ constructor(parent, _id, _envVariable, _export, _imageRef, _label, _platform, _publish, _shellEndpoint, _stderr, _stdout, _sync, _user, _workdir) {
123
161
  super(parent);
124
- this._endpoint = undefined;
162
+ this._id = undefined;
125
163
  this._envVariable = undefined;
126
164
  this._export = undefined;
127
- this._hostname = undefined;
128
- this._id = undefined;
129
165
  this._imageRef = undefined;
130
166
  this._label = undefined;
131
167
  this._platform = undefined;
132
168
  this._publish = undefined;
169
+ this._shellEndpoint = undefined;
133
170
  this._stderr = undefined;
134
171
  this._stdout = undefined;
135
172
  this._sync = undefined;
136
173
  this._user = undefined;
137
174
  this._workdir = undefined;
138
- this._endpoint = _endpoint;
175
+ this._id = _id;
139
176
  this._envVariable = _envVariable;
140
177
  this._export = _export;
141
- this._hostname = _hostname;
142
- this._id = _id;
143
178
  this._imageRef = _imageRef;
144
179
  this._label = _label;
145
180
  this._platform = _platform;
146
181
  this._publish = _publish;
182
+ this._shellEndpoint = _shellEndpoint;
147
183
  this._stderr = _stderr;
148
184
  this._stdout = _stdout;
149
185
  this._sync = _sync;
150
186
  this._user = _user;
151
187
  this._workdir = _workdir;
152
188
  }
189
+ /**
190
+ * A unique identifier for this container.
191
+ */
192
+ id() {
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ if (this._id) {
195
+ return this._id;
196
+ }
197
+ const response = yield computeQuery([
198
+ ...this._queryTree,
199
+ {
200
+ operation: "id",
201
+ },
202
+ ], this.client);
203
+ return response;
204
+ });
205
+ }
206
+ /**
207
+ * Turn the container into a Service.
208
+ *
209
+ * Be sure to set any exposed ports before this conversion.
210
+ */
211
+ asService() {
212
+ return new Service({
213
+ queryTree: [
214
+ ...this._queryTree,
215
+ {
216
+ operation: "asService",
217
+ },
218
+ ],
219
+ host: this.clientHost,
220
+ sessionToken: this.sessionToken,
221
+ });
222
+ }
223
+ /**
224
+ * Returns a File representing the container serialized to a tarball.
225
+ * @param opts.platformVariants Identifiers for other platform specific containers.
226
+ * Used for multi-platform image.
227
+ * @param opts.forcedCompression Force each layer of the image to use the specified compression algorithm.
228
+ * If this is unset, then if a layer already has a compressed blob in the engine's
229
+ * cache, that will be used (this can result in a mix of compression algorithms for
230
+ * different layers). If this is unset and a layer has no compressed blob in the
231
+ * engine's cache, then it will be compressed using Gzip.
232
+ * @param opts.mediaTypes Use the specified media types for the image's layers. Defaults to OCI, which
233
+ * is largely compatible with most recent container runtimes, but Docker may be needed
234
+ * for older runtimes without OCI support.
235
+ */
236
+ asTarball(opts) {
237
+ const metadata = {
238
+ forcedCompression: { is_enum: true },
239
+ mediaTypes: { is_enum: true },
240
+ };
241
+ return new File({
242
+ queryTree: [
243
+ ...this._queryTree,
244
+ {
245
+ operation: "asTarball",
246
+ args: Object.assign(Object.assign({}, opts), { __metadata: metadata }),
247
+ },
248
+ ],
249
+ host: this.clientHost,
250
+ sessionToken: this.sessionToken,
251
+ });
252
+ }
153
253
  /**
154
254
  * Initializes this container from a Dockerfile build.
155
255
  * @param context Directory context used by the Dockerfile.
@@ -212,32 +312,6 @@ export class Container extends BaseClient {
212
312
  sessionToken: this.sessionToken,
213
313
  });
214
314
  }
215
- /**
216
- * Retrieves an endpoint that clients can use to reach this container.
217
- *
218
- * If no port is specified, the first exposed port is used. If none exist an error is returned.
219
- *
220
- * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
221
- *
222
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
223
- * @param opts.port The exposed port number for the endpoint
224
- * @param opts.scheme Return a URL with the given scheme, eg. http for http://
225
- */
226
- endpoint(opts) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- if (this._endpoint) {
229
- return this._endpoint;
230
- }
231
- const response = yield computeQuery([
232
- ...this._queryTree,
233
- {
234
- operation: "endpoint",
235
- args: Object.assign({}, opts),
236
- },
237
- ], this.client);
238
- return response;
239
- });
240
- }
241
315
  /**
242
316
  * Retrieves entrypoint to be prepended to the arguments of all commands.
243
317
  */
@@ -334,8 +408,6 @@ export class Container extends BaseClient {
334
408
  *
335
409
  * This includes ports already exposed by the image, even if not
336
410
  * explicitly added with dagger.
337
- *
338
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
339
411
  */
340
412
  exposedPorts() {
341
413
  return __awaiter(this, void 0, void 0, function* () {
@@ -393,42 +465,6 @@ export class Container extends BaseClient {
393
465
  sessionToken: this.sessionToken,
394
466
  });
395
467
  }
396
- /**
397
- * Retrieves a hostname which can be used by clients to reach this container.
398
- *
399
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
400
- */
401
- hostname() {
402
- return __awaiter(this, void 0, void 0, function* () {
403
- if (this._hostname) {
404
- return this._hostname;
405
- }
406
- const response = yield computeQuery([
407
- ...this._queryTree,
408
- {
409
- operation: "hostname",
410
- },
411
- ], this.client);
412
- return response;
413
- });
414
- }
415
- /**
416
- * A unique identifier for this container.
417
- */
418
- id() {
419
- return __awaiter(this, void 0, void 0, function* () {
420
- if (this._id) {
421
- return this._id;
422
- }
423
- const response = yield computeQuery([
424
- ...this._queryTree,
425
- {
426
- operation: "id",
427
- },
428
- ], this.client);
429
- return response;
430
- });
431
- }
432
468
  /**
433
469
  * The unique image reference which can only be retrieved immediately after the 'Container.From' call.
434
470
  */
@@ -455,7 +491,7 @@ export class Container extends BaseClient {
455
491
  * @param opts.tag Identifies the tag to import from the archive, if the archive bundles
456
492
  * multiple tags.
457
493
  */
458
- import(source, opts) {
494
+ import_(source, opts) {
459
495
  return new Container({
460
496
  queryTree: [
461
497
  ...this._queryTree,
@@ -610,6 +646,26 @@ export class Container extends BaseClient {
610
646
  sessionToken: this.sessionToken,
611
647
  });
612
648
  }
649
+ /**
650
+ * Return a websocket endpoint that, if connected to, will start the container with a TTY streamed
651
+ * over the websocket.
652
+ *
653
+ * Primarily intended for internal use with the dagger CLI.
654
+ */
655
+ shellEndpoint() {
656
+ return __awaiter(this, void 0, void 0, function* () {
657
+ if (this._shellEndpoint) {
658
+ return this._shellEndpoint;
659
+ }
660
+ const response = yield computeQuery([
661
+ ...this._queryTree,
662
+ {
663
+ operation: "shellEndpoint",
664
+ },
665
+ ], this.client);
666
+ return response;
667
+ });
668
+ }
613
669
  /**
614
670
  * The error stream of the last executed command.
615
671
  *
@@ -797,8 +853,6 @@ export class Container extends BaseClient {
797
853
  * Exposed ports serve two purposes:
798
854
  * - For health checks and introspection, when running services
799
855
  * - For setting the EXPOSE OCI field when publishing the container
800
- *
801
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
802
856
  * @param port Port number to expose
803
857
  * @param opts.protocol Transport layer network protocol
804
858
  * @param opts.description Optional port description
@@ -1090,8 +1144,6 @@ export class Container extends BaseClient {
1090
1144
  * The service will be reachable from the container via the provided hostname alias.
1091
1145
  *
1092
1146
  * The service dependency will also convey to any files or directories produced by the container.
1093
- *
1094
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
1095
1147
  * @param alias A name that can be used to reach the service from the container
1096
1148
  * @param service Identifier of the service container
1097
1149
  */
@@ -1184,8 +1236,6 @@ export class Container extends BaseClient {
1184
1236
  }
1185
1237
  /**
1186
1238
  * Unexpose a previously exposed port.
1187
- *
1188
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
1189
1239
  * @param port Port number to unexpose
1190
1240
  * @param opts.protocol Port protocol to unexpose
1191
1241
  */
@@ -1325,15 +1375,58 @@ export class Directory extends BaseClient {
1325
1375
  /**
1326
1376
  * Constructor is used for internal usage only, do not create object from it.
1327
1377
  */
1328
- constructor(parent, _export, _id, _sync) {
1378
+ constructor(parent, _id, _export, _sync) {
1329
1379
  super(parent);
1330
- this._export = undefined;
1331
1380
  this._id = undefined;
1381
+ this._export = undefined;
1332
1382
  this._sync = undefined;
1333
- this._export = _export;
1334
1383
  this._id = _id;
1384
+ this._export = _export;
1335
1385
  this._sync = _sync;
1336
1386
  }
1387
+ /**
1388
+ * The content-addressed identifier of the directory.
1389
+ */
1390
+ id() {
1391
+ return __awaiter(this, void 0, void 0, function* () {
1392
+ if (this._id) {
1393
+ return this._id;
1394
+ }
1395
+ const response = yield computeQuery([
1396
+ ...this._queryTree,
1397
+ {
1398
+ operation: "id",
1399
+ },
1400
+ ], this.client);
1401
+ return response;
1402
+ });
1403
+ }
1404
+ /**
1405
+ * Load the directory as a Dagger module
1406
+ * @param opts.sourceSubpath An optional subpath of the directory which contains the module's source
1407
+ * code.
1408
+ *
1409
+ * This is needed when the module code is in a subdirectory but requires
1410
+ * parent directories to be loaded in order to execute. For example, the
1411
+ * module source code may need a go.mod, project.toml, package.json, etc. file
1412
+ * from a parent directory.
1413
+ *
1414
+ * If not set, the module source code is loaded from the root of the
1415
+ * directory.
1416
+ */
1417
+ asModule(opts) {
1418
+ return new Module_({
1419
+ queryTree: [
1420
+ ...this._queryTree,
1421
+ {
1422
+ operation: "asModule",
1423
+ args: Object.assign({}, opts),
1424
+ },
1425
+ ],
1426
+ host: this.clientHost,
1427
+ sessionToken: this.sessionToken,
1428
+ });
1429
+ }
1337
1430
  /**
1338
1431
  * Gets the difference between this directory and an another directory.
1339
1432
  * @param other Identifier of the directory to compare.
@@ -1445,23 +1538,6 @@ export class Directory extends BaseClient {
1445
1538
  sessionToken: this.sessionToken,
1446
1539
  });
1447
1540
  }
1448
- /**
1449
- * The content-addressed identifier of the directory.
1450
- */
1451
- id() {
1452
- return __awaiter(this, void 0, void 0, function* () {
1453
- if (this._id) {
1454
- return this._id;
1455
- }
1456
- const response = yield computeQuery([
1457
- ...this._queryTree,
1458
- {
1459
- operation: "id",
1460
- },
1461
- ], this.client);
1462
- return response;
1463
- });
1464
- }
1465
1541
  /**
1466
1542
  * Creates a named sub-pipeline
1467
1543
  * @param name Pipeline name.
@@ -1689,79 +1765,145 @@ export class EnvVariable extends BaseClient {
1689
1765
  }
1690
1766
  }
1691
1767
  /**
1692
- * A file.
1768
+ * A definition of a field on a custom object defined in a Module.
1769
+ * A field on an object has a static value, as opposed to a function on an
1770
+ * object whose value is computed by invoking code (and can accept arguments).
1693
1771
  */
1694
- export class File extends BaseClient {
1772
+ export class FieldTypeDef extends BaseClient {
1695
1773
  /**
1696
1774
  * Constructor is used for internal usage only, do not create object from it.
1697
1775
  */
1698
- constructor(parent, _contents, _export, _id, _size, _sync) {
1776
+ constructor(parent, _description, _name) {
1699
1777
  super(parent);
1700
- this._contents = undefined;
1701
- this._export = undefined;
1702
- this._id = undefined;
1703
- this._size = undefined;
1704
- this._sync = undefined;
1705
- this._contents = _contents;
1706
- this._export = _export;
1707
- this._id = _id;
1708
- this._size = _size;
1709
- this._sync = _sync;
1778
+ this._description = undefined;
1779
+ this._name = undefined;
1780
+ this._description = _description;
1781
+ this._name = _name;
1710
1782
  }
1711
1783
  /**
1712
- * Retrieves the contents of the file.
1784
+ * A doc string for the field, if any
1713
1785
  */
1714
- contents() {
1786
+ description() {
1715
1787
  return __awaiter(this, void 0, void 0, function* () {
1716
- if (this._contents) {
1717
- return this._contents;
1788
+ if (this._description) {
1789
+ return this._description;
1718
1790
  }
1719
1791
  const response = yield computeQuery([
1720
1792
  ...this._queryTree,
1721
1793
  {
1722
- operation: "contents",
1794
+ operation: "description",
1723
1795
  },
1724
1796
  ], this.client);
1725
1797
  return response;
1726
1798
  });
1727
1799
  }
1728
1800
  /**
1729
- * Writes the file to a file path on the host.
1730
- * @param path Location of the written directory (e.g., "output.txt").
1731
- * @param opts.allowParentDirPath If allowParentDirPath is true, the path argument can be a directory path, in which case
1732
- * the file will be created in that directory.
1801
+ * The name of the field in the object
1733
1802
  */
1734
- export(path, opts) {
1803
+ name() {
1735
1804
  return __awaiter(this, void 0, void 0, function* () {
1736
- if (this._export) {
1737
- return this._export;
1805
+ if (this._name) {
1806
+ return this._name;
1738
1807
  }
1739
1808
  const response = yield computeQuery([
1740
1809
  ...this._queryTree,
1741
1810
  {
1742
- operation: "export",
1743
- args: Object.assign({ path }, opts),
1811
+ operation: "name",
1744
1812
  },
1745
1813
  ], this.client);
1746
1814
  return response;
1747
1815
  });
1748
1816
  }
1749
1817
  /**
1750
- * Retrieves the content-addressed identifier of the file.
1818
+ * The type of the field
1751
1819
  */
1752
- id() {
1753
- return __awaiter(this, void 0, void 0, function* () {
1754
- if (this._id) {
1755
- return this._id;
1756
- }
1757
- const response = yield computeQuery([
1820
+ typeDef() {
1821
+ return new TypeDef({
1822
+ queryTree: [
1758
1823
  ...this._queryTree,
1759
1824
  {
1760
- operation: "id",
1825
+ operation: "typeDef",
1761
1826
  },
1762
- ], this.client);
1763
- return response;
1764
- });
1827
+ ],
1828
+ host: this.clientHost,
1829
+ sessionToken: this.sessionToken,
1830
+ });
1831
+ }
1832
+ }
1833
+ /**
1834
+ * A file.
1835
+ */
1836
+ export class File extends BaseClient {
1837
+ /**
1838
+ * Constructor is used for internal usage only, do not create object from it.
1839
+ */
1840
+ constructor(parent, _id, _contents, _export, _size, _sync) {
1841
+ super(parent);
1842
+ this._id = undefined;
1843
+ this._contents = undefined;
1844
+ this._export = undefined;
1845
+ this._size = undefined;
1846
+ this._sync = undefined;
1847
+ this._id = _id;
1848
+ this._contents = _contents;
1849
+ this._export = _export;
1850
+ this._size = _size;
1851
+ this._sync = _sync;
1852
+ }
1853
+ /**
1854
+ * Retrieves the content-addressed identifier of the file.
1855
+ */
1856
+ id() {
1857
+ return __awaiter(this, void 0, void 0, function* () {
1858
+ if (this._id) {
1859
+ return this._id;
1860
+ }
1861
+ const response = yield computeQuery([
1862
+ ...this._queryTree,
1863
+ {
1864
+ operation: "id",
1865
+ },
1866
+ ], this.client);
1867
+ return response;
1868
+ });
1869
+ }
1870
+ /**
1871
+ * Retrieves the contents of the file.
1872
+ */
1873
+ contents() {
1874
+ return __awaiter(this, void 0, void 0, function* () {
1875
+ if (this._contents) {
1876
+ return this._contents;
1877
+ }
1878
+ const response = yield computeQuery([
1879
+ ...this._queryTree,
1880
+ {
1881
+ operation: "contents",
1882
+ },
1883
+ ], this.client);
1884
+ return response;
1885
+ });
1886
+ }
1887
+ /**
1888
+ * Writes the file to a file path on the host.
1889
+ * @param path Location of the written directory (e.g., "output.txt").
1890
+ * @param opts.allowParentDirPath If allowParentDirPath is true, the path argument can be a directory path, in which case
1891
+ * the file will be created in that directory.
1892
+ */
1893
+ export(path, opts) {
1894
+ return __awaiter(this, void 0, void 0, function* () {
1895
+ if (this._export) {
1896
+ return this._export;
1897
+ }
1898
+ const response = yield computeQuery([
1899
+ ...this._queryTree,
1900
+ {
1901
+ operation: "export",
1902
+ args: Object.assign({ path }, opts),
1903
+ },
1904
+ ], this.client);
1905
+ return response;
1906
+ });
1765
1907
  }
1766
1908
  /**
1767
1909
  * Gets the size of the file, in bytes.
@@ -1823,134 +1965,131 @@ export class File extends BaseClient {
1823
1965
  }
1824
1966
  }
1825
1967
  /**
1826
- * A git ref (tag, branch or commit).
1968
+ * Function represents a resolver provided by a Module.
1969
+ *
1970
+ * A function always evaluates against a parent object and is given a set of
1971
+ * named arguments.
1827
1972
  */
1828
- export class GitRef extends BaseClient {
1973
+ export class Function_ extends BaseClient {
1829
1974
  /**
1830
1975
  * Constructor is used for internal usage only, do not create object from it.
1831
1976
  */
1832
- constructor(parent) {
1977
+ constructor(parent, _id, _call, _description, _name) {
1833
1978
  super(parent);
1979
+ this._id = undefined;
1980
+ this._call = undefined;
1981
+ this._description = undefined;
1982
+ this._name = undefined;
1983
+ this._id = _id;
1984
+ this._call = _call;
1985
+ this._description = _description;
1986
+ this._name = _name;
1834
1987
  }
1835
1988
  /**
1836
- * The filesystem tree at this ref.
1989
+ * The ID of the function
1837
1990
  */
1838
- tree(opts) {
1839
- return new Directory({
1840
- queryTree: [
1991
+ id() {
1992
+ return __awaiter(this, void 0, void 0, function* () {
1993
+ if (this._id) {
1994
+ return this._id;
1995
+ }
1996
+ const response = yield computeQuery([
1841
1997
  ...this._queryTree,
1842
1998
  {
1843
- operation: "tree",
1844
- args: Object.assign({}, opts),
1999
+ operation: "id",
1845
2000
  },
1846
- ],
1847
- host: this.clientHost,
1848
- sessionToken: this.sessionToken,
2001
+ ], this.client);
2002
+ return response;
1849
2003
  });
1850
2004
  }
1851
- }
1852
- /**
1853
- * A git repository.
1854
- */
1855
- export class GitRepository extends BaseClient {
1856
- /**
1857
- * Constructor is used for internal usage only, do not create object from it.
1858
- */
1859
- constructor(parent) {
1860
- super(parent);
1861
- }
1862
2005
  /**
1863
- * Returns details on one branch.
1864
- * @param name Branch's name (e.g., "main").
2006
+ * Arguments accepted by this function, if any
1865
2007
  */
1866
- branch(name) {
1867
- return new GitRef({
1868
- queryTree: [
2008
+ args() {
2009
+ return __awaiter(this, void 0, void 0, function* () {
2010
+ const response = yield computeQuery([
1869
2011
  ...this._queryTree,
1870
2012
  {
1871
- operation: "branch",
1872
- args: { name },
2013
+ operation: "args",
1873
2014
  },
1874
- ],
1875
- host: this.clientHost,
1876
- sessionToken: this.sessionToken,
2015
+ {
2016
+ operation: "id",
2017
+ },
2018
+ ], this.client);
2019
+ return response.map((r) => new FunctionArg({
2020
+ queryTree: this.queryTree,
2021
+ host: this.clientHost,
2022
+ sessionToken: this.sessionToken,
2023
+ }, r.id));
1877
2024
  });
1878
2025
  }
1879
2026
  /**
1880
- * Returns details on one commit.
1881
- * @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
2027
+ * Execute this function using dynamic input+output types.
2028
+ *
2029
+ * Typically, it's preferable to invoke a function using a type
2030
+ * safe graphql query rather than using this call field. However,
2031
+ * call is useful for some advanced use cases where dynamically
2032
+ * loading arbitrary modules and invoking functions in them is
2033
+ * required.
1882
2034
  */
1883
- commit(id) {
1884
- return new GitRef({
1885
- queryTree: [
2035
+ call(opts) {
2036
+ return __awaiter(this, void 0, void 0, function* () {
2037
+ if (this._call) {
2038
+ return this._call;
2039
+ }
2040
+ const response = yield computeQuery([
1886
2041
  ...this._queryTree,
1887
2042
  {
1888
- operation: "commit",
1889
- args: { id },
2043
+ operation: "call",
2044
+ args: Object.assign({}, opts),
1890
2045
  },
1891
- ],
1892
- host: this.clientHost,
1893
- sessionToken: this.sessionToken,
2046
+ ], this.client);
2047
+ return response;
1894
2048
  });
1895
2049
  }
1896
2050
  /**
1897
- * Returns details on one tag.
1898
- * @param name Tag's name (e.g., "v0.3.9").
2051
+ * A doc string for the function, if any
1899
2052
  */
1900
- tag(name) {
1901
- return new GitRef({
1902
- queryTree: [
2053
+ description() {
2054
+ return __awaiter(this, void 0, void 0, function* () {
2055
+ if (this._description) {
2056
+ return this._description;
2057
+ }
2058
+ const response = yield computeQuery([
1903
2059
  ...this._queryTree,
1904
2060
  {
1905
- operation: "tag",
1906
- args: { name },
2061
+ operation: "description",
1907
2062
  },
1908
- ],
1909
- host: this.clientHost,
1910
- sessionToken: this.sessionToken,
2063
+ ], this.client);
2064
+ return response;
1911
2065
  });
1912
2066
  }
1913
- }
1914
- /**
1915
- * Information about the host execution environment.
1916
- */
1917
- export class Host extends BaseClient {
1918
- /**
1919
- * Constructor is used for internal usage only, do not create object from it.
1920
- */
1921
- constructor(parent) {
1922
- super(parent);
1923
- }
1924
2067
  /**
1925
- * Accesses a directory on the host.
1926
- * @param path Location of the directory to access (e.g., ".").
1927
- * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1928
- * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2068
+ * The name of the function
1929
2069
  */
1930
- directory(path, opts) {
1931
- return new Directory({
1932
- queryTree: [
2070
+ name() {
2071
+ return __awaiter(this, void 0, void 0, function* () {
2072
+ if (this._name) {
2073
+ return this._name;
2074
+ }
2075
+ const response = yield computeQuery([
1933
2076
  ...this._queryTree,
1934
2077
  {
1935
- operation: "directory",
1936
- args: Object.assign({ path }, opts),
2078
+ operation: "name",
1937
2079
  },
1938
- ],
1939
- host: this.clientHost,
1940
- sessionToken: this.sessionToken,
2080
+ ], this.client);
2081
+ return response;
1941
2082
  });
1942
2083
  }
1943
2084
  /**
1944
- * Accesses a file on the host.
1945
- * @param path Location of the file to retrieve (e.g., "README.md").
2085
+ * The type returned by this function
1946
2086
  */
1947
- file(path) {
1948
- return new File({
2087
+ returnType() {
2088
+ return new TypeDef({
1949
2089
  queryTree: [
1950
2090
  ...this._queryTree,
1951
2091
  {
1952
- operation: "file",
1953
- args: { path },
2092
+ operation: "returnType",
1954
2093
  },
1955
2094
  ],
1956
2095
  host: this.clientHost,
@@ -1958,18 +2097,19 @@ export class Host extends BaseClient {
1958
2097
  });
1959
2098
  }
1960
2099
  /**
1961
- * Sets a secret given a user-defined name and the file path on the host, and returns the secret.
1962
- * The file is limited to a size of 512000 bytes.
1963
- * @param name The user defined name for this secret.
1964
- * @param path Location of the file to set as a secret.
2100
+ * Returns the function with the provided argument
2101
+ * @param name The name of the argument
2102
+ * @param typeDef The type of the argument
2103
+ * @param opts.description A doc string for the argument, if any
2104
+ * @param opts.defaultValue A default value to use for this argument if not explicitly set by the caller, if any
1965
2105
  */
1966
- setSecretFile(name, path) {
1967
- return new Secret({
2106
+ withArg(name, typeDef, opts) {
2107
+ return new Function_({
1968
2108
  queryTree: [
1969
2109
  ...this._queryTree,
1970
2110
  {
1971
- operation: "setSecretFile",
1972
- args: { name, path },
2111
+ operation: "withArg",
2112
+ args: Object.assign({ name, typeDef }, opts),
1973
2113
  },
1974
2114
  ],
1975
2115
  host: this.clientHost,
@@ -1977,90 +2117,87 @@ export class Host extends BaseClient {
1977
2117
  });
1978
2118
  }
1979
2119
  /**
1980
- * Accesses a Unix socket on the host.
1981
- * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
2120
+ * Returns the function with the doc string
1982
2121
  */
1983
- unixSocket(path) {
1984
- return new Socket({
2122
+ withDescription(description) {
2123
+ return new Function_({
1985
2124
  queryTree: [
1986
2125
  ...this._queryTree,
1987
2126
  {
1988
- operation: "unixSocket",
1989
- args: { path },
2127
+ operation: "withDescription",
2128
+ args: { description },
1990
2129
  },
1991
2130
  ],
1992
2131
  host: this.clientHost,
1993
2132
  sessionToken: this.sessionToken,
1994
2133
  });
1995
2134
  }
2135
+ /**
2136
+ * Call the provided function with current Function.
2137
+ *
2138
+ * This is useful for reusability and readability by not breaking the calling chain.
2139
+ */
2140
+ with(arg) {
2141
+ return arg(this);
2142
+ }
1996
2143
  }
1997
2144
  /**
1998
- * A simple key value object that represents a label.
2145
+ * An argument accepted by a function.
2146
+ *
2147
+ * This is a specification for an argument at function definition time, not an
2148
+ * argument passed at function call time.
1999
2149
  */
2000
- export class Label extends BaseClient {
2150
+ export class FunctionArg extends BaseClient {
2001
2151
  /**
2002
2152
  * Constructor is used for internal usage only, do not create object from it.
2003
2153
  */
2004
- constructor(parent, _name, _value) {
2154
+ constructor(parent, _id, _defaultValue, _description, _name) {
2005
2155
  super(parent);
2156
+ this._id = undefined;
2157
+ this._defaultValue = undefined;
2158
+ this._description = undefined;
2006
2159
  this._name = undefined;
2007
- this._value = undefined;
2160
+ this._id = _id;
2161
+ this._defaultValue = _defaultValue;
2162
+ this._description = _description;
2008
2163
  this._name = _name;
2009
- this._value = _value;
2010
2164
  }
2011
2165
  /**
2012
- * The label name.
2166
+ * The ID of the argument
2013
2167
  */
2014
- name() {
2168
+ id() {
2015
2169
  return __awaiter(this, void 0, void 0, function* () {
2016
- if (this._name) {
2017
- return this._name;
2170
+ if (this._id) {
2171
+ return this._id;
2018
2172
  }
2019
2173
  const response = yield computeQuery([
2020
2174
  ...this._queryTree,
2021
2175
  {
2022
- operation: "name",
2176
+ operation: "id",
2023
2177
  },
2024
2178
  ], this.client);
2025
2179
  return response;
2026
2180
  });
2027
2181
  }
2028
2182
  /**
2029
- * The label value.
2183
+ * A default value to use for this argument when not explicitly set by the caller, if any
2030
2184
  */
2031
- value() {
2185
+ defaultValue() {
2032
2186
  return __awaiter(this, void 0, void 0, function* () {
2033
- if (this._value) {
2034
- return this._value;
2187
+ if (this._defaultValue) {
2188
+ return this._defaultValue;
2035
2189
  }
2036
2190
  const response = yield computeQuery([
2037
2191
  ...this._queryTree,
2038
2192
  {
2039
- operation: "value",
2193
+ operation: "defaultValue",
2040
2194
  },
2041
2195
  ], this.client);
2042
2196
  return response;
2043
2197
  });
2044
2198
  }
2045
- }
2046
- /**
2047
- * A port exposed by a container.
2048
- */
2049
- export class Port extends BaseClient {
2050
- /**
2051
- * Constructor is used for internal usage only, do not create object from it.
2052
- */
2053
- constructor(parent, _description, _port, _protocol) {
2054
- super(parent);
2055
- this._description = undefined;
2056
- this._port = undefined;
2057
- this._protocol = undefined;
2058
- this._description = _description;
2059
- this._port = _port;
2060
- this._protocol = _protocol;
2061
- }
2062
2199
  /**
2063
- * The port description.
2200
+ * A doc string for the argument, if any
2064
2201
  */
2065
2202
  description() {
2066
2203
  return __awaiter(this, void 0, void 0, function* () {
@@ -2077,193 +2214,202 @@ export class Port extends BaseClient {
2077
2214
  });
2078
2215
  }
2079
2216
  /**
2080
- * The port number.
2217
+ * The name of the argument
2081
2218
  */
2082
- port() {
2219
+ name() {
2083
2220
  return __awaiter(this, void 0, void 0, function* () {
2084
- if (this._port) {
2085
- return this._port;
2221
+ if (this._name) {
2222
+ return this._name;
2086
2223
  }
2087
2224
  const response = yield computeQuery([
2088
2225
  ...this._queryTree,
2089
2226
  {
2090
- operation: "port",
2227
+ operation: "name",
2091
2228
  },
2092
2229
  ], this.client);
2093
2230
  return response;
2094
2231
  });
2095
2232
  }
2096
2233
  /**
2097
- * The transport layer network protocol.
2234
+ * The type of the argument
2098
2235
  */
2099
- protocol() {
2100
- return __awaiter(this, void 0, void 0, function* () {
2101
- if (this._protocol) {
2102
- return this._protocol;
2103
- }
2104
- const response = yield computeQuery([
2236
+ typeDef() {
2237
+ return new TypeDef({
2238
+ queryTree: [
2105
2239
  ...this._queryTree,
2106
2240
  {
2107
- operation: "protocol",
2241
+ operation: "typeDef",
2108
2242
  },
2109
- ], this.client);
2110
- return response;
2243
+ ],
2244
+ host: this.clientHost,
2245
+ sessionToken: this.sessionToken,
2111
2246
  });
2112
2247
  }
2113
2248
  }
2114
- /**
2115
- * A collection of Dagger resources that can be queried and invoked.
2116
- */
2117
- export class Project extends BaseClient {
2249
+ export class FunctionCall extends BaseClient {
2118
2250
  /**
2119
2251
  * Constructor is used for internal usage only, do not create object from it.
2120
2252
  */
2121
- constructor(parent, _id, _name) {
2253
+ constructor(parent, _name, _parent, _parentName, _returnValue) {
2122
2254
  super(parent);
2123
- this._id = undefined;
2124
2255
  this._name = undefined;
2125
- this._id = _id;
2256
+ this._parent = undefined;
2257
+ this._parentName = undefined;
2258
+ this._returnValue = undefined;
2126
2259
  this._name = _name;
2260
+ this._parent = _parent;
2261
+ this._parentName = _parentName;
2262
+ this._returnValue = _returnValue;
2127
2263
  }
2128
2264
  /**
2129
- * Commands provided by this project
2265
+ * The argument values the function is being invoked with.
2130
2266
  */
2131
- commands() {
2267
+ inputArgs() {
2132
2268
  return __awaiter(this, void 0, void 0, function* () {
2133
2269
  const response = yield computeQuery([
2134
2270
  ...this._queryTree,
2135
2271
  {
2136
- operation: "commands",
2272
+ operation: "inputArgs",
2137
2273
  },
2138
2274
  {
2139
- operation: "description id name resultType",
2275
+ operation: "name value",
2140
2276
  },
2141
2277
  ], this.client);
2142
- return response.map((r) => new ProjectCommand({
2278
+ return response.map((r) => new FunctionCallArgValue({
2143
2279
  queryTree: this.queryTree,
2144
2280
  host: this.clientHost,
2145
2281
  sessionToken: this.sessionToken,
2146
- }, r.description, r.id, r.name, r.resultType));
2282
+ }, r.name, r.value));
2147
2283
  });
2148
2284
  }
2149
2285
  /**
2150
- * A unique identifier for this project.
2286
+ * The name of the function being called.
2151
2287
  */
2152
- id() {
2288
+ name() {
2153
2289
  return __awaiter(this, void 0, void 0, function* () {
2154
- if (this._id) {
2155
- return this._id;
2290
+ if (this._name) {
2291
+ return this._name;
2156
2292
  }
2157
2293
  const response = yield computeQuery([
2158
2294
  ...this._queryTree,
2159
2295
  {
2160
- operation: "id",
2296
+ operation: "name",
2161
2297
  },
2162
2298
  ], this.client);
2163
2299
  return response;
2164
2300
  });
2165
2301
  }
2166
2302
  /**
2167
- * Initialize this project from the given directory and config path
2303
+ * The value of the parent object of the function being called.
2304
+ * If the function is "top-level" to the module, this is always an empty object.
2168
2305
  */
2169
- load(source, configPath) {
2170
- return new Project({
2171
- queryTree: [
2306
+ parent() {
2307
+ return __awaiter(this, void 0, void 0, function* () {
2308
+ if (this._parent) {
2309
+ return this._parent;
2310
+ }
2311
+ const response = yield computeQuery([
2172
2312
  ...this._queryTree,
2173
2313
  {
2174
- operation: "load",
2175
- args: { source, configPath },
2314
+ operation: "parent",
2176
2315
  },
2177
- ],
2178
- host: this.clientHost,
2179
- sessionToken: this.sessionToken,
2316
+ ], this.client);
2317
+ return response;
2180
2318
  });
2181
2319
  }
2182
2320
  /**
2183
- * Name of the project
2321
+ * The name of the parent object of the function being called.
2322
+ * If the function is "top-level" to the module, this is the name of the module.
2184
2323
  */
2185
- name() {
2324
+ parentName() {
2186
2325
  return __awaiter(this, void 0, void 0, function* () {
2187
- if (this._name) {
2188
- return this._name;
2326
+ if (this._parentName) {
2327
+ return this._parentName;
2189
2328
  }
2190
2329
  const response = yield computeQuery([
2191
2330
  ...this._queryTree,
2192
2331
  {
2193
- operation: "name",
2332
+ operation: "parentName",
2194
2333
  },
2195
2334
  ], this.client);
2196
2335
  return response;
2197
2336
  });
2198
2337
  }
2199
2338
  /**
2200
- * Call the provided function with current Project.
2201
- *
2202
- * This is useful for reusability and readability by not breaking the calling chain.
2339
+ * Set the return value of the function call to the provided value.
2340
+ * The value should be a string of the JSON serialization of the return value.
2203
2341
  */
2204
- with(arg) {
2205
- return arg(this);
2342
+ returnValue(value) {
2343
+ return __awaiter(this, void 0, void 0, function* () {
2344
+ if (this._returnValue) {
2345
+ return this._returnValue;
2346
+ }
2347
+ const response = yield computeQuery([
2348
+ ...this._queryTree,
2349
+ {
2350
+ operation: "returnValue",
2351
+ args: { value },
2352
+ },
2353
+ ], this.client);
2354
+ return response;
2355
+ });
2206
2356
  }
2207
2357
  }
2208
- /**
2209
- * A command defined in a project that can be invoked from the CLI.
2210
- */
2211
- export class ProjectCommand extends BaseClient {
2358
+ export class FunctionCallArgValue extends BaseClient {
2212
2359
  /**
2213
2360
  * Constructor is used for internal usage only, do not create object from it.
2214
2361
  */
2215
- constructor(parent, _description, _id, _name, _resultType) {
2362
+ constructor(parent, _name, _value) {
2216
2363
  super(parent);
2217
- this._description = undefined;
2218
- this._id = undefined;
2219
2364
  this._name = undefined;
2220
- this._resultType = undefined;
2221
- this._description = _description;
2222
- this._id = _id;
2365
+ this._value = undefined;
2223
2366
  this._name = _name;
2224
- this._resultType = _resultType;
2367
+ this._value = _value;
2225
2368
  }
2226
2369
  /**
2227
- * Documentation for what this command does.
2370
+ * The name of the argument.
2228
2371
  */
2229
- description() {
2372
+ name() {
2230
2373
  return __awaiter(this, void 0, void 0, function* () {
2231
- if (this._description) {
2232
- return this._description;
2374
+ if (this._name) {
2375
+ return this._name;
2233
2376
  }
2234
2377
  const response = yield computeQuery([
2235
2378
  ...this._queryTree,
2236
2379
  {
2237
- operation: "description",
2380
+ operation: "name",
2238
2381
  },
2239
2382
  ], this.client);
2240
2383
  return response;
2241
2384
  });
2242
2385
  }
2243
2386
  /**
2244
- * Flags accepted by this command.
2387
+ * The value of the argument represented as a string of the JSON serialization.
2245
2388
  */
2246
- flags() {
2389
+ value() {
2247
2390
  return __awaiter(this, void 0, void 0, function* () {
2391
+ if (this._value) {
2392
+ return this._value;
2393
+ }
2248
2394
  const response = yield computeQuery([
2249
2395
  ...this._queryTree,
2250
2396
  {
2251
- operation: "flags",
2252
- },
2253
- {
2254
- operation: "description name",
2397
+ operation: "value",
2255
2398
  },
2256
2399
  ], this.client);
2257
- return response.map((r) => new ProjectCommandFlag({
2258
- queryTree: this.queryTree,
2259
- host: this.clientHost,
2260
- sessionToken: this.sessionToken,
2261
- }, r.description, r.name));
2400
+ return response;
2262
2401
  });
2263
2402
  }
2403
+ }
2404
+ export class GeneratedCode extends BaseClient {
2264
2405
  /**
2265
- * A unique identifier for this command.
2406
+ * Constructor is used for internal usage only, do not create object from it.
2266
2407
  */
2408
+ constructor(parent, _id) {
2409
+ super(parent);
2410
+ this._id = undefined;
2411
+ this._id = _id;
2412
+ }
2267
2413
  id() {
2268
2414
  return __awaiter(this, void 0, void 0, function* () {
2269
2415
  if (this._id) {
@@ -2279,168 +2425,137 @@ export class ProjectCommand extends BaseClient {
2279
2425
  });
2280
2426
  }
2281
2427
  /**
2282
- * The name of the command.
2428
+ * The directory containing the generated code
2283
2429
  */
2284
- name() {
2285
- return __awaiter(this, void 0, void 0, function* () {
2286
- if (this._name) {
2287
- return this._name;
2288
- }
2289
- const response = yield computeQuery([
2430
+ code() {
2431
+ return new Directory({
2432
+ queryTree: [
2290
2433
  ...this._queryTree,
2291
2434
  {
2292
- operation: "name",
2435
+ operation: "code",
2293
2436
  },
2294
- ], this.client);
2295
- return response;
2437
+ ],
2438
+ host: this.clientHost,
2439
+ sessionToken: this.sessionToken,
2296
2440
  });
2297
2441
  }
2298
2442
  /**
2299
- * The name of the type returned by this command.
2443
+ * List of paths to mark generated in version control (i.e. .gitattributes)
2300
2444
  */
2301
- resultType() {
2445
+ vcsGeneratedPaths() {
2302
2446
  return __awaiter(this, void 0, void 0, function* () {
2303
- if (this._resultType) {
2304
- return this._resultType;
2305
- }
2306
2447
  const response = yield computeQuery([
2307
2448
  ...this._queryTree,
2308
2449
  {
2309
- operation: "resultType",
2450
+ operation: "vcsGeneratedPaths",
2310
2451
  },
2311
2452
  ], this.client);
2312
2453
  return response;
2313
2454
  });
2314
2455
  }
2315
2456
  /**
2316
- * Subcommands, if any, that this command provides.
2457
+ * List of paths to ignore in version control (i.e. .gitignore)
2317
2458
  */
2318
- subcommands() {
2459
+ vcsIgnoredPaths() {
2319
2460
  return __awaiter(this, void 0, void 0, function* () {
2320
2461
  const response = yield computeQuery([
2321
2462
  ...this._queryTree,
2322
2463
  {
2323
- operation: "subcommands",
2324
- },
2325
- {
2326
- operation: "description id name resultType",
2464
+ operation: "vcsIgnoredPaths",
2327
2465
  },
2328
2466
  ], this.client);
2329
- return response.map((r) => new ProjectCommand({
2330
- queryTree: this.queryTree,
2331
- host: this.clientHost,
2332
- sessionToken: this.sessionToken,
2333
- }, r.description, r.id, r.name, r.resultType));
2467
+ return response;
2334
2468
  });
2335
2469
  }
2336
- }
2337
- /**
2338
- * A flag accepted by a project command.
2339
- */
2340
- export class ProjectCommandFlag extends BaseClient {
2341
- /**
2342
- * Constructor is used for internal usage only, do not create object from it.
2343
- */
2344
- constructor(parent, _description, _name) {
2345
- super(parent);
2346
- this._description = undefined;
2347
- this._name = undefined;
2348
- this._description = _description;
2349
- this._name = _name;
2350
- }
2351
2470
  /**
2352
- * Documentation for what this flag sets.
2471
+ * Set the list of paths to mark generated in version control
2353
2472
  */
2354
- description() {
2355
- return __awaiter(this, void 0, void 0, function* () {
2356
- if (this._description) {
2357
- return this._description;
2358
- }
2359
- const response = yield computeQuery([
2473
+ withVCSGeneratedPaths(paths) {
2474
+ return new GeneratedCode({
2475
+ queryTree: [
2360
2476
  ...this._queryTree,
2361
2477
  {
2362
- operation: "description",
2478
+ operation: "withVCSGeneratedPaths",
2479
+ args: { paths },
2363
2480
  },
2364
- ], this.client);
2365
- return response;
2481
+ ],
2482
+ host: this.clientHost,
2483
+ sessionToken: this.sessionToken,
2366
2484
  });
2367
2485
  }
2368
2486
  /**
2369
- * The name of the flag.
2487
+ * Set the list of paths to ignore in version control
2370
2488
  */
2371
- name() {
2372
- return __awaiter(this, void 0, void 0, function* () {
2373
- if (this._name) {
2374
- return this._name;
2375
- }
2376
- const response = yield computeQuery([
2489
+ withVCSIgnoredPaths(paths) {
2490
+ return new GeneratedCode({
2491
+ queryTree: [
2377
2492
  ...this._queryTree,
2378
2493
  {
2379
- operation: "name",
2494
+ operation: "withVCSIgnoredPaths",
2495
+ args: { paths },
2380
2496
  },
2381
- ], this.client);
2382
- return response;
2497
+ ],
2498
+ host: this.clientHost,
2499
+ sessionToken: this.sessionToken,
2383
2500
  });
2384
2501
  }
2502
+ /**
2503
+ * Call the provided function with current GeneratedCode.
2504
+ *
2505
+ * This is useful for reusability and readability by not breaking the calling chain.
2506
+ */
2507
+ with(arg) {
2508
+ return arg(this);
2509
+ }
2385
2510
  }
2386
- export class Client extends BaseClient {
2511
+ /**
2512
+ * A git ref (tag, branch or commit).
2513
+ */
2514
+ export class GitRef extends BaseClient {
2387
2515
  /**
2388
2516
  * Constructor is used for internal usage only, do not create object from it.
2389
2517
  */
2390
- constructor(parent, _checkVersionCompatibility, _defaultPlatform) {
2518
+ constructor(parent) {
2391
2519
  super(parent);
2392
- this._checkVersionCompatibility = undefined;
2393
- this._defaultPlatform = undefined;
2394
- this._checkVersionCompatibility = _checkVersionCompatibility;
2395
- this._defaultPlatform = _defaultPlatform;
2396
2520
  }
2397
2521
  /**
2398
- * Constructs a cache volume for a given cache key.
2399
- * @param key A string identifier to target this cache volume (e.g., "modules-cache").
2522
+ * The filesystem tree at this ref.
2400
2523
  */
2401
- cacheVolume(key) {
2402
- return new CacheVolume({
2524
+ tree(opts) {
2525
+ return new Directory({
2403
2526
  queryTree: [
2404
2527
  ...this._queryTree,
2405
2528
  {
2406
- operation: "cacheVolume",
2407
- args: { key },
2529
+ operation: "tree",
2530
+ args: Object.assign({}, opts),
2408
2531
  },
2409
2532
  ],
2410
2533
  host: this.clientHost,
2411
2534
  sessionToken: this.sessionToken,
2412
2535
  });
2413
2536
  }
2537
+ }
2538
+ /**
2539
+ * A git repository.
2540
+ */
2541
+ export class GitRepository extends BaseClient {
2414
2542
  /**
2415
- * Checks if the current Dagger Engine is compatible with an SDK's required version.
2416
- * @param version The SDK's required version.
2543
+ * Constructor is used for internal usage only, do not create object from it.
2417
2544
  */
2418
- checkVersionCompatibility(version) {
2419
- return __awaiter(this, void 0, void 0, function* () {
2420
- const response = yield computeQuery([
2421
- ...this._queryTree,
2422
- {
2423
- operation: "checkVersionCompatibility",
2424
- args: { version },
2425
- },
2426
- ], this.client);
2427
- return response;
2428
- });
2545
+ constructor(parent) {
2546
+ super(parent);
2429
2547
  }
2430
2548
  /**
2431
- * Loads a container from ID.
2432
- *
2433
- * Null ID returns an empty container (scratch).
2434
- * Optional platform argument initializes new containers to execute and publish as that platform.
2435
- * Platform defaults to that of the builder's host.
2549
+ * Returns details on one branch.
2550
+ * @param name Branch's name (e.g., "main").
2436
2551
  */
2437
- container(opts) {
2438
- return new Container({
2552
+ branch(name) {
2553
+ return new GitRef({
2439
2554
  queryTree: [
2440
2555
  ...this._queryTree,
2441
2556
  {
2442
- operation: "container",
2443
- args: Object.assign({}, opts),
2557
+ operation: "branch",
2558
+ args: { name },
2444
2559
  },
2445
2560
  ],
2446
2561
  host: this.clientHost,
@@ -2448,66 +2563,63 @@ export class Client extends BaseClient {
2448
2563
  });
2449
2564
  }
2450
2565
  /**
2451
- * The default platform of the builder.
2566
+ * Returns details on one commit.
2567
+ * @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
2452
2568
  */
2453
- defaultPlatform() {
2454
- return __awaiter(this, void 0, void 0, function* () {
2455
- const response = yield computeQuery([
2569
+ commit(id) {
2570
+ return new GitRef({
2571
+ queryTree: [
2456
2572
  ...this._queryTree,
2457
2573
  {
2458
- operation: "defaultPlatform",
2574
+ operation: "commit",
2575
+ args: { id },
2459
2576
  },
2460
- ], this.client);
2461
- return response;
2577
+ ],
2578
+ host: this.clientHost,
2579
+ sessionToken: this.sessionToken,
2462
2580
  });
2463
2581
  }
2464
2582
  /**
2465
- * Load a directory by ID. No argument produces an empty directory.
2583
+ * Returns details on one tag.
2584
+ * @param name Tag's name (e.g., "v0.3.9").
2466
2585
  */
2467
- directory(opts) {
2468
- return new Directory({
2586
+ tag(name) {
2587
+ return new GitRef({
2469
2588
  queryTree: [
2470
2589
  ...this._queryTree,
2471
2590
  {
2472
- operation: "directory",
2473
- args: Object.assign({}, opts),
2591
+ operation: "tag",
2592
+ args: { name },
2474
2593
  },
2475
2594
  ],
2476
2595
  host: this.clientHost,
2477
2596
  sessionToken: this.sessionToken,
2478
2597
  });
2479
2598
  }
2599
+ }
2600
+ /**
2601
+ * Information about the host execution environment.
2602
+ */
2603
+ export class Host extends BaseClient {
2480
2604
  /**
2481
- * Loads a file by ID.
2605
+ * Constructor is used for internal usage only, do not create object from it.
2482
2606
  */
2483
- file(id) {
2484
- return new File({
2485
- queryTree: [
2486
- ...this._queryTree,
2487
- {
2488
- operation: "file",
2489
- args: { id },
2490
- },
2491
- ],
2492
- host: this.clientHost,
2493
- sessionToken: this.sessionToken,
2494
- });
2607
+ constructor(parent) {
2608
+ super(parent);
2495
2609
  }
2496
2610
  /**
2497
- * Queries a git repository.
2498
- * @param url Url of the git repository.
2499
- * Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo}
2500
- * Suffix ".git" is optional.
2501
- * @param opts.keepGitDir Set to true to keep .git directory.
2502
- * @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
2611
+ * Accesses a directory on the host.
2612
+ * @param path Location of the directory to access (e.g., ".").
2613
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
2614
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2503
2615
  */
2504
- git(url, opts) {
2505
- return new GitRepository({
2616
+ directory(path, opts) {
2617
+ return new Directory({
2506
2618
  queryTree: [
2507
2619
  ...this._queryTree,
2508
2620
  {
2509
- operation: "git",
2510
- args: Object.assign({ url }, opts),
2621
+ operation: "directory",
2622
+ args: Object.assign({ path }, opts),
2511
2623
  },
2512
2624
  ],
2513
2625
  host: this.clientHost,
@@ -2515,14 +2627,16 @@ export class Client extends BaseClient {
2515
2627
  });
2516
2628
  }
2517
2629
  /**
2518
- * Queries the host environment.
2630
+ * Accesses a file on the host.
2631
+ * @param path Location of the file to retrieve (e.g., "README.md").
2519
2632
  */
2520
- host() {
2521
- return new Host({
2633
+ file(path) {
2634
+ return new File({
2522
2635
  queryTree: [
2523
2636
  ...this._queryTree,
2524
2637
  {
2525
- operation: "host",
2638
+ operation: "file",
2639
+ args: { path },
2526
2640
  },
2527
2641
  ],
2528
2642
  host: this.clientHost,
@@ -2530,17 +2644,22 @@ export class Client extends BaseClient {
2530
2644
  });
2531
2645
  }
2532
2646
  /**
2533
- * Returns a file containing an http remote url content.
2534
- * @param url HTTP url to get the content from (e.g., "https://docs.dagger.io").
2535
- * @param opts.experimentalServiceHost A service which must be started before the URL is fetched.
2647
+ * Creates a service that forwards traffic to a specified address via the host.
2648
+ * @param ports Ports to expose via the service, forwarding through the host network.
2649
+ *
2650
+ * If a port's frontend is unspecified or 0, it defaults to the same as the
2651
+ * backend port.
2652
+ *
2653
+ * An empty set of ports is not valid; an error will be returned.
2654
+ * @param opts.host Upstream host to forward traffic to.
2536
2655
  */
2537
- http(url, opts) {
2538
- return new File({
2656
+ service(ports, opts) {
2657
+ return new Service({
2539
2658
  queryTree: [
2540
2659
  ...this._queryTree,
2541
2660
  {
2542
- operation: "http",
2543
- args: Object.assign({ url }, opts),
2661
+ operation: "service",
2662
+ args: Object.assign({ ports }, opts),
2544
2663
  },
2545
2664
  ],
2546
2665
  host: this.clientHost,
@@ -2548,18 +2667,18 @@ export class Client extends BaseClient {
2548
2667
  });
2549
2668
  }
2550
2669
  /**
2551
- * Creates a named sub-pipeline.
2552
- * @param name Pipeline name.
2553
- * @param opts.description Pipeline description.
2554
- * @param opts.labels Pipeline labels.
2670
+ * Sets a secret given a user-defined name and the file path on the host, and returns the secret.
2671
+ * The file is limited to a size of 512000 bytes.
2672
+ * @param name The user defined name for this secret.
2673
+ * @param path Location of the file to set as a secret.
2555
2674
  */
2556
- pipeline(name, opts) {
2557
- return new Client({
2675
+ setSecretFile(name, path) {
2676
+ return new Secret({
2558
2677
  queryTree: [
2559
2678
  ...this._queryTree,
2560
2679
  {
2561
- operation: "pipeline",
2562
- args: Object.assign({ name }, opts),
2680
+ operation: "setSecretFile",
2681
+ args: { name, path },
2563
2682
  },
2564
2683
  ],
2565
2684
  host: this.clientHost,
@@ -2567,15 +2686,30 @@ export class Client extends BaseClient {
2567
2686
  });
2568
2687
  }
2569
2688
  /**
2570
- * Load a project from ID.
2689
+ * Creates a tunnel that forwards traffic from the host to a service.
2690
+ * @param service Service to send traffic from the tunnel.
2691
+ * @param opts.native Map each service port to the same port on the host, as if the service were
2692
+ * running natively.
2693
+ *
2694
+ * Note: enabling may result in port conflicts.
2695
+ * @param opts.ports Configure explicit port forwarding rules for the tunnel.
2696
+ *
2697
+ * If a port's frontend is unspecified or 0, a random port will be chosen by
2698
+ * the host.
2699
+ *
2700
+ * If no ports are given, all of the service's ports are forwarded. If native
2701
+ * is true, each port maps to the same port on the host. If native is false,
2702
+ * each port maps to a random port chosen by the host.
2703
+ *
2704
+ * If ports are given and native is true, the ports are additive.
2571
2705
  */
2572
- project(opts) {
2573
- return new Project({
2706
+ tunnel(service, opts) {
2707
+ return new Service({
2574
2708
  queryTree: [
2575
2709
  ...this._queryTree,
2576
2710
  {
2577
- operation: "project",
2578
- args: Object.assign({}, opts),
2711
+ operation: "tunnel",
2712
+ args: Object.assign({ service }, opts),
2579
2713
  },
2580
2714
  ],
2581
2715
  host: this.clientHost,
@@ -2583,97 +2717,119 @@ export class Client extends BaseClient {
2583
2717
  });
2584
2718
  }
2585
2719
  /**
2586
- * Load a project command from ID.
2720
+ * Accesses a Unix socket on the host.
2721
+ * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
2587
2722
  */
2588
- projectCommand(opts) {
2589
- return new ProjectCommand({
2723
+ unixSocket(path) {
2724
+ return new Socket({
2590
2725
  queryTree: [
2591
2726
  ...this._queryTree,
2592
2727
  {
2593
- operation: "projectCommand",
2594
- args: Object.assign({}, opts),
2728
+ operation: "unixSocket",
2729
+ args: { path },
2595
2730
  },
2596
2731
  ],
2597
2732
  host: this.clientHost,
2598
2733
  sessionToken: this.sessionToken,
2599
2734
  });
2600
2735
  }
2736
+ }
2737
+ /**
2738
+ * A simple key value object that represents a label.
2739
+ */
2740
+ export class Label extends BaseClient {
2741
+ /**
2742
+ * Constructor is used for internal usage only, do not create object from it.
2743
+ */
2744
+ constructor(parent, _name, _value) {
2745
+ super(parent);
2746
+ this._name = undefined;
2747
+ this._value = undefined;
2748
+ this._name = _name;
2749
+ this._value = _value;
2750
+ }
2601
2751
  /**
2602
- * Loads a secret from its ID.
2752
+ * The label name.
2603
2753
  */
2604
- secret(id) {
2605
- return new Secret({
2606
- queryTree: [
2754
+ name() {
2755
+ return __awaiter(this, void 0, void 0, function* () {
2756
+ if (this._name) {
2757
+ return this._name;
2758
+ }
2759
+ const response = yield computeQuery([
2607
2760
  ...this._queryTree,
2608
2761
  {
2609
- operation: "secret",
2610
- args: { id },
2762
+ operation: "name",
2611
2763
  },
2612
- ],
2613
- host: this.clientHost,
2614
- sessionToken: this.sessionToken,
2764
+ ], this.client);
2765
+ return response;
2615
2766
  });
2616
2767
  }
2617
2768
  /**
2618
- * Sets a secret given a user defined name to its plaintext and returns the secret.
2619
- * The plaintext value is limited to a size of 128000 bytes.
2620
- * @param name The user defined name for this secret
2621
- * @param plaintext The plaintext of the secret
2769
+ * The label value.
2622
2770
  */
2623
- setSecret(name, plaintext) {
2624
- return new Secret({
2625
- queryTree: [
2771
+ value() {
2772
+ return __awaiter(this, void 0, void 0, function* () {
2773
+ if (this._value) {
2774
+ return this._value;
2775
+ }
2776
+ const response = yield computeQuery([
2626
2777
  ...this._queryTree,
2627
2778
  {
2628
- operation: "setSecret",
2629
- args: { name, plaintext },
2779
+ operation: "value",
2630
2780
  },
2631
- ],
2632
- host: this.clientHost,
2633
- sessionToken: this.sessionToken,
2781
+ ], this.client);
2782
+ return response;
2634
2783
  });
2635
2784
  }
2785
+ }
2786
+ /**
2787
+ * A definition of a list type in a Module.
2788
+ */
2789
+ export class ListTypeDef extends BaseClient {
2636
2790
  /**
2637
- * Loads a socket by its ID.
2791
+ * Constructor is used for internal usage only, do not create object from it.
2638
2792
  */
2639
- socket(opts) {
2640
- return new Socket({
2793
+ constructor(parent) {
2794
+ super(parent);
2795
+ }
2796
+ /**
2797
+ * The type of the elements in the list
2798
+ */
2799
+ elementTypeDef() {
2800
+ return new TypeDef({
2641
2801
  queryTree: [
2642
2802
  ...this._queryTree,
2643
2803
  {
2644
- operation: "socket",
2645
- args: Object.assign({}, opts),
2804
+ operation: "elementTypeDef",
2646
2805
  },
2647
2806
  ],
2648
2807
  host: this.clientHost,
2649
2808
  sessionToken: this.sessionToken,
2650
2809
  });
2651
2810
  }
2652
- /**
2653
- * Call the provided function with current Client.
2654
- *
2655
- * This is useful for reusability and readability by not breaking the calling chain.
2656
- */
2657
- with(arg) {
2658
- return arg(this);
2659
- }
2660
2811
  }
2661
- /**
2662
- * A reference to a secret value, which can be handled more safely than the value itself.
2663
- */
2664
- export class Secret extends BaseClient {
2812
+ export class Module_ extends BaseClient {
2665
2813
  /**
2666
2814
  * Constructor is used for internal usage only, do not create object from it.
2667
2815
  */
2668
- constructor(parent, _id, _plaintext) {
2816
+ constructor(parent, _id, _description, _name, _sdk, _serve, _sourceDirectorySubPath) {
2669
2817
  super(parent);
2670
2818
  this._id = undefined;
2671
- this._plaintext = undefined;
2819
+ this._description = undefined;
2820
+ this._name = undefined;
2821
+ this._sdk = undefined;
2822
+ this._serve = undefined;
2823
+ this._sourceDirectorySubPath = undefined;
2672
2824
  this._id = _id;
2673
- this._plaintext = _plaintext;
2825
+ this._description = _description;
2826
+ this._name = _name;
2827
+ this._sdk = _sdk;
2828
+ this._serve = _serve;
2829
+ this._sourceDirectorySubPath = _sourceDirectorySubPath;
2674
2830
  }
2675
2831
  /**
2676
- * The identifier for this secret.
2832
+ * The ID of the module
2677
2833
  */
2678
2834
  id() {
2679
2835
  return __awaiter(this, void 0, void 0, function* () {
@@ -2690,47 +2846,1428 @@ export class Secret extends BaseClient {
2690
2846
  });
2691
2847
  }
2692
2848
  /**
2693
- * The value of this secret.
2849
+ * Modules used by this module
2694
2850
  */
2695
- plaintext() {
2851
+ dependencies() {
2696
2852
  return __awaiter(this, void 0, void 0, function* () {
2697
- if (this._plaintext) {
2698
- return this._plaintext;
2853
+ const response = yield computeQuery([
2854
+ ...this._queryTree,
2855
+ {
2856
+ operation: "dependencies",
2857
+ },
2858
+ {
2859
+ operation: "id",
2860
+ },
2861
+ ], this.client);
2862
+ return response.map((r) => new Module_({
2863
+ queryTree: this.queryTree,
2864
+ host: this.clientHost,
2865
+ sessionToken: this.sessionToken,
2866
+ }, r.id));
2867
+ });
2868
+ }
2869
+ /**
2870
+ * The dependencies as configured by the module
2871
+ */
2872
+ dependencyConfig() {
2873
+ return __awaiter(this, void 0, void 0, function* () {
2874
+ const response = yield computeQuery([
2875
+ ...this._queryTree,
2876
+ {
2877
+ operation: "dependencyConfig",
2878
+ },
2879
+ ], this.client);
2880
+ return response;
2881
+ });
2882
+ }
2883
+ /**
2884
+ * The doc string of the module, if any
2885
+ */
2886
+ description() {
2887
+ return __awaiter(this, void 0, void 0, function* () {
2888
+ if (this._description) {
2889
+ return this._description;
2699
2890
  }
2700
2891
  const response = yield computeQuery([
2701
2892
  ...this._queryTree,
2702
2893
  {
2703
- operation: "plaintext",
2894
+ operation: "description",
2704
2895
  },
2705
2896
  ], this.client);
2706
2897
  return response;
2707
2898
  });
2708
2899
  }
2709
- }
2710
- export class Socket extends BaseClient {
2711
2900
  /**
2712
- * Constructor is used for internal usage only, do not create object from it.
2901
+ * The code generated by the SDK's runtime
2713
2902
  */
2714
- constructor(parent, _id) {
2715
- super(parent);
2716
- this._id = undefined;
2717
- this._id = _id;
2903
+ generatedCode() {
2904
+ return new GeneratedCode({
2905
+ queryTree: [
2906
+ ...this._queryTree,
2907
+ {
2908
+ operation: "generatedCode",
2909
+ },
2910
+ ],
2911
+ host: this.clientHost,
2912
+ sessionToken: this.sessionToken,
2913
+ });
2718
2914
  }
2719
2915
  /**
2720
- * The content-addressed identifier of the socket.
2916
+ * The name of the module
2721
2917
  */
2722
- id() {
2918
+ name() {
2723
2919
  return __awaiter(this, void 0, void 0, function* () {
2724
- if (this._id) {
2725
- return this._id;
2920
+ if (this._name) {
2921
+ return this._name;
2726
2922
  }
2727
2923
  const response = yield computeQuery([
2728
2924
  ...this._queryTree,
2729
2925
  {
2730
- operation: "id",
2926
+ operation: "name",
2731
2927
  },
2732
2928
  ], this.client);
2733
2929
  return response;
2734
2930
  });
2735
2931
  }
2932
+ /**
2933
+ * Objects served by this module
2934
+ */
2935
+ objects() {
2936
+ return __awaiter(this, void 0, void 0, function* () {
2937
+ const response = yield computeQuery([
2938
+ ...this._queryTree,
2939
+ {
2940
+ operation: "objects",
2941
+ },
2942
+ {
2943
+ operation: "id",
2944
+ },
2945
+ ], this.client);
2946
+ return response.map((r) => new TypeDef({
2947
+ queryTree: this.queryTree,
2948
+ host: this.clientHost,
2949
+ sessionToken: this.sessionToken,
2950
+ }, r.id));
2951
+ });
2952
+ }
2953
+ /**
2954
+ * The SDK used by this module. Either a name of a builtin SDK or a module ref pointing to the SDK's implementation.
2955
+ */
2956
+ sdk() {
2957
+ return __awaiter(this, void 0, void 0, function* () {
2958
+ if (this._sdk) {
2959
+ return this._sdk;
2960
+ }
2961
+ const response = yield computeQuery([
2962
+ ...this._queryTree,
2963
+ {
2964
+ operation: "sdk",
2965
+ },
2966
+ ], this.client);
2967
+ return response;
2968
+ });
2969
+ }
2970
+ /**
2971
+ * Serve a module's API in the current session.
2972
+ * Note: this can only be called once per session.
2973
+ * In the future, it could return a stream or service to remove the side effect.
2974
+ */
2975
+ serve() {
2976
+ return __awaiter(this, void 0, void 0, function* () {
2977
+ if (this._serve) {
2978
+ return this._serve;
2979
+ }
2980
+ const response = yield computeQuery([
2981
+ ...this._queryTree,
2982
+ {
2983
+ operation: "serve",
2984
+ },
2985
+ ], this.client);
2986
+ return response;
2987
+ });
2988
+ }
2989
+ /**
2990
+ * The directory containing the module's source code
2991
+ */
2992
+ sourceDirectory() {
2993
+ return new Directory({
2994
+ queryTree: [
2995
+ ...this._queryTree,
2996
+ {
2997
+ operation: "sourceDirectory",
2998
+ },
2999
+ ],
3000
+ host: this.clientHost,
3001
+ sessionToken: this.sessionToken,
3002
+ });
3003
+ }
3004
+ /**
3005
+ * The module's subpath within the source directory
3006
+ */
3007
+ sourceDirectorySubPath() {
3008
+ return __awaiter(this, void 0, void 0, function* () {
3009
+ if (this._sourceDirectorySubPath) {
3010
+ return this._sourceDirectorySubPath;
3011
+ }
3012
+ const response = yield computeQuery([
3013
+ ...this._queryTree,
3014
+ {
3015
+ operation: "sourceDirectorySubPath",
3016
+ },
3017
+ ], this.client);
3018
+ return response;
3019
+ });
3020
+ }
3021
+ /**
3022
+ * This module plus the given Object type and associated functions
3023
+ */
3024
+ withObject(object) {
3025
+ return new Module_({
3026
+ queryTree: [
3027
+ ...this._queryTree,
3028
+ {
3029
+ operation: "withObject",
3030
+ args: { object },
3031
+ },
3032
+ ],
3033
+ host: this.clientHost,
3034
+ sessionToken: this.sessionToken,
3035
+ });
3036
+ }
3037
+ /**
3038
+ * Call the provided function with current Module.
3039
+ *
3040
+ * This is useful for reusability and readability by not breaking the calling chain.
3041
+ */
3042
+ with(arg) {
3043
+ return arg(this);
3044
+ }
3045
+ }
3046
+ /**
3047
+ * Static configuration for a module (e.g. parsed contents of dagger.json)
3048
+ */
3049
+ export class ModuleConfig extends BaseClient {
3050
+ /**
3051
+ * Constructor is used for internal usage only, do not create object from it.
3052
+ */
3053
+ constructor(parent, _name, _root, _sdk) {
3054
+ super(parent);
3055
+ this._name = undefined;
3056
+ this._root = undefined;
3057
+ this._sdk = undefined;
3058
+ this._name = _name;
3059
+ this._root = _root;
3060
+ this._sdk = _sdk;
3061
+ }
3062
+ /**
3063
+ * Modules that this module depends on.
3064
+ */
3065
+ dependencies() {
3066
+ return __awaiter(this, void 0, void 0, function* () {
3067
+ const response = yield computeQuery([
3068
+ ...this._queryTree,
3069
+ {
3070
+ operation: "dependencies",
3071
+ },
3072
+ ], this.client);
3073
+ return response;
3074
+ });
3075
+ }
3076
+ /**
3077
+ * Exclude these file globs when loading the module root.
3078
+ */
3079
+ exclude() {
3080
+ return __awaiter(this, void 0, void 0, function* () {
3081
+ const response = yield computeQuery([
3082
+ ...this._queryTree,
3083
+ {
3084
+ operation: "exclude",
3085
+ },
3086
+ ], this.client);
3087
+ return response;
3088
+ });
3089
+ }
3090
+ /**
3091
+ * Include only these file globs when loading the module root.
3092
+ */
3093
+ include() {
3094
+ return __awaiter(this, void 0, void 0, function* () {
3095
+ const response = yield computeQuery([
3096
+ ...this._queryTree,
3097
+ {
3098
+ operation: "include",
3099
+ },
3100
+ ], this.client);
3101
+ return response;
3102
+ });
3103
+ }
3104
+ /**
3105
+ * The name of the module.
3106
+ */
3107
+ name() {
3108
+ return __awaiter(this, void 0, void 0, function* () {
3109
+ if (this._name) {
3110
+ return this._name;
3111
+ }
3112
+ const response = yield computeQuery([
3113
+ ...this._queryTree,
3114
+ {
3115
+ operation: "name",
3116
+ },
3117
+ ], this.client);
3118
+ return response;
3119
+ });
3120
+ }
3121
+ /**
3122
+ * The root directory of the module's project, which may be above the module source code.
3123
+ */
3124
+ root() {
3125
+ return __awaiter(this, void 0, void 0, function* () {
3126
+ if (this._root) {
3127
+ return this._root;
3128
+ }
3129
+ const response = yield computeQuery([
3130
+ ...this._queryTree,
3131
+ {
3132
+ operation: "root",
3133
+ },
3134
+ ], this.client);
3135
+ return response;
3136
+ });
3137
+ }
3138
+ /**
3139
+ * Either the name of a built-in SDK ('go', 'python', etc.) OR a module reference pointing to the SDK's module implementation.
3140
+ */
3141
+ sdk() {
3142
+ return __awaiter(this, void 0, void 0, function* () {
3143
+ if (this._sdk) {
3144
+ return this._sdk;
3145
+ }
3146
+ const response = yield computeQuery([
3147
+ ...this._queryTree,
3148
+ {
3149
+ operation: "sdk",
3150
+ },
3151
+ ], this.client);
3152
+ return response;
3153
+ });
3154
+ }
3155
+ }
3156
+ /**
3157
+ * A definition of a custom object defined in a Module.
3158
+ */
3159
+ export class ObjectTypeDef extends BaseClient {
3160
+ /**
3161
+ * Constructor is used for internal usage only, do not create object from it.
3162
+ */
3163
+ constructor(parent, _description, _name) {
3164
+ super(parent);
3165
+ this._description = undefined;
3166
+ this._name = undefined;
3167
+ this._description = _description;
3168
+ this._name = _name;
3169
+ }
3170
+ /**
3171
+ * The doc string for the object, if any
3172
+ */
3173
+ description() {
3174
+ return __awaiter(this, void 0, void 0, function* () {
3175
+ if (this._description) {
3176
+ return this._description;
3177
+ }
3178
+ const response = yield computeQuery([
3179
+ ...this._queryTree,
3180
+ {
3181
+ operation: "description",
3182
+ },
3183
+ ], this.client);
3184
+ return response;
3185
+ });
3186
+ }
3187
+ /**
3188
+ * Static fields defined on this object, if any
3189
+ */
3190
+ fields() {
3191
+ return __awaiter(this, void 0, void 0, function* () {
3192
+ const response = yield computeQuery([
3193
+ ...this._queryTree,
3194
+ {
3195
+ operation: "fields",
3196
+ },
3197
+ {
3198
+ operation: "description name",
3199
+ },
3200
+ ], this.client);
3201
+ return response.map((r) => new FieldTypeDef({
3202
+ queryTree: this.queryTree,
3203
+ host: this.clientHost,
3204
+ sessionToken: this.sessionToken,
3205
+ }, r.description, r.name));
3206
+ });
3207
+ }
3208
+ /**
3209
+ * Functions defined on this object, if any
3210
+ */
3211
+ functions() {
3212
+ return __awaiter(this, void 0, void 0, function* () {
3213
+ const response = yield computeQuery([
3214
+ ...this._queryTree,
3215
+ {
3216
+ operation: "functions",
3217
+ },
3218
+ {
3219
+ operation: "id",
3220
+ },
3221
+ ], this.client);
3222
+ return response.map((r) => new Function_({
3223
+ queryTree: this.queryTree,
3224
+ host: this.clientHost,
3225
+ sessionToken: this.sessionToken,
3226
+ }, r.id));
3227
+ });
3228
+ }
3229
+ /**
3230
+ * The name of the object
3231
+ */
3232
+ name() {
3233
+ return __awaiter(this, void 0, void 0, function* () {
3234
+ if (this._name) {
3235
+ return this._name;
3236
+ }
3237
+ const response = yield computeQuery([
3238
+ ...this._queryTree,
3239
+ {
3240
+ operation: "name",
3241
+ },
3242
+ ], this.client);
3243
+ return response;
3244
+ });
3245
+ }
3246
+ }
3247
+ /**
3248
+ * A port exposed by a container.
3249
+ */
3250
+ export class Port extends BaseClient {
3251
+ /**
3252
+ * Constructor is used for internal usage only, do not create object from it.
3253
+ */
3254
+ constructor(parent, _description, _port, _protocol) {
3255
+ super(parent);
3256
+ this._description = undefined;
3257
+ this._port = undefined;
3258
+ this._protocol = undefined;
3259
+ this._description = _description;
3260
+ this._port = _port;
3261
+ this._protocol = _protocol;
3262
+ }
3263
+ /**
3264
+ * The port description.
3265
+ */
3266
+ description() {
3267
+ return __awaiter(this, void 0, void 0, function* () {
3268
+ if (this._description) {
3269
+ return this._description;
3270
+ }
3271
+ const response = yield computeQuery([
3272
+ ...this._queryTree,
3273
+ {
3274
+ operation: "description",
3275
+ },
3276
+ ], this.client);
3277
+ return response;
3278
+ });
3279
+ }
3280
+ /**
3281
+ * The port number.
3282
+ */
3283
+ port() {
3284
+ return __awaiter(this, void 0, void 0, function* () {
3285
+ if (this._port) {
3286
+ return this._port;
3287
+ }
3288
+ const response = yield computeQuery([
3289
+ ...this._queryTree,
3290
+ {
3291
+ operation: "port",
3292
+ },
3293
+ ], this.client);
3294
+ return response;
3295
+ });
3296
+ }
3297
+ /**
3298
+ * The transport layer network protocol.
3299
+ */
3300
+ protocol() {
3301
+ return __awaiter(this, void 0, void 0, function* () {
3302
+ if (this._protocol) {
3303
+ return this._protocol;
3304
+ }
3305
+ const response = yield computeQuery([
3306
+ ...this._queryTree,
3307
+ {
3308
+ operation: "protocol",
3309
+ },
3310
+ ], this.client);
3311
+ return response;
3312
+ });
3313
+ }
3314
+ }
3315
+ export class Client extends BaseClient {
3316
+ /**
3317
+ * Constructor is used for internal usage only, do not create object from it.
3318
+ */
3319
+ constructor(parent, _checkVersionCompatibility, _defaultPlatform) {
3320
+ super(parent);
3321
+ this._checkVersionCompatibility = undefined;
3322
+ this._defaultPlatform = undefined;
3323
+ this._checkVersionCompatibility = _checkVersionCompatibility;
3324
+ this._defaultPlatform = _defaultPlatform;
3325
+ }
3326
+ /**
3327
+ * Constructs a cache volume for a given cache key.
3328
+ * @param key A string identifier to target this cache volume (e.g., "modules-cache").
3329
+ */
3330
+ cacheVolume(key) {
3331
+ return new CacheVolume({
3332
+ queryTree: [
3333
+ ...this._queryTree,
3334
+ {
3335
+ operation: "cacheVolume",
3336
+ args: { key },
3337
+ },
3338
+ ],
3339
+ host: this.clientHost,
3340
+ sessionToken: this.sessionToken,
3341
+ });
3342
+ }
3343
+ /**
3344
+ * Checks if the current Dagger Engine is compatible with an SDK's required version.
3345
+ * @param version The SDK's required version.
3346
+ */
3347
+ checkVersionCompatibility(version) {
3348
+ return __awaiter(this, void 0, void 0, function* () {
3349
+ const response = yield computeQuery([
3350
+ ...this._queryTree,
3351
+ {
3352
+ operation: "checkVersionCompatibility",
3353
+ args: { version },
3354
+ },
3355
+ ], this.client);
3356
+ return response;
3357
+ });
3358
+ }
3359
+ /**
3360
+ * Creates a scratch container or loads one by ID.
3361
+ *
3362
+ * Optional platform argument initializes new containers to execute and publish
3363
+ * as that platform. Platform defaults to that of the builder's host.
3364
+ */
3365
+ container(opts) {
3366
+ return new Container({
3367
+ queryTree: [
3368
+ ...this._queryTree,
3369
+ {
3370
+ operation: "container",
3371
+ args: Object.assign({}, opts),
3372
+ },
3373
+ ],
3374
+ host: this.clientHost,
3375
+ sessionToken: this.sessionToken,
3376
+ });
3377
+ }
3378
+ /**
3379
+ * The FunctionCall context that the SDK caller is currently executing in.
3380
+ * If the caller is not currently executing in a function, this will return
3381
+ * an error.
3382
+ */
3383
+ currentFunctionCall() {
3384
+ return new FunctionCall({
3385
+ queryTree: [
3386
+ ...this._queryTree,
3387
+ {
3388
+ operation: "currentFunctionCall",
3389
+ },
3390
+ ],
3391
+ host: this.clientHost,
3392
+ sessionToken: this.sessionToken,
3393
+ });
3394
+ }
3395
+ /**
3396
+ * The module currently being served in the session, if any.
3397
+ */
3398
+ currentModule() {
3399
+ return new Module_({
3400
+ queryTree: [
3401
+ ...this._queryTree,
3402
+ {
3403
+ operation: "currentModule",
3404
+ },
3405
+ ],
3406
+ host: this.clientHost,
3407
+ sessionToken: this.sessionToken,
3408
+ });
3409
+ }
3410
+ /**
3411
+ * The default platform of the builder.
3412
+ */
3413
+ defaultPlatform() {
3414
+ return __awaiter(this, void 0, void 0, function* () {
3415
+ const response = yield computeQuery([
3416
+ ...this._queryTree,
3417
+ {
3418
+ operation: "defaultPlatform",
3419
+ },
3420
+ ], this.client);
3421
+ return response;
3422
+ });
3423
+ }
3424
+ /**
3425
+ * Creates an empty directory or loads one by ID.
3426
+ */
3427
+ directory(opts) {
3428
+ return new Directory({
3429
+ queryTree: [
3430
+ ...this._queryTree,
3431
+ {
3432
+ operation: "directory",
3433
+ args: Object.assign({}, opts),
3434
+ },
3435
+ ],
3436
+ host: this.clientHost,
3437
+ sessionToken: this.sessionToken,
3438
+ });
3439
+ }
3440
+ /**
3441
+ * Loads a file by ID.
3442
+ * @deprecated Use loadFileFromID instead.
3443
+ */
3444
+ file(id) {
3445
+ return new File({
3446
+ queryTree: [
3447
+ ...this._queryTree,
3448
+ {
3449
+ operation: "file",
3450
+ args: { id },
3451
+ },
3452
+ ],
3453
+ host: this.clientHost,
3454
+ sessionToken: this.sessionToken,
3455
+ });
3456
+ }
3457
+ /**
3458
+ * Create a function.
3459
+ */
3460
+ function_(name, returnType) {
3461
+ return new Function_({
3462
+ queryTree: [
3463
+ ...this._queryTree,
3464
+ {
3465
+ operation: "function",
3466
+ args: { name, returnType },
3467
+ },
3468
+ ],
3469
+ host: this.clientHost,
3470
+ sessionToken: this.sessionToken,
3471
+ });
3472
+ }
3473
+ /**
3474
+ * Create a code generation result, given a directory containing the generated
3475
+ * code.
3476
+ */
3477
+ generatedCode(code) {
3478
+ return new GeneratedCode({
3479
+ queryTree: [
3480
+ ...this._queryTree,
3481
+ {
3482
+ operation: "generatedCode",
3483
+ args: { code },
3484
+ },
3485
+ ],
3486
+ host: this.clientHost,
3487
+ sessionToken: this.sessionToken,
3488
+ });
3489
+ }
3490
+ /**
3491
+ * Queries a git repository.
3492
+ * @param url Url of the git repository.
3493
+ * Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo}
3494
+ * Suffix ".git" is optional.
3495
+ * @param opts.keepGitDir Set to true to keep .git directory.
3496
+ * @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
3497
+ */
3498
+ git(url, opts) {
3499
+ return new GitRepository({
3500
+ queryTree: [
3501
+ ...this._queryTree,
3502
+ {
3503
+ operation: "git",
3504
+ args: Object.assign({ url }, opts),
3505
+ },
3506
+ ],
3507
+ host: this.clientHost,
3508
+ sessionToken: this.sessionToken,
3509
+ });
3510
+ }
3511
+ /**
3512
+ * Queries the host environment.
3513
+ */
3514
+ host() {
3515
+ return new Host({
3516
+ queryTree: [
3517
+ ...this._queryTree,
3518
+ {
3519
+ operation: "host",
3520
+ },
3521
+ ],
3522
+ host: this.clientHost,
3523
+ sessionToken: this.sessionToken,
3524
+ });
3525
+ }
3526
+ /**
3527
+ * Returns a file containing an http remote url content.
3528
+ * @param url HTTP url to get the content from (e.g., "https://docs.dagger.io").
3529
+ * @param opts.experimentalServiceHost A service which must be started before the URL is fetched.
3530
+ */
3531
+ http(url, opts) {
3532
+ return new File({
3533
+ queryTree: [
3534
+ ...this._queryTree,
3535
+ {
3536
+ operation: "http",
3537
+ args: Object.assign({ url }, opts),
3538
+ },
3539
+ ],
3540
+ host: this.clientHost,
3541
+ sessionToken: this.sessionToken,
3542
+ });
3543
+ }
3544
+ /**
3545
+ * Load a CacheVolume from its ID.
3546
+ */
3547
+ loadCacheVolumeFromID(id) {
3548
+ return new CacheVolume({
3549
+ queryTree: [
3550
+ ...this._queryTree,
3551
+ {
3552
+ operation: "loadCacheVolumeFromID",
3553
+ args: { id },
3554
+ },
3555
+ ],
3556
+ host: this.clientHost,
3557
+ sessionToken: this.sessionToken,
3558
+ });
3559
+ }
3560
+ /**
3561
+ * Loads a container from an ID.
3562
+ */
3563
+ loadContainerFromID(id) {
3564
+ return new Container({
3565
+ queryTree: [
3566
+ ...this._queryTree,
3567
+ {
3568
+ operation: "loadContainerFromID",
3569
+ args: { id },
3570
+ },
3571
+ ],
3572
+ host: this.clientHost,
3573
+ sessionToken: this.sessionToken,
3574
+ });
3575
+ }
3576
+ /**
3577
+ * Load a Directory from its ID.
3578
+ */
3579
+ loadDirectoryFromID(id) {
3580
+ return new Directory({
3581
+ queryTree: [
3582
+ ...this._queryTree,
3583
+ {
3584
+ operation: "loadDirectoryFromID",
3585
+ args: { id },
3586
+ },
3587
+ ],
3588
+ host: this.clientHost,
3589
+ sessionToken: this.sessionToken,
3590
+ });
3591
+ }
3592
+ /**
3593
+ * Load a File from its ID.
3594
+ */
3595
+ loadFileFromID(id) {
3596
+ return new File({
3597
+ queryTree: [
3598
+ ...this._queryTree,
3599
+ {
3600
+ operation: "loadFileFromID",
3601
+ args: { id },
3602
+ },
3603
+ ],
3604
+ host: this.clientHost,
3605
+ sessionToken: this.sessionToken,
3606
+ });
3607
+ }
3608
+ /**
3609
+ * Load a function argument by ID.
3610
+ */
3611
+ loadFunctionArgFromID(id) {
3612
+ return new FunctionArg({
3613
+ queryTree: [
3614
+ ...this._queryTree,
3615
+ {
3616
+ operation: "loadFunctionArgFromID",
3617
+ args: { id },
3618
+ },
3619
+ ],
3620
+ host: this.clientHost,
3621
+ sessionToken: this.sessionToken,
3622
+ });
3623
+ }
3624
+ /**
3625
+ * Load a function by ID.
3626
+ */
3627
+ loadFunctionFromID(id) {
3628
+ return new Function_({
3629
+ queryTree: [
3630
+ ...this._queryTree,
3631
+ {
3632
+ operation: "loadFunctionFromID",
3633
+ args: { id },
3634
+ },
3635
+ ],
3636
+ host: this.clientHost,
3637
+ sessionToken: this.sessionToken,
3638
+ });
3639
+ }
3640
+ /**
3641
+ * Load a GeneratedCode by ID.
3642
+ */
3643
+ loadGeneratedCodeFromID(id) {
3644
+ return new GeneratedCode({
3645
+ queryTree: [
3646
+ ...this._queryTree,
3647
+ {
3648
+ operation: "loadGeneratedCodeFromID",
3649
+ args: { id },
3650
+ },
3651
+ ],
3652
+ host: this.clientHost,
3653
+ sessionToken: this.sessionToken,
3654
+ });
3655
+ }
3656
+ /**
3657
+ * Load a module by ID.
3658
+ */
3659
+ loadModuleFromID(id) {
3660
+ return new Module_({
3661
+ queryTree: [
3662
+ ...this._queryTree,
3663
+ {
3664
+ operation: "loadModuleFromID",
3665
+ args: { id },
3666
+ },
3667
+ ],
3668
+ host: this.clientHost,
3669
+ sessionToken: this.sessionToken,
3670
+ });
3671
+ }
3672
+ /**
3673
+ * Load a Secret from its ID.
3674
+ */
3675
+ loadSecretFromID(id) {
3676
+ return new Secret({
3677
+ queryTree: [
3678
+ ...this._queryTree,
3679
+ {
3680
+ operation: "loadSecretFromID",
3681
+ args: { id },
3682
+ },
3683
+ ],
3684
+ host: this.clientHost,
3685
+ sessionToken: this.sessionToken,
3686
+ });
3687
+ }
3688
+ /**
3689
+ * Loads a service from ID.
3690
+ */
3691
+ loadServiceFromID(id) {
3692
+ return new Service({
3693
+ queryTree: [
3694
+ ...this._queryTree,
3695
+ {
3696
+ operation: "loadServiceFromID",
3697
+ args: { id },
3698
+ },
3699
+ ],
3700
+ host: this.clientHost,
3701
+ sessionToken: this.sessionToken,
3702
+ });
3703
+ }
3704
+ /**
3705
+ * Load a Socket from its ID.
3706
+ */
3707
+ loadSocketFromID(id) {
3708
+ return new Socket({
3709
+ queryTree: [
3710
+ ...this._queryTree,
3711
+ {
3712
+ operation: "loadSocketFromID",
3713
+ args: { id },
3714
+ },
3715
+ ],
3716
+ host: this.clientHost,
3717
+ sessionToken: this.sessionToken,
3718
+ });
3719
+ }
3720
+ /**
3721
+ * Load a TypeDef by ID.
3722
+ */
3723
+ loadTypeDefFromID(id) {
3724
+ return new TypeDef({
3725
+ queryTree: [
3726
+ ...this._queryTree,
3727
+ {
3728
+ operation: "loadTypeDefFromID",
3729
+ args: { id },
3730
+ },
3731
+ ],
3732
+ host: this.clientHost,
3733
+ sessionToken: this.sessionToken,
3734
+ });
3735
+ }
3736
+ /**
3737
+ * Create a new module.
3738
+ */
3739
+ module_() {
3740
+ return new Module_({
3741
+ queryTree: [
3742
+ ...this._queryTree,
3743
+ {
3744
+ operation: "module",
3745
+ },
3746
+ ],
3747
+ host: this.clientHost,
3748
+ sessionToken: this.sessionToken,
3749
+ });
3750
+ }
3751
+ /**
3752
+ * Load the static configuration for a module from the given source directory and optional subpath.
3753
+ */
3754
+ moduleConfig(sourceDirectory, opts) {
3755
+ return new ModuleConfig({
3756
+ queryTree: [
3757
+ ...this._queryTree,
3758
+ {
3759
+ operation: "moduleConfig",
3760
+ args: Object.assign({ sourceDirectory }, opts),
3761
+ },
3762
+ ],
3763
+ host: this.clientHost,
3764
+ sessionToken: this.sessionToken,
3765
+ });
3766
+ }
3767
+ /**
3768
+ * Creates a named sub-pipeline.
3769
+ * @param name Pipeline name.
3770
+ * @param opts.description Pipeline description.
3771
+ * @param opts.labels Pipeline labels.
3772
+ */
3773
+ pipeline(name, opts) {
3774
+ return new Client({
3775
+ queryTree: [
3776
+ ...this._queryTree,
3777
+ {
3778
+ operation: "pipeline",
3779
+ args: Object.assign({ name }, opts),
3780
+ },
3781
+ ],
3782
+ host: this.clientHost,
3783
+ sessionToken: this.sessionToken,
3784
+ });
3785
+ }
3786
+ /**
3787
+ * Loads a secret from its ID.
3788
+ * @deprecated Use loadSecretFromID instead
3789
+ */
3790
+ secret(id) {
3791
+ return new Secret({
3792
+ queryTree: [
3793
+ ...this._queryTree,
3794
+ {
3795
+ operation: "secret",
3796
+ args: { id },
3797
+ },
3798
+ ],
3799
+ host: this.clientHost,
3800
+ sessionToken: this.sessionToken,
3801
+ });
3802
+ }
3803
+ /**
3804
+ * Sets a secret given a user defined name to its plaintext and returns the secret.
3805
+ * The plaintext value is limited to a size of 128000 bytes.
3806
+ * @param name The user defined name for this secret
3807
+ * @param plaintext The plaintext of the secret
3808
+ */
3809
+ setSecret(name, plaintext) {
3810
+ return new Secret({
3811
+ queryTree: [
3812
+ ...this._queryTree,
3813
+ {
3814
+ operation: "setSecret",
3815
+ args: { name, plaintext },
3816
+ },
3817
+ ],
3818
+ host: this.clientHost,
3819
+ sessionToken: this.sessionToken,
3820
+ });
3821
+ }
3822
+ /**
3823
+ * Loads a socket by its ID.
3824
+ * @deprecated Use loadSocketFromID instead.
3825
+ */
3826
+ socket(opts) {
3827
+ return new Socket({
3828
+ queryTree: [
3829
+ ...this._queryTree,
3830
+ {
3831
+ operation: "socket",
3832
+ args: Object.assign({}, opts),
3833
+ },
3834
+ ],
3835
+ host: this.clientHost,
3836
+ sessionToken: this.sessionToken,
3837
+ });
3838
+ }
3839
+ /**
3840
+ * Create a new TypeDef.
3841
+ */
3842
+ typeDef() {
3843
+ return new TypeDef({
3844
+ queryTree: [
3845
+ ...this._queryTree,
3846
+ {
3847
+ operation: "typeDef",
3848
+ },
3849
+ ],
3850
+ host: this.clientHost,
3851
+ sessionToken: this.sessionToken,
3852
+ });
3853
+ }
3854
+ /**
3855
+ * Call the provided function with current Client.
3856
+ *
3857
+ * This is useful for reusability and readability by not breaking the calling chain.
3858
+ */
3859
+ with(arg) {
3860
+ return arg(this);
3861
+ }
3862
+ }
3863
+ /**
3864
+ * A reference to a secret value, which can be handled more safely than the value itself.
3865
+ */
3866
+ export class Secret extends BaseClient {
3867
+ /**
3868
+ * Constructor is used for internal usage only, do not create object from it.
3869
+ */
3870
+ constructor(parent, _id, _plaintext) {
3871
+ super(parent);
3872
+ this._id = undefined;
3873
+ this._plaintext = undefined;
3874
+ this._id = _id;
3875
+ this._plaintext = _plaintext;
3876
+ }
3877
+ /**
3878
+ * The identifier for this secret.
3879
+ */
3880
+ id() {
3881
+ return __awaiter(this, void 0, void 0, function* () {
3882
+ if (this._id) {
3883
+ return this._id;
3884
+ }
3885
+ const response = yield computeQuery([
3886
+ ...this._queryTree,
3887
+ {
3888
+ operation: "id",
3889
+ },
3890
+ ], this.client);
3891
+ return response;
3892
+ });
3893
+ }
3894
+ /**
3895
+ * The value of this secret.
3896
+ */
3897
+ plaintext() {
3898
+ return __awaiter(this, void 0, void 0, function* () {
3899
+ if (this._plaintext) {
3900
+ return this._plaintext;
3901
+ }
3902
+ const response = yield computeQuery([
3903
+ ...this._queryTree,
3904
+ {
3905
+ operation: "plaintext",
3906
+ },
3907
+ ], this.client);
3908
+ return response;
3909
+ });
3910
+ }
3911
+ }
3912
+ export class Service extends BaseClient {
3913
+ /**
3914
+ * Constructor is used for internal usage only, do not create object from it.
3915
+ */
3916
+ constructor(parent, _id, _endpoint, _hostname, _start, _stop) {
3917
+ super(parent);
3918
+ this._id = undefined;
3919
+ this._endpoint = undefined;
3920
+ this._hostname = undefined;
3921
+ this._start = undefined;
3922
+ this._stop = undefined;
3923
+ this._id = _id;
3924
+ this._endpoint = _endpoint;
3925
+ this._hostname = _hostname;
3926
+ this._start = _start;
3927
+ this._stop = _stop;
3928
+ }
3929
+ /**
3930
+ * A unique identifier for this service.
3931
+ */
3932
+ id() {
3933
+ return __awaiter(this, void 0, void 0, function* () {
3934
+ if (this._id) {
3935
+ return this._id;
3936
+ }
3937
+ const response = yield computeQuery([
3938
+ ...this._queryTree,
3939
+ {
3940
+ operation: "id",
3941
+ },
3942
+ ], this.client);
3943
+ return response;
3944
+ });
3945
+ }
3946
+ /**
3947
+ * Retrieves an endpoint that clients can use to reach this container.
3948
+ *
3949
+ * If no port is specified, the first exposed port is used. If none exist an error is returned.
3950
+ *
3951
+ * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
3952
+ * @param opts.port The exposed port number for the endpoint
3953
+ * @param opts.scheme Return a URL with the given scheme, eg. http for http://
3954
+ */
3955
+ endpoint(opts) {
3956
+ return __awaiter(this, void 0, void 0, function* () {
3957
+ if (this._endpoint) {
3958
+ return this._endpoint;
3959
+ }
3960
+ const response = yield computeQuery([
3961
+ ...this._queryTree,
3962
+ {
3963
+ operation: "endpoint",
3964
+ args: Object.assign({}, opts),
3965
+ },
3966
+ ], this.client);
3967
+ return response;
3968
+ });
3969
+ }
3970
+ /**
3971
+ * Retrieves a hostname which can be used by clients to reach this container.
3972
+ */
3973
+ hostname() {
3974
+ return __awaiter(this, void 0, void 0, function* () {
3975
+ if (this._hostname) {
3976
+ return this._hostname;
3977
+ }
3978
+ const response = yield computeQuery([
3979
+ ...this._queryTree,
3980
+ {
3981
+ operation: "hostname",
3982
+ },
3983
+ ], this.client);
3984
+ return response;
3985
+ });
3986
+ }
3987
+ /**
3988
+ * Retrieves the list of ports provided by the service.
3989
+ */
3990
+ ports() {
3991
+ return __awaiter(this, void 0, void 0, function* () {
3992
+ const response = yield computeQuery([
3993
+ ...this._queryTree,
3994
+ {
3995
+ operation: "ports",
3996
+ },
3997
+ {
3998
+ operation: "description port protocol",
3999
+ },
4000
+ ], this.client);
4001
+ return response.map((r) => new Port({
4002
+ queryTree: this.queryTree,
4003
+ host: this.clientHost,
4004
+ sessionToken: this.sessionToken,
4005
+ }, r.description, r.port, r.protocol));
4006
+ });
4007
+ }
4008
+ /**
4009
+ * Start the service and wait for its health checks to succeed.
4010
+ *
4011
+ * Services bound to a Container do not need to be manually started.
4012
+ */
4013
+ start() {
4014
+ return __awaiter(this, void 0, void 0, function* () {
4015
+ yield computeQuery([
4016
+ ...this._queryTree,
4017
+ {
4018
+ operation: "start",
4019
+ },
4020
+ ], this.client);
4021
+ return this;
4022
+ });
4023
+ }
4024
+ /**
4025
+ * Stop the service.
4026
+ */
4027
+ stop() {
4028
+ return __awaiter(this, void 0, void 0, function* () {
4029
+ yield computeQuery([
4030
+ ...this._queryTree,
4031
+ {
4032
+ operation: "stop",
4033
+ },
4034
+ ], this.client);
4035
+ return this;
4036
+ });
4037
+ }
4038
+ }
4039
+ export class Socket extends BaseClient {
4040
+ /**
4041
+ * Constructor is used for internal usage only, do not create object from it.
4042
+ */
4043
+ constructor(parent, _id) {
4044
+ super(parent);
4045
+ this._id = undefined;
4046
+ this._id = _id;
4047
+ }
4048
+ /**
4049
+ * The content-addressed identifier of the socket.
4050
+ */
4051
+ id() {
4052
+ return __awaiter(this, void 0, void 0, function* () {
4053
+ if (this._id) {
4054
+ return this._id;
4055
+ }
4056
+ const response = yield computeQuery([
4057
+ ...this._queryTree,
4058
+ {
4059
+ operation: "id",
4060
+ },
4061
+ ], this.client);
4062
+ return response;
4063
+ });
4064
+ }
4065
+ }
4066
+ /**
4067
+ * A definition of a parameter or return type in a Module.
4068
+ */
4069
+ export class TypeDef extends BaseClient {
4070
+ /**
4071
+ * Constructor is used for internal usage only, do not create object from it.
4072
+ */
4073
+ constructor(parent, _id, _kind, _optional) {
4074
+ super(parent);
4075
+ this._id = undefined;
4076
+ this._kind = undefined;
4077
+ this._optional = undefined;
4078
+ this._id = _id;
4079
+ this._kind = _kind;
4080
+ this._optional = _optional;
4081
+ }
4082
+ id() {
4083
+ return __awaiter(this, void 0, void 0, function* () {
4084
+ if (this._id) {
4085
+ return this._id;
4086
+ }
4087
+ const response = yield computeQuery([
4088
+ ...this._queryTree,
4089
+ {
4090
+ operation: "id",
4091
+ },
4092
+ ], this.client);
4093
+ return response;
4094
+ });
4095
+ }
4096
+ /**
4097
+ * If kind is LIST, the list-specific type definition.
4098
+ * If kind is not LIST, this will be null.
4099
+ */
4100
+ asList() {
4101
+ return new ListTypeDef({
4102
+ queryTree: [
4103
+ ...this._queryTree,
4104
+ {
4105
+ operation: "asList",
4106
+ },
4107
+ ],
4108
+ host: this.clientHost,
4109
+ sessionToken: this.sessionToken,
4110
+ });
4111
+ }
4112
+ /**
4113
+ * If kind is OBJECT, the object-specific type definition.
4114
+ * If kind is not OBJECT, this will be null.
4115
+ */
4116
+ asObject() {
4117
+ return new ObjectTypeDef({
4118
+ queryTree: [
4119
+ ...this._queryTree,
4120
+ {
4121
+ operation: "asObject",
4122
+ },
4123
+ ],
4124
+ host: this.clientHost,
4125
+ sessionToken: this.sessionToken,
4126
+ });
4127
+ }
4128
+ /**
4129
+ * The kind of type this is (e.g. primitive, list, object)
4130
+ */
4131
+ kind() {
4132
+ return __awaiter(this, void 0, void 0, function* () {
4133
+ if (this._kind) {
4134
+ return this._kind;
4135
+ }
4136
+ const response = yield computeQuery([
4137
+ ...this._queryTree,
4138
+ {
4139
+ operation: "kind",
4140
+ },
4141
+ ], this.client);
4142
+ return response;
4143
+ });
4144
+ }
4145
+ /**
4146
+ * Whether this type can be set to null. Defaults to false.
4147
+ */
4148
+ optional() {
4149
+ return __awaiter(this, void 0, void 0, function* () {
4150
+ if (this._optional) {
4151
+ return this._optional;
4152
+ }
4153
+ const response = yield computeQuery([
4154
+ ...this._queryTree,
4155
+ {
4156
+ operation: "optional",
4157
+ },
4158
+ ], this.client);
4159
+ return response;
4160
+ });
4161
+ }
4162
+ /**
4163
+ * Adds a static field for an Object TypeDef, failing if the type is not an object.
4164
+ * @param name The name of the field in the object
4165
+ * @param typeDef The type of the field
4166
+ * @param opts.description A doc string for the field, if any
4167
+ */
4168
+ withField(name, typeDef, opts) {
4169
+ return new TypeDef({
4170
+ queryTree: [
4171
+ ...this._queryTree,
4172
+ {
4173
+ operation: "withField",
4174
+ args: Object.assign({ name, typeDef }, opts),
4175
+ },
4176
+ ],
4177
+ host: this.clientHost,
4178
+ sessionToken: this.sessionToken,
4179
+ });
4180
+ }
4181
+ /**
4182
+ * Adds a function for an Object TypeDef, failing if the type is not an object.
4183
+ */
4184
+ withFunction(function_) {
4185
+ return new TypeDef({
4186
+ queryTree: [
4187
+ ...this._queryTree,
4188
+ {
4189
+ operation: "withFunction",
4190
+ args: { function_ },
4191
+ },
4192
+ ],
4193
+ host: this.clientHost,
4194
+ sessionToken: this.sessionToken,
4195
+ });
4196
+ }
4197
+ /**
4198
+ * Sets the kind of the type.
4199
+ */
4200
+ withKind(kind) {
4201
+ return new TypeDef({
4202
+ queryTree: [
4203
+ ...this._queryTree,
4204
+ {
4205
+ operation: "withKind",
4206
+ args: { kind },
4207
+ },
4208
+ ],
4209
+ host: this.clientHost,
4210
+ sessionToken: this.sessionToken,
4211
+ });
4212
+ }
4213
+ /**
4214
+ * Returns a TypeDef of kind List with the provided type for its elements.
4215
+ */
4216
+ withListOf(elementType) {
4217
+ return new TypeDef({
4218
+ queryTree: [
4219
+ ...this._queryTree,
4220
+ {
4221
+ operation: "withListOf",
4222
+ args: { elementType },
4223
+ },
4224
+ ],
4225
+ host: this.clientHost,
4226
+ sessionToken: this.sessionToken,
4227
+ });
4228
+ }
4229
+ /**
4230
+ * Returns a TypeDef of kind Object with the provided name.
4231
+ *
4232
+ * Note that an object's fields and functions may be omitted if the intent is
4233
+ * only to refer to an object. This is how functions are able to return their
4234
+ * own object, or any other circular reference.
4235
+ */
4236
+ withObject(name, opts) {
4237
+ return new TypeDef({
4238
+ queryTree: [
4239
+ ...this._queryTree,
4240
+ {
4241
+ operation: "withObject",
4242
+ args: Object.assign({ name }, opts),
4243
+ },
4244
+ ],
4245
+ host: this.clientHost,
4246
+ sessionToken: this.sessionToken,
4247
+ });
4248
+ }
4249
+ /**
4250
+ * Sets whether this type can be set to null.
4251
+ */
4252
+ withOptional(optional) {
4253
+ return new TypeDef({
4254
+ queryTree: [
4255
+ ...this._queryTree,
4256
+ {
4257
+ operation: "withOptional",
4258
+ args: { optional },
4259
+ },
4260
+ ],
4261
+ host: this.clientHost,
4262
+ sessionToken: this.sessionToken,
4263
+ });
4264
+ }
4265
+ /**
4266
+ * Call the provided function with current TypeDef.
4267
+ *
4268
+ * This is useful for reusability and readability by not breaking the calling chain.
4269
+ */
4270
+ with(arg) {
4271
+ return arg(this);
4272
+ }
2736
4273
  }