@dagger.io/dagger 0.13.6 → 0.14.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.
@@ -73,6 +73,24 @@ export var NetworkProtocol;
73
73
  NetworkProtocol["Tcp"] = "TCP";
74
74
  NetworkProtocol["Udp"] = "UDP";
75
75
  })(NetworkProtocol || (NetworkProtocol = {}));
76
+ /**
77
+ * Expected return type of an execution
78
+ */
79
+ export var ReturnType;
80
+ (function (ReturnType) {
81
+ /**
82
+ * Any execution (exit codes 0-127)
83
+ */
84
+ ReturnType["Any"] = "ANY";
85
+ /**
86
+ * A failed execution (exit codes 1-127)
87
+ */
88
+ ReturnType["Failure"] = "FAILURE";
89
+ /**
90
+ * A successful execution (exit code 0)
91
+ */
92
+ ReturnType["Success"] = "SUCCESS";
93
+ })(ReturnType || (ReturnType = {}));
76
94
  /**
77
95
  * Distinguishes the different kinds of TypeDefs.
78
96
  */
@@ -163,6 +181,7 @@ export class CacheVolume extends BaseClient {
163
181
  export class Container extends BaseClient {
164
182
  _id = undefined;
165
183
  _envVariable = undefined;
184
+ _exitCode = undefined;
166
185
  _export = undefined;
167
186
  _imageRef = undefined;
168
187
  _label = undefined;
@@ -177,10 +196,11 @@ export class Container extends BaseClient {
177
196
  /**
178
197
  * Constructor is used for internal usage only, do not create object from it.
179
198
  */
180
- constructor(parent, _id, _envVariable, _export, _imageRef, _label, _platform, _publish, _stderr, _stdout, _sync, _up, _user, _workdir) {
199
+ constructor(parent, _id, _envVariable, _exitCode, _export, _imageRef, _label, _platform, _publish, _stderr, _stdout, _sync, _up, _user, _workdir) {
181
200
  super(parent);
182
201
  this._id = _id;
183
202
  this._envVariable = _envVariable;
203
+ this._exitCode = _exitCode;
184
204
  this._export = _export;
185
205
  this._imageRef = _imageRef;
186
206
  this._label = _label;
@@ -359,6 +379,23 @@ export class Container extends BaseClient {
359
379
  ctx: this._ctx,
360
380
  }, r.id));
361
381
  };
382
+ /**
383
+ * The exit code of the last executed command.
384
+ *
385
+ * Returns an error if no command was set.
386
+ */
387
+ exitCode = async () => {
388
+ if (this._exitCode) {
389
+ return this._exitCode;
390
+ }
391
+ const response = await computeQuery([
392
+ ...this._queryTree,
393
+ {
394
+ operation: "exitCode",
395
+ },
396
+ ], await this._ctx.connection());
397
+ return response;
398
+ };
362
399
  /**
363
400
  * EXPERIMENTAL API! Subject to change/removal at any time.
364
401
  *
@@ -646,7 +683,7 @@ export class Container extends BaseClient {
646
683
  /**
647
684
  * The error stream of the last executed command.
648
685
  *
649
- * Will execute default command if none is set, or error if there's no default.
686
+ * Returns an error if no command was set.
650
687
  */
651
688
  stderr = async () => {
652
689
  if (this._stderr) {
@@ -663,7 +700,7 @@ export class Container extends BaseClient {
663
700
  /**
664
701
  * The output stream of the last executed command.
665
702
  *
666
- * Will execute default command if none is set, or error if there's no default.
703
+ * Returns an error if no command was set.
667
704
  */
668
705
  stdout = async () => {
669
706
  if (this._stdout) {
@@ -877,6 +914,7 @@ export class Container extends BaseClient {
877
914
  * @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
878
915
  * @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
879
916
  * @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
917
+ * @param opts.expect Exit codes this command is allowed to exit with without error
880
918
  * @param opts.experimentalPrivilegedNesting Provides Dagger access to the executed command.
881
919
  *
882
920
  * Do not use this option unless you trust the command being executed; the command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
@@ -887,12 +925,15 @@ export class Container extends BaseClient {
887
925
  * This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
888
926
  */
889
927
  withExec = (args, opts) => {
928
+ const metadata = {
929
+ expect: { is_enum: true },
930
+ };
890
931
  return new Container({
891
932
  queryTree: [
892
933
  ...this._queryTree,
893
934
  {
894
935
  operation: "withExec",
895
- args: { args, ...opts },
936
+ args: { args, ...opts, __metadata: metadata },
896
937
  },
897
938
  ],
898
939
  ctx: this._ctx,
@@ -974,20 +1015,6 @@ export class Container extends BaseClient {
974
1015
  ctx: this._ctx,
975
1016
  });
976
1017
  };
977
- /**
978
- * Indicate that subsequent operations should be featured more prominently in the UI.
979
- */
980
- withFocus = () => {
981
- return new Container({
982
- queryTree: [
983
- ...this._queryTree,
984
- {
985
- operation: "withFocus",
986
- },
987
- ],
988
- ctx: this._ctx,
989
- });
990
- };
991
1018
  /**
992
1019
  * Retrieves this container plus the given label.
993
1020
  * @param name The name of the label (e.g., "org.opencontainers.artifact.created").
@@ -1414,22 +1441,6 @@ export class Container extends BaseClient {
1414
1441
  ctx: this._ctx,
1415
1442
  });
1416
1443
  };
1417
- /**
1418
- * Indicate that subsequent operations should not be featured more prominently in the UI.
1419
- *
1420
- * This is the initial state of all containers.
1421
- */
1422
- withoutFocus = () => {
1423
- return new Container({
1424
- queryTree: [
1425
- ...this._queryTree,
1426
- {
1427
- operation: "withoutFocus",
1428
- },
1429
- ],
1430
- ctx: this._ctx,
1431
- });
1432
- };
1433
1444
  /**
1434
1445
  * Retrieves this container minus the given environment label.
1435
1446
  * @param name The name of the label to remove (e.g., "org.opencontainers.artifact.created").
@@ -1664,19 +1675,25 @@ export class CurrentModule extends BaseClient {
1664
1675
  };
1665
1676
  }
1666
1677
  /**
1667
- * The Dagger engine configuration and state
1678
+ * A directory.
1668
1679
  */
1669
- export class DaggerEngine extends BaseClient {
1680
+ export class Directory extends BaseClient {
1670
1681
  _id = undefined;
1682
+ _digest = undefined;
1683
+ _export = undefined;
1684
+ _sync = undefined;
1671
1685
  /**
1672
1686
  * Constructor is used for internal usage only, do not create object from it.
1673
1687
  */
1674
- constructor(parent, _id) {
1688
+ constructor(parent, _id, _digest, _export, _sync) {
1675
1689
  super(parent);
1676
1690
  this._id = _id;
1691
+ this._digest = _digest;
1692
+ this._export = _export;
1693
+ this._sync = _sync;
1677
1694
  }
1678
1695
  /**
1679
- * A unique identifier for this DaggerEngine.
1696
+ * A unique identifier for this Directory.
1680
1697
  */
1681
1698
  id = async () => {
1682
1699
  if (this._id) {
@@ -1691,341 +1708,192 @@ export class DaggerEngine extends BaseClient {
1691
1708
  return response;
1692
1709
  };
1693
1710
  /**
1694
- * The local (on-disk) cache for the Dagger engine
1711
+ * Load the directory as a Dagger module
1712
+ * @param opts.sourceRootPath An optional subpath of the directory which contains the module's configuration file.
1713
+ *
1714
+ * This is needed when the module code is in a subdirectory but requires parent directories to be loaded in order to execute. For example, the module source code may need a go.mod, project.toml, package.json, etc. file from a parent directory.
1715
+ *
1716
+ * If not set, the module source code is loaded from the root of the directory.
1717
+ * @param opts.engineVersion The engine version to upgrade to.
1695
1718
  */
1696
- localCache = () => {
1697
- return new DaggerEngineCache({
1719
+ asModule = (opts) => {
1720
+ return new Module_({
1698
1721
  queryTree: [
1699
1722
  ...this._queryTree,
1700
1723
  {
1701
- operation: "localCache",
1724
+ operation: "asModule",
1725
+ args: { ...opts },
1702
1726
  },
1703
1727
  ],
1704
1728
  ctx: this._ctx,
1705
1729
  });
1706
1730
  };
1707
- }
1708
- /**
1709
- * A cache storage for the Dagger engine
1710
- */
1711
- export class DaggerEngineCache extends BaseClient {
1712
- _id = undefined;
1713
- _keepBytes = undefined;
1714
- _prune = undefined;
1715
- /**
1716
- * Constructor is used for internal usage only, do not create object from it.
1717
- */
1718
- constructor(parent, _id, _keepBytes, _prune) {
1719
- super(parent);
1720
- this._id = _id;
1721
- this._keepBytes = _keepBytes;
1722
- this._prune = _prune;
1723
- }
1724
- /**
1725
- * A unique identifier for this DaggerEngineCache.
1726
- */
1727
- id = async () => {
1728
- if (this._id) {
1729
- return this._id;
1730
- }
1731
- const response = await computeQuery([
1732
- ...this._queryTree,
1733
- {
1734
- operation: "id",
1735
- },
1736
- ], await this._ctx.connection());
1737
- return response;
1738
- };
1739
1731
  /**
1740
- * The current set of entries in the cache
1732
+ * Gets the difference between this directory and an another directory.
1733
+ * @param other Identifier of the directory to compare.
1741
1734
  */
1742
- entrySet = () => {
1743
- return new DaggerEngineCacheEntrySet({
1735
+ diff = (other) => {
1736
+ return new Directory({
1744
1737
  queryTree: [
1745
1738
  ...this._queryTree,
1746
1739
  {
1747
- operation: "entrySet",
1740
+ operation: "diff",
1741
+ args: { other },
1748
1742
  },
1749
1743
  ],
1750
1744
  ctx: this._ctx,
1751
1745
  });
1752
1746
  };
1753
1747
  /**
1754
- * The maximum bytes to keep in the cache without pruning, after which automatic pruning may kick in.
1748
+ * Return the directory's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
1755
1749
  */
1756
- keepBytes = async () => {
1757
- if (this._keepBytes) {
1758
- return this._keepBytes;
1750
+ digest = async () => {
1751
+ if (this._digest) {
1752
+ return this._digest;
1759
1753
  }
1760
1754
  const response = await computeQuery([
1761
1755
  ...this._queryTree,
1762
1756
  {
1763
- operation: "keepBytes",
1757
+ operation: "digest",
1764
1758
  },
1765
1759
  ], await this._ctx.connection());
1766
1760
  return response;
1767
1761
  };
1768
1762
  /**
1769
- * Prune the cache of releaseable entries
1763
+ * Retrieves a directory at the given path.
1764
+ * @param path Location of the directory to retrieve (e.g., "/src").
1770
1765
  */
1771
- prune = async () => {
1772
- if (this._prune) {
1773
- return;
1774
- }
1775
- await computeQuery([
1776
- ...this._queryTree,
1777
- {
1778
- operation: "prune",
1779
- },
1780
- ], await this._ctx.connection());
1766
+ directory = (path) => {
1767
+ return new Directory({
1768
+ queryTree: [
1769
+ ...this._queryTree,
1770
+ {
1771
+ operation: "directory",
1772
+ args: { path },
1773
+ },
1774
+ ],
1775
+ ctx: this._ctx,
1776
+ });
1781
1777
  };
1782
- }
1783
- /**
1784
- * An individual cache entry in a cache entry set
1785
- */
1786
- export class DaggerEngineCacheEntry extends BaseClient {
1787
- _id = undefined;
1788
- _activelyUsed = undefined;
1789
- _createdTimeUnixNano = undefined;
1790
- _description = undefined;
1791
- _diskSpaceBytes = undefined;
1792
- _mostRecentUseTimeUnixNano = undefined;
1793
1778
  /**
1794
- * Constructor is used for internal usage only, do not create object from it.
1779
+ * Builds a new Docker container from this directory.
1780
+ * @param opts.platform The platform to build.
1781
+ * @param opts.dockerfile Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
1782
+ * @param opts.target Target build stage to build.
1783
+ * @param opts.buildArgs Build arguments to use in the build.
1784
+ * @param opts.secrets Secrets to pass to the build.
1785
+ *
1786
+ * They will be mounted at /run/secrets/[secret-name].
1795
1787
  */
1796
- constructor(parent, _id, _activelyUsed, _createdTimeUnixNano, _description, _diskSpaceBytes, _mostRecentUseTimeUnixNano) {
1797
- super(parent);
1798
- this._id = _id;
1799
- this._activelyUsed = _activelyUsed;
1800
- this._createdTimeUnixNano = _createdTimeUnixNano;
1801
- this._description = _description;
1802
- this._diskSpaceBytes = _diskSpaceBytes;
1803
- this._mostRecentUseTimeUnixNano = _mostRecentUseTimeUnixNano;
1804
- }
1788
+ dockerBuild = (opts) => {
1789
+ return new Container({
1790
+ queryTree: [
1791
+ ...this._queryTree,
1792
+ {
1793
+ operation: "dockerBuild",
1794
+ args: { ...opts },
1795
+ },
1796
+ ],
1797
+ ctx: this._ctx,
1798
+ });
1799
+ };
1805
1800
  /**
1806
- * A unique identifier for this DaggerEngineCacheEntry.
1801
+ * Returns a list of files and directories at the given path.
1802
+ * @param opts.path Location of the directory to look at (e.g., "/src").
1807
1803
  */
1808
- id = async () => {
1809
- if (this._id) {
1810
- return this._id;
1811
- }
1804
+ entries = async (opts) => {
1812
1805
  const response = await computeQuery([
1813
1806
  ...this._queryTree,
1814
1807
  {
1815
- operation: "id",
1808
+ operation: "entries",
1809
+ args: { ...opts },
1816
1810
  },
1817
1811
  ], await this._ctx.connection());
1818
1812
  return response;
1819
1813
  };
1820
1814
  /**
1821
- * Whether the cache entry is actively being used.
1815
+ * Writes the contents of the directory to a path on the host.
1816
+ * @param path Location of the copied directory (e.g., "logs/").
1817
+ * @param opts.wipe If true, then the host directory will be wiped clean before exporting so that it exactly matches the directory being exported; this means it will delete any files on the host that aren't in the exported dir. If false (the default), the contents of the directory will be merged with any existing contents of the host directory, leaving any existing files on the host that aren't in the exported directory alone.
1822
1818
  */
1823
- activelyUsed = async () => {
1824
- if (this._activelyUsed) {
1825
- return this._activelyUsed;
1819
+ export = async (path, opts) => {
1820
+ if (this._export) {
1821
+ return this._export;
1826
1822
  }
1827
1823
  const response = await computeQuery([
1828
1824
  ...this._queryTree,
1829
1825
  {
1830
- operation: "activelyUsed",
1826
+ operation: "export",
1827
+ args: { path, ...opts },
1831
1828
  },
1832
1829
  ], await this._ctx.connection());
1833
1830
  return response;
1834
1831
  };
1835
1832
  /**
1836
- * The time the cache entry was created, in Unix nanoseconds.
1833
+ * Retrieves a file at the given path.
1834
+ * @param path Location of the file to retrieve (e.g., "README.md").
1837
1835
  */
1838
- createdTimeUnixNano = async () => {
1839
- if (this._createdTimeUnixNano) {
1840
- return this._createdTimeUnixNano;
1841
- }
1842
- const response = await computeQuery([
1843
- ...this._queryTree,
1844
- {
1845
- operation: "createdTimeUnixNano",
1846
- },
1847
- ], await this._ctx.connection());
1848
- return response;
1836
+ file = (path) => {
1837
+ return new File({
1838
+ queryTree: [
1839
+ ...this._queryTree,
1840
+ {
1841
+ operation: "file",
1842
+ args: { path },
1843
+ },
1844
+ ],
1845
+ ctx: this._ctx,
1846
+ });
1849
1847
  };
1850
1848
  /**
1851
- * The description of the cache entry.
1849
+ * Returns a list of files and directories that matche the given pattern.
1850
+ * @param pattern Pattern to match (e.g., "*.md").
1852
1851
  */
1853
- description = async () => {
1854
- if (this._description) {
1855
- return this._description;
1856
- }
1852
+ glob = async (pattern) => {
1857
1853
  const response = await computeQuery([
1858
1854
  ...this._queryTree,
1859
1855
  {
1860
- operation: "description",
1856
+ operation: "glob",
1857
+ args: { pattern },
1861
1858
  },
1862
1859
  ], await this._ctx.connection());
1863
1860
  return response;
1864
1861
  };
1865
1862
  /**
1866
- * The disk space used by the cache entry.
1863
+ * Force evaluation in the engine.
1867
1864
  */
1868
- diskSpaceBytes = async () => {
1869
- if (this._diskSpaceBytes) {
1870
- return this._diskSpaceBytes;
1871
- }
1865
+ sync = async () => {
1872
1866
  const response = await computeQuery([
1873
1867
  ...this._queryTree,
1874
1868
  {
1875
- operation: "diskSpaceBytes",
1869
+ operation: "sync",
1876
1870
  },
1877
1871
  ], await this._ctx.connection());
1878
- return response;
1879
- };
1880
- /**
1881
- * The most recent time the cache entry was used, in Unix nanoseconds.
1882
- */
1883
- mostRecentUseTimeUnixNano = async () => {
1884
- if (this._mostRecentUseTimeUnixNano) {
1885
- return this._mostRecentUseTimeUnixNano;
1886
- }
1887
- const response = await computeQuery([
1888
- ...this._queryTree,
1889
- {
1890
- operation: "mostRecentUseTimeUnixNano",
1891
- },
1892
- ], await this._ctx.connection());
1893
- return response;
1894
- };
1895
- }
1896
- /**
1897
- * A set of cache entries returned by a query to a cache
1898
- */
1899
- export class DaggerEngineCacheEntrySet extends BaseClient {
1900
- _id = undefined;
1901
- _diskSpaceBytes = undefined;
1902
- _entryCount = undefined;
1903
- /**
1904
- * Constructor is used for internal usage only, do not create object from it.
1905
- */
1906
- constructor(parent, _id, _diskSpaceBytes, _entryCount) {
1907
- super(parent);
1908
- this._id = _id;
1909
- this._diskSpaceBytes = _diskSpaceBytes;
1910
- this._entryCount = _entryCount;
1911
- }
1912
- /**
1913
- * A unique identifier for this DaggerEngineCacheEntrySet.
1914
- */
1915
- id = async () => {
1916
- if (this._id) {
1917
- return this._id;
1918
- }
1919
- const response = await computeQuery([
1920
- ...this._queryTree,
1921
- {
1922
- operation: "id",
1923
- },
1924
- ], await this._ctx.connection());
1925
- return response;
1926
- };
1927
- /**
1928
- * The total disk space used by the cache entries in this set.
1929
- */
1930
- diskSpaceBytes = async () => {
1931
- if (this._diskSpaceBytes) {
1932
- return this._diskSpaceBytes;
1933
- }
1934
- const response = await computeQuery([
1935
- ...this._queryTree,
1936
- {
1937
- operation: "diskSpaceBytes",
1938
- },
1939
- ], await this._ctx.connection());
1940
- return response;
1941
- };
1942
- /**
1943
- * The list of individual cache entries in the set
1944
- */
1945
- entries = async () => {
1946
- const response = await computeQuery([
1947
- ...this._queryTree,
1948
- {
1949
- operation: "entries",
1950
- },
1951
- {
1952
- operation: "id",
1953
- },
1954
- ], await this._ctx.connection());
1955
- return response.map((r) => new DaggerEngineCacheEntry({
1872
+ return new Directory({
1956
1873
  queryTree: [
1957
1874
  {
1958
- operation: "loadDaggerEngineCacheEntryFromID",
1959
- args: { id: r.id },
1875
+ operation: "loadDirectoryFromID",
1876
+ args: { id: response },
1960
1877
  },
1961
1878
  ],
1962
1879
  ctx: this._ctx,
1963
- }, r.id));
1964
- };
1965
- /**
1966
- * The number of cache entries in this set.
1967
- */
1968
- entryCount = async () => {
1969
- if (this._entryCount) {
1970
- return this._entryCount;
1971
- }
1972
- const response = await computeQuery([
1973
- ...this._queryTree,
1974
- {
1975
- operation: "entryCount",
1976
- },
1977
- ], await this._ctx.connection());
1978
- return response;
1979
- };
1980
- }
1981
- /**
1982
- * A directory.
1983
- */
1984
- export class Directory extends BaseClient {
1985
- _id = undefined;
1986
- _digest = undefined;
1987
- _export = undefined;
1988
- _sync = undefined;
1989
- /**
1990
- * Constructor is used for internal usage only, do not create object from it.
1991
- */
1992
- constructor(parent, _id, _digest, _export, _sync) {
1993
- super(parent);
1994
- this._id = _id;
1995
- this._digest = _digest;
1996
- this._export = _export;
1997
- this._sync = _sync;
1998
- }
1999
- /**
2000
- * A unique identifier for this Directory.
2001
- */
2002
- id = async () => {
2003
- if (this._id) {
2004
- return this._id;
2005
- }
2006
- const response = await computeQuery([
2007
- ...this._queryTree,
2008
- {
2009
- operation: "id",
2010
- },
2011
- ], await this._ctx.connection());
2012
- return response;
1880
+ });
2013
1881
  };
2014
1882
  /**
2015
- * Load the directory as a Dagger module
2016
- * @param opts.sourceRootPath An optional subpath of the directory which contains the module's configuration file.
2017
- *
2018
- * This is needed when the module code is in a subdirectory but requires parent directories to be loaded in order to execute. For example, the module source code may need a go.mod, project.toml, package.json, etc. file from a parent directory.
1883
+ * Opens an interactive terminal in new container with this directory mounted inside.
1884
+ * @param opts.cmd If set, override the container's default terminal command and invoke these command arguments instead.
1885
+ * @param opts.experimentalPrivilegedNesting Provides Dagger access to the executed command.
2019
1886
  *
2020
- * If not set, the module source code is loaded from the root of the directory.
2021
- * @param opts.engineVersion The engine version to upgrade to.
1887
+ * Do not use this option unless you trust the command being executed; the command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
1888
+ * @param opts.insecureRootCapabilities Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
1889
+ * @param opts.container If set, override the default container used for the terminal.
2022
1890
  */
2023
- asModule = (opts) => {
2024
- return new Module_({
1891
+ terminal = (opts) => {
1892
+ return new Directory({
2025
1893
  queryTree: [
2026
1894
  ...this._queryTree,
2027
1895
  {
2028
- operation: "asModule",
1896
+ operation: "terminal",
2029
1897
  args: { ...opts },
2030
1898
  },
2031
1899
  ],
@@ -2033,340 +1901,532 @@ export class Directory extends BaseClient {
2033
1901
  });
2034
1902
  };
2035
1903
  /**
2036
- * Gets the difference between this directory and an another directory.
2037
- * @param other Identifier of the directory to compare.
1904
+ * Retrieves this directory plus a directory written at the given path.
1905
+ * @param path Location of the written directory (e.g., "/src/").
1906
+ * @param directory Identifier of the directory to copy.
1907
+ * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
1908
+ * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2038
1909
  */
2039
- diff = (other) => {
1910
+ withDirectory = (path, directory, opts) => {
2040
1911
  return new Directory({
2041
1912
  queryTree: [
2042
1913
  ...this._queryTree,
2043
1914
  {
2044
- operation: "diff",
2045
- args: { other },
1915
+ operation: "withDirectory",
1916
+ args: { path, directory, ...opts },
2046
1917
  },
2047
1918
  ],
2048
1919
  ctx: this._ctx,
2049
1920
  });
2050
1921
  };
2051
1922
  /**
2052
- * Return the directory's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
2053
- */
2054
- digest = async () => {
2055
- if (this._digest) {
2056
- return this._digest;
2057
- }
2058
- const response = await computeQuery([
2059
- ...this._queryTree,
2060
- {
2061
- operation: "digest",
2062
- },
2063
- ], await this._ctx.connection());
2064
- return response;
2065
- };
2066
- /**
2067
- * Retrieves a directory at the given path.
2068
- * @param path Location of the directory to retrieve (e.g., "/src").
1923
+ * Retrieves this directory plus the contents of the given file copied to the given path.
1924
+ * @param path Location of the copied file (e.g., "/file.txt").
1925
+ * @param source Identifier of the file to copy.
1926
+ * @param opts.permissions Permission given to the copied file (e.g., 0600).
2069
1927
  */
2070
- directory = (path) => {
1928
+ withFile = (path, source, opts) => {
2071
1929
  return new Directory({
2072
1930
  queryTree: [
2073
1931
  ...this._queryTree,
2074
1932
  {
2075
- operation: "directory",
2076
- args: { path },
1933
+ operation: "withFile",
1934
+ args: { path, source, ...opts },
2077
1935
  },
2078
1936
  ],
2079
1937
  ctx: this._ctx,
2080
1938
  });
2081
1939
  };
2082
1940
  /**
2083
- * Builds a new Docker container from this directory.
2084
- * @param opts.platform The platform to build.
2085
- * @param opts.dockerfile Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
2086
- * @param opts.target Target build stage to build.
2087
- * @param opts.buildArgs Build arguments to use in the build.
2088
- * @param opts.secrets Secrets to pass to the build.
2089
- *
2090
- * They will be mounted at /run/secrets/[secret-name].
1941
+ * Retrieves this directory plus the contents of the given files copied to the given path.
1942
+ * @param path Location where copied files should be placed (e.g., "/src").
1943
+ * @param sources Identifiers of the files to copy.
1944
+ * @param opts.permissions Permission given to the copied files (e.g., 0600).
2091
1945
  */
2092
- dockerBuild = (opts) => {
2093
- return new Container({
1946
+ withFiles = (path, sources, opts) => {
1947
+ return new Directory({
2094
1948
  queryTree: [
2095
1949
  ...this._queryTree,
2096
1950
  {
2097
- operation: "dockerBuild",
2098
- args: { ...opts },
1951
+ operation: "withFiles",
1952
+ args: { path, sources, ...opts },
2099
1953
  },
2100
1954
  ],
2101
1955
  ctx: this._ctx,
2102
1956
  });
2103
1957
  };
2104
1958
  /**
2105
- * Returns a list of files and directories at the given path.
2106
- * @param opts.path Location of the directory to look at (e.g., "/src").
2107
- */
2108
- entries = async (opts) => {
2109
- const response = await computeQuery([
2110
- ...this._queryTree,
2111
- {
2112
- operation: "entries",
2113
- args: { ...opts },
2114
- },
2115
- ], await this._ctx.connection());
2116
- return response;
2117
- };
2118
- /**
2119
- * Writes the contents of the directory to a path on the host.
2120
- * @param path Location of the copied directory (e.g., "logs/").
2121
- * @param opts.wipe If true, then the host directory will be wiped clean before exporting so that it exactly matches the directory being exported; this means it will delete any files on the host that aren't in the exported dir. If false (the default), the contents of the directory will be merged with any existing contents of the host directory, leaving any existing files on the host that aren't in the exported directory alone.
2122
- */
2123
- export = async (path, opts) => {
2124
- if (this._export) {
2125
- return this._export;
2126
- }
2127
- const response = await computeQuery([
2128
- ...this._queryTree,
2129
- {
2130
- operation: "export",
2131
- args: { path, ...opts },
2132
- },
2133
- ], await this._ctx.connection());
2134
- return response;
2135
- };
2136
- /**
2137
- * Retrieves a file at the given path.
2138
- * @param path Location of the file to retrieve (e.g., "README.md").
1959
+ * Retrieves this directory plus a new directory created at the given path.
1960
+ * @param path Location of the directory created (e.g., "/logs").
1961
+ * @param opts.permissions Permission granted to the created directory (e.g., 0777).
2139
1962
  */
2140
- file = (path) => {
2141
- return new File({
1963
+ withNewDirectory = (path, opts) => {
1964
+ return new Directory({
2142
1965
  queryTree: [
2143
1966
  ...this._queryTree,
2144
1967
  {
2145
- operation: "file",
2146
- args: { path },
1968
+ operation: "withNewDirectory",
1969
+ args: { path, ...opts },
2147
1970
  },
2148
1971
  ],
2149
1972
  ctx: this._ctx,
2150
1973
  });
2151
1974
  };
2152
1975
  /**
2153
- * Returns a list of files and directories that matche the given pattern.
2154
- * @param pattern Pattern to match (e.g., "*.md").
1976
+ * Retrieves this directory plus a new file written at the given path.
1977
+ * @param path Location of the written file (e.g., "/file.txt").
1978
+ * @param contents Content of the written file (e.g., "Hello world!").
1979
+ * @param opts.permissions Permission given to the copied file (e.g., 0600).
2155
1980
  */
2156
- glob = async (pattern) => {
2157
- const response = await computeQuery([
2158
- ...this._queryTree,
2159
- {
2160
- operation: "glob",
2161
- args: { pattern },
2162
- },
2163
- ], await this._ctx.connection());
2164
- return response;
2165
- };
2166
- /**
2167
- * Force evaluation in the engine.
2168
- */
2169
- sync = async () => {
2170
- const response = await computeQuery([
2171
- ...this._queryTree,
2172
- {
2173
- operation: "sync",
2174
- },
2175
- ], await this._ctx.connection());
1981
+ withNewFile = (path, contents, opts) => {
2176
1982
  return new Directory({
2177
1983
  queryTree: [
1984
+ ...this._queryTree,
2178
1985
  {
2179
- operation: "loadDirectoryFromID",
2180
- args: { id: response },
1986
+ operation: "withNewFile",
1987
+ args: { path, contents, ...opts },
2181
1988
  },
2182
1989
  ],
2183
1990
  ctx: this._ctx,
2184
1991
  });
2185
1992
  };
2186
1993
  /**
2187
- * Opens an interactive terminal in new container with this directory mounted inside.
2188
- * @param opts.cmd If set, override the container's default terminal command and invoke these command arguments instead.
2189
- * @param opts.experimentalPrivilegedNesting Provides Dagger access to the executed command.
1994
+ * Retrieves this directory with all file/dir timestamps set to the given time.
1995
+ * @param timestamp Timestamp to set dir/files in.
2190
1996
  *
2191
- * Do not use this option unless you trust the command being executed; the command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
2192
- * @param opts.insecureRootCapabilities Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
2193
- * @param opts.container If set, override the default container used for the terminal.
1997
+ * Formatted in seconds following Unix epoch (e.g., 1672531199).
2194
1998
  */
2195
- terminal = (opts) => {
1999
+ withTimestamps = (timestamp) => {
2196
2000
  return new Directory({
2197
2001
  queryTree: [
2198
2002
  ...this._queryTree,
2199
2003
  {
2200
- operation: "terminal",
2201
- args: { ...opts },
2004
+ operation: "withTimestamps",
2005
+ args: { timestamp },
2202
2006
  },
2203
2007
  ],
2204
2008
  ctx: this._ctx,
2205
2009
  });
2206
2010
  };
2207
2011
  /**
2208
- * Retrieves this directory plus a directory written at the given path.
2209
- * @param path Location of the written directory (e.g., "/src/").
2210
- * @param directory Identifier of the directory to copy.
2211
- * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
2212
- * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2012
+ * Retrieves this directory with the directory at the given path removed.
2013
+ * @param path Location of the directory to remove (e.g., ".github/").
2213
2014
  */
2214
- withDirectory = (path, directory, opts) => {
2015
+ withoutDirectory = (path) => {
2215
2016
  return new Directory({
2216
2017
  queryTree: [
2217
2018
  ...this._queryTree,
2218
2019
  {
2219
- operation: "withDirectory",
2220
- args: { path, directory, ...opts },
2020
+ operation: "withoutDirectory",
2021
+ args: { path },
2221
2022
  },
2222
2023
  ],
2223
2024
  ctx: this._ctx,
2224
2025
  });
2225
2026
  };
2226
2027
  /**
2227
- * Retrieves this directory plus the contents of the given file copied to the given path.
2228
- * @param path Location of the copied file (e.g., "/file.txt").
2229
- * @param source Identifier of the file to copy.
2230
- * @param opts.permissions Permission given to the copied file (e.g., 0600).
2028
+ * Retrieves this directory with the file at the given path removed.
2029
+ * @param path Location of the file to remove (e.g., "/file.txt").
2231
2030
  */
2232
- withFile = (path, source, opts) => {
2031
+ withoutFile = (path) => {
2233
2032
  return new Directory({
2234
2033
  queryTree: [
2235
2034
  ...this._queryTree,
2236
2035
  {
2237
- operation: "withFile",
2238
- args: { path, source, ...opts },
2036
+ operation: "withoutFile",
2037
+ args: { path },
2239
2038
  },
2240
2039
  ],
2241
2040
  ctx: this._ctx,
2242
2041
  });
2243
2042
  };
2244
2043
  /**
2245
- * Retrieves this directory plus the contents of the given files copied to the given path.
2246
- * @param path Location where copied files should be placed (e.g., "/src").
2247
- * @param sources Identifiers of the files to copy.
2248
- * @param opts.permissions Permission given to the copied files (e.g., 0600).
2044
+ * Retrieves this directory with the files at the given paths removed.
2045
+ * @param paths Location of the file to remove (e.g., ["/file.txt"]).
2249
2046
  */
2250
- withFiles = (path, sources, opts) => {
2047
+ withoutFiles = (paths) => {
2251
2048
  return new Directory({
2252
2049
  queryTree: [
2253
2050
  ...this._queryTree,
2254
2051
  {
2255
- operation: "withFiles",
2256
- args: { path, sources, ...opts },
2052
+ operation: "withoutFiles",
2053
+ args: { paths },
2257
2054
  },
2258
2055
  ],
2259
2056
  ctx: this._ctx,
2260
2057
  });
2261
2058
  };
2262
2059
  /**
2263
- * Retrieves this directory plus a new directory created at the given path.
2264
- * @param path Location of the directory created (e.g., "/logs").
2265
- * @param opts.permissions Permission granted to the created directory (e.g., 0777).
2060
+ * Call the provided function with current Directory.
2061
+ *
2062
+ * This is useful for reusability and readability by not breaking the calling chain.
2266
2063
  */
2267
- withNewDirectory = (path, opts) => {
2268
- return new Directory({
2269
- queryTree: [
2270
- ...this._queryTree,
2271
- {
2272
- operation: "withNewDirectory",
2273
- args: { path, ...opts },
2274
- },
2275
- ],
2276
- ctx: this._ctx,
2277
- });
2064
+ with = (arg) => {
2065
+ return arg(this);
2066
+ };
2067
+ }
2068
+ /**
2069
+ * The Dagger engine configuration and state
2070
+ */
2071
+ export class Engine extends BaseClient {
2072
+ _id = undefined;
2073
+ /**
2074
+ * Constructor is used for internal usage only, do not create object from it.
2075
+ */
2076
+ constructor(parent, _id) {
2077
+ super(parent);
2078
+ this._id = _id;
2079
+ }
2080
+ /**
2081
+ * A unique identifier for this Engine.
2082
+ */
2083
+ id = async () => {
2084
+ if (this._id) {
2085
+ return this._id;
2086
+ }
2087
+ const response = await computeQuery([
2088
+ ...this._queryTree,
2089
+ {
2090
+ operation: "id",
2091
+ },
2092
+ ], await this._ctx.connection());
2093
+ return response;
2278
2094
  };
2279
2095
  /**
2280
- * Retrieves this directory plus a new file written at the given path.
2281
- * @param path Location of the written file (e.g., "/file.txt").
2282
- * @param contents Content of the written file (e.g., "Hello world!").
2283
- * @param opts.permissions Permission given to the copied file (e.g., 0600).
2096
+ * The local (on-disk) cache for the Dagger engine
2284
2097
  */
2285
- withNewFile = (path, contents, opts) => {
2286
- return new Directory({
2098
+ localCache = () => {
2099
+ return new EngineCache({
2287
2100
  queryTree: [
2288
2101
  ...this._queryTree,
2289
2102
  {
2290
- operation: "withNewFile",
2291
- args: { path, contents, ...opts },
2103
+ operation: "localCache",
2292
2104
  },
2293
2105
  ],
2294
2106
  ctx: this._ctx,
2295
2107
  });
2296
2108
  };
2109
+ }
2110
+ /**
2111
+ * A cache storage for the Dagger engine
2112
+ */
2113
+ export class EngineCache extends BaseClient {
2114
+ _id = undefined;
2115
+ _keepBytes = undefined;
2116
+ _maxUsedSpace = undefined;
2117
+ _minFreeSpace = undefined;
2118
+ _prune = undefined;
2119
+ _reservedSpace = undefined;
2297
2120
  /**
2298
- * Retrieves this directory with all file/dir timestamps set to the given time.
2299
- * @param timestamp Timestamp to set dir/files in.
2300
- *
2301
- * Formatted in seconds following Unix epoch (e.g., 1672531199).
2121
+ * Constructor is used for internal usage only, do not create object from it.
2302
2122
  */
2303
- withTimestamps = (timestamp) => {
2304
- return new Directory({
2305
- queryTree: [
2306
- ...this._queryTree,
2307
- {
2308
- operation: "withTimestamps",
2309
- args: { timestamp },
2310
- },
2311
- ],
2312
- ctx: this._ctx,
2313
- });
2123
+ constructor(parent, _id, _keepBytes, _maxUsedSpace, _minFreeSpace, _prune, _reservedSpace) {
2124
+ super(parent);
2125
+ this._id = _id;
2126
+ this._keepBytes = _keepBytes;
2127
+ this._maxUsedSpace = _maxUsedSpace;
2128
+ this._minFreeSpace = _minFreeSpace;
2129
+ this._prune = _prune;
2130
+ this._reservedSpace = _reservedSpace;
2131
+ }
2132
+ /**
2133
+ * A unique identifier for this EngineCache.
2134
+ */
2135
+ id = async () => {
2136
+ if (this._id) {
2137
+ return this._id;
2138
+ }
2139
+ const response = await computeQuery([
2140
+ ...this._queryTree,
2141
+ {
2142
+ operation: "id",
2143
+ },
2144
+ ], await this._ctx.connection());
2145
+ return response;
2314
2146
  };
2315
2147
  /**
2316
- * Retrieves this directory with the directory at the given path removed.
2317
- * @param path Location of the directory to remove (e.g., ".github/").
2148
+ * The current set of entries in the cache
2318
2149
  */
2319
- withoutDirectory = (path) => {
2320
- return new Directory({
2150
+ entrySet = () => {
2151
+ return new EngineCacheEntrySet({
2321
2152
  queryTree: [
2322
2153
  ...this._queryTree,
2323
2154
  {
2324
- operation: "withoutDirectory",
2325
- args: { path },
2155
+ operation: "entrySet",
2326
2156
  },
2327
2157
  ],
2328
2158
  ctx: this._ctx,
2329
2159
  });
2330
2160
  };
2331
2161
  /**
2332
- * Retrieves this directory with the file at the given path removed.
2333
- * @param path Location of the file to remove (e.g., "/file.txt").
2162
+ * The maximum bytes to keep in the cache without pruning, after which automatic pruning may kick in.
2163
+ * @deprecated Use minFreeSpace instead.
2164
+ */
2165
+ keepBytes = async () => {
2166
+ if (this._keepBytes) {
2167
+ return this._keepBytes;
2168
+ }
2169
+ const response = await computeQuery([
2170
+ ...this._queryTree,
2171
+ {
2172
+ operation: "keepBytes",
2173
+ },
2174
+ ], await this._ctx.connection());
2175
+ return response;
2176
+ };
2177
+ /**
2178
+ * The maximum bytes to keep in the cache without pruning.
2179
+ */
2180
+ maxUsedSpace = async () => {
2181
+ if (this._maxUsedSpace) {
2182
+ return this._maxUsedSpace;
2183
+ }
2184
+ const response = await computeQuery([
2185
+ ...this._queryTree,
2186
+ {
2187
+ operation: "maxUsedSpace",
2188
+ },
2189
+ ], await this._ctx.connection());
2190
+ return response;
2191
+ };
2192
+ /**
2193
+ * The target amount of free disk space the garbage collector will attempt to leave.
2194
+ */
2195
+ minFreeSpace = async () => {
2196
+ if (this._minFreeSpace) {
2197
+ return this._minFreeSpace;
2198
+ }
2199
+ const response = await computeQuery([
2200
+ ...this._queryTree,
2201
+ {
2202
+ operation: "minFreeSpace",
2203
+ },
2204
+ ], await this._ctx.connection());
2205
+ return response;
2206
+ };
2207
+ /**
2208
+ * Prune the cache of releaseable entries
2209
+ */
2210
+ prune = async () => {
2211
+ if (this._prune) {
2212
+ return;
2213
+ }
2214
+ await computeQuery([
2215
+ ...this._queryTree,
2216
+ {
2217
+ operation: "prune",
2218
+ },
2219
+ ], await this._ctx.connection());
2220
+ };
2221
+ reservedSpace = async () => {
2222
+ if (this._reservedSpace) {
2223
+ return this._reservedSpace;
2224
+ }
2225
+ const response = await computeQuery([
2226
+ ...this._queryTree,
2227
+ {
2228
+ operation: "reservedSpace",
2229
+ },
2230
+ ], await this._ctx.connection());
2231
+ return response;
2232
+ };
2233
+ }
2234
+ /**
2235
+ * An individual cache entry in a cache entry set
2236
+ */
2237
+ export class EngineCacheEntry extends BaseClient {
2238
+ _id = undefined;
2239
+ _activelyUsed = undefined;
2240
+ _createdTimeUnixNano = undefined;
2241
+ _description = undefined;
2242
+ _diskSpaceBytes = undefined;
2243
+ _mostRecentUseTimeUnixNano = undefined;
2244
+ /**
2245
+ * Constructor is used for internal usage only, do not create object from it.
2246
+ */
2247
+ constructor(parent, _id, _activelyUsed, _createdTimeUnixNano, _description, _diskSpaceBytes, _mostRecentUseTimeUnixNano) {
2248
+ super(parent);
2249
+ this._id = _id;
2250
+ this._activelyUsed = _activelyUsed;
2251
+ this._createdTimeUnixNano = _createdTimeUnixNano;
2252
+ this._description = _description;
2253
+ this._diskSpaceBytes = _diskSpaceBytes;
2254
+ this._mostRecentUseTimeUnixNano = _mostRecentUseTimeUnixNano;
2255
+ }
2256
+ /**
2257
+ * A unique identifier for this EngineCacheEntry.
2258
+ */
2259
+ id = async () => {
2260
+ if (this._id) {
2261
+ return this._id;
2262
+ }
2263
+ const response = await computeQuery([
2264
+ ...this._queryTree,
2265
+ {
2266
+ operation: "id",
2267
+ },
2268
+ ], await this._ctx.connection());
2269
+ return response;
2270
+ };
2271
+ /**
2272
+ * Whether the cache entry is actively being used.
2273
+ */
2274
+ activelyUsed = async () => {
2275
+ if (this._activelyUsed) {
2276
+ return this._activelyUsed;
2277
+ }
2278
+ const response = await computeQuery([
2279
+ ...this._queryTree,
2280
+ {
2281
+ operation: "activelyUsed",
2282
+ },
2283
+ ], await this._ctx.connection());
2284
+ return response;
2285
+ };
2286
+ /**
2287
+ * The time the cache entry was created, in Unix nanoseconds.
2288
+ */
2289
+ createdTimeUnixNano = async () => {
2290
+ if (this._createdTimeUnixNano) {
2291
+ return this._createdTimeUnixNano;
2292
+ }
2293
+ const response = await computeQuery([
2294
+ ...this._queryTree,
2295
+ {
2296
+ operation: "createdTimeUnixNano",
2297
+ },
2298
+ ], await this._ctx.connection());
2299
+ return response;
2300
+ };
2301
+ /**
2302
+ * The description of the cache entry.
2303
+ */
2304
+ description = async () => {
2305
+ if (this._description) {
2306
+ return this._description;
2307
+ }
2308
+ const response = await computeQuery([
2309
+ ...this._queryTree,
2310
+ {
2311
+ operation: "description",
2312
+ },
2313
+ ], await this._ctx.connection());
2314
+ return response;
2315
+ };
2316
+ /**
2317
+ * The disk space used by the cache entry.
2318
+ */
2319
+ diskSpaceBytes = async () => {
2320
+ if (this._diskSpaceBytes) {
2321
+ return this._diskSpaceBytes;
2322
+ }
2323
+ const response = await computeQuery([
2324
+ ...this._queryTree,
2325
+ {
2326
+ operation: "diskSpaceBytes",
2327
+ },
2328
+ ], await this._ctx.connection());
2329
+ return response;
2330
+ };
2331
+ /**
2332
+ * The most recent time the cache entry was used, in Unix nanoseconds.
2333
+ */
2334
+ mostRecentUseTimeUnixNano = async () => {
2335
+ if (this._mostRecentUseTimeUnixNano) {
2336
+ return this._mostRecentUseTimeUnixNano;
2337
+ }
2338
+ const response = await computeQuery([
2339
+ ...this._queryTree,
2340
+ {
2341
+ operation: "mostRecentUseTimeUnixNano",
2342
+ },
2343
+ ], await this._ctx.connection());
2344
+ return response;
2345
+ };
2346
+ }
2347
+ /**
2348
+ * A set of cache entries returned by a query to a cache
2349
+ */
2350
+ export class EngineCacheEntrySet extends BaseClient {
2351
+ _id = undefined;
2352
+ _diskSpaceBytes = undefined;
2353
+ _entryCount = undefined;
2354
+ /**
2355
+ * Constructor is used for internal usage only, do not create object from it.
2356
+ */
2357
+ constructor(parent, _id, _diskSpaceBytes, _entryCount) {
2358
+ super(parent);
2359
+ this._id = _id;
2360
+ this._diskSpaceBytes = _diskSpaceBytes;
2361
+ this._entryCount = _entryCount;
2362
+ }
2363
+ /**
2364
+ * A unique identifier for this EngineCacheEntrySet.
2365
+ */
2366
+ id = async () => {
2367
+ if (this._id) {
2368
+ return this._id;
2369
+ }
2370
+ const response = await computeQuery([
2371
+ ...this._queryTree,
2372
+ {
2373
+ operation: "id",
2374
+ },
2375
+ ], await this._ctx.connection());
2376
+ return response;
2377
+ };
2378
+ /**
2379
+ * The total disk space used by the cache entries in this set.
2334
2380
  */
2335
- withoutFile = (path) => {
2336
- return new Directory({
2337
- queryTree: [
2338
- ...this._queryTree,
2339
- {
2340
- operation: "withoutFile",
2341
- args: { path },
2342
- },
2343
- ],
2344
- ctx: this._ctx,
2345
- });
2381
+ diskSpaceBytes = async () => {
2382
+ if (this._diskSpaceBytes) {
2383
+ return this._diskSpaceBytes;
2384
+ }
2385
+ const response = await computeQuery([
2386
+ ...this._queryTree,
2387
+ {
2388
+ operation: "diskSpaceBytes",
2389
+ },
2390
+ ], await this._ctx.connection());
2391
+ return response;
2346
2392
  };
2347
2393
  /**
2348
- * Retrieves this directory with the files at the given paths removed.
2349
- * @param paths Location of the file to remove (e.g., ["/file.txt"]).
2394
+ * The list of individual cache entries in the set
2350
2395
  */
2351
- withoutFiles = (paths) => {
2352
- return new Directory({
2396
+ entries = async () => {
2397
+ const response = await computeQuery([
2398
+ ...this._queryTree,
2399
+ {
2400
+ operation: "entries",
2401
+ },
2402
+ {
2403
+ operation: "id",
2404
+ },
2405
+ ], await this._ctx.connection());
2406
+ return response.map((r) => new EngineCacheEntry({
2353
2407
  queryTree: [
2354
- ...this._queryTree,
2355
2408
  {
2356
- operation: "withoutFiles",
2357
- args: { paths },
2409
+ operation: "loadEngineCacheEntryFromID",
2410
+ args: { id: r.id },
2358
2411
  },
2359
2412
  ],
2360
2413
  ctx: this._ctx,
2361
- });
2414
+ }, r.id));
2362
2415
  };
2363
2416
  /**
2364
- * Call the provided function with current Directory.
2365
- *
2366
- * This is useful for reusability and readability by not breaking the calling chain.
2417
+ * The number of cache entries in this set.
2367
2418
  */
2368
- with = (arg) => {
2369
- return arg(this);
2419
+ entryCount = async () => {
2420
+ if (this._entryCount) {
2421
+ return this._entryCount;
2422
+ }
2423
+ const response = await computeQuery([
2424
+ ...this._queryTree,
2425
+ {
2426
+ operation: "entryCount",
2427
+ },
2428
+ ], await this._ctx.connection());
2429
+ return response;
2370
2430
  };
2371
2431
  }
2372
2432
  /**
@@ -2432,6 +2492,20 @@ export class EnumTypeDef extends BaseClient {
2432
2492
  ], await this._ctx.connection());
2433
2493
  return response;
2434
2494
  };
2495
+ /**
2496
+ * The location of this enum declaration.
2497
+ */
2498
+ sourceMap = () => {
2499
+ return new SourceMap({
2500
+ queryTree: [
2501
+ ...this._queryTree,
2502
+ {
2503
+ operation: "sourceMap",
2504
+ },
2505
+ ],
2506
+ ctx: this._ctx,
2507
+ });
2508
+ };
2435
2509
  /**
2436
2510
  * If this EnumTypeDef is associated with a Module, the name of the module. Unset otherwise.
2437
2511
  */
@@ -2532,6 +2606,20 @@ export class EnumValueTypeDef extends BaseClient {
2532
2606
  ], await this._ctx.connection());
2533
2607
  return response;
2534
2608
  };
2609
+ /**
2610
+ * The location of this enum value declaration.
2611
+ */
2612
+ sourceMap = () => {
2613
+ return new SourceMap({
2614
+ queryTree: [
2615
+ ...this._queryTree,
2616
+ {
2617
+ operation: "sourceMap",
2618
+ },
2619
+ ],
2620
+ ctx: this._ctx,
2621
+ });
2622
+ };
2535
2623
  }
2536
2624
  /**
2537
2625
  * An environment variable name and value.
@@ -2658,6 +2746,20 @@ export class FieldTypeDef extends BaseClient {
2658
2746
  ], await this._ctx.connection());
2659
2747
  return response;
2660
2748
  };
2749
+ /**
2750
+ * The location of this field declaration.
2751
+ */
2752
+ sourceMap = () => {
2753
+ return new SourceMap({
2754
+ queryTree: [
2755
+ ...this._queryTree,
2756
+ {
2757
+ operation: "sourceMap",
2758
+ },
2759
+ ],
2760
+ ctx: this._ctx,
2761
+ });
2762
+ };
2661
2763
  /**
2662
2764
  * The type of the field.
2663
2765
  */
@@ -2955,6 +3057,20 @@ export class Function_ extends BaseClient {
2955
3057
  ctx: this._ctx,
2956
3058
  });
2957
3059
  };
3060
+ /**
3061
+ * The location of this function declaration.
3062
+ */
3063
+ sourceMap = () => {
3064
+ return new SourceMap({
3065
+ queryTree: [
3066
+ ...this._queryTree,
3067
+ {
3068
+ operation: "sourceMap",
3069
+ },
3070
+ ],
3071
+ ctx: this._ctx,
3072
+ });
3073
+ };
2958
3074
  /**
2959
3075
  * Returns the function with the provided argument
2960
3076
  * @param name The name of the argument
@@ -2992,6 +3108,22 @@ export class Function_ extends BaseClient {
2992
3108
  ctx: this._ctx,
2993
3109
  });
2994
3110
  };
3111
+ /**
3112
+ * Returns the function with the given source map.
3113
+ * @param sourceMap The source map for the function definition.
3114
+ */
3115
+ withSourceMap = (sourceMap) => {
3116
+ return new Function_({
3117
+ queryTree: [
3118
+ ...this._queryTree,
3119
+ {
3120
+ operation: "withSourceMap",
3121
+ args: { sourceMap },
3122
+ },
3123
+ ],
3124
+ ctx: this._ctx,
3125
+ });
3126
+ };
2995
3127
  /**
2996
3128
  * Call the provided function with current Function.
2997
3129
  *
@@ -3110,6 +3242,20 @@ export class FunctionArg extends BaseClient {
3110
3242
  ], await this._ctx.connection());
3111
3243
  return response;
3112
3244
  };
3245
+ /**
3246
+ * The location of this arg declaration.
3247
+ */
3248
+ sourceMap = () => {
3249
+ return new SourceMap({
3250
+ queryTree: [
3251
+ ...this._queryTree,
3252
+ {
3253
+ operation: "sourceMap",
3254
+ },
3255
+ ],
3256
+ ctx: this._ctx,
3257
+ });
3258
+ };
3113
3259
  /**
3114
3260
  * The type of the argument.
3115
3261
  */
@@ -4094,6 +4240,20 @@ export class InterfaceTypeDef extends BaseClient {
4094
4240
  ], await this._ctx.connection());
4095
4241
  return response;
4096
4242
  };
4243
+ /**
4244
+ * The location of this interface declaration.
4245
+ */
4246
+ sourceMap = () => {
4247
+ return new SourceMap({
4248
+ queryTree: [
4249
+ ...this._queryTree,
4250
+ {
4251
+ operation: "sourceMap",
4252
+ },
4253
+ ],
4254
+ ctx: this._ctx,
4255
+ });
4256
+ };
4097
4257
  /**
4098
4258
  * If this InterfaceTypeDef is associated with a Module, the name of the module. Unset otherwise.
4099
4259
  */
@@ -5385,6 +5545,20 @@ export class ObjectTypeDef extends BaseClient {
5385
5545
  ], await this._ctx.connection());
5386
5546
  return response;
5387
5547
  };
5548
+ /**
5549
+ * The location of this object declaration.
5550
+ */
5551
+ sourceMap = () => {
5552
+ return new SourceMap({
5553
+ queryTree: [
5554
+ ...this._queryTree,
5555
+ {
5556
+ operation: "sourceMap",
5557
+ },
5558
+ ],
5559
+ ctx: this._ctx,
5560
+ });
5561
+ };
5388
5562
  /**
5389
5563
  * If this ObjectTypeDef is associated with a Module, the name of the module. Unset otherwise.
5390
5564
  */
@@ -5639,20 +5813,6 @@ export class Client extends BaseClient {
5639
5813
  ctx: this._ctx,
5640
5814
  }, r.id));
5641
5815
  };
5642
- /**
5643
- * The Dagger engine container configuration and state
5644
- */
5645
- daggerEngine = () => {
5646
- return new DaggerEngine({
5647
- queryTree: [
5648
- ...this._queryTree,
5649
- {
5650
- operation: "daggerEngine",
5651
- },
5652
- ],
5653
- ctx: this._ctx,
5654
- });
5655
- };
5656
5816
  /**
5657
5817
  * The default platform of the engine.
5658
5818
  */
@@ -5679,6 +5839,20 @@ export class Client extends BaseClient {
5679
5839
  ctx: this._ctx,
5680
5840
  });
5681
5841
  };
5842
+ /**
5843
+ * The Dagger engine container configuration and state
5844
+ */
5845
+ engine = () => {
5846
+ return new Engine({
5847
+ queryTree: [
5848
+ ...this._queryTree,
5849
+ {
5850
+ operation: "engine",
5851
+ },
5852
+ ],
5853
+ ctx: this._ctx,
5854
+ });
5855
+ };
5682
5856
  /**
5683
5857
  * Creates a function.
5684
5858
  * @param name Name of the function, in its original format from the implementation language.
@@ -5812,14 +5986,14 @@ export class Client extends BaseClient {
5812
5986
  });
5813
5987
  };
5814
5988
  /**
5815
- * Load a DaggerEngineCacheEntry from its ID.
5989
+ * Load a Directory from its ID.
5816
5990
  */
5817
- loadDaggerEngineCacheEntryFromID = (id) => {
5818
- return new DaggerEngineCacheEntry({
5991
+ loadDirectoryFromID = (id) => {
5992
+ return new Directory({
5819
5993
  queryTree: [
5820
5994
  ...this._queryTree,
5821
5995
  {
5822
- operation: "loadDaggerEngineCacheEntryFromID",
5996
+ operation: "loadDirectoryFromID",
5823
5997
  args: { id },
5824
5998
  },
5825
5999
  ],
@@ -5827,14 +6001,14 @@ export class Client extends BaseClient {
5827
6001
  });
5828
6002
  };
5829
6003
  /**
5830
- * Load a DaggerEngineCacheEntrySet from its ID.
6004
+ * Load a EngineCacheEntry from its ID.
5831
6005
  */
5832
- loadDaggerEngineCacheEntrySetFromID = (id) => {
5833
- return new DaggerEngineCacheEntrySet({
6006
+ loadEngineCacheEntryFromID = (id) => {
6007
+ return new EngineCacheEntry({
5834
6008
  queryTree: [
5835
6009
  ...this._queryTree,
5836
6010
  {
5837
- operation: "loadDaggerEngineCacheEntrySetFromID",
6011
+ operation: "loadEngineCacheEntryFromID",
5838
6012
  args: { id },
5839
6013
  },
5840
6014
  ],
@@ -5842,14 +6016,14 @@ export class Client extends BaseClient {
5842
6016
  });
5843
6017
  };
5844
6018
  /**
5845
- * Load a DaggerEngineCache from its ID.
6019
+ * Load a EngineCacheEntrySet from its ID.
5846
6020
  */
5847
- loadDaggerEngineCacheFromID = (id) => {
5848
- return new DaggerEngineCache({
6021
+ loadEngineCacheEntrySetFromID = (id) => {
6022
+ return new EngineCacheEntrySet({
5849
6023
  queryTree: [
5850
6024
  ...this._queryTree,
5851
6025
  {
5852
- operation: "loadDaggerEngineCacheFromID",
6026
+ operation: "loadEngineCacheEntrySetFromID",
5853
6027
  args: { id },
5854
6028
  },
5855
6029
  ],
@@ -5857,14 +6031,14 @@ export class Client extends BaseClient {
5857
6031
  });
5858
6032
  };
5859
6033
  /**
5860
- * Load a DaggerEngine from its ID.
6034
+ * Load a EngineCache from its ID.
5861
6035
  */
5862
- loadDaggerEngineFromID = (id) => {
5863
- return new DaggerEngine({
6036
+ loadEngineCacheFromID = (id) => {
6037
+ return new EngineCache({
5864
6038
  queryTree: [
5865
6039
  ...this._queryTree,
5866
6040
  {
5867
- operation: "loadDaggerEngineFromID",
6041
+ operation: "loadEngineCacheFromID",
5868
6042
  args: { id },
5869
6043
  },
5870
6044
  ],
@@ -5872,14 +6046,14 @@ export class Client extends BaseClient {
5872
6046
  });
5873
6047
  };
5874
6048
  /**
5875
- * Load a Directory from its ID.
6049
+ * Load a Engine from its ID.
5876
6050
  */
5877
- loadDirectoryFromID = (id) => {
5878
- return new Directory({
6051
+ loadEngineFromID = (id) => {
6052
+ return new Engine({
5879
6053
  queryTree: [
5880
6054
  ...this._queryTree,
5881
6055
  {
5882
- operation: "loadDirectoryFromID",
6056
+ operation: "loadEngineFromID",
5883
6057
  args: { id },
5884
6058
  },
5885
6059
  ],
@@ -6321,6 +6495,21 @@ export class Client extends BaseClient {
6321
6495
  ctx: this._ctx,
6322
6496
  });
6323
6497
  };
6498
+ /**
6499
+ * Load a SourceMap from its ID.
6500
+ */
6501
+ loadSourceMapFromID = (id) => {
6502
+ return new SourceMap({
6503
+ queryTree: [
6504
+ ...this._queryTree,
6505
+ {
6506
+ operation: "loadSourceMapFromID",
6507
+ args: { id },
6508
+ },
6509
+ ],
6510
+ ctx: this._ctx,
6511
+ });
6512
+ };
6324
6513
  /**
6325
6514
  * Load a Terminal from its ID.
6326
6515
  */
@@ -6435,6 +6624,24 @@ export class Client extends BaseClient {
6435
6624
  ctx: this._ctx,
6436
6625
  });
6437
6626
  };
6627
+ /**
6628
+ * Creates source map metadata.
6629
+ * @param filename The filename from the module source.
6630
+ * @param line The line number within the filename.
6631
+ * @param column The column number within the line.
6632
+ */
6633
+ sourceMap = (filename, line, column) => {
6634
+ return new SourceMap({
6635
+ queryTree: [
6636
+ ...this._queryTree,
6637
+ {
6638
+ operation: "sourceMap",
6639
+ args: { filename, line, column },
6640
+ },
6641
+ ],
6642
+ ctx: this._ctx,
6643
+ });
6644
+ };
6438
6645
  /**
6439
6646
  * Create a new TypeDef.
6440
6647
  */
@@ -6816,6 +7023,102 @@ export class Socket extends BaseClient {
6816
7023
  return response;
6817
7024
  };
6818
7025
  }
7026
+ /**
7027
+ * Source location information.
7028
+ */
7029
+ export class SourceMap extends BaseClient {
7030
+ _id = undefined;
7031
+ _column = undefined;
7032
+ _filename = undefined;
7033
+ _line = undefined;
7034
+ _module = undefined;
7035
+ /**
7036
+ * Constructor is used for internal usage only, do not create object from it.
7037
+ */
7038
+ constructor(parent, _id, _column, _filename, _line, _module) {
7039
+ super(parent);
7040
+ this._id = _id;
7041
+ this._column = _column;
7042
+ this._filename = _filename;
7043
+ this._line = _line;
7044
+ this._module = _module;
7045
+ }
7046
+ /**
7047
+ * A unique identifier for this SourceMap.
7048
+ */
7049
+ id = async () => {
7050
+ if (this._id) {
7051
+ return this._id;
7052
+ }
7053
+ const response = await computeQuery([
7054
+ ...this._queryTree,
7055
+ {
7056
+ operation: "id",
7057
+ },
7058
+ ], await this._ctx.connection());
7059
+ return response;
7060
+ };
7061
+ /**
7062
+ * The column number within the line.
7063
+ */
7064
+ column = async () => {
7065
+ if (this._column) {
7066
+ return this._column;
7067
+ }
7068
+ const response = await computeQuery([
7069
+ ...this._queryTree,
7070
+ {
7071
+ operation: "column",
7072
+ },
7073
+ ], await this._ctx.connection());
7074
+ return response;
7075
+ };
7076
+ /**
7077
+ * The filename from the module source.
7078
+ */
7079
+ filename = async () => {
7080
+ if (this._filename) {
7081
+ return this._filename;
7082
+ }
7083
+ const response = await computeQuery([
7084
+ ...this._queryTree,
7085
+ {
7086
+ operation: "filename",
7087
+ },
7088
+ ], await this._ctx.connection());
7089
+ return response;
7090
+ };
7091
+ /**
7092
+ * The line number within the filename.
7093
+ */
7094
+ line = async () => {
7095
+ if (this._line) {
7096
+ return this._line;
7097
+ }
7098
+ const response = await computeQuery([
7099
+ ...this._queryTree,
7100
+ {
7101
+ operation: "line",
7102
+ },
7103
+ ], await this._ctx.connection());
7104
+ return response;
7105
+ };
7106
+ /**
7107
+ * The module dependency this was declared in.
7108
+ */
7109
+ module_ = async () => {
7110
+ if (this._module) {
7111
+ return this._module;
7112
+ }
7113
+ const response = await computeQuery([
7114
+ ...this._queryTree,
7115
+ {
7116
+ operation: "module",
7117
+ },
7118
+ ], await this._ctx.connection());
7119
+ return response;
7120
+ };
7121
+ }
6819
7122
  /**
6820
7123
  * An interactive terminal that clients can connect to.
6821
7124
  */
@@ -7036,6 +7339,7 @@ export class TypeDef extends BaseClient {
7036
7339
  * Note that an enum's values may be omitted if the intent is only to refer to an enum. This is how functions are able to return their own, or any other circular reference.
7037
7340
  * @param name The name of the enum
7038
7341
  * @param opts.description A doc string for the enum, if any
7342
+ * @param opts.sourceMap The source map for the enum definition.
7039
7343
  */
7040
7344
  withEnum = (name, opts) => {
7041
7345
  return new TypeDef({
@@ -7053,6 +7357,7 @@ export class TypeDef extends BaseClient {
7053
7357
  * Adds a static value for an Enum TypeDef, failing if the type is not an enum.
7054
7358
  * @param value The name of the value in the enum
7055
7359
  * @param opts.description A doc string for the value, if any
7360
+ * @param opts.sourceMap The source map for the enum value definition.
7056
7361
  */
7057
7362
  withEnumValue = (value, opts) => {
7058
7363
  return new TypeDef({
@@ -7071,6 +7376,7 @@ export class TypeDef extends BaseClient {
7071
7376
  * @param name The name of the field in the object
7072
7377
  * @param typeDef The type of the field
7073
7378
  * @param opts.description A doc string for the field, if any
7379
+ * @param opts.sourceMap The source map for the field definition.
7074
7380
  */
7075
7381
  withField = (name, typeDef, opts) => {
7076
7382
  return new TypeDef({