+24
-43
.fluentci/deno.lock
+24
-43
.fluentci/deno.lock
···
1
1
{
2
2
"version": "3",
3
-
"packages": {
4
-
"specifiers": {
5
-
"npm:nexus": "npm:nexus@1.3.0_graphql@16.8.1"
6
-
},
7
-
"npm": {
8
-
"graphql@16.8.1": {
9
-
"integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==",
10
-
"dependencies": {}
11
-
},
12
-
"iterall@1.3.0": {
13
-
"integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==",
14
-
"dependencies": {}
15
-
},
16
-
"nexus@1.3.0_graphql@16.8.1": {
17
-
"integrity": "sha512-w/s19OiNOs0LrtP7pBmD9/FqJHvZLmCipVRt6v1PM8cRUYIbhEswyNKGHVoC4eHZGPSnD+bOf5A3+gnbt0A5/A==",
18
-
"dependencies": {
19
-
"graphql": "graphql@16.8.1",
20
-
"iterall": "iterall@1.3.0",
21
-
"tslib": "tslib@2.6.2"
22
-
}
23
-
},
24
-
"tslib@2.6.2": {
25
-
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
26
-
"dependencies": {}
27
-
}
28
-
}
29
-
},
30
3
"remote": {
31
4
"https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/deps.ts": "096395daebc7ed8a18f0484e4ffcc3a7f70e50946735f7df9611a7fcfd8272cc",
32
5
"https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/mod.ts": "e269d71c72ae68e82c1960e5db2a0c7419c97c9683ef717de0ab75d90f364713",
33
6
"https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/src/interface.ts": "3d4371b7590e90af7b191b93f8681ea7add6f5dca0d26a4d171701de09707c4f",
34
7
"https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/src/tar.ts": "9b02eaaa784b225ad7a23d2769cd492adf113ea7c11c02e3646849e98f4ae43b",
8
+
"https://cdn.skypack.dev/-/lodash@v4.17.21-K6GEbP02mWFnLA45zAmi/dist=es2019,mode=imports/optimized/lodash.js": "10c4df47937ffc78548d136dd535a021df5f57182a653260d715c0690dd22978",
9
+
"https://cdn.skypack.dev/lodash": "8280de0b3efd87f06ea0eb330d15b8de32c059556023b8c6524e9eb9e4844dc0",
35
10
"https://deno.land/std@0.129.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
36
11
"https://deno.land/std@0.129.0/_util/os.ts": "49b92edea1e82ba295ec946de8ffd956ed123e2948d9bd1d3e901b04e4307617",
37
12
"https://deno.land/std@0.129.0/archive/tar.ts": "35ea1baddec7988cc4034765a2cee7613bc8074bd40940d3f5e98f63070a716a",
···
150
125
"https://deno.land/std@0.203.0/path/to_file_url.ts": "00e6322373dd51ad109956b775e4e72e5f9fa68ce2c6b04e4af2a6eed3825d31",
151
126
"https://deno.land/std@0.203.0/path/to_namespaced_path.ts": "1b1db3055c343ab389901adfbda34e82b7386bcd1c744d54f9c1496ee0fd0c3d",
152
127
"https://deno.land/std@0.203.0/path/win32.ts": "8b3f80ef7a462511d5e8020ff490edcaa0a0d118f1b1e9da50e2916bdd73f9dd",
128
+
"https://deno.land/std@0.205.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee",
129
+
"https://deno.land/std@0.205.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56",
130
+
"https://deno.land/std@0.205.0/flags/mod.ts": "0948466fc437f017f00c0b972a422b3dc3317a790bcf326429d23182977eaf9f",
153
131
"https://deno.land/std@0.52.0/fmt/colors.ts": "ec9d653672a9a3c7b6eafe53c5bc797364a2db2dcf766ab649c1155fea7a80b2",
154
132
"https://deno.land/x/crc32@v0.2.0/mod.ts": "de7a3fa2d4ef24b96fc21e1cc4d2d65d1d2b1dcea92f63960e3e11bfa82df0fa",
155
133
"https://deno.land/x/fluent_aws_codepipeline@v0.2.3/mod.ts": "79cc758901d20a3573d7e3cc2db9f0a5fe56833f4d9befcedc072b94d542eec7",
···
192
170
"https://deno.land/x/zod@v3.22.1/locales/en.ts": "a7a25cd23563ccb5e0eed214d9b31846305ddbcdb9c5c8f508b108943366ab4c",
193
171
"https://deno.land/x/zod@v3.22.1/mod.ts": "64e55237cb4410e17d968cd08975566059f27638ebb0b86048031b987ba251c4",
194
172
"https://deno.land/x/zod@v3.22.1/types.ts": "4edc1823385f446532c8c9f676d84550c6dc54b17135e34508576647d9612d0e",
195
-
"https://esm.sh/@dagger.io/dagger@0.8.4": "486a8a8e4105ddceed0d754f7ea5b8a0b2513aa079ff6bc201a61c484f29be88",
196
-
"https://esm.sh/@dagger.io/dagger@0.8.8": "15f25b274941de6f12d11de78245bf3d0326ba226212bfea57747b0b2a3e6542",
173
+
"https://esm.sh/@dagger.io/dagger@0.10.0": "fe3ac97e861bd6d72c8f592fd534249b971c3dfe870eec240c8285e5f632976a",
174
+
"https://esm.sh/@dagger.io/dagger@0.9.3": "9bd1df6375031727868e2a7aa24e7517d1eba916b49529a412f9a214a0d58992",
197
175
"https://esm.sh/graphql-tag@2.12.6": "132ebb1ed959bb4dac146160b0cd0fa678c7b9e6bd04f349bf4cacbfb46d0b53",
198
176
"https://esm.sh/nanoid@4.0.2": "eb872595ebf6390181971c3e477d1b0fe7ea8383d9b66ced7d09ac8f9c4cf2c7",
199
177
"https://esm.sh/stringify-tree@1.1.1": "bb68a933167b8d80b88481df0beff172fc9b645db0c32fbe7dc2d822f61ebaea",
···
205
183
"https://esm.sh/v128/yaml@2.3.1/denonext/yaml.mjs": "71f677b4bfc69271af9d98db5194e354f9a1863955e208e26d32a9ef78bd89f5",
206
184
"https://esm.sh/v131/yaml@2.3.1": "1fe2490feb3d9c6d2c71c64dbdbed90acd4164b00628b3c68a311b6731ca38b5",
207
185
"https://esm.sh/v131/yaml@2.3.1/denonext/yaml.mjs": "71f677b4bfc69271af9d98db5194e354f9a1863955e208e26d32a9ef78bd89f5",
208
-
"https://esm.sh/v135/@dagger.io/dagger@0.8.4/denonext/dagger.mjs": "c60f551097e706768950fa2b5ef0e58045a2281ad22e68903421de86bcd184e8",
209
-
"https://esm.sh/v135/@dagger.io/dagger@0.8.8/denonext/dagger.mjs": "417c7cc5b660567bf8cfbac1edc7192ff7c1325abe152611e05fd0bbefc7c010",
186
+
"https://esm.sh/v135/@dagger.io/dagger@0.10.0/denonext/dagger.mjs": "c91bedd8503b3ad78203d23aa93cf155e3e9dfff63c11eda31a3f28d88850b9a",
187
+
"https://esm.sh/v135/@dagger.io/dagger@0.9.3/denonext/dagger.mjs": "998e8e63729621141c0a9b74128db8f81ab7446d1a5d4ff41a6a6b0944db4ddf",
210
188
"https://esm.sh/v135/adm-zip@0.5.10/denonext/adm-zip.mjs": "9441de5c60a276046d55945f45775d674a319e8e5fd3a8ab7131d8d192d9abb3",
189
+
"https://esm.sh/v135/buffer-from@1.1.2/denonext/buffer-from.mjs": "078451542b62cb4261c01a01ff7e9bc0f94bef4eb710831d40e1f92c4dfe3883",
211
190
"https://esm.sh/v135/chownr@2.0.0/denonext/chownr.mjs": "d7282b2612a9f13c62084c76fc72cdfb20503bccce959178b77b6def14d3ffd2",
212
191
"https://esm.sh/v135/cross-fetch@3.1.8/denonext/cross-fetch.mjs": "8fba9e7c3fbaf0d2168beb63ce0cd21b5bfbfbd77e2fcbf8d957d533a71222f6",
213
192
"https://esm.sh/v135/cross-spawn@7.0.3/denonext/cross-spawn.mjs": "4d5a257de3627fb09c512b23fed30f1b393e29a2c13f8325e89720b8ca6673c1",
214
193
"https://esm.sh/v135/env-paths@3.0.0/denonext/env-paths.mjs": "77984a05eb16450087f25060a070ed500ec546719d471143e16d976ca73ca956",
215
-
"https://esm.sh/v135/execa@7.2.0/denonext/execa.mjs": "2d15fa250d869b777d31a1414ebb0974624782b35955b006030bb2df3085508b",
216
194
"https://esm.sh/v135/execa@8.0.1/denonext/execa.mjs": "cfcca6be54deae22c8d7c4d8be8df397a9506a54d9af9171519b9eea8daea9a5",
217
195
"https://esm.sh/v135/fs-minipass@2.1.0/denonext/fs-minipass.mjs": "4b5b69251541833f5a1035be0e98d46bd6d02843fd7d40720577baf6caca21ce",
218
-
"https://esm.sh/v135/get-stream@6.0.1/denonext/get-stream.mjs": "40659bc61ff2e49a7acf20f46d53c9b09b6d594f15bce414257f377f6f3934a7",
219
196
"https://esm.sh/v135/get-stream@8.0.1/denonext/get-stream.mjs": "b8ab640bf2638c1ae704a217b79e0a56e7a1f97bb48bbe40d723d5ea87eb0ecb",
220
197
"https://esm.sh/v135/graphql-request@6.1.0/denonext/graphql-request.mjs": "c97af0ff1802c36ae6fdf544153140ef4d950bf164f0e5e839e71aa599ea1555",
221
198
"https://esm.sh/v135/graphql-tag@2.12.6/denonext/graphql-tag.mjs": "ebaceefc216cba74424ddc55fde9e677f6e5a3e9d556a250faa1b53483574f03",
222
199
"https://esm.sh/v135/graphql@16.8.1/denonext/graphql.mjs": "585b84022623b931e27a7a8134cd24ec50b33ea12fd18b43254527628a0fddac",
223
-
"https://esm.sh/v135/human-signals@4.3.1/denonext/human-signals.mjs": "2bd5c0009d640e8280779e7ba91fc089156e2df9ecec66b40de97199fda5b16f",
224
200
"https://esm.sh/v135/human-signals@5.0.0/denonext/human-signals.mjs": "ab3130133ac5943273c909d7887e3c16b8374f66d72c38caeea2c44d659af023",
225
201
"https://esm.sh/v135/is-stream@3.0.0/denonext/is-stream.mjs": "5c8b65f2fa051c4b18e88bbae11dac8bba9caf57752577d69bcea86d1f05c5b7",
226
202
"https://esm.sh/v135/isexe@2.0.0/denonext/isexe.mjs": "4675d9d53a332f096efd344cb1418dbda8e6f2effc8a5c81edd43cdd56636be7",
···
233
209
"https://esm.sh/v135/mkdirp@1.0.4/denonext/mkdirp.mjs": "41bc43ec9478e772660e2b0edf998f27f0158388c94003b7292d8093e699eb7b",
234
210
"https://esm.sh/v135/nanoid@4.0.2/denonext/nanoid.mjs": "4f26e89bc0867e6a838069435b3d75af305017d87ce5b51c9d6edc680954b52f",
235
211
"https://esm.sh/v135/node-color-log@10.0.2/denonext/node-color-log.mjs": "2504391bd0ce1dd4c2bf0ed0b839b8a3ad84c028d9dd17cc58dccd2e14dacfde",
212
+
"https://esm.sh/v135/node-color-log@11.0.1/denonext/node-color-log.mjs": "e88a8bc16035cb4532b08acee784c2f5bb5b11be13e448e211bdd907fba2db4a",
236
213
"https://esm.sh/v135/node_fetch.js": "b11355358cf61343a3c30bd5942df60a3586d13e2c979b515164bfe851662798",
214
+
"https://esm.sh/v135/node_inspector.js": "a19e0177c22009003670499765ac8abdb8f6f49175105ced47bfea73bfca8b46",
237
215
"https://esm.sh/v135/npm-run-path@5.1.0/denonext/npm-run-path.mjs": "4772cda227b5c18f4293db7edf53998879c75d48e776533009ce1a8daa464bf5",
238
216
"https://esm.sh/v135/onetime@6.0.0/denonext/onetime.mjs": "5326fe5207b076a7ebc96740b4c3dcec7a2522a1aa5985e3b4157c1b9cb1e2dd",
239
217
"https://esm.sh/v135/original-fs@1.2.0/denonext/original-fs.mjs": "2b1098818e54d2c6748ff5b0dd9ea5f6a61b4b6d0f63fb625f21773d11cfc667",
240
218
"https://esm.sh/v135/path-key@3.1.1/denonext/path-key.mjs": "add83c631278b7df9b33ae84e41142db88bb291295bcc27eb4e77a1cbdfa71d0",
241
219
"https://esm.sh/v135/path-key@4.0.0/denonext/path-key.mjs": "2c2e3922bd0e6e414fa2752ff800bdc6b9208035ce797fa22e49b859f8259417",
220
+
"https://esm.sh/v135/reflect-metadata@0.2.1/denonext/reflect-metadata.mjs": "f0ceb2fd343cebcc3cb7041d1dd75473a159d1c279293bc308d7ac1b90bf2371",
242
221
"https://esm.sh/v135/shebang-command@2.0.0/denonext/shebang-command.mjs": "245674cc2dffa2d06fcef0540b81040b626227485e5f41d76e77d386b30b18e0",
243
222
"https://esm.sh/v135/shebang-regex@3.0.0/denonext/shebang-regex.mjs": "03983ba59dd2cba9402935e21b46d05f5249364cba9f5757aef23c6c2fea65b9",
244
-
"https://esm.sh/v135/signal-exit@3.0.7/denonext/signal-exit.mjs": "bf418caffe54af9f76da6c7a4998b093dd95740016482c3ababa83da7fb1bb6c",
245
223
"https://esm.sh/v135/signal-exit@4.1.0/denonext/signal-exit.mjs": "c450b9024df3b59ded71e7b52aada1ac4b3856aad93e9d64bbc6ea3cdd181824",
224
+
"https://esm.sh/v135/source-map-support@0.5.21/denonext/source-map-support.mjs": "4a3185b099f49b540b1ee768cb9d1912de4f27872b2e0d8ccfa93a3b3529d66a",
225
+
"https://esm.sh/v135/source-map@0.6.1/denonext/source-map.mjs": "ccff3bb06dea7c01a2c83cf12113697592e418fd06b55ae2bb4cb0a4e51a98b8",
246
226
"https://esm.sh/v135/stringify-tree@1.1.1/denonext/stringify-tree.mjs": "6cacda15ffe7dc2e1343636549956877e1bd830be5bd56587f40f94ca7becda4",
247
227
"https://esm.sh/v135/strip-final-newline@3.0.0/denonext/strip-final-newline.mjs": "139c0958b1fb9387d8ae5b95941682245a3f3d9ae531f5de9638c2e9109831e0",
248
228
"https://esm.sh/v135/tar@6.2.0/denonext/tar.mjs": "e13b56d41286f4935cb29acae60a040148af6e2649326a70e04c5ca6fe5ef04d",
249
229
"https://esm.sh/v135/tslib@2.6.2/denonext/tslib.mjs": "29782bcd3139f77ec063dc5a9385c0fff4a8d0a23b6765c73d9edeb169a04bf1",
230
+
"https://esm.sh/v135/typescript@5.3.3/denonext/typescript.mjs": "2cde33a9040058d919060a6ca8b2a51f601679aee4e4e5be93f2428d176b7d27",
250
231
"https://esm.sh/v135/which@2.0.2/denonext/which.mjs": "360f7d0aa13233975c86f120e2b1aa9695252b16e287ccdc651d3123473a3482",
251
232
"https://esm.sh/v135/yallist@4.0.0/denonext/yallist.mjs": "61f180d807dda50bac17028eda05d5722a3fecef6e98a9064e2353ea6864fd82",
252
233
"https://esm.sh/v135/yaml@2.3.1/denonext/yaml.mjs": "71f677b4bfc69271af9d98db5194e354f9a1863955e208e26d32a9ef78bd89f5",
253
234
"https://esm.sh/yaml@v2.3.1": "0b42df3dec58b0999df5639390c02346de67b8dae76717a156189855fb616858",
254
-
"https://nix.fluentci.io/v0.5.2/deps.ts": "6ccc8510c72998a52c24bc02c848b669413b5ef1d15dccd7e03a25dd0e408564",
255
-
"https://nix.fluentci.io/v0.5.2/src/dagger/steps.ts": "b766f4fa9624a032e7af884a5ca47bc666a529c4a472d38b74b55ca0d63cf81d",
256
-
"https://sdk.fluentci.io/v0.2.0/deps.ts": "20dd191afaf88662b82c2a42164afe6d06f2e79942f40ce07aa0972719fc858f",
257
-
"https://sdk.fluentci.io/v0.2.0/mod.ts": "261ba81a4728f5def4e327a5cd80664ea8449515a2f4eea5f3f416acae39a1fa",
258
-
"https://sdk.fluentci.io/v0.2.0/src/client.ts": "d350d4f59763e32a9b35f3f06f0b1058e5c8e5a3824e6d096cdaf3fc4332dcf6",
259
-
"https://sdk.fluentci.io/v0.2.0/src/connect.ts": "4aff111c403cf78672384a10214a9885e08319dde579ec458f98a7bb04874101",
260
-
"https://sdk.fluentci.io/v0.2.0/src/context.ts": "2939ff58d0a79d7377d5553e725c9a2110a0013035a5a57abe9a9a5da975c4ce",
261
-
"https://sdk.fluentci.io/v0.2.0/src/utils.ts": "5dcd6d83553930502069d067ff42bc44698e22c23426fdb78630c4b39769d308"
235
+
"https://nix.fluentci.io/v0.5.3/deps.ts": "469c1f084eda8d2ee78135b0bf4f9490b80b36d8d0bdb88594167133a918da8e",
236
+
"https://nix.fluentci.io/v0.5.3/src/dagger/steps.ts": "b766f4fa9624a032e7af884a5ca47bc666a529c4a472d38b74b55ca0d63cf81d",
237
+
"https://sdk.fluentci.io/v0.3.0/deps.ts": "3a145e76b4345a9a7888f09b1b48cb54523ebfa43247a1abebc40a9e82d555f4",
238
+
"https://sdk.fluentci.io/v0.3.0/mod.ts": "261ba81a4728f5def4e327a5cd80664ea8449515a2f4eea5f3f416acae39a1fa",
239
+
"https://sdk.fluentci.io/v0.3.0/src/client.ts": "7f1df4b1fee62dd6f946fa9d15d47a37b938ffb4ac91faf3d39b44b83d4f5921",
240
+
"https://sdk.fluentci.io/v0.3.0/src/connect.ts": "4aff111c403cf78672384a10214a9885e08319dde579ec458f98a7bb04874101",
241
+
"https://sdk.fluentci.io/v0.3.0/src/context.ts": "2939ff58d0a79d7377d5553e725c9a2110a0013035a5a57abe9a9a5da975c4ce",
242
+
"https://sdk.fluentci.io/v0.3.0/src/utils.ts": "5dcd6d83553930502069d067ff42bc44698e22c23426fdb78630c4b39769d308"
262
243
}
263
244
}
+31
-17
.fluentci/deps.ts
+31
-17
.fluentci/deps.ts
···
1
1
export { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import Client from "https://sdk.fluentci.io/v0.2.0/mod.ts";
2
+
import { Client } from "./sdk/client.gen.ts";
3
3
export default Client;
4
4
5
-
export {
6
-
connect,
7
-
uploadContext,
8
-
CacheSharingMode,
9
-
Container,
10
-
} from "https://sdk.fluentci.io/v0.2.0/mod.ts";
5
+
export type { DirectoryID, SecretID } from "./sdk/client.gen.ts";
6
+
export { Directory, Secret, File } from "./sdk/client.gen.ts";
7
+
export { connect, uploadContext } from "https://sdk.fluentci.io/v0.3.0/mod.ts";
11
8
export { brightGreen } from "https://deno.land/std@0.191.0/fmt/colors.ts";
12
-
export { withDevbox } from "https://nix.fluentci.io/v0.5.2/src/dagger/steps.ts";
9
+
export { withDevbox } from "https://nix.fluentci.io/v0.5.3/src/dagger/steps.ts";
13
10
export { stringifyTree } from "https://esm.sh/stringify-tree@1.1.1";
14
11
import gql from "https://esm.sh/graphql-tag@2.12.6";
15
12
export { gql };
16
-
17
-
export {
18
-
arg,
19
-
queryType,
20
-
stringArg,
21
-
intArg,
22
-
nonNull,
23
-
makeSchema,
24
-
} from "npm:nexus";
25
13
export {
26
14
dirname,
27
15
join,
28
16
resolve,
29
17
} from "https://deno.land/std@0.203.0/path/mod.ts";
18
+
export { parse } from "https://deno.land/std@0.205.0/flags/mod.ts";
19
+
export { snakeCase, camelCase } from "https://cdn.skypack.dev/lodash";
20
+
21
+
export {
22
+
ClientError,
23
+
GraphQLClient,
24
+
} from "https://esm.sh/v128/graphql-request@6.1.0";
25
+
export {
26
+
DaggerSDKError,
27
+
UnknownDaggerError,
28
+
DockerImageRefValidationError,
29
+
EngineSessionConnectParamsParseError,
30
+
ExecError,
31
+
GraphQLRequestError,
32
+
InitEngineSessionBinaryError,
33
+
TooManyNestedObjectsError,
34
+
EngineSessionError,
35
+
EngineSessionConnectionTimeoutError,
36
+
NotAwaitedRequestError,
37
+
ERROR_CODES,
38
+
} from "https://esm.sh/@dagger.io/dagger@0.9.3";
39
+
40
+
export type {
41
+
CallbackFct,
42
+
ConnectOpts,
43
+
} from "https://sdk.fluentci.io/v0.3.0/mod.ts";
30
44
31
45
export * as FluentGitlabCI from "https://deno.land/x/fluent_gitlab_ci@v0.4.2/mod.ts";
32
46
export * as FluentGithubActions from "https://deno.land/x/fluent_github_actions@v0.2.1/mod.ts";
-139
.fluentci/gen/nexus.ts
-139
.fluentci/gen/nexus.ts
···
1
-
/**
2
-
* This file was generated by Nexus Schema
3
-
* Do not make changes to this file directly
4
-
*/
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
declare global {
13
-
interface NexusGen extends NexusGenTypes {}
14
-
}
15
-
16
-
export interface NexusGenInputs {
17
-
}
18
-
19
-
export interface NexusGenEnums {
20
-
}
21
-
22
-
export interface NexusGenScalars {
23
-
String: string
24
-
Int: number
25
-
Float: number
26
-
Boolean: boolean
27
-
ID: string
28
-
}
29
-
30
-
export interface NexusGenObjects {
31
-
Query: {};
32
-
}
33
-
34
-
export interface NexusGenInterfaces {
35
-
}
36
-
37
-
export interface NexusGenUnions {
38
-
}
39
-
40
-
export type NexusGenRootTypes = NexusGenObjects
41
-
42
-
export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars
43
-
44
-
export interface NexusGenFieldTypes {
45
-
Query: { // field return type
46
-
build: string | null; // String
47
-
test: string | null; // String
48
-
}
49
-
}
50
-
51
-
export interface NexusGenFieldTypeNames {
52
-
Query: { // field return type name
53
-
build: 'String'
54
-
test: 'String'
55
-
}
56
-
}
57
-
58
-
export interface NexusGenArgTypes {
59
-
Query: {
60
-
build: { // args
61
-
src: string; // String!
62
-
}
63
-
test: { // args
64
-
src: string; // String!
65
-
}
66
-
}
67
-
}
68
-
69
-
export interface NexusGenAbstractTypeMembers {
70
-
}
71
-
72
-
export interface NexusGenTypeInterfaces {
73
-
}
74
-
75
-
export type NexusGenObjectNames = keyof NexusGenObjects;
76
-
77
-
export type NexusGenInputNames = never;
78
-
79
-
export type NexusGenEnumNames = never;
80
-
81
-
export type NexusGenInterfaceNames = never;
82
-
83
-
export type NexusGenScalarNames = keyof NexusGenScalars;
84
-
85
-
export type NexusGenUnionNames = never;
86
-
87
-
export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never;
88
-
89
-
export type NexusGenAbstractsUsingStrategyResolveType = never;
90
-
91
-
export type NexusGenFeaturesConfig = {
92
-
abstractTypeStrategies: {
93
-
isTypeOf: false
94
-
resolveType: true
95
-
__typename: false
96
-
}
97
-
}
98
-
99
-
export interface NexusGenTypes {
100
-
context: any;
101
-
inputTypes: NexusGenInputs;
102
-
rootTypes: NexusGenRootTypes;
103
-
inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars;
104
-
argTypes: NexusGenArgTypes;
105
-
fieldTypes: NexusGenFieldTypes;
106
-
fieldTypeNames: NexusGenFieldTypeNames;
107
-
allTypes: NexusGenAllTypes;
108
-
typeInterfaces: NexusGenTypeInterfaces;
109
-
objectNames: NexusGenObjectNames;
110
-
inputNames: NexusGenInputNames;
111
-
enumNames: NexusGenEnumNames;
112
-
interfaceNames: NexusGenInterfaceNames;
113
-
scalarNames: NexusGenScalarNames;
114
-
unionNames: NexusGenUnionNames;
115
-
allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames'];
116
-
allOutputTypes: NexusGenTypes['objectNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['unionNames'] | NexusGenTypes['interfaceNames'] | NexusGenTypes['scalarNames'];
117
-
allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes']
118
-
abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames'];
119
-
abstractTypeMembers: NexusGenAbstractTypeMembers;
120
-
objectsUsingAbstractStrategyIsTypeOf: NexusGenObjectsUsingAbstractStrategyIsTypeOf;
121
-
abstractsUsingStrategyResolveType: NexusGenAbstractsUsingStrategyResolveType;
122
-
features: NexusGenFeaturesConfig;
123
-
}
124
-
125
-
126
-
declare global {
127
-
interface NexusGenPluginTypeConfig<TypeName extends string> {
128
-
}
129
-
interface NexusGenPluginInputTypeConfig<TypeName extends string> {
130
-
}
131
-
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {
132
-
}
133
-
interface NexusGenPluginInputFieldConfig<TypeName extends string, FieldName extends string> {
134
-
}
135
-
interface NexusGenPluginSchemaConfig {
136
-
}
137
-
interface NexusGenPluginArgConfig {
138
-
}
139
-
}
-2
.fluentci/mod.ts
-2
.fluentci/mod.ts
-8
.fluentci/schema.graphql
-8
.fluentci/schema.graphql
+30
.fluentci/sdk/builder.ts
+30
.fluentci/sdk/builder.ts
···
1
+
import { createGQLClient } from "./client.ts";
2
+
import { Context } from "./context.ts";
3
+
4
+
/**
5
+
* @hidden
6
+
*
7
+
* Initialize a default client context from environment.
8
+
*/
9
+
export function initDefaultContext(): Context {
10
+
let ctx = new Context();
11
+
12
+
// Prefer DAGGER_SESSION_PORT if set
13
+
const daggerSessionPort = Deno.env.get("DAGGER_SESSION_PORT");
14
+
if (daggerSessionPort) {
15
+
const sessionToken = Deno.env.get("DAGGER_SESSION_TOKEN");
16
+
if (!sessionToken) {
17
+
throw new Error(
18
+
"DAGGER_SESSION_TOKEN must be set when using DAGGER_SESSION_PORT"
19
+
);
20
+
}
21
+
22
+
ctx = new Context({
23
+
client: createGQLClient(Number(daggerSessionPort), sessionToken),
24
+
});
25
+
} else {
26
+
throw new Error("DAGGER_SESSION_PORT must be set");
27
+
}
28
+
29
+
return ctx;
30
+
}
+7914
.fluentci/sdk/client.gen.ts
+7914
.fluentci/sdk/client.gen.ts
···
1
+
/**
2
+
* This file was auto-generated by `client-gen`.
3
+
* Do not make direct changes to the file.
4
+
*/
5
+
import { Context, defaultContext } from "./context.ts";
6
+
import { computeQuery } from "./utils.ts";
7
+
8
+
/**
9
+
* @hidden
10
+
*/
11
+
export type QueryTree = {
12
+
operation: string;
13
+
args?: Record<string, unknown>;
14
+
};
15
+
16
+
/**
17
+
* @hidden
18
+
*/
19
+
export type Metadata = {
20
+
[key: string]: {
21
+
is_enum?: boolean;
22
+
};
23
+
};
24
+
25
+
interface ClientConfig {
26
+
queryTree?: QueryTree[];
27
+
ctx?: Context;
28
+
}
29
+
30
+
class BaseClient {
31
+
protected _queryTree: QueryTree[];
32
+
protected _ctx: Context;
33
+
34
+
/**
35
+
* @hidden
36
+
*/
37
+
constructor({ queryTree, ctx }: ClientConfig = {}) {
38
+
this._queryTree = queryTree || [];
39
+
this._ctx = ctx || new Context();
40
+
}
41
+
42
+
/**
43
+
* @hidden
44
+
*/
45
+
get queryTree() {
46
+
return this._queryTree;
47
+
}
48
+
}
49
+
50
+
export type BuildArg = {
51
+
/**
52
+
* The build argument name.
53
+
*/
54
+
name: string;
55
+
56
+
/**
57
+
* The build argument value.
58
+
*/
59
+
value: string;
60
+
};
61
+
62
+
/**
63
+
* Sharing mode of the cache volume.
64
+
*/
65
+
export enum CacheSharingMode {
66
+
/**
67
+
* Shares the cache volume amongst many build pipelines, but will serialize the writes
68
+
*/
69
+
Locked = "LOCKED",
70
+
71
+
/**
72
+
* Keeps a cache volume for a single build pipeline
73
+
*/
74
+
Private = "PRIVATE",
75
+
76
+
/**
77
+
* Shares the cache volume amongst many build pipelines
78
+
*/
79
+
Shared = "SHARED",
80
+
}
81
+
/**
82
+
* The `CacheVolumeID` scalar type represents an identifier for an object of type CacheVolume.
83
+
*/
84
+
export type CacheVolumeID = string & { __CacheVolumeID: never };
85
+
86
+
export type ContainerAsTarballOpts = {
87
+
/**
88
+
* Identifiers for other platform specific containers.
89
+
*
90
+
* Used for multi-platform images.
91
+
*/
92
+
platformVariants?: Container[];
93
+
94
+
/**
95
+
* Force each layer of the image to use the specified compression algorithm.
96
+
*
97
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
98
+
*/
99
+
forcedCompression?: ImageLayerCompression;
100
+
101
+
/**
102
+
* Use the specified media types for the image's layers.
103
+
*
104
+
* Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
105
+
*/
106
+
mediaTypes?: ImageMediaTypes;
107
+
};
108
+
109
+
export type ContainerBuildOpts = {
110
+
/**
111
+
* Path to the Dockerfile to use.
112
+
*/
113
+
dockerfile?: string;
114
+
115
+
/**
116
+
* Target build stage to build.
117
+
*/
118
+
target?: string;
119
+
120
+
/**
121
+
* Additional build arguments.
122
+
*/
123
+
buildArgs?: BuildArg[];
124
+
125
+
/**
126
+
* Secrets to pass to the build.
127
+
*
128
+
* They will be mounted at /run/secrets/[secret-name] in the build container
129
+
*
130
+
* They can be accessed in the Dockerfile using the "secret" mount type and mount path /run/secrets/[secret-name], e.g. RUN --mount=type=secret,id=my-secret curl http://example.com?token=$(cat /run/secrets/my-secret)
131
+
*/
132
+
secrets?: Secret[];
133
+
};
134
+
135
+
export type ContainerExportOpts = {
136
+
/**
137
+
* Identifiers for other platform specific containers.
138
+
*
139
+
* Used for multi-platform image.
140
+
*/
141
+
platformVariants?: Container[];
142
+
143
+
/**
144
+
* Force each layer of the exported image to use the specified compression algorithm.
145
+
*
146
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
147
+
*/
148
+
forcedCompression?: ImageLayerCompression;
149
+
150
+
/**
151
+
* Use the specified media types for the exported image's layers.
152
+
*
153
+
* Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
154
+
*/
155
+
mediaTypes?: ImageMediaTypes;
156
+
};
157
+
158
+
export type ContainerImportOpts = {
159
+
/**
160
+
* Identifies the tag to import from the archive, if the archive bundles multiple tags.
161
+
*/
162
+
tag?: string;
163
+
};
164
+
165
+
export type ContainerPipelineOpts = {
166
+
/**
167
+
* Description of the sub-pipeline.
168
+
*/
169
+
description?: string;
170
+
171
+
/**
172
+
* Labels to apply to the sub-pipeline.
173
+
*/
174
+
labels?: PipelineLabel[];
175
+
};
176
+
177
+
export type ContainerPublishOpts = {
178
+
/**
179
+
* Identifiers for other platform specific containers.
180
+
*
181
+
* Used for multi-platform image.
182
+
*/
183
+
platformVariants?: Container[];
184
+
185
+
/**
186
+
* Force each layer of the published image to use the specified compression algorithm.
187
+
*
188
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
189
+
*/
190
+
forcedCompression?: ImageLayerCompression;
191
+
192
+
/**
193
+
* Use the specified media types for the published image's layers.
194
+
*
195
+
* Defaults to OCI, which is largely compatible with most recent registries, but Docker may be needed for older registries without OCI support.
196
+
*/
197
+
mediaTypes?: ImageMediaTypes;
198
+
};
199
+
200
+
export type ContainerTerminalOpts = {
201
+
/**
202
+
* If set, override the container's default terminal command and invoke these command arguments instead.
203
+
*/
204
+
cmd?: string[];
205
+
};
206
+
207
+
export type ContainerWithDirectoryOpts = {
208
+
/**
209
+
* Patterns to exclude in the written directory (e.g. ["node_modules/**", ".gitignore", ".git/"]).
210
+
*/
211
+
exclude?: string[];
212
+
213
+
/**
214
+
* Patterns to include in the written directory (e.g. ["*.go", "go.mod", "go.sum"]).
215
+
*/
216
+
include?: string[];
217
+
218
+
/**
219
+
* A user:group to set for the directory and its contents.
220
+
*
221
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
222
+
*
223
+
* If the group is omitted, it defaults to the same as the user.
224
+
*/
225
+
owner?: string;
226
+
};
227
+
228
+
export type ContainerWithEntrypointOpts = {
229
+
/**
230
+
* Don't remove the default arguments when setting the entrypoint.
231
+
*/
232
+
keepDefaultArgs?: boolean;
233
+
};
234
+
235
+
export type ContainerWithEnvVariableOpts = {
236
+
/**
237
+
* Replace `${VAR}` or `$VAR` in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
238
+
*/
239
+
expand?: boolean;
240
+
};
241
+
242
+
export type ContainerWithExecOpts = {
243
+
/**
244
+
* If the container has an entrypoint, ignore it for args rather than using it to wrap them.
245
+
*/
246
+
skipEntrypoint?: boolean;
247
+
248
+
/**
249
+
* Content to write to the command's standard input before closing (e.g., "Hello world").
250
+
*/
251
+
stdin?: string;
252
+
253
+
/**
254
+
* Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
255
+
*/
256
+
redirectStdout?: string;
257
+
258
+
/**
259
+
* Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
260
+
*/
261
+
redirectStderr?: string;
262
+
263
+
/**
264
+
* Provides dagger access to the executed command.
265
+
*
266
+
* 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.
267
+
*/
268
+
experimentalPrivilegedNesting?: boolean;
269
+
270
+
/**
271
+
* 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.
272
+
*/
273
+
insecureRootCapabilities?: boolean;
274
+
};
275
+
276
+
export type ContainerWithExposedPortOpts = {
277
+
/**
278
+
* Transport layer network protocol
279
+
*/
280
+
protocol?: NetworkProtocol;
281
+
282
+
/**
283
+
* Optional port description
284
+
*/
285
+
description?: string;
286
+
287
+
/**
288
+
* Skip the health check when run as a service.
289
+
*/
290
+
experimentalSkipHealthcheck?: boolean;
291
+
};
292
+
293
+
export type ContainerWithFileOpts = {
294
+
/**
295
+
* Permission given to the copied file (e.g., 0600).
296
+
*/
297
+
permissions?: number;
298
+
299
+
/**
300
+
* A user:group to set for the file.
301
+
*
302
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
303
+
*
304
+
* If the group is omitted, it defaults to the same as the user.
305
+
*/
306
+
owner?: string;
307
+
};
308
+
309
+
export type ContainerWithMountedCacheOpts = {
310
+
/**
311
+
* Identifier of the directory to use as the cache volume's root.
312
+
*/
313
+
source?: Directory;
314
+
315
+
/**
316
+
* Sharing mode of the cache volume.
317
+
*/
318
+
sharing?: CacheSharingMode;
319
+
320
+
/**
321
+
* A user:group to set for the mounted cache directory.
322
+
*
323
+
* Note that this changes the ownership of the specified mount along with the initial filesystem provided by source (if any). It does not have any effect if/when the cache has already been created.
324
+
*
325
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
326
+
*
327
+
* If the group is omitted, it defaults to the same as the user.
328
+
*/
329
+
owner?: string;
330
+
};
331
+
332
+
export type ContainerWithMountedDirectoryOpts = {
333
+
/**
334
+
* A user:group to set for the mounted directory and its contents.
335
+
*
336
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
337
+
*
338
+
* If the group is omitted, it defaults to the same as the user.
339
+
*/
340
+
owner?: string;
341
+
};
342
+
343
+
export type ContainerWithMountedFileOpts = {
344
+
/**
345
+
* A user or user:group to set for the mounted file.
346
+
*
347
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
348
+
*
349
+
* If the group is omitted, it defaults to the same as the user.
350
+
*/
351
+
owner?: string;
352
+
};
353
+
354
+
export type ContainerWithMountedSecretOpts = {
355
+
/**
356
+
* A user:group to set for the mounted secret.
357
+
*
358
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
359
+
*
360
+
* If the group is omitted, it defaults to the same as the user.
361
+
*/
362
+
owner?: string;
363
+
364
+
/**
365
+
* Permission given to the mounted secret (e.g., 0600).
366
+
*
367
+
* This option requires an owner to be set to be active.
368
+
*/
369
+
mode?: number;
370
+
};
371
+
372
+
export type ContainerWithNewFileOpts = {
373
+
/**
374
+
* Content of the file to write (e.g., "Hello world!").
375
+
*/
376
+
contents?: string;
377
+
378
+
/**
379
+
* Permission given to the written file (e.g., 0600).
380
+
*/
381
+
permissions?: number;
382
+
383
+
/**
384
+
* A user:group to set for the file.
385
+
*
386
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
387
+
*
388
+
* If the group is omitted, it defaults to the same as the user.
389
+
*/
390
+
owner?: string;
391
+
};
392
+
393
+
export type ContainerWithUnixSocketOpts = {
394
+
/**
395
+
* A user:group to set for the mounted socket.
396
+
*
397
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
398
+
*
399
+
* If the group is omitted, it defaults to the same as the user.
400
+
*/
401
+
owner?: string;
402
+
};
403
+
404
+
export type ContainerWithoutEntrypointOpts = {
405
+
/**
406
+
* Don't remove the default arguments when unsetting the entrypoint.
407
+
*/
408
+
keepDefaultArgs?: boolean;
409
+
};
410
+
411
+
export type ContainerWithoutExposedPortOpts = {
412
+
/**
413
+
* Port protocol to unexpose
414
+
*/
415
+
protocol?: NetworkProtocol;
416
+
};
417
+
418
+
/**
419
+
* The `ContainerID` scalar type represents an identifier for an object of type Container.
420
+
*/
421
+
export type ContainerID = string & { __ContainerID: never };
422
+
423
+
export type CurrentModuleWorkdirOpts = {
424
+
/**
425
+
* Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
426
+
*/
427
+
exclude?: string[];
428
+
429
+
/**
430
+
* Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
431
+
*/
432
+
include?: string[];
433
+
};
434
+
435
+
/**
436
+
* The `CurrentModuleID` scalar type represents an identifier for an object of type CurrentModule.
437
+
*/
438
+
export type CurrentModuleID = string & { __CurrentModuleID: never };
439
+
440
+
export type DirectoryAsModuleOpts = {
441
+
/**
442
+
* An optional subpath of the directory which contains the module's source code.
443
+
*
444
+
* 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.
445
+
*
446
+
* If not set, the module source code is loaded from the root of the directory.
447
+
*/
448
+
sourceSubpath?: string;
449
+
};
450
+
451
+
export type DirectoryDockerBuildOpts = {
452
+
/**
453
+
* The platform to build.
454
+
*/
455
+
platform?: Platform;
456
+
457
+
/**
458
+
* Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
459
+
*/
460
+
dockerfile?: string;
461
+
462
+
/**
463
+
* Target build stage to build.
464
+
*/
465
+
target?: string;
466
+
467
+
/**
468
+
* Build arguments to use in the build.
469
+
*/
470
+
buildArgs?: BuildArg[];
471
+
472
+
/**
473
+
* Secrets to pass to the build.
474
+
*
475
+
* They will be mounted at /run/secrets/[secret-name].
476
+
*/
477
+
secrets?: Secret[];
478
+
};
479
+
480
+
export type DirectoryEntriesOpts = {
481
+
/**
482
+
* Location of the directory to look at (e.g., "/src").
483
+
*/
484
+
path?: string;
485
+
};
486
+
487
+
export type DirectoryPipelineOpts = {
488
+
/**
489
+
* Description of the sub-pipeline.
490
+
*/
491
+
description?: string;
492
+
493
+
/**
494
+
* Labels to apply to the sub-pipeline.
495
+
*/
496
+
labels?: PipelineLabel[];
497
+
};
498
+
499
+
export type DirectoryWithDirectoryOpts = {
500
+
/**
501
+
* Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
502
+
*/
503
+
exclude?: string[];
504
+
505
+
/**
506
+
* Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
507
+
*/
508
+
include?: string[];
509
+
};
510
+
511
+
export type DirectoryWithFileOpts = {
512
+
/**
513
+
* Permission given to the copied file (e.g., 0600).
514
+
*/
515
+
permissions?: number;
516
+
};
517
+
518
+
export type DirectoryWithNewDirectoryOpts = {
519
+
/**
520
+
* Permission granted to the created directory (e.g., 0777).
521
+
*/
522
+
permissions?: number;
523
+
};
524
+
525
+
export type DirectoryWithNewFileOpts = {
526
+
/**
527
+
* Permission given to the copied file (e.g., 0600).
528
+
*/
529
+
permissions?: number;
530
+
};
531
+
532
+
/**
533
+
* The `DirectoryID` scalar type represents an identifier for an object of type Directory.
534
+
*/
535
+
export type DirectoryID = string & { __DirectoryID: never };
536
+
537
+
/**
538
+
* The `EnvVariableID` scalar type represents an identifier for an object of type EnvVariable.
539
+
*/
540
+
export type EnvVariableID = string & { __EnvVariableID: never };
541
+
542
+
/**
543
+
* The `FieldTypeDefID` scalar type represents an identifier for an object of type FieldTypeDef.
544
+
*/
545
+
export type FieldTypeDefID = string & { __FieldTypeDefID: never };
546
+
547
+
export type FileExportOpts = {
548
+
/**
549
+
* If allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.
550
+
*/
551
+
allowParentDirPath?: boolean;
552
+
};
553
+
554
+
/**
555
+
* The `FileID` scalar type represents an identifier for an object of type File.
556
+
*/
557
+
export type FileID = string & { __FileID: never };
558
+
559
+
export type FunctionWithArgOpts = {
560
+
/**
561
+
* A doc string for the argument, if any
562
+
*/
563
+
description?: string;
564
+
565
+
/**
566
+
* A default value to use for this argument if not explicitly set by the caller, if any
567
+
*/
568
+
defaultValue?: JSON;
569
+
};
570
+
571
+
/**
572
+
* The `FunctionArgID` scalar type represents an identifier for an object of type FunctionArg.
573
+
*/
574
+
export type FunctionArgID = string & { __FunctionArgID: never };
575
+
576
+
/**
577
+
* The `FunctionCallArgValueID` scalar type represents an identifier for an object of type FunctionCallArgValue.
578
+
*/
579
+
export type FunctionCallArgValueID = string & {
580
+
__FunctionCallArgValueID: never;
581
+
};
582
+
583
+
/**
584
+
* The `FunctionCallID` scalar type represents an identifier for an object of type FunctionCall.
585
+
*/
586
+
export type FunctionCallID = string & { __FunctionCallID: never };
587
+
588
+
/**
589
+
* The `FunctionID` scalar type represents an identifier for an object of type Function.
590
+
*/
591
+
export type FunctionID = string & { __FunctionID: never };
592
+
593
+
/**
594
+
* The `GeneratedCodeID` scalar type represents an identifier for an object of type GeneratedCode.
595
+
*/
596
+
export type GeneratedCodeID = string & { __GeneratedCodeID: never };
597
+
598
+
/**
599
+
* The `GitModuleSourceID` scalar type represents an identifier for an object of type GitModuleSource.
600
+
*/
601
+
export type GitModuleSourceID = string & { __GitModuleSourceID: never };
602
+
603
+
export type GitRefTreeOpts = {
604
+
/**
605
+
* DEPRECATED: This option should be passed to `git` instead.
606
+
*/
607
+
sshKnownHosts?: string;
608
+
609
+
/**
610
+
* DEPRECATED: This option should be passed to `git` instead.
611
+
*/
612
+
sshAuthSocket?: Socket;
613
+
};
614
+
615
+
/**
616
+
* The `GitRefID` scalar type represents an identifier for an object of type GitRef.
617
+
*/
618
+
export type GitRefID = string & { __GitRefID: never };
619
+
620
+
/**
621
+
* The `GitRepositoryID` scalar type represents an identifier for an object of type GitRepository.
622
+
*/
623
+
export type GitRepositoryID = string & { __GitRepositoryID: never };
624
+
625
+
export type HostDirectoryOpts = {
626
+
/**
627
+
* Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
628
+
*/
629
+
exclude?: string[];
630
+
631
+
/**
632
+
* Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
633
+
*/
634
+
include?: string[];
635
+
};
636
+
637
+
export type HostServiceOpts = {
638
+
/**
639
+
* Upstream host to forward traffic to.
640
+
*/
641
+
host?: string;
642
+
643
+
/**
644
+
* Ports to expose via the service, forwarding through the host network.
645
+
*
646
+
* If a port's frontend is unspecified or 0, it defaults to the same as the backend port.
647
+
*
648
+
* An empty set of ports is not valid; an error will be returned.
649
+
*/
650
+
ports: PortForward[];
651
+
};
652
+
653
+
export type HostTunnelOpts = {
654
+
/**
655
+
* Configure explicit port forwarding rules for the tunnel.
656
+
*
657
+
* If a port's frontend is unspecified or 0, a random port will be chosen by the host.
658
+
*
659
+
* If no ports are given, all of the service's ports are forwarded. If native is true, each port maps to the same port on the host. If native is false, each port maps to a random port chosen by the host.
660
+
*
661
+
* If ports are given and native is true, the ports are additive.
662
+
*/
663
+
ports?: PortForward[];
664
+
665
+
/**
666
+
* Map each service port to the same port on the host, as if the service were running natively.
667
+
*
668
+
* Note: enabling may result in port conflicts.
669
+
*/
670
+
native?: boolean;
671
+
};
672
+
673
+
/**
674
+
* The `HostID` scalar type represents an identifier for an object of type Host.
675
+
*/
676
+
export type HostID = string & { __HostID: never };
677
+
678
+
/**
679
+
* Compression algorithm to use for image layers.
680
+
*/
681
+
export enum ImageLayerCompression {
682
+
Estargz = "EStarGZ",
683
+
Gzip = "Gzip",
684
+
Uncompressed = "Uncompressed",
685
+
Zstd = "Zstd",
686
+
}
687
+
/**
688
+
* Mediatypes to use in published or exported image metadata.
689
+
*/
690
+
export enum ImageMediaTypes {
691
+
Dockermediatypes = "DockerMediaTypes",
692
+
Ocimediatypes = "OCIMediaTypes",
693
+
}
694
+
/**
695
+
* The `InputTypeDefID` scalar type represents an identifier for an object of type InputTypeDef.
696
+
*/
697
+
export type InputTypeDefID = string & { __InputTypeDefID: never };
698
+
699
+
/**
700
+
* The `InterfaceTypeDefID` scalar type represents an identifier for an object of type InterfaceTypeDef.
701
+
*/
702
+
export type InterfaceTypeDefID = string & { __InterfaceTypeDefID: never };
703
+
704
+
/**
705
+
* An arbitrary JSON-encoded value.
706
+
*/
707
+
export type JSON = string & { __JSON: never };
708
+
709
+
/**
710
+
* The `LabelID` scalar type represents an identifier for an object of type Label.
711
+
*/
712
+
export type LabelID = string & { __LabelID: never };
713
+
714
+
/**
715
+
* The `ListTypeDefID` scalar type represents an identifier for an object of type ListTypeDef.
716
+
*/
717
+
export type ListTypeDefID = string & { __ListTypeDefID: never };
718
+
719
+
/**
720
+
* The `LocalModuleSourceID` scalar type represents an identifier for an object of type LocalModuleSource.
721
+
*/
722
+
export type LocalModuleSourceID = string & { __LocalModuleSourceID: never };
723
+
724
+
/**
725
+
* The `ModuleDependencyID` scalar type represents an identifier for an object of type ModuleDependency.
726
+
*/
727
+
export type ModuleDependencyID = string & { __ModuleDependencyID: never };
728
+
729
+
/**
730
+
* The `ModuleID` scalar type represents an identifier for an object of type Module.
731
+
*/
732
+
export type ModuleID = string & { __ModuleID: never };
733
+
734
+
/**
735
+
* The `ModuleSourceID` scalar type represents an identifier for an object of type ModuleSource.
736
+
*/
737
+
export type ModuleSourceID = string & { __ModuleSourceID: never };
738
+
739
+
/**
740
+
* The kind of module source.
741
+
*/
742
+
export enum ModuleSourceKind {
743
+
GitSource = "GIT_SOURCE",
744
+
LocalSource = "LOCAL_SOURCE",
745
+
}
746
+
/**
747
+
* Transport layer network protocol associated to a port.
748
+
*/
749
+
export enum NetworkProtocol {
750
+
Tcp = "TCP",
751
+
Udp = "UDP",
752
+
}
753
+
/**
754
+
* The `ObjectTypeDefID` scalar type represents an identifier for an object of type ObjectTypeDef.
755
+
*/
756
+
export type ObjectTypeDefID = string & { __ObjectTypeDefID: never };
757
+
758
+
export type PipelineLabel = {
759
+
/**
760
+
* Label name.
761
+
*/
762
+
name: string;
763
+
764
+
/**
765
+
* Label value.
766
+
*/
767
+
value: string;
768
+
};
769
+
770
+
/**
771
+
* The platform config OS and architecture in a Container.
772
+
*
773
+
* The format is [os]/[platform]/[version] (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
774
+
*/
775
+
export type Platform = string & { __Platform: never };
776
+
777
+
export type PortForward = {
778
+
/**
779
+
* Destination port for traffic.
780
+
*/
781
+
backend: number;
782
+
783
+
/**
784
+
* Port to expose to clients. If unspecified, a default will be chosen.
785
+
*/
786
+
frontend?: number;
787
+
788
+
/**
789
+
* Transport layer protocol to use for traffic.
790
+
*/
791
+
protocol?: NetworkProtocol;
792
+
};
793
+
794
+
/**
795
+
* The `PortID` scalar type represents an identifier for an object of type Port.
796
+
*/
797
+
export type PortID = string & { __PortID: never };
798
+
799
+
export type ClientContainerOpts = {
800
+
/**
801
+
* DEPRECATED: Use `loadContainerFromID` instead.
802
+
*/
803
+
id?: ContainerID;
804
+
805
+
/**
806
+
* Platform to initialize the container with.
807
+
*/
808
+
platform?: Platform;
809
+
};
810
+
811
+
export type ClientDirectoryOpts = {
812
+
/**
813
+
* DEPRECATED: Use `loadDirectoryFromID` isntead.
814
+
*/
815
+
id?: DirectoryID;
816
+
};
817
+
818
+
export type ClientGitOpts = {
819
+
/**
820
+
* Set to true to keep .git directory.
821
+
*/
822
+
keepGitDir?: boolean;
823
+
824
+
/**
825
+
* A service which must be started before the repo is fetched.
826
+
*/
827
+
experimentalServiceHost?: Service;
828
+
829
+
/**
830
+
* Set SSH known hosts
831
+
*/
832
+
sshKnownHosts?: string;
833
+
834
+
/**
835
+
* Set SSH auth socket
836
+
*/
837
+
sshAuthSocket?: Socket;
838
+
};
839
+
840
+
export type ClientHttpOpts = {
841
+
/**
842
+
* A service which must be started before the URL is fetched.
843
+
*/
844
+
experimentalServiceHost?: Service;
845
+
};
846
+
847
+
export type ClientModuleDependencyOpts = {
848
+
/**
849
+
* If set, the name to use for the dependency. Otherwise, once installed to a parent module, the name of the dependency module will be used by default.
850
+
*/
851
+
name?: string;
852
+
};
853
+
854
+
export type ClientModuleSourceOpts = {
855
+
/**
856
+
* An explicitly set root directory for the module source. This is required to load local sources as modules; other source types implicitly encode the root directory and do not require this.
857
+
*/
858
+
rootDirectory?: Directory;
859
+
860
+
/**
861
+
* If true, enforce that the source is a stable version for source kinds that support versioning.
862
+
*/
863
+
stable?: boolean;
864
+
};
865
+
866
+
export type ClientPipelineOpts = {
867
+
/**
868
+
* Description of the sub-pipeline.
869
+
*/
870
+
description?: string;
871
+
872
+
/**
873
+
* Labels to apply to the sub-pipeline.
874
+
*/
875
+
labels?: PipelineLabel[];
876
+
};
877
+
878
+
/**
879
+
* The `SecretID` scalar type represents an identifier for an object of type Secret.
880
+
*/
881
+
export type SecretID = string & { __SecretID: never };
882
+
883
+
export type ServiceEndpointOpts = {
884
+
/**
885
+
* The exposed port number for the endpoint
886
+
*/
887
+
port?: number;
888
+
889
+
/**
890
+
* Return a URL with the given scheme, eg. http for http://
891
+
*/
892
+
scheme?: string;
893
+
};
894
+
895
+
export type ServiceStopOpts = {
896
+
/**
897
+
* Immediately kill the service without waiting for a graceful exit
898
+
*/
899
+
kill?: boolean;
900
+
};
901
+
902
+
export type ServiceUpOpts = {
903
+
/**
904
+
* List of frontend/backend port mappings to forward.
905
+
*
906
+
* Frontend is the port accepting traffic on the host, backend is the service port.
907
+
*/
908
+
ports?: PortForward[];
909
+
910
+
/**
911
+
* Bind each tunnel port to a random port on the host.
912
+
*/
913
+
random?: boolean;
914
+
};
915
+
916
+
/**
917
+
* The `ServiceID` scalar type represents an identifier for an object of type Service.
918
+
*/
919
+
export type ServiceID = string & { __ServiceID: never };
920
+
921
+
/**
922
+
* The `SocketID` scalar type represents an identifier for an object of type Socket.
923
+
*/
924
+
export type SocketID = string & { __SocketID: never };
925
+
926
+
/**
927
+
* The `TerminalID` scalar type represents an identifier for an object of type Terminal.
928
+
*/
929
+
export type TerminalID = string & { __TerminalID: never };
930
+
931
+
export type TypeDefWithFieldOpts = {
932
+
/**
933
+
* A doc string for the field, if any
934
+
*/
935
+
description?: string;
936
+
};
937
+
938
+
export type TypeDefWithInterfaceOpts = {
939
+
description?: string;
940
+
};
941
+
942
+
export type TypeDefWithObjectOpts = {
943
+
description?: string;
944
+
};
945
+
946
+
/**
947
+
* The `TypeDefID` scalar type represents an identifier for an object of type TypeDef.
948
+
*/
949
+
export type TypeDefID = string & { __TypeDefID: never };
950
+
951
+
/**
952
+
* Distinguishes the different kinds of TypeDefs.
953
+
*/
954
+
export enum TypeDefKind {
955
+
/**
956
+
* A boolean value.
957
+
*/
958
+
BooleanKind = "BOOLEAN_KIND",
959
+
960
+
/**
961
+
* A graphql input type, used only when representing the core API via TypeDefs.
962
+
*/
963
+
InputKind = "INPUT_KIND",
964
+
965
+
/**
966
+
* An integer value.
967
+
*/
968
+
IntegerKind = "INTEGER_KIND",
969
+
970
+
/**
971
+
* A named type of functions that can be matched+implemented by other objects+interfaces.
972
+
*
973
+
* Always paired with an InterfaceTypeDef.
974
+
*/
975
+
InterfaceKind = "INTERFACE_KIND",
976
+
977
+
/**
978
+
* A list of values all having the same type.
979
+
*
980
+
* Always paired with a ListTypeDef.
981
+
*/
982
+
ListKind = "LIST_KIND",
983
+
984
+
/**
985
+
* A named type defined in the GraphQL schema, with fields and functions.
986
+
*
987
+
* Always paired with an ObjectTypeDef.
988
+
*/
989
+
ObjectKind = "OBJECT_KIND",
990
+
991
+
/**
992
+
* A string value.
993
+
*/
994
+
StringKind = "STRING_KIND",
995
+
996
+
/**
997
+
* A special kind used to signify that no value is returned.
998
+
*
999
+
* This is used for functions that have no return value. The outer TypeDef specifying this Kind is always Optional, as the Void is never actually represented.
1000
+
*/
1001
+
VoidKind = "VOID_KIND",
1002
+
}
1003
+
/**
1004
+
* The absence of a value.
1005
+
*
1006
+
* A Null Void is used as a placeholder for resolvers that do not return anything.
1007
+
*/
1008
+
export type Void = string & { __Void: never };
1009
+
1010
+
export type __TypeEnumValuesOpts = {
1011
+
includeDeprecated?: boolean;
1012
+
};
1013
+
1014
+
export type __TypeFieldsOpts = {
1015
+
includeDeprecated?: boolean;
1016
+
};
1017
+
1018
+
/**
1019
+
* A directory whose contents persist across runs.
1020
+
*/
1021
+
export class CacheVolume extends BaseClient {
1022
+
private readonly _id?: CacheVolumeID = undefined;
1023
+
1024
+
/**
1025
+
* Constructor is used for internal usage only, do not create object from it.
1026
+
*/
1027
+
constructor(
1028
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
1029
+
_id?: CacheVolumeID
1030
+
) {
1031
+
super(parent);
1032
+
1033
+
this._id = _id;
1034
+
}
1035
+
1036
+
/**
1037
+
* A unique identifier for this CacheVolume.
1038
+
*/
1039
+
id = async (): Promise<CacheVolumeID> => {
1040
+
if (this._id) {
1041
+
return this._id;
1042
+
}
1043
+
1044
+
const response: Awaited<CacheVolumeID> = await computeQuery(
1045
+
[
1046
+
...this._queryTree,
1047
+
{
1048
+
operation: "id",
1049
+
},
1050
+
],
1051
+
await this._ctx.connection()
1052
+
);
1053
+
1054
+
return response;
1055
+
};
1056
+
}
1057
+
1058
+
/**
1059
+
* An OCI-compatible container, also known as a Docker container.
1060
+
*/
1061
+
export class Container extends BaseClient {
1062
+
private readonly _id?: ContainerID = undefined;
1063
+
private readonly _envVariable?: string = undefined;
1064
+
private readonly _export?: boolean = undefined;
1065
+
private readonly _imageRef?: string = undefined;
1066
+
private readonly _label?: string = undefined;
1067
+
private readonly _platform?: Platform = undefined;
1068
+
private readonly _publish?: string = undefined;
1069
+
private readonly _stderr?: string = undefined;
1070
+
private readonly _stdout?: string = undefined;
1071
+
private readonly _sync?: ContainerID = undefined;
1072
+
private readonly _user?: string = undefined;
1073
+
private readonly _workdir?: string = undefined;
1074
+
1075
+
/**
1076
+
* Constructor is used for internal usage only, do not create object from it.
1077
+
*/
1078
+
constructor(
1079
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
1080
+
_id?: ContainerID,
1081
+
_envVariable?: string,
1082
+
_export?: boolean,
1083
+
_imageRef?: string,
1084
+
_label?: string,
1085
+
_platform?: Platform,
1086
+
_publish?: string,
1087
+
_stderr?: string,
1088
+
_stdout?: string,
1089
+
_sync?: ContainerID,
1090
+
_user?: string,
1091
+
_workdir?: string
1092
+
) {
1093
+
super(parent);
1094
+
1095
+
this._id = _id;
1096
+
this._envVariable = _envVariable;
1097
+
this._export = _export;
1098
+
this._imageRef = _imageRef;
1099
+
this._label = _label;
1100
+
this._platform = _platform;
1101
+
this._publish = _publish;
1102
+
this._stderr = _stderr;
1103
+
this._stdout = _stdout;
1104
+
this._sync = _sync;
1105
+
this._user = _user;
1106
+
this._workdir = _workdir;
1107
+
}
1108
+
1109
+
/**
1110
+
* A unique identifier for this Container.
1111
+
*/
1112
+
id = async (): Promise<ContainerID> => {
1113
+
if (this._id) {
1114
+
return this._id;
1115
+
}
1116
+
1117
+
const response: Awaited<ContainerID> = await computeQuery(
1118
+
[
1119
+
...this._queryTree,
1120
+
{
1121
+
operation: "id",
1122
+
},
1123
+
],
1124
+
await this._ctx.connection()
1125
+
);
1126
+
1127
+
return response;
1128
+
};
1129
+
1130
+
/**
1131
+
* Turn the container into a Service.
1132
+
*
1133
+
* Be sure to set any exposed ports before this conversion.
1134
+
*/
1135
+
asService = (): Service => {
1136
+
return new Service({
1137
+
queryTree: [
1138
+
...this._queryTree,
1139
+
{
1140
+
operation: "asService",
1141
+
},
1142
+
],
1143
+
ctx: this._ctx,
1144
+
});
1145
+
};
1146
+
1147
+
/**
1148
+
* Returns a File representing the container serialized to a tarball.
1149
+
* @param opts.platformVariants Identifiers for other platform specific containers.
1150
+
*
1151
+
* Used for multi-platform images.
1152
+
* @param opts.forcedCompression Force each layer of the image to use the specified compression algorithm.
1153
+
*
1154
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
1155
+
* @param opts.mediaTypes Use the specified media types for the image's layers.
1156
+
*
1157
+
* Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
1158
+
*/
1159
+
asTarball = (opts?: ContainerAsTarballOpts): File => {
1160
+
const metadata: Metadata = {
1161
+
forcedCompression: { is_enum: true },
1162
+
mediaTypes: { is_enum: true },
1163
+
};
1164
+
1165
+
return new File({
1166
+
queryTree: [
1167
+
...this._queryTree,
1168
+
{
1169
+
operation: "asTarball",
1170
+
args: { ...opts, __metadata: metadata },
1171
+
},
1172
+
],
1173
+
ctx: this._ctx,
1174
+
});
1175
+
};
1176
+
1177
+
/**
1178
+
* Initializes this container from a Dockerfile build.
1179
+
* @param context Directory context used by the Dockerfile.
1180
+
* @param opts.dockerfile Path to the Dockerfile to use.
1181
+
* @param opts.target Target build stage to build.
1182
+
* @param opts.buildArgs Additional build arguments.
1183
+
* @param opts.secrets Secrets to pass to the build.
1184
+
*
1185
+
* They will be mounted at /run/secrets/[secret-name] in the build container
1186
+
*
1187
+
* They can be accessed in the Dockerfile using the "secret" mount type and mount path /run/secrets/[secret-name], e.g. RUN --mount=type=secret,id=my-secret curl http://example.com?token=$(cat /run/secrets/my-secret)
1188
+
*/
1189
+
build = (context: Directory, opts?: ContainerBuildOpts): Container => {
1190
+
return new Container({
1191
+
queryTree: [
1192
+
...this._queryTree,
1193
+
{
1194
+
operation: "build",
1195
+
args: { context, ...opts },
1196
+
},
1197
+
],
1198
+
ctx: this._ctx,
1199
+
});
1200
+
};
1201
+
1202
+
/**
1203
+
* Retrieves default arguments for future commands.
1204
+
*/
1205
+
defaultArgs = async (): Promise<string[]> => {
1206
+
const response: Awaited<string[]> = await computeQuery(
1207
+
[
1208
+
...this._queryTree,
1209
+
{
1210
+
operation: "defaultArgs",
1211
+
},
1212
+
],
1213
+
await this._ctx.connection()
1214
+
);
1215
+
1216
+
return response;
1217
+
};
1218
+
1219
+
/**
1220
+
* Retrieves a directory at the given path.
1221
+
*
1222
+
* Mounts are included.
1223
+
* @param path The path of the directory to retrieve (e.g., "./src").
1224
+
*/
1225
+
directory = (path: string): Directory => {
1226
+
return new Directory({
1227
+
queryTree: [
1228
+
...this._queryTree,
1229
+
{
1230
+
operation: "directory",
1231
+
args: { path },
1232
+
},
1233
+
],
1234
+
ctx: this._ctx,
1235
+
});
1236
+
};
1237
+
1238
+
/**
1239
+
* Retrieves entrypoint to be prepended to the arguments of all commands.
1240
+
*/
1241
+
entrypoint = async (): Promise<string[]> => {
1242
+
const response: Awaited<string[]> = await computeQuery(
1243
+
[
1244
+
...this._queryTree,
1245
+
{
1246
+
operation: "entrypoint",
1247
+
},
1248
+
],
1249
+
await this._ctx.connection()
1250
+
);
1251
+
1252
+
return response;
1253
+
};
1254
+
1255
+
/**
1256
+
* Retrieves the value of the specified environment variable.
1257
+
* @param name The name of the environment variable to retrieve (e.g., "PATH").
1258
+
*/
1259
+
envVariable = async (name: string): Promise<string> => {
1260
+
if (this._envVariable) {
1261
+
return this._envVariable;
1262
+
}
1263
+
1264
+
const response: Awaited<string> = await computeQuery(
1265
+
[
1266
+
...this._queryTree,
1267
+
{
1268
+
operation: "envVariable",
1269
+
args: { name },
1270
+
},
1271
+
],
1272
+
await this._ctx.connection()
1273
+
);
1274
+
1275
+
return response;
1276
+
};
1277
+
1278
+
/**
1279
+
* Retrieves the list of environment variables passed to commands.
1280
+
*/
1281
+
envVariables = async (): Promise<EnvVariable[]> => {
1282
+
type envVariables = {
1283
+
id: EnvVariableID;
1284
+
};
1285
+
1286
+
const response: Awaited<envVariables[]> = await computeQuery(
1287
+
[
1288
+
...this._queryTree,
1289
+
{
1290
+
operation: "envVariables",
1291
+
},
1292
+
{
1293
+
operation: "id",
1294
+
},
1295
+
],
1296
+
await this._ctx.connection()
1297
+
);
1298
+
1299
+
return response.map(
1300
+
(r) =>
1301
+
new EnvVariable(
1302
+
{
1303
+
queryTree: [
1304
+
{
1305
+
operation: "loadEnvVariableFromID",
1306
+
args: { id: r.id },
1307
+
},
1308
+
],
1309
+
ctx: this._ctx,
1310
+
},
1311
+
r.id
1312
+
)
1313
+
);
1314
+
};
1315
+
1316
+
/**
1317
+
* EXPERIMENTAL API! Subject to change/removal at any time.
1318
+
*
1319
+
* Configures all available GPUs on the host to be accessible to this container.
1320
+
*
1321
+
* This currently works for Nvidia devices only.
1322
+
*/
1323
+
experimentalWithAllGPUs = (): Container => {
1324
+
return new Container({
1325
+
queryTree: [
1326
+
...this._queryTree,
1327
+
{
1328
+
operation: "experimentalWithAllGPUs",
1329
+
},
1330
+
],
1331
+
ctx: this._ctx,
1332
+
});
1333
+
};
1334
+
1335
+
/**
1336
+
* EXPERIMENTAL API! Subject to change/removal at any time.
1337
+
*
1338
+
* Configures the provided list of devices to be accesible to this container.
1339
+
*
1340
+
* This currently works for Nvidia devices only.
1341
+
* @param devices List of devices to be accessible to this container.
1342
+
*/
1343
+
experimentalWithGPU = (devices: string[]): Container => {
1344
+
return new Container({
1345
+
queryTree: [
1346
+
...this._queryTree,
1347
+
{
1348
+
operation: "experimentalWithGPU",
1349
+
args: { devices },
1350
+
},
1351
+
],
1352
+
ctx: this._ctx,
1353
+
});
1354
+
};
1355
+
1356
+
/**
1357
+
* Writes the container as an OCI tarball to the destination file path on the host.
1358
+
*
1359
+
* Return true on success.
1360
+
*
1361
+
* It can also export platform variants.
1362
+
* @param path Host's destination path (e.g., "./tarball").
1363
+
*
1364
+
* Path can be relative to the engine's workdir or absolute.
1365
+
* @param opts.platformVariants Identifiers for other platform specific containers.
1366
+
*
1367
+
* Used for multi-platform image.
1368
+
* @param opts.forcedCompression Force each layer of the exported image to use the specified compression algorithm.
1369
+
*
1370
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
1371
+
* @param opts.mediaTypes Use the specified media types for the exported image's layers.
1372
+
*
1373
+
* Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
1374
+
*/
1375
+
export = async (
1376
+
path: string,
1377
+
opts?: ContainerExportOpts
1378
+
): Promise<boolean> => {
1379
+
if (this._export) {
1380
+
return this._export;
1381
+
}
1382
+
1383
+
const metadata: Metadata = {
1384
+
forcedCompression: { is_enum: true },
1385
+
mediaTypes: { is_enum: true },
1386
+
};
1387
+
1388
+
const response: Awaited<boolean> = await computeQuery(
1389
+
[
1390
+
...this._queryTree,
1391
+
{
1392
+
operation: "export",
1393
+
args: { path, ...opts, __metadata: metadata },
1394
+
},
1395
+
],
1396
+
await this._ctx.connection()
1397
+
);
1398
+
1399
+
return response;
1400
+
};
1401
+
1402
+
/**
1403
+
* Retrieves the list of exposed ports.
1404
+
*
1405
+
* This includes ports already exposed by the image, even if not explicitly added with dagger.
1406
+
*/
1407
+
exposedPorts = async (): Promise<Port[]> => {
1408
+
type exposedPorts = {
1409
+
id: PortID;
1410
+
};
1411
+
1412
+
const response: Awaited<exposedPorts[]> = await computeQuery(
1413
+
[
1414
+
...this._queryTree,
1415
+
{
1416
+
operation: "exposedPorts",
1417
+
},
1418
+
{
1419
+
operation: "id",
1420
+
},
1421
+
],
1422
+
await this._ctx.connection()
1423
+
);
1424
+
1425
+
return response.map(
1426
+
(r) =>
1427
+
new Port(
1428
+
{
1429
+
queryTree: [
1430
+
{
1431
+
operation: "loadPortFromID",
1432
+
args: { id: r.id },
1433
+
},
1434
+
],
1435
+
ctx: this._ctx,
1436
+
},
1437
+
r.id
1438
+
)
1439
+
);
1440
+
};
1441
+
1442
+
/**
1443
+
* Retrieves a file at the given path.
1444
+
*
1445
+
* Mounts are included.
1446
+
* @param path The path of the file to retrieve (e.g., "./README.md").
1447
+
*/
1448
+
file = (path: string): File => {
1449
+
return new File({
1450
+
queryTree: [
1451
+
...this._queryTree,
1452
+
{
1453
+
operation: "file",
1454
+
args: { path },
1455
+
},
1456
+
],
1457
+
ctx: this._ctx,
1458
+
});
1459
+
};
1460
+
1461
+
/**
1462
+
* Initializes this container from a pulled base image.
1463
+
* @param address Image's address from its registry.
1464
+
*
1465
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g., "docker.io/dagger/dagger:main").
1466
+
*/
1467
+
from = (address: string): Container => {
1468
+
return new Container({
1469
+
queryTree: [
1470
+
...this._queryTree,
1471
+
{
1472
+
operation: "from",
1473
+
args: { address },
1474
+
},
1475
+
],
1476
+
ctx: this._ctx,
1477
+
});
1478
+
};
1479
+
1480
+
/**
1481
+
* The unique image reference which can only be retrieved immediately after the 'Container.From' call.
1482
+
*/
1483
+
imageRef = async (): Promise<string> => {
1484
+
if (this._imageRef) {
1485
+
return this._imageRef;
1486
+
}
1487
+
1488
+
const response: Awaited<string> = await computeQuery(
1489
+
[
1490
+
...this._queryTree,
1491
+
{
1492
+
operation: "imageRef",
1493
+
},
1494
+
],
1495
+
await this._ctx.connection()
1496
+
);
1497
+
1498
+
return response;
1499
+
};
1500
+
1501
+
/**
1502
+
* Reads the container from an OCI tarball.
1503
+
* @param source File to read the container from.
1504
+
* @param opts.tag Identifies the tag to import from the archive, if the archive bundles multiple tags.
1505
+
*/
1506
+
import_ = (source: File, opts?: ContainerImportOpts): Container => {
1507
+
return new Container({
1508
+
queryTree: [
1509
+
...this._queryTree,
1510
+
{
1511
+
operation: "import",
1512
+
args: { source, ...opts },
1513
+
},
1514
+
],
1515
+
ctx: this._ctx,
1516
+
});
1517
+
};
1518
+
1519
+
/**
1520
+
* Retrieves the value of the specified label.
1521
+
* @param name The name of the label (e.g., "org.opencontainers.artifact.created").
1522
+
*/
1523
+
label = async (name: string): Promise<string> => {
1524
+
if (this._label) {
1525
+
return this._label;
1526
+
}
1527
+
1528
+
const response: Awaited<string> = await computeQuery(
1529
+
[
1530
+
...this._queryTree,
1531
+
{
1532
+
operation: "label",
1533
+
args: { name },
1534
+
},
1535
+
],
1536
+
await this._ctx.connection()
1537
+
);
1538
+
1539
+
return response;
1540
+
};
1541
+
1542
+
/**
1543
+
* Retrieves the list of labels passed to container.
1544
+
*/
1545
+
labels = async (): Promise<Label[]> => {
1546
+
type labels = {
1547
+
id: LabelID;
1548
+
};
1549
+
1550
+
const response: Awaited<labels[]> = await computeQuery(
1551
+
[
1552
+
...this._queryTree,
1553
+
{
1554
+
operation: "labels",
1555
+
},
1556
+
{
1557
+
operation: "id",
1558
+
},
1559
+
],
1560
+
await this._ctx.connection()
1561
+
);
1562
+
1563
+
return response.map(
1564
+
(r) =>
1565
+
new Label(
1566
+
{
1567
+
queryTree: [
1568
+
{
1569
+
operation: "loadLabelFromID",
1570
+
args: { id: r.id },
1571
+
},
1572
+
],
1573
+
ctx: this._ctx,
1574
+
},
1575
+
r.id
1576
+
)
1577
+
);
1578
+
};
1579
+
1580
+
/**
1581
+
* Retrieves the list of paths where a directory is mounted.
1582
+
*/
1583
+
mounts = async (): Promise<string[]> => {
1584
+
const response: Awaited<string[]> = await computeQuery(
1585
+
[
1586
+
...this._queryTree,
1587
+
{
1588
+
operation: "mounts",
1589
+
},
1590
+
],
1591
+
await this._ctx.connection()
1592
+
);
1593
+
1594
+
return response;
1595
+
};
1596
+
1597
+
/**
1598
+
* Creates a named sub-pipeline.
1599
+
* @param name Name of the sub-pipeline.
1600
+
* @param opts.description Description of the sub-pipeline.
1601
+
* @param opts.labels Labels to apply to the sub-pipeline.
1602
+
*/
1603
+
pipeline = (name: string, opts?: ContainerPipelineOpts): Container => {
1604
+
return new Container({
1605
+
queryTree: [
1606
+
...this._queryTree,
1607
+
{
1608
+
operation: "pipeline",
1609
+
args: { name, ...opts },
1610
+
},
1611
+
],
1612
+
ctx: this._ctx,
1613
+
});
1614
+
};
1615
+
1616
+
/**
1617
+
* The platform this container executes and publishes as.
1618
+
*/
1619
+
platform = async (): Promise<Platform> => {
1620
+
if (this._platform) {
1621
+
return this._platform;
1622
+
}
1623
+
1624
+
const response: Awaited<Platform> = await computeQuery(
1625
+
[
1626
+
...this._queryTree,
1627
+
{
1628
+
operation: "platform",
1629
+
},
1630
+
],
1631
+
await this._ctx.connection()
1632
+
);
1633
+
1634
+
return response;
1635
+
};
1636
+
1637
+
/**
1638
+
* Publishes this container as a new image to the specified address.
1639
+
*
1640
+
* Publish returns a fully qualified ref.
1641
+
*
1642
+
* It can also publish platform variants.
1643
+
* @param address Registry's address to publish the image to.
1644
+
*
1645
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
1646
+
* @param opts.platformVariants Identifiers for other platform specific containers.
1647
+
*
1648
+
* Used for multi-platform image.
1649
+
* @param opts.forcedCompression Force each layer of the published image to use the specified compression algorithm.
1650
+
*
1651
+
* If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
1652
+
* @param opts.mediaTypes Use the specified media types for the published image's layers.
1653
+
*
1654
+
* Defaults to OCI, which is largely compatible with most recent registries, but Docker may be needed for older registries without OCI support.
1655
+
*/
1656
+
publish = async (
1657
+
address: string,
1658
+
opts?: ContainerPublishOpts
1659
+
): Promise<string> => {
1660
+
if (this._publish) {
1661
+
return this._publish;
1662
+
}
1663
+
1664
+
const metadata: Metadata = {
1665
+
forcedCompression: { is_enum: true },
1666
+
mediaTypes: { is_enum: true },
1667
+
};
1668
+
1669
+
const response: Awaited<string> = await computeQuery(
1670
+
[
1671
+
...this._queryTree,
1672
+
{
1673
+
operation: "publish",
1674
+
args: { address, ...opts, __metadata: metadata },
1675
+
},
1676
+
],
1677
+
await this._ctx.connection()
1678
+
);
1679
+
1680
+
return response;
1681
+
};
1682
+
1683
+
/**
1684
+
* Retrieves this container's root filesystem. Mounts are not included.
1685
+
*/
1686
+
rootfs = (): Directory => {
1687
+
return new Directory({
1688
+
queryTree: [
1689
+
...this._queryTree,
1690
+
{
1691
+
operation: "rootfs",
1692
+
},
1693
+
],
1694
+
ctx: this._ctx,
1695
+
});
1696
+
};
1697
+
1698
+
/**
1699
+
* The error stream of the last executed command.
1700
+
*
1701
+
* Will execute default command if none is set, or error if there's no default.
1702
+
*/
1703
+
stderr = async (): Promise<string> => {
1704
+
if (this._stderr) {
1705
+
return this._stderr;
1706
+
}
1707
+
1708
+
const response: Awaited<string> = await computeQuery(
1709
+
[
1710
+
...this._queryTree,
1711
+
{
1712
+
operation: "stderr",
1713
+
},
1714
+
],
1715
+
await this._ctx.connection()
1716
+
);
1717
+
1718
+
return response;
1719
+
};
1720
+
1721
+
/**
1722
+
* The output stream of the last executed command.
1723
+
*
1724
+
* Will execute default command if none is set, or error if there's no default.
1725
+
*/
1726
+
stdout = async (): Promise<string> => {
1727
+
if (this._stdout) {
1728
+
return this._stdout;
1729
+
}
1730
+
1731
+
const response: Awaited<string> = await computeQuery(
1732
+
[
1733
+
...this._queryTree,
1734
+
{
1735
+
operation: "stdout",
1736
+
},
1737
+
],
1738
+
await this._ctx.connection()
1739
+
);
1740
+
1741
+
return response;
1742
+
};
1743
+
1744
+
/**
1745
+
* Forces evaluation of the pipeline in the engine.
1746
+
*
1747
+
* It doesn't run the default command if no exec has been set.
1748
+
*/
1749
+
sync = async (): Promise<Container> => {
1750
+
await computeQuery(
1751
+
[
1752
+
...this._queryTree,
1753
+
{
1754
+
operation: "sync",
1755
+
},
1756
+
],
1757
+
await this._ctx.connection()
1758
+
);
1759
+
1760
+
return this;
1761
+
};
1762
+
1763
+
/**
1764
+
* Return an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).
1765
+
* @param opts.cmd If set, override the container's default terminal command and invoke these command arguments instead.
1766
+
*/
1767
+
terminal = (opts?: ContainerTerminalOpts): Terminal => {
1768
+
return new Terminal({
1769
+
queryTree: [
1770
+
...this._queryTree,
1771
+
{
1772
+
operation: "terminal",
1773
+
args: { ...opts },
1774
+
},
1775
+
],
1776
+
ctx: this._ctx,
1777
+
});
1778
+
};
1779
+
1780
+
/**
1781
+
* Retrieves the user to be set for all commands.
1782
+
*/
1783
+
user = async (): Promise<string> => {
1784
+
if (this._user) {
1785
+
return this._user;
1786
+
}
1787
+
1788
+
const response: Awaited<string> = await computeQuery(
1789
+
[
1790
+
...this._queryTree,
1791
+
{
1792
+
operation: "user",
1793
+
},
1794
+
],
1795
+
await this._ctx.connection()
1796
+
);
1797
+
1798
+
return response;
1799
+
};
1800
+
1801
+
/**
1802
+
* Configures default arguments for future commands.
1803
+
* @param args Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
1804
+
*/
1805
+
withDefaultArgs = (args: string[]): Container => {
1806
+
return new Container({
1807
+
queryTree: [
1808
+
...this._queryTree,
1809
+
{
1810
+
operation: "withDefaultArgs",
1811
+
args: { args },
1812
+
},
1813
+
],
1814
+
ctx: this._ctx,
1815
+
});
1816
+
};
1817
+
1818
+
/**
1819
+
* Set the default command to invoke for the container's terminal API.
1820
+
* @param args The args of the command.
1821
+
*/
1822
+
withDefaultTerminalCmd = (args: string[]): Container => {
1823
+
return new Container({
1824
+
queryTree: [
1825
+
...this._queryTree,
1826
+
{
1827
+
operation: "withDefaultTerminalCmd",
1828
+
args: { args },
1829
+
},
1830
+
],
1831
+
ctx: this._ctx,
1832
+
});
1833
+
};
1834
+
1835
+
/**
1836
+
* Retrieves this container plus a directory written at the given path.
1837
+
* @param path Location of the written directory (e.g., "/tmp/directory").
1838
+
* @param directory Identifier of the directory to write
1839
+
* @param opts.exclude Patterns to exclude in the written directory (e.g. ["node_modules/**", ".gitignore", ".git/"]).
1840
+
* @param opts.include Patterns to include in the written directory (e.g. ["*.go", "go.mod", "go.sum"]).
1841
+
* @param opts.owner A user:group to set for the directory and its contents.
1842
+
*
1843
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
1844
+
*
1845
+
* If the group is omitted, it defaults to the same as the user.
1846
+
*/
1847
+
withDirectory = (
1848
+
path: string,
1849
+
directory: Directory,
1850
+
opts?: ContainerWithDirectoryOpts
1851
+
): Container => {
1852
+
return new Container({
1853
+
queryTree: [
1854
+
...this._queryTree,
1855
+
{
1856
+
operation: "withDirectory",
1857
+
args: { path, directory, ...opts },
1858
+
},
1859
+
],
1860
+
ctx: this._ctx,
1861
+
});
1862
+
};
1863
+
1864
+
/**
1865
+
* Retrieves this container but with a different command entrypoint.
1866
+
* @param args Entrypoint to use for future executions (e.g., ["go", "run"]).
1867
+
* @param opts.keepDefaultArgs Don't remove the default arguments when setting the entrypoint.
1868
+
*/
1869
+
withEntrypoint = (
1870
+
args: string[],
1871
+
opts?: ContainerWithEntrypointOpts
1872
+
): Container => {
1873
+
return new Container({
1874
+
queryTree: [
1875
+
...this._queryTree,
1876
+
{
1877
+
operation: "withEntrypoint",
1878
+
args: { args, ...opts },
1879
+
},
1880
+
],
1881
+
ctx: this._ctx,
1882
+
});
1883
+
};
1884
+
1885
+
/**
1886
+
* Retrieves this container plus the given environment variable.
1887
+
* @param name The name of the environment variable (e.g., "HOST").
1888
+
* @param value The value of the environment variable. (e.g., "localhost").
1889
+
* @param opts.expand Replace `${VAR}` or `$VAR` in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
1890
+
*/
1891
+
withEnvVariable = (
1892
+
name: string,
1893
+
value: string,
1894
+
opts?: ContainerWithEnvVariableOpts
1895
+
): Container => {
1896
+
return new Container({
1897
+
queryTree: [
1898
+
...this._queryTree,
1899
+
{
1900
+
operation: "withEnvVariable",
1901
+
args: { name, value, ...opts },
1902
+
},
1903
+
],
1904
+
ctx: this._ctx,
1905
+
});
1906
+
};
1907
+
1908
+
/**
1909
+
* Retrieves this container after executing the specified command inside it.
1910
+
* @param args Command to run instead of the container's default command (e.g., ["run", "main.go"]).
1911
+
*
1912
+
* If empty, the container's default command is used.
1913
+
* @param opts.skipEntrypoint If the container has an entrypoint, ignore it for args rather than using it to wrap them.
1914
+
* @param opts.stdin Content to write to the command's standard input before closing (e.g., "Hello world").
1915
+
* @param opts.redirectStdout Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
1916
+
* @param opts.redirectStderr Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
1917
+
* @param opts.experimentalPrivilegedNesting Provides dagger access to the executed command.
1918
+
*
1919
+
* 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.
1920
+
* @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.
1921
+
*/
1922
+
withExec = (args: string[], opts?: ContainerWithExecOpts): Container => {
1923
+
return new Container({
1924
+
queryTree: [
1925
+
...this._queryTree,
1926
+
{
1927
+
operation: "withExec",
1928
+
args: { args, ...opts },
1929
+
},
1930
+
],
1931
+
ctx: this._ctx,
1932
+
});
1933
+
};
1934
+
1935
+
/**
1936
+
* Expose a network port.
1937
+
*
1938
+
* Exposed ports serve two purposes:
1939
+
*
1940
+
* - For health checks and introspection, when running services
1941
+
*
1942
+
* - For setting the EXPOSE OCI field when publishing the container
1943
+
* @param port Port number to expose
1944
+
* @param opts.protocol Transport layer network protocol
1945
+
* @param opts.description Optional port description
1946
+
* @param opts.experimentalSkipHealthcheck Skip the health check when run as a service.
1947
+
*/
1948
+
withExposedPort = (
1949
+
port: number,
1950
+
opts?: ContainerWithExposedPortOpts
1951
+
): Container => {
1952
+
const metadata: Metadata = {
1953
+
protocol: { is_enum: true },
1954
+
};
1955
+
1956
+
return new Container({
1957
+
queryTree: [
1958
+
...this._queryTree,
1959
+
{
1960
+
operation: "withExposedPort",
1961
+
args: { port, ...opts, __metadata: metadata },
1962
+
},
1963
+
],
1964
+
ctx: this._ctx,
1965
+
});
1966
+
};
1967
+
1968
+
/**
1969
+
* Retrieves this container plus the contents of the given file copied to the given path.
1970
+
* @param path Location of the copied file (e.g., "/tmp/file.txt").
1971
+
* @param source Identifier of the file to copy.
1972
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
1973
+
* @param opts.owner A user:group to set for the file.
1974
+
*
1975
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
1976
+
*
1977
+
* If the group is omitted, it defaults to the same as the user.
1978
+
*/
1979
+
withFile = (
1980
+
path: string,
1981
+
source: File,
1982
+
opts?: ContainerWithFileOpts
1983
+
): Container => {
1984
+
return new Container({
1985
+
queryTree: [
1986
+
...this._queryTree,
1987
+
{
1988
+
operation: "withFile",
1989
+
args: { path, source, ...opts },
1990
+
},
1991
+
],
1992
+
ctx: this._ctx,
1993
+
});
1994
+
};
1995
+
1996
+
/**
1997
+
* Indicate that subsequent operations should be featured more prominently in the UI.
1998
+
*/
1999
+
withFocus = (): Container => {
2000
+
return new Container({
2001
+
queryTree: [
2002
+
...this._queryTree,
2003
+
{
2004
+
operation: "withFocus",
2005
+
},
2006
+
],
2007
+
ctx: this._ctx,
2008
+
});
2009
+
};
2010
+
2011
+
/**
2012
+
* Retrieves this container plus the given label.
2013
+
* @param name The name of the label (e.g., "org.opencontainers.artifact.created").
2014
+
* @param value The value of the label (e.g., "2023-01-01T00:00:00Z").
2015
+
*/
2016
+
withLabel = (name: string, value: string): Container => {
2017
+
return new Container({
2018
+
queryTree: [
2019
+
...this._queryTree,
2020
+
{
2021
+
operation: "withLabel",
2022
+
args: { name, value },
2023
+
},
2024
+
],
2025
+
ctx: this._ctx,
2026
+
});
2027
+
};
2028
+
2029
+
/**
2030
+
* Retrieves this container plus a cache volume mounted at the given path.
2031
+
* @param path Location of the cache directory (e.g., "/cache/node_modules").
2032
+
* @param cache Identifier of the cache volume to mount.
2033
+
* @param opts.source Identifier of the directory to use as the cache volume's root.
2034
+
* @param opts.sharing Sharing mode of the cache volume.
2035
+
* @param opts.owner A user:group to set for the mounted cache directory.
2036
+
*
2037
+
* Note that this changes the ownership of the specified mount along with the initial filesystem provided by source (if any). It does not have any effect if/when the cache has already been created.
2038
+
*
2039
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2040
+
*
2041
+
* If the group is omitted, it defaults to the same as the user.
2042
+
*/
2043
+
withMountedCache = (
2044
+
path: string,
2045
+
cache: CacheVolume,
2046
+
opts?: ContainerWithMountedCacheOpts
2047
+
): Container => {
2048
+
const metadata: Metadata = {
2049
+
sharing: { is_enum: true },
2050
+
};
2051
+
2052
+
return new Container({
2053
+
queryTree: [
2054
+
...this._queryTree,
2055
+
{
2056
+
operation: "withMountedCache",
2057
+
args: { path, cache, ...opts, __metadata: metadata },
2058
+
},
2059
+
],
2060
+
ctx: this._ctx,
2061
+
});
2062
+
};
2063
+
2064
+
/**
2065
+
* Retrieves this container plus a directory mounted at the given path.
2066
+
* @param path Location of the mounted directory (e.g., "/mnt/directory").
2067
+
* @param source Identifier of the mounted directory.
2068
+
* @param opts.owner A user:group to set for the mounted directory and its contents.
2069
+
*
2070
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2071
+
*
2072
+
* If the group is omitted, it defaults to the same as the user.
2073
+
*/
2074
+
withMountedDirectory = (
2075
+
path: string,
2076
+
source: Directory,
2077
+
opts?: ContainerWithMountedDirectoryOpts
2078
+
): Container => {
2079
+
return new Container({
2080
+
queryTree: [
2081
+
...this._queryTree,
2082
+
{
2083
+
operation: "withMountedDirectory",
2084
+
args: { path, source, ...opts },
2085
+
},
2086
+
],
2087
+
ctx: this._ctx,
2088
+
});
2089
+
};
2090
+
2091
+
/**
2092
+
* Retrieves this container plus a file mounted at the given path.
2093
+
* @param path Location of the mounted file (e.g., "/tmp/file.txt").
2094
+
* @param source Identifier of the mounted file.
2095
+
* @param opts.owner A user or user:group to set for the mounted file.
2096
+
*
2097
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2098
+
*
2099
+
* If the group is omitted, it defaults to the same as the user.
2100
+
*/
2101
+
withMountedFile = (
2102
+
path: string,
2103
+
source: File,
2104
+
opts?: ContainerWithMountedFileOpts
2105
+
): Container => {
2106
+
return new Container({
2107
+
queryTree: [
2108
+
...this._queryTree,
2109
+
{
2110
+
operation: "withMountedFile",
2111
+
args: { path, source, ...opts },
2112
+
},
2113
+
],
2114
+
ctx: this._ctx,
2115
+
});
2116
+
};
2117
+
2118
+
/**
2119
+
* Retrieves this container plus a secret mounted into a file at the given path.
2120
+
* @param path Location of the secret file (e.g., "/tmp/secret.txt").
2121
+
* @param source Identifier of the secret to mount.
2122
+
* @param opts.owner A user:group to set for the mounted secret.
2123
+
*
2124
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2125
+
*
2126
+
* If the group is omitted, it defaults to the same as the user.
2127
+
* @param opts.mode Permission given to the mounted secret (e.g., 0600).
2128
+
*
2129
+
* This option requires an owner to be set to be active.
2130
+
*/
2131
+
withMountedSecret = (
2132
+
path: string,
2133
+
source: Secret,
2134
+
opts?: ContainerWithMountedSecretOpts
2135
+
): Container => {
2136
+
return new Container({
2137
+
queryTree: [
2138
+
...this._queryTree,
2139
+
{
2140
+
operation: "withMountedSecret",
2141
+
args: { path, source, ...opts },
2142
+
},
2143
+
],
2144
+
ctx: this._ctx,
2145
+
});
2146
+
};
2147
+
2148
+
/**
2149
+
* Retrieves this container plus a temporary directory mounted at the given path.
2150
+
* @param path Location of the temporary directory (e.g., "/tmp/temp_dir").
2151
+
*/
2152
+
withMountedTemp = (path: string): Container => {
2153
+
return new Container({
2154
+
queryTree: [
2155
+
...this._queryTree,
2156
+
{
2157
+
operation: "withMountedTemp",
2158
+
args: { path },
2159
+
},
2160
+
],
2161
+
ctx: this._ctx,
2162
+
});
2163
+
};
2164
+
2165
+
/**
2166
+
* Retrieves this container plus a new file written at the given path.
2167
+
* @param path Location of the written file (e.g., "/tmp/file.txt").
2168
+
* @param opts.contents Content of the file to write (e.g., "Hello world!").
2169
+
* @param opts.permissions Permission given to the written file (e.g., 0600).
2170
+
* @param opts.owner A user:group to set for the file.
2171
+
*
2172
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2173
+
*
2174
+
* If the group is omitted, it defaults to the same as the user.
2175
+
*/
2176
+
withNewFile = (path: string, opts?: ContainerWithNewFileOpts): Container => {
2177
+
return new Container({
2178
+
queryTree: [
2179
+
...this._queryTree,
2180
+
{
2181
+
operation: "withNewFile",
2182
+
args: { path, ...opts },
2183
+
},
2184
+
],
2185
+
ctx: this._ctx,
2186
+
});
2187
+
};
2188
+
2189
+
/**
2190
+
* Retrieves this container with a registry authentication for a given address.
2191
+
* @param address Registry's address to bind the authentication to.
2192
+
*
2193
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
2194
+
* @param username The username of the registry's account (e.g., "Dagger").
2195
+
* @param secret The API key, password or token to authenticate to this registry.
2196
+
*/
2197
+
withRegistryAuth = (
2198
+
address: string,
2199
+
username: string,
2200
+
secret: Secret
2201
+
): Container => {
2202
+
return new Container({
2203
+
queryTree: [
2204
+
...this._queryTree,
2205
+
{
2206
+
operation: "withRegistryAuth",
2207
+
args: { address, username, secret },
2208
+
},
2209
+
],
2210
+
ctx: this._ctx,
2211
+
});
2212
+
};
2213
+
2214
+
/**
2215
+
* Retrieves the container with the given directory mounted to /.
2216
+
* @param directory Directory to mount.
2217
+
*/
2218
+
withRootfs = (directory: Directory): Container => {
2219
+
return new Container({
2220
+
queryTree: [
2221
+
...this._queryTree,
2222
+
{
2223
+
operation: "withRootfs",
2224
+
args: { directory },
2225
+
},
2226
+
],
2227
+
ctx: this._ctx,
2228
+
});
2229
+
};
2230
+
2231
+
/**
2232
+
* Retrieves this container plus an env variable containing the given secret.
2233
+
* @param name The name of the secret variable (e.g., "API_SECRET").
2234
+
* @param secret The identifier of the secret value.
2235
+
*/
2236
+
withSecretVariable = (name: string, secret: Secret): Container => {
2237
+
return new Container({
2238
+
queryTree: [
2239
+
...this._queryTree,
2240
+
{
2241
+
operation: "withSecretVariable",
2242
+
args: { name, secret },
2243
+
},
2244
+
],
2245
+
ctx: this._ctx,
2246
+
});
2247
+
};
2248
+
2249
+
/**
2250
+
* Establish a runtime dependency on a service.
2251
+
*
2252
+
* The service will be started automatically when needed and detached when it is no longer needed, executing the default command if none is set.
2253
+
*
2254
+
* The service will be reachable from the container via the provided hostname alias.
2255
+
*
2256
+
* The service dependency will also convey to any files or directories produced by the container.
2257
+
* @param alias A name that can be used to reach the service from the container
2258
+
* @param service Identifier of the service container
2259
+
*/
2260
+
withServiceBinding = (alias: string, service: Service): Container => {
2261
+
return new Container({
2262
+
queryTree: [
2263
+
...this._queryTree,
2264
+
{
2265
+
operation: "withServiceBinding",
2266
+
args: { alias, service },
2267
+
},
2268
+
],
2269
+
ctx: this._ctx,
2270
+
});
2271
+
};
2272
+
2273
+
/**
2274
+
* Retrieves this container plus a socket forwarded to the given Unix socket path.
2275
+
* @param path Location of the forwarded Unix socket (e.g., "/tmp/socket").
2276
+
* @param source Identifier of the socket to forward.
2277
+
* @param opts.owner A user:group to set for the mounted socket.
2278
+
*
2279
+
* The user and group can either be an ID (1000:1000) or a name (foo:bar).
2280
+
*
2281
+
* If the group is omitted, it defaults to the same as the user.
2282
+
*/
2283
+
withUnixSocket = (
2284
+
path: string,
2285
+
source: Socket,
2286
+
opts?: ContainerWithUnixSocketOpts
2287
+
): Container => {
2288
+
return new Container({
2289
+
queryTree: [
2290
+
...this._queryTree,
2291
+
{
2292
+
operation: "withUnixSocket",
2293
+
args: { path, source, ...opts },
2294
+
},
2295
+
],
2296
+
ctx: this._ctx,
2297
+
});
2298
+
};
2299
+
2300
+
/**
2301
+
* Retrieves this container with a different command user.
2302
+
* @param name The user to set (e.g., "root").
2303
+
*/
2304
+
withUser = (name: string): Container => {
2305
+
return new Container({
2306
+
queryTree: [
2307
+
...this._queryTree,
2308
+
{
2309
+
operation: "withUser",
2310
+
args: { name },
2311
+
},
2312
+
],
2313
+
ctx: this._ctx,
2314
+
});
2315
+
};
2316
+
2317
+
/**
2318
+
* Retrieves this container with a different working directory.
2319
+
* @param path The path to set as the working directory (e.g., "/app").
2320
+
*/
2321
+
withWorkdir = (path: string): Container => {
2322
+
return new Container({
2323
+
queryTree: [
2324
+
...this._queryTree,
2325
+
{
2326
+
operation: "withWorkdir",
2327
+
args: { path },
2328
+
},
2329
+
],
2330
+
ctx: this._ctx,
2331
+
});
2332
+
};
2333
+
2334
+
/**
2335
+
* Retrieves this container with unset default arguments for future commands.
2336
+
*/
2337
+
withoutDefaultArgs = (): Container => {
2338
+
return new Container({
2339
+
queryTree: [
2340
+
...this._queryTree,
2341
+
{
2342
+
operation: "withoutDefaultArgs",
2343
+
},
2344
+
],
2345
+
ctx: this._ctx,
2346
+
});
2347
+
};
2348
+
2349
+
/**
2350
+
* Retrieves this container with an unset command entrypoint.
2351
+
* @param opts.keepDefaultArgs Don't remove the default arguments when unsetting the entrypoint.
2352
+
*/
2353
+
withoutEntrypoint = (opts?: ContainerWithoutEntrypointOpts): Container => {
2354
+
return new Container({
2355
+
queryTree: [
2356
+
...this._queryTree,
2357
+
{
2358
+
operation: "withoutEntrypoint",
2359
+
args: { ...opts },
2360
+
},
2361
+
],
2362
+
ctx: this._ctx,
2363
+
});
2364
+
};
2365
+
2366
+
/**
2367
+
* Retrieves this container minus the given environment variable.
2368
+
* @param name The name of the environment variable (e.g., "HOST").
2369
+
*/
2370
+
withoutEnvVariable = (name: string): Container => {
2371
+
return new Container({
2372
+
queryTree: [
2373
+
...this._queryTree,
2374
+
{
2375
+
operation: "withoutEnvVariable",
2376
+
args: { name },
2377
+
},
2378
+
],
2379
+
ctx: this._ctx,
2380
+
});
2381
+
};
2382
+
2383
+
/**
2384
+
* Unexpose a previously exposed port.
2385
+
* @param port Port number to unexpose
2386
+
* @param opts.protocol Port protocol to unexpose
2387
+
*/
2388
+
withoutExposedPort = (
2389
+
port: number,
2390
+
opts?: ContainerWithoutExposedPortOpts
2391
+
): Container => {
2392
+
const metadata: Metadata = {
2393
+
protocol: { is_enum: true },
2394
+
};
2395
+
2396
+
return new Container({
2397
+
queryTree: [
2398
+
...this._queryTree,
2399
+
{
2400
+
operation: "withoutExposedPort",
2401
+
args: { port, ...opts, __metadata: metadata },
2402
+
},
2403
+
],
2404
+
ctx: this._ctx,
2405
+
});
2406
+
};
2407
+
2408
+
/**
2409
+
* Indicate that subsequent operations should not be featured more prominently in the UI.
2410
+
*
2411
+
* This is the initial state of all containers.
2412
+
*/
2413
+
withoutFocus = (): Container => {
2414
+
return new Container({
2415
+
queryTree: [
2416
+
...this._queryTree,
2417
+
{
2418
+
operation: "withoutFocus",
2419
+
},
2420
+
],
2421
+
ctx: this._ctx,
2422
+
});
2423
+
};
2424
+
2425
+
/**
2426
+
* Retrieves this container minus the given environment label.
2427
+
* @param name The name of the label to remove (e.g., "org.opencontainers.artifact.created").
2428
+
*/
2429
+
withoutLabel = (name: string): Container => {
2430
+
return new Container({
2431
+
queryTree: [
2432
+
...this._queryTree,
2433
+
{
2434
+
operation: "withoutLabel",
2435
+
args: { name },
2436
+
},
2437
+
],
2438
+
ctx: this._ctx,
2439
+
});
2440
+
};
2441
+
2442
+
/**
2443
+
* Retrieves this container after unmounting everything at the given path.
2444
+
* @param path Location of the cache directory (e.g., "/cache/node_modules").
2445
+
*/
2446
+
withoutMount = (path: string): Container => {
2447
+
return new Container({
2448
+
queryTree: [
2449
+
...this._queryTree,
2450
+
{
2451
+
operation: "withoutMount",
2452
+
args: { path },
2453
+
},
2454
+
],
2455
+
ctx: this._ctx,
2456
+
});
2457
+
};
2458
+
2459
+
/**
2460
+
* Retrieves this container without the registry authentication of a given address.
2461
+
* @param address Registry's address to remove the authentication from.
2462
+
*
2463
+
* Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
2464
+
*/
2465
+
withoutRegistryAuth = (address: string): Container => {
2466
+
return new Container({
2467
+
queryTree: [
2468
+
...this._queryTree,
2469
+
{
2470
+
operation: "withoutRegistryAuth",
2471
+
args: { address },
2472
+
},
2473
+
],
2474
+
ctx: this._ctx,
2475
+
});
2476
+
};
2477
+
2478
+
/**
2479
+
* Retrieves this container with a previously added Unix socket removed.
2480
+
* @param path Location of the socket to remove (e.g., "/tmp/socket").
2481
+
*/
2482
+
withoutUnixSocket = (path: string): Container => {
2483
+
return new Container({
2484
+
queryTree: [
2485
+
...this._queryTree,
2486
+
{
2487
+
operation: "withoutUnixSocket",
2488
+
args: { path },
2489
+
},
2490
+
],
2491
+
ctx: this._ctx,
2492
+
});
2493
+
};
2494
+
2495
+
/**
2496
+
* Retrieves this container with an unset command user.
2497
+
*
2498
+
* Should default to root.
2499
+
*/
2500
+
withoutUser = (): Container => {
2501
+
return new Container({
2502
+
queryTree: [
2503
+
...this._queryTree,
2504
+
{
2505
+
operation: "withoutUser",
2506
+
},
2507
+
],
2508
+
ctx: this._ctx,
2509
+
});
2510
+
};
2511
+
2512
+
/**
2513
+
* Retrieves this container with an unset working directory.
2514
+
*
2515
+
* Should default to "/".
2516
+
*/
2517
+
withoutWorkdir = (): Container => {
2518
+
return new Container({
2519
+
queryTree: [
2520
+
...this._queryTree,
2521
+
{
2522
+
operation: "withoutWorkdir",
2523
+
},
2524
+
],
2525
+
ctx: this._ctx,
2526
+
});
2527
+
};
2528
+
2529
+
/**
2530
+
* Retrieves the working directory for all commands.
2531
+
*/
2532
+
workdir = async (): Promise<string> => {
2533
+
if (this._workdir) {
2534
+
return this._workdir;
2535
+
}
2536
+
2537
+
const response: Awaited<string> = await computeQuery(
2538
+
[
2539
+
...this._queryTree,
2540
+
{
2541
+
operation: "workdir",
2542
+
},
2543
+
],
2544
+
await this._ctx.connection()
2545
+
);
2546
+
2547
+
return response;
2548
+
};
2549
+
2550
+
/**
2551
+
* Call the provided function with current Container.
2552
+
*
2553
+
* This is useful for reusability and readability by not breaking the calling chain.
2554
+
*/
2555
+
with = (arg: (param: Container) => Container) => {
2556
+
return arg(this);
2557
+
};
2558
+
}
2559
+
2560
+
/**
2561
+
* Reflective module API provided to functions at runtime.
2562
+
*/
2563
+
export class CurrentModule extends BaseClient {
2564
+
private readonly _id?: CurrentModuleID = undefined;
2565
+
private readonly _name?: string = undefined;
2566
+
2567
+
/**
2568
+
* Constructor is used for internal usage only, do not create object from it.
2569
+
*/
2570
+
constructor(
2571
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
2572
+
_id?: CurrentModuleID,
2573
+
_name?: string
2574
+
) {
2575
+
super(parent);
2576
+
2577
+
this._id = _id;
2578
+
this._name = _name;
2579
+
}
2580
+
2581
+
/**
2582
+
* A unique identifier for this CurrentModule.
2583
+
*/
2584
+
id = async (): Promise<CurrentModuleID> => {
2585
+
if (this._id) {
2586
+
return this._id;
2587
+
}
2588
+
2589
+
const response: Awaited<CurrentModuleID> = await computeQuery(
2590
+
[
2591
+
...this._queryTree,
2592
+
{
2593
+
operation: "id",
2594
+
},
2595
+
],
2596
+
await this._ctx.connection()
2597
+
);
2598
+
2599
+
return response;
2600
+
};
2601
+
2602
+
/**
2603
+
* The name of the module being executed in
2604
+
*/
2605
+
name = async (): Promise<string> => {
2606
+
if (this._name) {
2607
+
return this._name;
2608
+
}
2609
+
2610
+
const response: Awaited<string> = await computeQuery(
2611
+
[
2612
+
...this._queryTree,
2613
+
{
2614
+
operation: "name",
2615
+
},
2616
+
],
2617
+
await this._ctx.connection()
2618
+
);
2619
+
2620
+
return response;
2621
+
};
2622
+
2623
+
/**
2624
+
* The directory containing the module's source code loaded into the engine (plus any generated code that may have been created).
2625
+
*/
2626
+
source = (): Directory => {
2627
+
return new Directory({
2628
+
queryTree: [
2629
+
...this._queryTree,
2630
+
{
2631
+
operation: "source",
2632
+
},
2633
+
],
2634
+
ctx: this._ctx,
2635
+
});
2636
+
};
2637
+
2638
+
/**
2639
+
* Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution.
2640
+
* @param path Location of the directory to access (e.g., ".").
2641
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
2642
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2643
+
*/
2644
+
workdir = (path: string, opts?: CurrentModuleWorkdirOpts): Directory => {
2645
+
return new Directory({
2646
+
queryTree: [
2647
+
...this._queryTree,
2648
+
{
2649
+
operation: "workdir",
2650
+
args: { path, ...opts },
2651
+
},
2652
+
],
2653
+
ctx: this._ctx,
2654
+
});
2655
+
};
2656
+
2657
+
/**
2658
+
* Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.
2659
+
* @param path Location of the file to retrieve (e.g., "README.md").
2660
+
*/
2661
+
workdirFile = (path: string): File => {
2662
+
return new File({
2663
+
queryTree: [
2664
+
...this._queryTree,
2665
+
{
2666
+
operation: "workdirFile",
2667
+
args: { path },
2668
+
},
2669
+
],
2670
+
ctx: this._ctx,
2671
+
});
2672
+
};
2673
+
}
2674
+
2675
+
/**
2676
+
* A directory.
2677
+
*/
2678
+
export class Directory extends BaseClient {
2679
+
private readonly _id?: DirectoryID = undefined;
2680
+
private readonly _export?: boolean = undefined;
2681
+
private readonly _sync?: DirectoryID = undefined;
2682
+
2683
+
/**
2684
+
* Constructor is used for internal usage only, do not create object from it.
2685
+
*/
2686
+
constructor(
2687
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
2688
+
_id?: DirectoryID,
2689
+
_export?: boolean,
2690
+
_sync?: DirectoryID
2691
+
) {
2692
+
super(parent);
2693
+
2694
+
this._id = _id;
2695
+
this._export = _export;
2696
+
this._sync = _sync;
2697
+
}
2698
+
2699
+
/**
2700
+
* A unique identifier for this Directory.
2701
+
*/
2702
+
id = async (): Promise<DirectoryID> => {
2703
+
if (this._id) {
2704
+
return this._id;
2705
+
}
2706
+
2707
+
const response: Awaited<DirectoryID> = await computeQuery(
2708
+
[
2709
+
...this._queryTree,
2710
+
{
2711
+
operation: "id",
2712
+
},
2713
+
],
2714
+
await this._ctx.connection()
2715
+
);
2716
+
2717
+
return response;
2718
+
};
2719
+
2720
+
/**
2721
+
* Load the directory as a Dagger module
2722
+
* @param opts.sourceSubpath An optional subpath of the directory which contains the module's source code.
2723
+
*
2724
+
* 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.
2725
+
*
2726
+
* If not set, the module source code is loaded from the root of the directory.
2727
+
*/
2728
+
asModule = (opts?: DirectoryAsModuleOpts): Module_ => {
2729
+
return new Module_({
2730
+
queryTree: [
2731
+
...this._queryTree,
2732
+
{
2733
+
operation: "asModule",
2734
+
args: { ...opts },
2735
+
},
2736
+
],
2737
+
ctx: this._ctx,
2738
+
});
2739
+
};
2740
+
2741
+
/**
2742
+
* Gets the difference between this directory and an another directory.
2743
+
* @param other Identifier of the directory to compare.
2744
+
*/
2745
+
diff = (other: Directory): Directory => {
2746
+
return new Directory({
2747
+
queryTree: [
2748
+
...this._queryTree,
2749
+
{
2750
+
operation: "diff",
2751
+
args: { other },
2752
+
},
2753
+
],
2754
+
ctx: this._ctx,
2755
+
});
2756
+
};
2757
+
2758
+
/**
2759
+
* Retrieves a directory at the given path.
2760
+
* @param path Location of the directory to retrieve (e.g., "/src").
2761
+
*/
2762
+
directory = (path: string): Directory => {
2763
+
return new Directory({
2764
+
queryTree: [
2765
+
...this._queryTree,
2766
+
{
2767
+
operation: "directory",
2768
+
args: { path },
2769
+
},
2770
+
],
2771
+
ctx: this._ctx,
2772
+
});
2773
+
};
2774
+
2775
+
/**
2776
+
* Builds a new Docker container from this directory.
2777
+
* @param opts.platform The platform to build.
2778
+
* @param opts.dockerfile Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
2779
+
* @param opts.target Target build stage to build.
2780
+
* @param opts.buildArgs Build arguments to use in the build.
2781
+
* @param opts.secrets Secrets to pass to the build.
2782
+
*
2783
+
* They will be mounted at /run/secrets/[secret-name].
2784
+
*/
2785
+
dockerBuild = (opts?: DirectoryDockerBuildOpts): Container => {
2786
+
return new Container({
2787
+
queryTree: [
2788
+
...this._queryTree,
2789
+
{
2790
+
operation: "dockerBuild",
2791
+
args: { ...opts },
2792
+
},
2793
+
],
2794
+
ctx: this._ctx,
2795
+
});
2796
+
};
2797
+
2798
+
/**
2799
+
* Returns a list of files and directories at the given path.
2800
+
* @param opts.path Location of the directory to look at (e.g., "/src").
2801
+
*/
2802
+
entries = async (opts?: DirectoryEntriesOpts): Promise<string[]> => {
2803
+
const response: Awaited<string[]> = await computeQuery(
2804
+
[
2805
+
...this._queryTree,
2806
+
{
2807
+
operation: "entries",
2808
+
args: { ...opts },
2809
+
},
2810
+
],
2811
+
await this._ctx.connection()
2812
+
);
2813
+
2814
+
return response;
2815
+
};
2816
+
2817
+
/**
2818
+
* Writes the contents of the directory to a path on the host.
2819
+
* @param path Location of the copied directory (e.g., "logs/").
2820
+
*/
2821
+
export = async (path: string): Promise<boolean> => {
2822
+
if (this._export) {
2823
+
return this._export;
2824
+
}
2825
+
2826
+
const response: Awaited<boolean> = await computeQuery(
2827
+
[
2828
+
...this._queryTree,
2829
+
{
2830
+
operation: "export",
2831
+
args: { path },
2832
+
},
2833
+
],
2834
+
await this._ctx.connection()
2835
+
);
2836
+
2837
+
return response;
2838
+
};
2839
+
2840
+
/**
2841
+
* Retrieves a file at the given path.
2842
+
* @param path Location of the file to retrieve (e.g., "README.md").
2843
+
*/
2844
+
file = (path: string): File => {
2845
+
return new File({
2846
+
queryTree: [
2847
+
...this._queryTree,
2848
+
{
2849
+
operation: "file",
2850
+
args: { path },
2851
+
},
2852
+
],
2853
+
ctx: this._ctx,
2854
+
});
2855
+
};
2856
+
2857
+
/**
2858
+
* Returns a list of files and directories that matche the given pattern.
2859
+
* @param pattern Pattern to match (e.g., "*.md").
2860
+
*/
2861
+
glob = async (pattern: string): Promise<string[]> => {
2862
+
const response: Awaited<string[]> = await computeQuery(
2863
+
[
2864
+
...this._queryTree,
2865
+
{
2866
+
operation: "glob",
2867
+
args: { pattern },
2868
+
},
2869
+
],
2870
+
await this._ctx.connection()
2871
+
);
2872
+
2873
+
return response;
2874
+
};
2875
+
2876
+
/**
2877
+
* Creates a named sub-pipeline.
2878
+
* @param name Name of the sub-pipeline.
2879
+
* @param opts.description Description of the sub-pipeline.
2880
+
* @param opts.labels Labels to apply to the sub-pipeline.
2881
+
*/
2882
+
pipeline = (name: string, opts?: DirectoryPipelineOpts): Directory => {
2883
+
return new Directory({
2884
+
queryTree: [
2885
+
...this._queryTree,
2886
+
{
2887
+
operation: "pipeline",
2888
+
args: { name, ...opts },
2889
+
},
2890
+
],
2891
+
ctx: this._ctx,
2892
+
});
2893
+
};
2894
+
2895
+
/**
2896
+
* Force evaluation in the engine.
2897
+
*/
2898
+
sync = async (): Promise<Directory> => {
2899
+
await computeQuery(
2900
+
[
2901
+
...this._queryTree,
2902
+
{
2903
+
operation: "sync",
2904
+
},
2905
+
],
2906
+
await this._ctx.connection()
2907
+
);
2908
+
2909
+
return this;
2910
+
};
2911
+
2912
+
/**
2913
+
* Retrieves this directory plus a directory written at the given path.
2914
+
* @param path Location of the written directory (e.g., "/src/").
2915
+
* @param directory Identifier of the directory to copy.
2916
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
2917
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2918
+
*/
2919
+
withDirectory = (
2920
+
path: string,
2921
+
directory: Directory,
2922
+
opts?: DirectoryWithDirectoryOpts
2923
+
): Directory => {
2924
+
return new Directory({
2925
+
queryTree: [
2926
+
...this._queryTree,
2927
+
{
2928
+
operation: "withDirectory",
2929
+
args: { path, directory, ...opts },
2930
+
},
2931
+
],
2932
+
ctx: this._ctx,
2933
+
});
2934
+
};
2935
+
2936
+
/**
2937
+
* Retrieves this directory plus the contents of the given file copied to the given path.
2938
+
* @param path Location of the copied file (e.g., "/file.txt").
2939
+
* @param source Identifier of the file to copy.
2940
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
2941
+
*/
2942
+
withFile = (
2943
+
path: string,
2944
+
source: File,
2945
+
opts?: DirectoryWithFileOpts
2946
+
): Directory => {
2947
+
return new Directory({
2948
+
queryTree: [
2949
+
...this._queryTree,
2950
+
{
2951
+
operation: "withFile",
2952
+
args: { path, source, ...opts },
2953
+
},
2954
+
],
2955
+
ctx: this._ctx,
2956
+
});
2957
+
};
2958
+
2959
+
/**
2960
+
* Retrieves this directory plus a new directory created at the given path.
2961
+
* @param path Location of the directory created (e.g., "/logs").
2962
+
* @param opts.permissions Permission granted to the created directory (e.g., 0777).
2963
+
*/
2964
+
withNewDirectory = (
2965
+
path: string,
2966
+
opts?: DirectoryWithNewDirectoryOpts
2967
+
): Directory => {
2968
+
return new Directory({
2969
+
queryTree: [
2970
+
...this._queryTree,
2971
+
{
2972
+
operation: "withNewDirectory",
2973
+
args: { path, ...opts },
2974
+
},
2975
+
],
2976
+
ctx: this._ctx,
2977
+
});
2978
+
};
2979
+
2980
+
/**
2981
+
* Retrieves this directory plus a new file written at the given path.
2982
+
* @param path Location of the written file (e.g., "/file.txt").
2983
+
* @param contents Content of the written file (e.g., "Hello world!").
2984
+
* @param opts.permissions Permission given to the copied file (e.g., 0600).
2985
+
*/
2986
+
withNewFile = (
2987
+
path: string,
2988
+
contents: string,
2989
+
opts?: DirectoryWithNewFileOpts
2990
+
): Directory => {
2991
+
return new Directory({
2992
+
queryTree: [
2993
+
...this._queryTree,
2994
+
{
2995
+
operation: "withNewFile",
2996
+
args: { path, contents, ...opts },
2997
+
},
2998
+
],
2999
+
ctx: this._ctx,
3000
+
});
3001
+
};
3002
+
3003
+
/**
3004
+
* Retrieves this directory with all file/dir timestamps set to the given time.
3005
+
* @param timestamp Timestamp to set dir/files in.
3006
+
*
3007
+
* Formatted in seconds following Unix epoch (e.g., 1672531199).
3008
+
*/
3009
+
withTimestamps = (timestamp: number): Directory => {
3010
+
return new Directory({
3011
+
queryTree: [
3012
+
...this._queryTree,
3013
+
{
3014
+
operation: "withTimestamps",
3015
+
args: { timestamp },
3016
+
},
3017
+
],
3018
+
ctx: this._ctx,
3019
+
});
3020
+
};
3021
+
3022
+
/**
3023
+
* Retrieves this directory with the directory at the given path removed.
3024
+
* @param path Location of the directory to remove (e.g., ".github/").
3025
+
*/
3026
+
withoutDirectory = (path: string): Directory => {
3027
+
return new Directory({
3028
+
queryTree: [
3029
+
...this._queryTree,
3030
+
{
3031
+
operation: "withoutDirectory",
3032
+
args: { path },
3033
+
},
3034
+
],
3035
+
ctx: this._ctx,
3036
+
});
3037
+
};
3038
+
3039
+
/**
3040
+
* Retrieves this directory with the file at the given path removed.
3041
+
* @param path Location of the file to remove (e.g., "/file.txt").
3042
+
*/
3043
+
withoutFile = (path: string): Directory => {
3044
+
return new Directory({
3045
+
queryTree: [
3046
+
...this._queryTree,
3047
+
{
3048
+
operation: "withoutFile",
3049
+
args: { path },
3050
+
},
3051
+
],
3052
+
ctx: this._ctx,
3053
+
});
3054
+
};
3055
+
3056
+
/**
3057
+
* Call the provided function with current Directory.
3058
+
*
3059
+
* This is useful for reusability and readability by not breaking the calling chain.
3060
+
*/
3061
+
with = (arg: (param: Directory) => Directory) => {
3062
+
return arg(this);
3063
+
};
3064
+
}
3065
+
3066
+
/**
3067
+
* An environment variable name and value.
3068
+
*/
3069
+
export class EnvVariable extends BaseClient {
3070
+
private readonly _id?: EnvVariableID = undefined;
3071
+
private readonly _name?: string = undefined;
3072
+
private readonly _value?: string = undefined;
3073
+
3074
+
/**
3075
+
* Constructor is used for internal usage only, do not create object from it.
3076
+
*/
3077
+
constructor(
3078
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3079
+
_id?: EnvVariableID,
3080
+
_name?: string,
3081
+
_value?: string
3082
+
) {
3083
+
super(parent);
3084
+
3085
+
this._id = _id;
3086
+
this._name = _name;
3087
+
this._value = _value;
3088
+
}
3089
+
3090
+
/**
3091
+
* A unique identifier for this EnvVariable.
3092
+
*/
3093
+
id = async (): Promise<EnvVariableID> => {
3094
+
if (this._id) {
3095
+
return this._id;
3096
+
}
3097
+
3098
+
const response: Awaited<EnvVariableID> = await computeQuery(
3099
+
[
3100
+
...this._queryTree,
3101
+
{
3102
+
operation: "id",
3103
+
},
3104
+
],
3105
+
await this._ctx.connection()
3106
+
);
3107
+
3108
+
return response;
3109
+
};
3110
+
3111
+
/**
3112
+
* The environment variable name.
3113
+
*/
3114
+
name = async (): Promise<string> => {
3115
+
if (this._name) {
3116
+
return this._name;
3117
+
}
3118
+
3119
+
const response: Awaited<string> = await computeQuery(
3120
+
[
3121
+
...this._queryTree,
3122
+
{
3123
+
operation: "name",
3124
+
},
3125
+
],
3126
+
await this._ctx.connection()
3127
+
);
3128
+
3129
+
return response;
3130
+
};
3131
+
3132
+
/**
3133
+
* The environment variable value.
3134
+
*/
3135
+
value = async (): Promise<string> => {
3136
+
if (this._value) {
3137
+
return this._value;
3138
+
}
3139
+
3140
+
const response: Awaited<string> = await computeQuery(
3141
+
[
3142
+
...this._queryTree,
3143
+
{
3144
+
operation: "value",
3145
+
},
3146
+
],
3147
+
await this._ctx.connection()
3148
+
);
3149
+
3150
+
return response;
3151
+
};
3152
+
}
3153
+
3154
+
/**
3155
+
* A definition of a field on a custom object defined in a Module.
3156
+
*
3157
+
* A field on an object has a static value, as opposed to a function on an object whose value is computed by invoking code (and can accept arguments).
3158
+
*/
3159
+
export class FieldTypeDef extends BaseClient {
3160
+
private readonly _id?: FieldTypeDefID = undefined;
3161
+
private readonly _description?: string = undefined;
3162
+
private readonly _name?: string = undefined;
3163
+
3164
+
/**
3165
+
* Constructor is used for internal usage only, do not create object from it.
3166
+
*/
3167
+
constructor(
3168
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3169
+
_id?: FieldTypeDefID,
3170
+
_description?: string,
3171
+
_name?: string
3172
+
) {
3173
+
super(parent);
3174
+
3175
+
this._id = _id;
3176
+
this._description = _description;
3177
+
this._name = _name;
3178
+
}
3179
+
3180
+
/**
3181
+
* A unique identifier for this FieldTypeDef.
3182
+
*/
3183
+
id = async (): Promise<FieldTypeDefID> => {
3184
+
if (this._id) {
3185
+
return this._id;
3186
+
}
3187
+
3188
+
const response: Awaited<FieldTypeDefID> = await computeQuery(
3189
+
[
3190
+
...this._queryTree,
3191
+
{
3192
+
operation: "id",
3193
+
},
3194
+
],
3195
+
await this._ctx.connection()
3196
+
);
3197
+
3198
+
return response;
3199
+
};
3200
+
3201
+
/**
3202
+
* A doc string for the field, if any.
3203
+
*/
3204
+
description = async (): Promise<string> => {
3205
+
if (this._description) {
3206
+
return this._description;
3207
+
}
3208
+
3209
+
const response: Awaited<string> = await computeQuery(
3210
+
[
3211
+
...this._queryTree,
3212
+
{
3213
+
operation: "description",
3214
+
},
3215
+
],
3216
+
await this._ctx.connection()
3217
+
);
3218
+
3219
+
return response;
3220
+
};
3221
+
3222
+
/**
3223
+
* The name of the field in lowerCamelCase format.
3224
+
*/
3225
+
name = async (): Promise<string> => {
3226
+
if (this._name) {
3227
+
return this._name;
3228
+
}
3229
+
3230
+
const response: Awaited<string> = await computeQuery(
3231
+
[
3232
+
...this._queryTree,
3233
+
{
3234
+
operation: "name",
3235
+
},
3236
+
],
3237
+
await this._ctx.connection()
3238
+
);
3239
+
3240
+
return response;
3241
+
};
3242
+
3243
+
/**
3244
+
* The type of the field.
3245
+
*/
3246
+
typeDef = (): TypeDef => {
3247
+
return new TypeDef({
3248
+
queryTree: [
3249
+
...this._queryTree,
3250
+
{
3251
+
operation: "typeDef",
3252
+
},
3253
+
],
3254
+
ctx: this._ctx,
3255
+
});
3256
+
};
3257
+
}
3258
+
3259
+
/**
3260
+
* A file.
3261
+
*/
3262
+
export class File extends BaseClient {
3263
+
private readonly _id?: FileID = undefined;
3264
+
private readonly _contents?: string = undefined;
3265
+
private readonly _export?: boolean = undefined;
3266
+
private readonly _name?: string = undefined;
3267
+
private readonly _size?: number = undefined;
3268
+
private readonly _sync?: FileID = undefined;
3269
+
3270
+
/**
3271
+
* Constructor is used for internal usage only, do not create object from it.
3272
+
*/
3273
+
constructor(
3274
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3275
+
_id?: FileID,
3276
+
_contents?: string,
3277
+
_export?: boolean,
3278
+
_name?: string,
3279
+
_size?: number,
3280
+
_sync?: FileID
3281
+
) {
3282
+
super(parent);
3283
+
3284
+
this._id = _id;
3285
+
this._contents = _contents;
3286
+
this._export = _export;
3287
+
this._name = _name;
3288
+
this._size = _size;
3289
+
this._sync = _sync;
3290
+
}
3291
+
3292
+
/**
3293
+
* A unique identifier for this File.
3294
+
*/
3295
+
id = async (): Promise<FileID> => {
3296
+
if (this._id) {
3297
+
return this._id;
3298
+
}
3299
+
3300
+
const response: Awaited<FileID> = await computeQuery(
3301
+
[
3302
+
...this._queryTree,
3303
+
{
3304
+
operation: "id",
3305
+
},
3306
+
],
3307
+
await this._ctx.connection()
3308
+
);
3309
+
3310
+
return response;
3311
+
};
3312
+
3313
+
/**
3314
+
* Retrieves the contents of the file.
3315
+
*/
3316
+
contents = async (): Promise<string> => {
3317
+
if (this._contents) {
3318
+
return this._contents;
3319
+
}
3320
+
3321
+
const response: Awaited<string> = await computeQuery(
3322
+
[
3323
+
...this._queryTree,
3324
+
{
3325
+
operation: "contents",
3326
+
},
3327
+
],
3328
+
await this._ctx.connection()
3329
+
);
3330
+
3331
+
return response;
3332
+
};
3333
+
3334
+
/**
3335
+
* Writes the file to a file path on the host.
3336
+
* @param path Location of the written directory (e.g., "output.txt").
3337
+
* @param opts.allowParentDirPath If allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.
3338
+
*/
3339
+
export = async (path: string, opts?: FileExportOpts): Promise<boolean> => {
3340
+
if (this._export) {
3341
+
return this._export;
3342
+
}
3343
+
3344
+
const response: Awaited<boolean> = await computeQuery(
3345
+
[
3346
+
...this._queryTree,
3347
+
{
3348
+
operation: "export",
3349
+
args: { path, ...opts },
3350
+
},
3351
+
],
3352
+
await this._ctx.connection()
3353
+
);
3354
+
3355
+
return response;
3356
+
};
3357
+
3358
+
/**
3359
+
* Retrieves the name of the file.
3360
+
*/
3361
+
name = async (): Promise<string> => {
3362
+
if (this._name) {
3363
+
return this._name;
3364
+
}
3365
+
3366
+
const response: Awaited<string> = await computeQuery(
3367
+
[
3368
+
...this._queryTree,
3369
+
{
3370
+
operation: "name",
3371
+
},
3372
+
],
3373
+
await this._ctx.connection()
3374
+
);
3375
+
3376
+
return response;
3377
+
};
3378
+
3379
+
/**
3380
+
* Retrieves the size of the file, in bytes.
3381
+
*/
3382
+
size = async (): Promise<number> => {
3383
+
if (this._size) {
3384
+
return this._size;
3385
+
}
3386
+
3387
+
const response: Awaited<number> = await computeQuery(
3388
+
[
3389
+
...this._queryTree,
3390
+
{
3391
+
operation: "size",
3392
+
},
3393
+
],
3394
+
await this._ctx.connection()
3395
+
);
3396
+
3397
+
return response;
3398
+
};
3399
+
3400
+
/**
3401
+
* Force evaluation in the engine.
3402
+
*/
3403
+
sync = async (): Promise<File> => {
3404
+
await computeQuery(
3405
+
[
3406
+
...this._queryTree,
3407
+
{
3408
+
operation: "sync",
3409
+
},
3410
+
],
3411
+
await this._ctx.connection()
3412
+
);
3413
+
3414
+
return this;
3415
+
};
3416
+
3417
+
/**
3418
+
* Retrieves this file with its created/modified timestamps set to the given time.
3419
+
* @param timestamp Timestamp to set dir/files in.
3420
+
*
3421
+
* Formatted in seconds following Unix epoch (e.g., 1672531199).
3422
+
*/
3423
+
withTimestamps = (timestamp: number): File => {
3424
+
return new File({
3425
+
queryTree: [
3426
+
...this._queryTree,
3427
+
{
3428
+
operation: "withTimestamps",
3429
+
args: { timestamp },
3430
+
},
3431
+
],
3432
+
ctx: this._ctx,
3433
+
});
3434
+
};
3435
+
3436
+
/**
3437
+
* Call the provided function with current File.
3438
+
*
3439
+
* This is useful for reusability and readability by not breaking the calling chain.
3440
+
*/
3441
+
with = (arg: (param: File) => File) => {
3442
+
return arg(this);
3443
+
};
3444
+
}
3445
+
3446
+
/**
3447
+
* Function represents a resolver provided by a Module.
3448
+
*
3449
+
* A function always evaluates against a parent object and is given a set of named arguments.
3450
+
*/
3451
+
export class Function_ extends BaseClient {
3452
+
private readonly _id?: FunctionID = undefined;
3453
+
private readonly _description?: string = undefined;
3454
+
private readonly _name?: string = undefined;
3455
+
3456
+
/**
3457
+
* Constructor is used for internal usage only, do not create object from it.
3458
+
*/
3459
+
constructor(
3460
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3461
+
_id?: FunctionID,
3462
+
_description?: string,
3463
+
_name?: string
3464
+
) {
3465
+
super(parent);
3466
+
3467
+
this._id = _id;
3468
+
this._description = _description;
3469
+
this._name = _name;
3470
+
}
3471
+
3472
+
/**
3473
+
* A unique identifier for this Function.
3474
+
*/
3475
+
id = async (): Promise<FunctionID> => {
3476
+
if (this._id) {
3477
+
return this._id;
3478
+
}
3479
+
3480
+
const response: Awaited<FunctionID> = await computeQuery(
3481
+
[
3482
+
...this._queryTree,
3483
+
{
3484
+
operation: "id",
3485
+
},
3486
+
],
3487
+
await this._ctx.connection()
3488
+
);
3489
+
3490
+
return response;
3491
+
};
3492
+
3493
+
/**
3494
+
* Arguments accepted by the function, if any.
3495
+
*/
3496
+
args = async (): Promise<FunctionArg[]> => {
3497
+
type args = {
3498
+
id: FunctionArgID;
3499
+
};
3500
+
3501
+
const response: Awaited<args[]> = await computeQuery(
3502
+
[
3503
+
...this._queryTree,
3504
+
{
3505
+
operation: "args",
3506
+
},
3507
+
{
3508
+
operation: "id",
3509
+
},
3510
+
],
3511
+
await this._ctx.connection()
3512
+
);
3513
+
3514
+
return response.map(
3515
+
(r) =>
3516
+
new FunctionArg(
3517
+
{
3518
+
queryTree: [
3519
+
{
3520
+
operation: "loadFunctionArgFromID",
3521
+
args: { id: r.id },
3522
+
},
3523
+
],
3524
+
ctx: this._ctx,
3525
+
},
3526
+
r.id
3527
+
)
3528
+
);
3529
+
};
3530
+
3531
+
/**
3532
+
* A doc string for the function, if any.
3533
+
*/
3534
+
description = async (): Promise<string> => {
3535
+
if (this._description) {
3536
+
return this._description;
3537
+
}
3538
+
3539
+
const response: Awaited<string> = await computeQuery(
3540
+
[
3541
+
...this._queryTree,
3542
+
{
3543
+
operation: "description",
3544
+
},
3545
+
],
3546
+
await this._ctx.connection()
3547
+
);
3548
+
3549
+
return response;
3550
+
};
3551
+
3552
+
/**
3553
+
* The name of the function.
3554
+
*/
3555
+
name = async (): Promise<string> => {
3556
+
if (this._name) {
3557
+
return this._name;
3558
+
}
3559
+
3560
+
const response: Awaited<string> = await computeQuery(
3561
+
[
3562
+
...this._queryTree,
3563
+
{
3564
+
operation: "name",
3565
+
},
3566
+
],
3567
+
await this._ctx.connection()
3568
+
);
3569
+
3570
+
return response;
3571
+
};
3572
+
3573
+
/**
3574
+
* The type returned by the function.
3575
+
*/
3576
+
returnType = (): TypeDef => {
3577
+
return new TypeDef({
3578
+
queryTree: [
3579
+
...this._queryTree,
3580
+
{
3581
+
operation: "returnType",
3582
+
},
3583
+
],
3584
+
ctx: this._ctx,
3585
+
});
3586
+
};
3587
+
3588
+
/**
3589
+
* Returns the function with the provided argument
3590
+
* @param name The name of the argument
3591
+
* @param typeDef The type of the argument
3592
+
* @param opts.description A doc string for the argument, if any
3593
+
* @param opts.defaultValue A default value to use for this argument if not explicitly set by the caller, if any
3594
+
*/
3595
+
withArg = (
3596
+
name: string,
3597
+
typeDef: TypeDef,
3598
+
opts?: FunctionWithArgOpts
3599
+
): Function_ => {
3600
+
return new Function_({
3601
+
queryTree: [
3602
+
...this._queryTree,
3603
+
{
3604
+
operation: "withArg",
3605
+
args: { name, typeDef, ...opts },
3606
+
},
3607
+
],
3608
+
ctx: this._ctx,
3609
+
});
3610
+
};
3611
+
3612
+
/**
3613
+
* Returns the function with the given doc string.
3614
+
* @param description The doc string to set.
3615
+
*/
3616
+
withDescription = (description: string): Function_ => {
3617
+
return new Function_({
3618
+
queryTree: [
3619
+
...this._queryTree,
3620
+
{
3621
+
operation: "withDescription",
3622
+
args: { description },
3623
+
},
3624
+
],
3625
+
ctx: this._ctx,
3626
+
});
3627
+
};
3628
+
3629
+
/**
3630
+
* Call the provided function with current Function.
3631
+
*
3632
+
* This is useful for reusability and readability by not breaking the calling chain.
3633
+
*/
3634
+
with = (arg: (param: Function_) => Function_) => {
3635
+
return arg(this);
3636
+
};
3637
+
}
3638
+
3639
+
/**
3640
+
* An argument accepted by a function.
3641
+
*
3642
+
* This is a specification for an argument at function definition time, not an argument passed at function call time.
3643
+
*/
3644
+
export class FunctionArg extends BaseClient {
3645
+
private readonly _id?: FunctionArgID = undefined;
3646
+
private readonly _defaultValue?: JSON = undefined;
3647
+
private readonly _description?: string = undefined;
3648
+
private readonly _name?: string = undefined;
3649
+
3650
+
/**
3651
+
* Constructor is used for internal usage only, do not create object from it.
3652
+
*/
3653
+
constructor(
3654
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3655
+
_id?: FunctionArgID,
3656
+
_defaultValue?: JSON,
3657
+
_description?: string,
3658
+
_name?: string
3659
+
) {
3660
+
super(parent);
3661
+
3662
+
this._id = _id;
3663
+
this._defaultValue = _defaultValue;
3664
+
this._description = _description;
3665
+
this._name = _name;
3666
+
}
3667
+
3668
+
/**
3669
+
* A unique identifier for this FunctionArg.
3670
+
*/
3671
+
id = async (): Promise<FunctionArgID> => {
3672
+
if (this._id) {
3673
+
return this._id;
3674
+
}
3675
+
3676
+
const response: Awaited<FunctionArgID> = await computeQuery(
3677
+
[
3678
+
...this._queryTree,
3679
+
{
3680
+
operation: "id",
3681
+
},
3682
+
],
3683
+
await this._ctx.connection()
3684
+
);
3685
+
3686
+
return response;
3687
+
};
3688
+
3689
+
/**
3690
+
* A default value to use for this argument when not explicitly set by the caller, if any.
3691
+
*/
3692
+
defaultValue = async (): Promise<JSON> => {
3693
+
if (this._defaultValue) {
3694
+
return this._defaultValue;
3695
+
}
3696
+
3697
+
const response: Awaited<JSON> = await computeQuery(
3698
+
[
3699
+
...this._queryTree,
3700
+
{
3701
+
operation: "defaultValue",
3702
+
},
3703
+
],
3704
+
await this._ctx.connection()
3705
+
);
3706
+
3707
+
return response;
3708
+
};
3709
+
3710
+
/**
3711
+
* A doc string for the argument, if any.
3712
+
*/
3713
+
description = async (): Promise<string> => {
3714
+
if (this._description) {
3715
+
return this._description;
3716
+
}
3717
+
3718
+
const response: Awaited<string> = await computeQuery(
3719
+
[
3720
+
...this._queryTree,
3721
+
{
3722
+
operation: "description",
3723
+
},
3724
+
],
3725
+
await this._ctx.connection()
3726
+
);
3727
+
3728
+
return response;
3729
+
};
3730
+
3731
+
/**
3732
+
* The name of the argument in lowerCamelCase format.
3733
+
*/
3734
+
name = async (): Promise<string> => {
3735
+
if (this._name) {
3736
+
return this._name;
3737
+
}
3738
+
3739
+
const response: Awaited<string> = await computeQuery(
3740
+
[
3741
+
...this._queryTree,
3742
+
{
3743
+
operation: "name",
3744
+
},
3745
+
],
3746
+
await this._ctx.connection()
3747
+
);
3748
+
3749
+
return response;
3750
+
};
3751
+
3752
+
/**
3753
+
* The type of the argument.
3754
+
*/
3755
+
typeDef = (): TypeDef => {
3756
+
return new TypeDef({
3757
+
queryTree: [
3758
+
...this._queryTree,
3759
+
{
3760
+
operation: "typeDef",
3761
+
},
3762
+
],
3763
+
ctx: this._ctx,
3764
+
});
3765
+
};
3766
+
}
3767
+
3768
+
/**
3769
+
* An active function call.
3770
+
*/
3771
+
export class FunctionCall extends BaseClient {
3772
+
private readonly _id?: FunctionCallID = undefined;
3773
+
private readonly _name?: string = undefined;
3774
+
private readonly _parent?: JSON = undefined;
3775
+
private readonly _parentName?: string = undefined;
3776
+
private readonly _returnValue?: Void = undefined;
3777
+
3778
+
/**
3779
+
* Constructor is used for internal usage only, do not create object from it.
3780
+
*/
3781
+
constructor(
3782
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3783
+
_id?: FunctionCallID,
3784
+
_name?: string,
3785
+
_parent?: JSON,
3786
+
_parentName?: string,
3787
+
_returnValue?: Void
3788
+
) {
3789
+
super(parent);
3790
+
3791
+
this._id = _id;
3792
+
this._name = _name;
3793
+
this._parent = _parent;
3794
+
this._parentName = _parentName;
3795
+
this._returnValue = _returnValue;
3796
+
}
3797
+
3798
+
/**
3799
+
* A unique identifier for this FunctionCall.
3800
+
*/
3801
+
id = async (): Promise<FunctionCallID> => {
3802
+
if (this._id) {
3803
+
return this._id;
3804
+
}
3805
+
3806
+
const response: Awaited<FunctionCallID> = await computeQuery(
3807
+
[
3808
+
...this._queryTree,
3809
+
{
3810
+
operation: "id",
3811
+
},
3812
+
],
3813
+
await this._ctx.connection()
3814
+
);
3815
+
3816
+
return response;
3817
+
};
3818
+
3819
+
/**
3820
+
* The argument values the function is being invoked with.
3821
+
*/
3822
+
inputArgs = async (): Promise<FunctionCallArgValue[]> => {
3823
+
type inputArgs = {
3824
+
id: FunctionCallArgValueID;
3825
+
};
3826
+
3827
+
const response: Awaited<inputArgs[]> = await computeQuery(
3828
+
[
3829
+
...this._queryTree,
3830
+
{
3831
+
operation: "inputArgs",
3832
+
},
3833
+
{
3834
+
operation: "id",
3835
+
},
3836
+
],
3837
+
await this._ctx.connection()
3838
+
);
3839
+
3840
+
return response.map(
3841
+
(r) =>
3842
+
new FunctionCallArgValue(
3843
+
{
3844
+
queryTree: [
3845
+
{
3846
+
operation: "loadFunctionCallArgValueFromID",
3847
+
args: { id: r.id },
3848
+
},
3849
+
],
3850
+
ctx: this._ctx,
3851
+
},
3852
+
r.id
3853
+
)
3854
+
);
3855
+
};
3856
+
3857
+
/**
3858
+
* The name of the function being called.
3859
+
*/
3860
+
name = async (): Promise<string> => {
3861
+
if (this._name) {
3862
+
return this._name;
3863
+
}
3864
+
3865
+
const response: Awaited<string> = await computeQuery(
3866
+
[
3867
+
...this._queryTree,
3868
+
{
3869
+
operation: "name",
3870
+
},
3871
+
],
3872
+
await this._ctx.connection()
3873
+
);
3874
+
3875
+
return response;
3876
+
};
3877
+
3878
+
/**
3879
+
* The value of the parent object of the function being called. If the function is top-level to the module, this is always an empty object.
3880
+
*/
3881
+
parent = async (): Promise<JSON> => {
3882
+
if (this._parent) {
3883
+
return this._parent;
3884
+
}
3885
+
3886
+
const response: Awaited<JSON> = await computeQuery(
3887
+
[
3888
+
...this._queryTree,
3889
+
{
3890
+
operation: "parent",
3891
+
},
3892
+
],
3893
+
await this._ctx.connection()
3894
+
);
3895
+
3896
+
return response;
3897
+
};
3898
+
3899
+
/**
3900
+
* The name of the parent object of the function being called. If the function is top-level to the module, this is the name of the module.
3901
+
*/
3902
+
parentName = async (): Promise<string> => {
3903
+
if (this._parentName) {
3904
+
return this._parentName;
3905
+
}
3906
+
3907
+
const response: Awaited<string> = await computeQuery(
3908
+
[
3909
+
...this._queryTree,
3910
+
{
3911
+
operation: "parentName",
3912
+
},
3913
+
],
3914
+
await this._ctx.connection()
3915
+
);
3916
+
3917
+
return response;
3918
+
};
3919
+
3920
+
/**
3921
+
* Set the return value of the function call to the provided value.
3922
+
* @param value JSON serialization of the return value.
3923
+
*/
3924
+
returnValue = async (value: JSON): Promise<Void> => {
3925
+
if (this._returnValue) {
3926
+
return this._returnValue;
3927
+
}
3928
+
3929
+
const response: Awaited<Void> = await computeQuery(
3930
+
[
3931
+
...this._queryTree,
3932
+
{
3933
+
operation: "returnValue",
3934
+
args: { value },
3935
+
},
3936
+
],
3937
+
await this._ctx.connection()
3938
+
);
3939
+
3940
+
return response;
3941
+
};
3942
+
}
3943
+
3944
+
/**
3945
+
* A value passed as a named argument to a function call.
3946
+
*/
3947
+
export class FunctionCallArgValue extends BaseClient {
3948
+
private readonly _id?: FunctionCallArgValueID = undefined;
3949
+
private readonly _name?: string = undefined;
3950
+
private readonly _value?: JSON = undefined;
3951
+
3952
+
/**
3953
+
* Constructor is used for internal usage only, do not create object from it.
3954
+
*/
3955
+
constructor(
3956
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
3957
+
_id?: FunctionCallArgValueID,
3958
+
_name?: string,
3959
+
_value?: JSON
3960
+
) {
3961
+
super(parent);
3962
+
3963
+
this._id = _id;
3964
+
this._name = _name;
3965
+
this._value = _value;
3966
+
}
3967
+
3968
+
/**
3969
+
* A unique identifier for this FunctionCallArgValue.
3970
+
*/
3971
+
id = async (): Promise<FunctionCallArgValueID> => {
3972
+
if (this._id) {
3973
+
return this._id;
3974
+
}
3975
+
3976
+
const response: Awaited<FunctionCallArgValueID> = await computeQuery(
3977
+
[
3978
+
...this._queryTree,
3979
+
{
3980
+
operation: "id",
3981
+
},
3982
+
],
3983
+
await this._ctx.connection()
3984
+
);
3985
+
3986
+
return response;
3987
+
};
3988
+
3989
+
/**
3990
+
* The name of the argument.
3991
+
*/
3992
+
name = async (): Promise<string> => {
3993
+
if (this._name) {
3994
+
return this._name;
3995
+
}
3996
+
3997
+
const response: Awaited<string> = await computeQuery(
3998
+
[
3999
+
...this._queryTree,
4000
+
{
4001
+
operation: "name",
4002
+
},
4003
+
],
4004
+
await this._ctx.connection()
4005
+
);
4006
+
4007
+
return response;
4008
+
};
4009
+
4010
+
/**
4011
+
* The value of the argument represented as a JSON serialized string.
4012
+
*/
4013
+
value = async (): Promise<JSON> => {
4014
+
if (this._value) {
4015
+
return this._value;
4016
+
}
4017
+
4018
+
const response: Awaited<JSON> = await computeQuery(
4019
+
[
4020
+
...this._queryTree,
4021
+
{
4022
+
operation: "value",
4023
+
},
4024
+
],
4025
+
await this._ctx.connection()
4026
+
);
4027
+
4028
+
return response;
4029
+
};
4030
+
}
4031
+
4032
+
/**
4033
+
* The result of running an SDK's codegen.
4034
+
*/
4035
+
export class GeneratedCode extends BaseClient {
4036
+
private readonly _id?: GeneratedCodeID = undefined;
4037
+
4038
+
/**
4039
+
* Constructor is used for internal usage only, do not create object from it.
4040
+
*/
4041
+
constructor(
4042
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4043
+
_id?: GeneratedCodeID
4044
+
) {
4045
+
super(parent);
4046
+
4047
+
this._id = _id;
4048
+
}
4049
+
4050
+
/**
4051
+
* A unique identifier for this GeneratedCode.
4052
+
*/
4053
+
id = async (): Promise<GeneratedCodeID> => {
4054
+
if (this._id) {
4055
+
return this._id;
4056
+
}
4057
+
4058
+
const response: Awaited<GeneratedCodeID> = await computeQuery(
4059
+
[
4060
+
...this._queryTree,
4061
+
{
4062
+
operation: "id",
4063
+
},
4064
+
],
4065
+
await this._ctx.connection()
4066
+
);
4067
+
4068
+
return response;
4069
+
};
4070
+
4071
+
/**
4072
+
* The directory containing the generated code.
4073
+
*/
4074
+
code = (): Directory => {
4075
+
return new Directory({
4076
+
queryTree: [
4077
+
...this._queryTree,
4078
+
{
4079
+
operation: "code",
4080
+
},
4081
+
],
4082
+
ctx: this._ctx,
4083
+
});
4084
+
};
4085
+
4086
+
/**
4087
+
* List of paths to mark generated in version control (i.e. .gitattributes).
4088
+
*/
4089
+
vcsGeneratedPaths = async (): Promise<string[]> => {
4090
+
const response: Awaited<string[]> = await computeQuery(
4091
+
[
4092
+
...this._queryTree,
4093
+
{
4094
+
operation: "vcsGeneratedPaths",
4095
+
},
4096
+
],
4097
+
await this._ctx.connection()
4098
+
);
4099
+
4100
+
return response;
4101
+
};
4102
+
4103
+
/**
4104
+
* List of paths to ignore in version control (i.e. .gitignore).
4105
+
*/
4106
+
vcsIgnoredPaths = async (): Promise<string[]> => {
4107
+
const response: Awaited<string[]> = await computeQuery(
4108
+
[
4109
+
...this._queryTree,
4110
+
{
4111
+
operation: "vcsIgnoredPaths",
4112
+
},
4113
+
],
4114
+
await this._ctx.connection()
4115
+
);
4116
+
4117
+
return response;
4118
+
};
4119
+
4120
+
/**
4121
+
* Set the list of paths to mark generated in version control.
4122
+
*/
4123
+
withVCSGeneratedPaths = (paths: string[]): GeneratedCode => {
4124
+
return new GeneratedCode({
4125
+
queryTree: [
4126
+
...this._queryTree,
4127
+
{
4128
+
operation: "withVCSGeneratedPaths",
4129
+
args: { paths },
4130
+
},
4131
+
],
4132
+
ctx: this._ctx,
4133
+
});
4134
+
};
4135
+
4136
+
/**
4137
+
* Set the list of paths to ignore in version control.
4138
+
*/
4139
+
withVCSIgnoredPaths = (paths: string[]): GeneratedCode => {
4140
+
return new GeneratedCode({
4141
+
queryTree: [
4142
+
...this._queryTree,
4143
+
{
4144
+
operation: "withVCSIgnoredPaths",
4145
+
args: { paths },
4146
+
},
4147
+
],
4148
+
ctx: this._ctx,
4149
+
});
4150
+
};
4151
+
4152
+
/**
4153
+
* Call the provided function with current GeneratedCode.
4154
+
*
4155
+
* This is useful for reusability and readability by not breaking the calling chain.
4156
+
*/
4157
+
with = (arg: (param: GeneratedCode) => GeneratedCode) => {
4158
+
return arg(this);
4159
+
};
4160
+
}
4161
+
4162
+
/**
4163
+
* Module source originating from a git repo.
4164
+
*/
4165
+
export class GitModuleSource extends BaseClient {
4166
+
private readonly _id?: GitModuleSourceID = undefined;
4167
+
private readonly _cloneURL?: string = undefined;
4168
+
private readonly _commit?: string = undefined;
4169
+
private readonly _htmlURL?: string = undefined;
4170
+
private readonly _sourceSubpath?: string = undefined;
4171
+
private readonly _version?: string = undefined;
4172
+
4173
+
/**
4174
+
* Constructor is used for internal usage only, do not create object from it.
4175
+
*/
4176
+
constructor(
4177
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4178
+
_id?: GitModuleSourceID,
4179
+
_cloneURL?: string,
4180
+
_commit?: string,
4181
+
_htmlURL?: string,
4182
+
_sourceSubpath?: string,
4183
+
_version?: string
4184
+
) {
4185
+
super(parent);
4186
+
4187
+
this._id = _id;
4188
+
this._cloneURL = _cloneURL;
4189
+
this._commit = _commit;
4190
+
this._htmlURL = _htmlURL;
4191
+
this._sourceSubpath = _sourceSubpath;
4192
+
this._version = _version;
4193
+
}
4194
+
4195
+
/**
4196
+
* A unique identifier for this GitModuleSource.
4197
+
*/
4198
+
id = async (): Promise<GitModuleSourceID> => {
4199
+
if (this._id) {
4200
+
return this._id;
4201
+
}
4202
+
4203
+
const response: Awaited<GitModuleSourceID> = await computeQuery(
4204
+
[
4205
+
...this._queryTree,
4206
+
{
4207
+
operation: "id",
4208
+
},
4209
+
],
4210
+
await this._ctx.connection()
4211
+
);
4212
+
4213
+
return response;
4214
+
};
4215
+
4216
+
/**
4217
+
* The URL from which the source's git repo can be cloned.
4218
+
*/
4219
+
cloneURL = async (): Promise<string> => {
4220
+
if (this._cloneURL) {
4221
+
return this._cloneURL;
4222
+
}
4223
+
4224
+
const response: Awaited<string> = await computeQuery(
4225
+
[
4226
+
...this._queryTree,
4227
+
{
4228
+
operation: "cloneURL",
4229
+
},
4230
+
],
4231
+
await this._ctx.connection()
4232
+
);
4233
+
4234
+
return response;
4235
+
};
4236
+
4237
+
/**
4238
+
* The resolved commit of the git repo this source points to.
4239
+
*/
4240
+
commit = async (): Promise<string> => {
4241
+
if (this._commit) {
4242
+
return this._commit;
4243
+
}
4244
+
4245
+
const response: Awaited<string> = await computeQuery(
4246
+
[
4247
+
...this._queryTree,
4248
+
{
4249
+
operation: "commit",
4250
+
},
4251
+
],
4252
+
await this._ctx.connection()
4253
+
);
4254
+
4255
+
return response;
4256
+
};
4257
+
4258
+
/**
4259
+
* The URL to the source's git repo in a web browser
4260
+
*/
4261
+
htmlURL = async (): Promise<string> => {
4262
+
if (this._htmlURL) {
4263
+
return this._htmlURL;
4264
+
}
4265
+
4266
+
const response: Awaited<string> = await computeQuery(
4267
+
[
4268
+
...this._queryTree,
4269
+
{
4270
+
operation: "htmlURL",
4271
+
},
4272
+
],
4273
+
await this._ctx.connection()
4274
+
);
4275
+
4276
+
return response;
4277
+
};
4278
+
4279
+
/**
4280
+
* The path to the module source code dir specified by this source relative to the source's root directory.
4281
+
*/
4282
+
sourceSubpath = async (): Promise<string> => {
4283
+
if (this._sourceSubpath) {
4284
+
return this._sourceSubpath;
4285
+
}
4286
+
4287
+
const response: Awaited<string> = await computeQuery(
4288
+
[
4289
+
...this._queryTree,
4290
+
{
4291
+
operation: "sourceSubpath",
4292
+
},
4293
+
],
4294
+
await this._ctx.connection()
4295
+
);
4296
+
4297
+
return response;
4298
+
};
4299
+
4300
+
/**
4301
+
* The specified version of the git repo this source points to.
4302
+
*/
4303
+
version = async (): Promise<string> => {
4304
+
if (this._version) {
4305
+
return this._version;
4306
+
}
4307
+
4308
+
const response: Awaited<string> = await computeQuery(
4309
+
[
4310
+
...this._queryTree,
4311
+
{
4312
+
operation: "version",
4313
+
},
4314
+
],
4315
+
await this._ctx.connection()
4316
+
);
4317
+
4318
+
return response;
4319
+
};
4320
+
}
4321
+
4322
+
/**
4323
+
* A git ref (tag, branch, or commit).
4324
+
*/
4325
+
export class GitRef extends BaseClient {
4326
+
private readonly _id?: GitRefID = undefined;
4327
+
private readonly _commit?: string = undefined;
4328
+
4329
+
/**
4330
+
* Constructor is used for internal usage only, do not create object from it.
4331
+
*/
4332
+
constructor(
4333
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4334
+
_id?: GitRefID,
4335
+
_commit?: string
4336
+
) {
4337
+
super(parent);
4338
+
4339
+
this._id = _id;
4340
+
this._commit = _commit;
4341
+
}
4342
+
4343
+
/**
4344
+
* A unique identifier for this GitRef.
4345
+
*/
4346
+
id = async (): Promise<GitRefID> => {
4347
+
if (this._id) {
4348
+
return this._id;
4349
+
}
4350
+
4351
+
const response: Awaited<GitRefID> = await computeQuery(
4352
+
[
4353
+
...this._queryTree,
4354
+
{
4355
+
operation: "id",
4356
+
},
4357
+
],
4358
+
await this._ctx.connection()
4359
+
);
4360
+
4361
+
return response;
4362
+
};
4363
+
4364
+
/**
4365
+
* The resolved commit id at this ref.
4366
+
*/
4367
+
commit = async (): Promise<string> => {
4368
+
if (this._commit) {
4369
+
return this._commit;
4370
+
}
4371
+
4372
+
const response: Awaited<string> = await computeQuery(
4373
+
[
4374
+
...this._queryTree,
4375
+
{
4376
+
operation: "commit",
4377
+
},
4378
+
],
4379
+
await this._ctx.connection()
4380
+
);
4381
+
4382
+
return response;
4383
+
};
4384
+
4385
+
/**
4386
+
* The filesystem tree at this ref.
4387
+
* @param opts.sshKnownHosts DEPRECATED: This option should be passed to `git` instead.
4388
+
* @param opts.sshAuthSocket DEPRECATED: This option should be passed to `git` instead.
4389
+
*/
4390
+
tree = (opts?: GitRefTreeOpts): Directory => {
4391
+
return new Directory({
4392
+
queryTree: [
4393
+
...this._queryTree,
4394
+
{
4395
+
operation: "tree",
4396
+
args: { ...opts },
4397
+
},
4398
+
],
4399
+
ctx: this._ctx,
4400
+
});
4401
+
};
4402
+
}
4403
+
4404
+
/**
4405
+
* A git repository.
4406
+
*/
4407
+
export class GitRepository extends BaseClient {
4408
+
private readonly _id?: GitRepositoryID = undefined;
4409
+
4410
+
/**
4411
+
* Constructor is used for internal usage only, do not create object from it.
4412
+
*/
4413
+
constructor(
4414
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4415
+
_id?: GitRepositoryID
4416
+
) {
4417
+
super(parent);
4418
+
4419
+
this._id = _id;
4420
+
}
4421
+
4422
+
/**
4423
+
* A unique identifier for this GitRepository.
4424
+
*/
4425
+
id = async (): Promise<GitRepositoryID> => {
4426
+
if (this._id) {
4427
+
return this._id;
4428
+
}
4429
+
4430
+
const response: Awaited<GitRepositoryID> = await computeQuery(
4431
+
[
4432
+
...this._queryTree,
4433
+
{
4434
+
operation: "id",
4435
+
},
4436
+
],
4437
+
await this._ctx.connection()
4438
+
);
4439
+
4440
+
return response;
4441
+
};
4442
+
4443
+
/**
4444
+
* Returns details of a branch.
4445
+
* @param name Branch's name (e.g., "main").
4446
+
*/
4447
+
branch = (name: string): GitRef => {
4448
+
return new GitRef({
4449
+
queryTree: [
4450
+
...this._queryTree,
4451
+
{
4452
+
operation: "branch",
4453
+
args: { name },
4454
+
},
4455
+
],
4456
+
ctx: this._ctx,
4457
+
});
4458
+
};
4459
+
4460
+
/**
4461
+
* Returns details of a commit.
4462
+
* @param id Identifier of the commit (e.g., "b6315d8f2810962c601af73f86831f6866ea798b").
4463
+
*/
4464
+
commit = (id: string): GitRef => {
4465
+
return new GitRef({
4466
+
queryTree: [
4467
+
...this._queryTree,
4468
+
{
4469
+
operation: "commit",
4470
+
args: { id },
4471
+
},
4472
+
],
4473
+
ctx: this._ctx,
4474
+
});
4475
+
};
4476
+
4477
+
/**
4478
+
* Returns details of a ref.
4479
+
* @param name Ref's name (can be a commit identifier, a tag name, a branch name, or a fully-qualified ref).
4480
+
*/
4481
+
ref = (name: string): GitRef => {
4482
+
return new GitRef({
4483
+
queryTree: [
4484
+
...this._queryTree,
4485
+
{
4486
+
operation: "ref",
4487
+
args: { name },
4488
+
},
4489
+
],
4490
+
ctx: this._ctx,
4491
+
});
4492
+
};
4493
+
4494
+
/**
4495
+
* Returns details of a tag.
4496
+
* @param name Tag's name (e.g., "v0.3.9").
4497
+
*/
4498
+
tag = (name: string): GitRef => {
4499
+
return new GitRef({
4500
+
queryTree: [
4501
+
...this._queryTree,
4502
+
{
4503
+
operation: "tag",
4504
+
args: { name },
4505
+
},
4506
+
],
4507
+
ctx: this._ctx,
4508
+
});
4509
+
};
4510
+
}
4511
+
4512
+
/**
4513
+
* Information about the host environment.
4514
+
*/
4515
+
export class Host extends BaseClient {
4516
+
private readonly _id?: HostID = undefined;
4517
+
4518
+
/**
4519
+
* Constructor is used for internal usage only, do not create object from it.
4520
+
*/
4521
+
constructor(
4522
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4523
+
_id?: HostID
4524
+
) {
4525
+
super(parent);
4526
+
4527
+
this._id = _id;
4528
+
}
4529
+
4530
+
/**
4531
+
* A unique identifier for this Host.
4532
+
*/
4533
+
id = async (): Promise<HostID> => {
4534
+
if (this._id) {
4535
+
return this._id;
4536
+
}
4537
+
4538
+
const response: Awaited<HostID> = await computeQuery(
4539
+
[
4540
+
...this._queryTree,
4541
+
{
4542
+
operation: "id",
4543
+
},
4544
+
],
4545
+
await this._ctx.connection()
4546
+
);
4547
+
4548
+
return response;
4549
+
};
4550
+
4551
+
/**
4552
+
* Accesses a directory on the host.
4553
+
* @param path Location of the directory to access (e.g., ".").
4554
+
* @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
4555
+
* @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
4556
+
*/
4557
+
directory = (path: string, opts?: HostDirectoryOpts): Directory => {
4558
+
return new Directory({
4559
+
queryTree: [
4560
+
...this._queryTree,
4561
+
{
4562
+
operation: "directory",
4563
+
args: { path, ...opts },
4564
+
},
4565
+
],
4566
+
ctx: this._ctx,
4567
+
});
4568
+
};
4569
+
4570
+
/**
4571
+
* Accesses a file on the host.
4572
+
* @param path Location of the file to retrieve (e.g., "README.md").
4573
+
*/
4574
+
file = (path: string): File => {
4575
+
return new File({
4576
+
queryTree: [
4577
+
...this._queryTree,
4578
+
{
4579
+
operation: "file",
4580
+
args: { path },
4581
+
},
4582
+
],
4583
+
ctx: this._ctx,
4584
+
});
4585
+
};
4586
+
4587
+
/**
4588
+
* Creates a service that forwards traffic to a specified address via the host.
4589
+
* @param opts.host Upstream host to forward traffic to.
4590
+
* @param opts.ports Ports to expose via the service, forwarding through the host network.
4591
+
*
4592
+
* If a port's frontend is unspecified or 0, it defaults to the same as the backend port.
4593
+
*
4594
+
* An empty set of ports is not valid; an error will be returned.
4595
+
*/
4596
+
service = (opts?: HostServiceOpts): Service => {
4597
+
return new Service({
4598
+
queryTree: [
4599
+
...this._queryTree,
4600
+
{
4601
+
operation: "service",
4602
+
args: { ...opts },
4603
+
},
4604
+
],
4605
+
ctx: this._ctx,
4606
+
});
4607
+
};
4608
+
4609
+
/**
4610
+
* Sets a secret given a user-defined name and the file path on the host, and returns the secret.
4611
+
*
4612
+
* The file is limited to a size of 512000 bytes.
4613
+
* @param name The user defined name for this secret.
4614
+
* @param path Location of the file to set as a secret.
4615
+
*/
4616
+
setSecretFile = (name: string, path: string): Secret => {
4617
+
return new Secret({
4618
+
queryTree: [
4619
+
...this._queryTree,
4620
+
{
4621
+
operation: "setSecretFile",
4622
+
args: { name, path },
4623
+
},
4624
+
],
4625
+
ctx: this._ctx,
4626
+
});
4627
+
};
4628
+
4629
+
/**
4630
+
* Creates a tunnel that forwards traffic from the host to a service.
4631
+
* @param service Service to send traffic from the tunnel.
4632
+
* @param opts.ports Configure explicit port forwarding rules for the tunnel.
4633
+
*
4634
+
* If a port's frontend is unspecified or 0, a random port will be chosen by the host.
4635
+
*
4636
+
* If no ports are given, all of the service's ports are forwarded. If native is true, each port maps to the same port on the host. If native is false, each port maps to a random port chosen by the host.
4637
+
*
4638
+
* If ports are given and native is true, the ports are additive.
4639
+
* @param opts.native Map each service port to the same port on the host, as if the service were running natively.
4640
+
*
4641
+
* Note: enabling may result in port conflicts.
4642
+
*/
4643
+
tunnel = (service: Service, opts?: HostTunnelOpts): Service => {
4644
+
return new Service({
4645
+
queryTree: [
4646
+
...this._queryTree,
4647
+
{
4648
+
operation: "tunnel",
4649
+
args: { service, ...opts },
4650
+
},
4651
+
],
4652
+
ctx: this._ctx,
4653
+
});
4654
+
};
4655
+
4656
+
/**
4657
+
* Accesses a Unix socket on the host.
4658
+
* @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
4659
+
*/
4660
+
unixSocket = (path: string): Socket => {
4661
+
return new Socket({
4662
+
queryTree: [
4663
+
...this._queryTree,
4664
+
{
4665
+
operation: "unixSocket",
4666
+
args: { path },
4667
+
},
4668
+
],
4669
+
ctx: this._ctx,
4670
+
});
4671
+
};
4672
+
}
4673
+
4674
+
/**
4675
+
* A graphql input type, which is essentially just a group of named args.
4676
+
* This is currently only used to represent pre-existing usage of graphql input types
4677
+
* in the core API. It is not used by user modules and shouldn't ever be as user
4678
+
* module accept input objects via their id rather than graphql input types.
4679
+
*/
4680
+
export class InputTypeDef extends BaseClient {
4681
+
private readonly _id?: InputTypeDefID = undefined;
4682
+
private readonly _name?: string = undefined;
4683
+
4684
+
/**
4685
+
* Constructor is used for internal usage only, do not create object from it.
4686
+
*/
4687
+
constructor(
4688
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4689
+
_id?: InputTypeDefID,
4690
+
_name?: string
4691
+
) {
4692
+
super(parent);
4693
+
4694
+
this._id = _id;
4695
+
this._name = _name;
4696
+
}
4697
+
4698
+
/**
4699
+
* A unique identifier for this InputTypeDef.
4700
+
*/
4701
+
id = async (): Promise<InputTypeDefID> => {
4702
+
if (this._id) {
4703
+
return this._id;
4704
+
}
4705
+
4706
+
const response: Awaited<InputTypeDefID> = await computeQuery(
4707
+
[
4708
+
...this._queryTree,
4709
+
{
4710
+
operation: "id",
4711
+
},
4712
+
],
4713
+
await this._ctx.connection()
4714
+
);
4715
+
4716
+
return response;
4717
+
};
4718
+
4719
+
/**
4720
+
* Static fields defined on this input object, if any.
4721
+
*/
4722
+
fields = async (): Promise<FieldTypeDef[]> => {
4723
+
type fields = {
4724
+
id: FieldTypeDefID;
4725
+
};
4726
+
4727
+
const response: Awaited<fields[]> = await computeQuery(
4728
+
[
4729
+
...this._queryTree,
4730
+
{
4731
+
operation: "fields",
4732
+
},
4733
+
{
4734
+
operation: "id",
4735
+
},
4736
+
],
4737
+
await this._ctx.connection()
4738
+
);
4739
+
4740
+
return response.map(
4741
+
(r) =>
4742
+
new FieldTypeDef(
4743
+
{
4744
+
queryTree: [
4745
+
{
4746
+
operation: "loadFieldTypeDefFromID",
4747
+
args: { id: r.id },
4748
+
},
4749
+
],
4750
+
ctx: this._ctx,
4751
+
},
4752
+
r.id
4753
+
)
4754
+
);
4755
+
};
4756
+
4757
+
/**
4758
+
* The name of the input object.
4759
+
*/
4760
+
name = async (): Promise<string> => {
4761
+
if (this._name) {
4762
+
return this._name;
4763
+
}
4764
+
4765
+
const response: Awaited<string> = await computeQuery(
4766
+
[
4767
+
...this._queryTree,
4768
+
{
4769
+
operation: "name",
4770
+
},
4771
+
],
4772
+
await this._ctx.connection()
4773
+
);
4774
+
4775
+
return response;
4776
+
};
4777
+
}
4778
+
4779
+
/**
4780
+
* A definition of a custom interface defined in a Module.
4781
+
*/
4782
+
export class InterfaceTypeDef extends BaseClient {
4783
+
private readonly _id?: InterfaceTypeDefID = undefined;
4784
+
private readonly _description?: string = undefined;
4785
+
private readonly _name?: string = undefined;
4786
+
private readonly _sourceModuleName?: string = undefined;
4787
+
4788
+
/**
4789
+
* Constructor is used for internal usage only, do not create object from it.
4790
+
*/
4791
+
constructor(
4792
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4793
+
_id?: InterfaceTypeDefID,
4794
+
_description?: string,
4795
+
_name?: string,
4796
+
_sourceModuleName?: string
4797
+
) {
4798
+
super(parent);
4799
+
4800
+
this._id = _id;
4801
+
this._description = _description;
4802
+
this._name = _name;
4803
+
this._sourceModuleName = _sourceModuleName;
4804
+
}
4805
+
4806
+
/**
4807
+
* A unique identifier for this InterfaceTypeDef.
4808
+
*/
4809
+
id = async (): Promise<InterfaceTypeDefID> => {
4810
+
if (this._id) {
4811
+
return this._id;
4812
+
}
4813
+
4814
+
const response: Awaited<InterfaceTypeDefID> = await computeQuery(
4815
+
[
4816
+
...this._queryTree,
4817
+
{
4818
+
operation: "id",
4819
+
},
4820
+
],
4821
+
await this._ctx.connection()
4822
+
);
4823
+
4824
+
return response;
4825
+
};
4826
+
4827
+
/**
4828
+
* The doc string for the interface, if any.
4829
+
*/
4830
+
description = async (): Promise<string> => {
4831
+
if (this._description) {
4832
+
return this._description;
4833
+
}
4834
+
4835
+
const response: Awaited<string> = await computeQuery(
4836
+
[
4837
+
...this._queryTree,
4838
+
{
4839
+
operation: "description",
4840
+
},
4841
+
],
4842
+
await this._ctx.connection()
4843
+
);
4844
+
4845
+
return response;
4846
+
};
4847
+
4848
+
/**
4849
+
* Functions defined on this interface, if any.
4850
+
*/
4851
+
functions = async (): Promise<Function_[]> => {
4852
+
type functions = {
4853
+
id: FunctionID;
4854
+
};
4855
+
4856
+
const response: Awaited<functions[]> = await computeQuery(
4857
+
[
4858
+
...this._queryTree,
4859
+
{
4860
+
operation: "functions",
4861
+
},
4862
+
{
4863
+
operation: "id",
4864
+
},
4865
+
],
4866
+
await this._ctx.connection()
4867
+
);
4868
+
4869
+
return response.map(
4870
+
(r) =>
4871
+
new Function_(
4872
+
{
4873
+
queryTree: [
4874
+
{
4875
+
operation: "loadFunction_FromID",
4876
+
args: { id: r.id },
4877
+
},
4878
+
],
4879
+
ctx: this._ctx,
4880
+
},
4881
+
r.id
4882
+
)
4883
+
);
4884
+
};
4885
+
4886
+
/**
4887
+
* The name of the interface.
4888
+
*/
4889
+
name = async (): Promise<string> => {
4890
+
if (this._name) {
4891
+
return this._name;
4892
+
}
4893
+
4894
+
const response: Awaited<string> = await computeQuery(
4895
+
[
4896
+
...this._queryTree,
4897
+
{
4898
+
operation: "name",
4899
+
},
4900
+
],
4901
+
await this._ctx.connection()
4902
+
);
4903
+
4904
+
return response;
4905
+
};
4906
+
4907
+
/**
4908
+
* If this InterfaceTypeDef is associated with a Module, the name of the module. Unset otherwise.
4909
+
*/
4910
+
sourceModuleName = async (): Promise<string> => {
4911
+
if (this._sourceModuleName) {
4912
+
return this._sourceModuleName;
4913
+
}
4914
+
4915
+
const response: Awaited<string> = await computeQuery(
4916
+
[
4917
+
...this._queryTree,
4918
+
{
4919
+
operation: "sourceModuleName",
4920
+
},
4921
+
],
4922
+
await this._ctx.connection()
4923
+
);
4924
+
4925
+
return response;
4926
+
};
4927
+
}
4928
+
4929
+
/**
4930
+
* A simple key value object that represents a label.
4931
+
*/
4932
+
export class Label extends BaseClient {
4933
+
private readonly _id?: LabelID = undefined;
4934
+
private readonly _name?: string = undefined;
4935
+
private readonly _value?: string = undefined;
4936
+
4937
+
/**
4938
+
* Constructor is used for internal usage only, do not create object from it.
4939
+
*/
4940
+
constructor(
4941
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
4942
+
_id?: LabelID,
4943
+
_name?: string,
4944
+
_value?: string
4945
+
) {
4946
+
super(parent);
4947
+
4948
+
this._id = _id;
4949
+
this._name = _name;
4950
+
this._value = _value;
4951
+
}
4952
+
4953
+
/**
4954
+
* A unique identifier for this Label.
4955
+
*/
4956
+
id = async (): Promise<LabelID> => {
4957
+
if (this._id) {
4958
+
return this._id;
4959
+
}
4960
+
4961
+
const response: Awaited<LabelID> = await computeQuery(
4962
+
[
4963
+
...this._queryTree,
4964
+
{
4965
+
operation: "id",
4966
+
},
4967
+
],
4968
+
await this._ctx.connection()
4969
+
);
4970
+
4971
+
return response;
4972
+
};
4973
+
4974
+
/**
4975
+
* The label name.
4976
+
*/
4977
+
name = async (): Promise<string> => {
4978
+
if (this._name) {
4979
+
return this._name;
4980
+
}
4981
+
4982
+
const response: Awaited<string> = await computeQuery(
4983
+
[
4984
+
...this._queryTree,
4985
+
{
4986
+
operation: "name",
4987
+
},
4988
+
],
4989
+
await this._ctx.connection()
4990
+
);
4991
+
4992
+
return response;
4993
+
};
4994
+
4995
+
/**
4996
+
* The label value.
4997
+
*/
4998
+
value = async (): Promise<string> => {
4999
+
if (this._value) {
5000
+
return this._value;
5001
+
}
5002
+
5003
+
const response: Awaited<string> = await computeQuery(
5004
+
[
5005
+
...this._queryTree,
5006
+
{
5007
+
operation: "value",
5008
+
},
5009
+
],
5010
+
await this._ctx.connection()
5011
+
);
5012
+
5013
+
return response;
5014
+
};
5015
+
}
5016
+
5017
+
/**
5018
+
* A definition of a list type in a Module.
5019
+
*/
5020
+
export class ListTypeDef extends BaseClient {
5021
+
private readonly _id?: ListTypeDefID = undefined;
5022
+
5023
+
/**
5024
+
* Constructor is used for internal usage only, do not create object from it.
5025
+
*/
5026
+
constructor(
5027
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5028
+
_id?: ListTypeDefID
5029
+
) {
5030
+
super(parent);
5031
+
5032
+
this._id = _id;
5033
+
}
5034
+
5035
+
/**
5036
+
* A unique identifier for this ListTypeDef.
5037
+
*/
5038
+
id = async (): Promise<ListTypeDefID> => {
5039
+
if (this._id) {
5040
+
return this._id;
5041
+
}
5042
+
5043
+
const response: Awaited<ListTypeDefID> = await computeQuery(
5044
+
[
5045
+
...this._queryTree,
5046
+
{
5047
+
operation: "id",
5048
+
},
5049
+
],
5050
+
await this._ctx.connection()
5051
+
);
5052
+
5053
+
return response;
5054
+
};
5055
+
5056
+
/**
5057
+
* The type of the elements in the list.
5058
+
*/
5059
+
elementTypeDef = (): TypeDef => {
5060
+
return new TypeDef({
5061
+
queryTree: [
5062
+
...this._queryTree,
5063
+
{
5064
+
operation: "elementTypeDef",
5065
+
},
5066
+
],
5067
+
ctx: this._ctx,
5068
+
});
5069
+
};
5070
+
}
5071
+
5072
+
/**
5073
+
* Module source that that originates from a path locally relative to an arbitrary directory.
5074
+
*/
5075
+
export class LocalModuleSource extends BaseClient {
5076
+
private readonly _id?: LocalModuleSourceID = undefined;
5077
+
private readonly _sourceSubpath?: string = undefined;
5078
+
5079
+
/**
5080
+
* Constructor is used for internal usage only, do not create object from it.
5081
+
*/
5082
+
constructor(
5083
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5084
+
_id?: LocalModuleSourceID,
5085
+
_sourceSubpath?: string
5086
+
) {
5087
+
super(parent);
5088
+
5089
+
this._id = _id;
5090
+
this._sourceSubpath = _sourceSubpath;
5091
+
}
5092
+
5093
+
/**
5094
+
* A unique identifier for this LocalModuleSource.
5095
+
*/
5096
+
id = async (): Promise<LocalModuleSourceID> => {
5097
+
if (this._id) {
5098
+
return this._id;
5099
+
}
5100
+
5101
+
const response: Awaited<LocalModuleSourceID> = await computeQuery(
5102
+
[
5103
+
...this._queryTree,
5104
+
{
5105
+
operation: "id",
5106
+
},
5107
+
],
5108
+
await this._ctx.connection()
5109
+
);
5110
+
5111
+
return response;
5112
+
};
5113
+
5114
+
/**
5115
+
* The path to the module source code dir specified by this source.
5116
+
*/
5117
+
sourceSubpath = async (): Promise<string> => {
5118
+
if (this._sourceSubpath) {
5119
+
return this._sourceSubpath;
5120
+
}
5121
+
5122
+
const response: Awaited<string> = await computeQuery(
5123
+
[
5124
+
...this._queryTree,
5125
+
{
5126
+
operation: "sourceSubpath",
5127
+
},
5128
+
],
5129
+
await this._ctx.connection()
5130
+
);
5131
+
5132
+
return response;
5133
+
};
5134
+
}
5135
+
5136
+
/**
5137
+
* A Dagger module.
5138
+
*/
5139
+
export class Module_ extends BaseClient {
5140
+
private readonly _id?: ModuleID = undefined;
5141
+
private readonly _description?: string = undefined;
5142
+
private readonly _name?: string = undefined;
5143
+
private readonly _sdk?: string = undefined;
5144
+
private readonly _serve?: Void = undefined;
5145
+
5146
+
/**
5147
+
* Constructor is used for internal usage only, do not create object from it.
5148
+
*/
5149
+
constructor(
5150
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5151
+
_id?: ModuleID,
5152
+
_description?: string,
5153
+
_name?: string,
5154
+
_sdk?: string,
5155
+
_serve?: Void
5156
+
) {
5157
+
super(parent);
5158
+
5159
+
this._id = _id;
5160
+
this._description = _description;
5161
+
this._name = _name;
5162
+
this._sdk = _sdk;
5163
+
this._serve = _serve;
5164
+
}
5165
+
5166
+
/**
5167
+
* A unique identifier for this Module.
5168
+
*/
5169
+
id = async (): Promise<ModuleID> => {
5170
+
if (this._id) {
5171
+
return this._id;
5172
+
}
5173
+
5174
+
const response: Awaited<ModuleID> = await computeQuery(
5175
+
[
5176
+
...this._queryTree,
5177
+
{
5178
+
operation: "id",
5179
+
},
5180
+
],
5181
+
await this._ctx.connection()
5182
+
);
5183
+
5184
+
return response;
5185
+
};
5186
+
5187
+
/**
5188
+
* Modules used by this module.
5189
+
*/
5190
+
dependencies = async (): Promise<Module_[]> => {
5191
+
type dependencies = {
5192
+
id: ModuleID;
5193
+
};
5194
+
5195
+
const response: Awaited<dependencies[]> = await computeQuery(
5196
+
[
5197
+
...this._queryTree,
5198
+
{
5199
+
operation: "dependencies",
5200
+
},
5201
+
{
5202
+
operation: "id",
5203
+
},
5204
+
],
5205
+
await this._ctx.connection()
5206
+
);
5207
+
5208
+
return response.map(
5209
+
(r) =>
5210
+
new Module_(
5211
+
{
5212
+
queryTree: [
5213
+
{
5214
+
operation: "loadModule_FromID",
5215
+
args: { id: r.id },
5216
+
},
5217
+
],
5218
+
ctx: this._ctx,
5219
+
},
5220
+
r.id
5221
+
)
5222
+
);
5223
+
};
5224
+
5225
+
/**
5226
+
* The dependencies as configured by the module.
5227
+
*/
5228
+
dependencyConfig = async (): Promise<ModuleDependency[]> => {
5229
+
type dependencyConfig = {
5230
+
id: ModuleDependencyID;
5231
+
};
5232
+
5233
+
const response: Awaited<dependencyConfig[]> = await computeQuery(
5234
+
[
5235
+
...this._queryTree,
5236
+
{
5237
+
operation: "dependencyConfig",
5238
+
},
5239
+
{
5240
+
operation: "id",
5241
+
},
5242
+
],
5243
+
await this._ctx.connection()
5244
+
);
5245
+
5246
+
return response.map(
5247
+
(r) =>
5248
+
new ModuleDependency(
5249
+
{
5250
+
queryTree: [
5251
+
{
5252
+
operation: "loadModuleDependencyFromID",
5253
+
args: { id: r.id },
5254
+
},
5255
+
],
5256
+
ctx: this._ctx,
5257
+
},
5258
+
r.id
5259
+
)
5260
+
);
5261
+
};
5262
+
5263
+
/**
5264
+
* The doc string of the module, if any
5265
+
*/
5266
+
description = async (): Promise<string> => {
5267
+
if (this._description) {
5268
+
return this._description;
5269
+
}
5270
+
5271
+
const response: Awaited<string> = await computeQuery(
5272
+
[
5273
+
...this._queryTree,
5274
+
{
5275
+
operation: "description",
5276
+
},
5277
+
],
5278
+
await this._ctx.connection()
5279
+
);
5280
+
5281
+
return response;
5282
+
};
5283
+
5284
+
/**
5285
+
* The module's root directory containing the config file for it and its source (possibly as a subdir). It includes any generated code or updated config files created after initial load, but not any files/directories that were unchanged after sdk codegen was run.
5286
+
*/
5287
+
generatedSourceRootDirectory = (): Directory => {
5288
+
return new Directory({
5289
+
queryTree: [
5290
+
...this._queryTree,
5291
+
{
5292
+
operation: "generatedSourceRootDirectory",
5293
+
},
5294
+
],
5295
+
ctx: this._ctx,
5296
+
});
5297
+
};
5298
+
5299
+
/**
5300
+
* Retrieves the module with the objects loaded via its SDK.
5301
+
*/
5302
+
initialize = (): Module_ => {
5303
+
return new Module_({
5304
+
queryTree: [
5305
+
...this._queryTree,
5306
+
{
5307
+
operation: "initialize",
5308
+
},
5309
+
],
5310
+
ctx: this._ctx,
5311
+
});
5312
+
};
5313
+
5314
+
/**
5315
+
* Interfaces served by this module.
5316
+
*/
5317
+
interfaces = async (): Promise<TypeDef[]> => {
5318
+
type interfaces = {
5319
+
id: TypeDefID;
5320
+
};
5321
+
5322
+
const response: Awaited<interfaces[]> = await computeQuery(
5323
+
[
5324
+
...this._queryTree,
5325
+
{
5326
+
operation: "interfaces",
5327
+
},
5328
+
{
5329
+
operation: "id",
5330
+
},
5331
+
],
5332
+
await this._ctx.connection()
5333
+
);
5334
+
5335
+
return response.map(
5336
+
(r) =>
5337
+
new TypeDef(
5338
+
{
5339
+
queryTree: [
5340
+
{
5341
+
operation: "loadTypeDefFromID",
5342
+
args: { id: r.id },
5343
+
},
5344
+
],
5345
+
ctx: this._ctx,
5346
+
},
5347
+
r.id
5348
+
)
5349
+
);
5350
+
};
5351
+
5352
+
/**
5353
+
* The name of the module
5354
+
*/
5355
+
name = async (): Promise<string> => {
5356
+
if (this._name) {
5357
+
return this._name;
5358
+
}
5359
+
5360
+
const response: Awaited<string> = await computeQuery(
5361
+
[
5362
+
...this._queryTree,
5363
+
{
5364
+
operation: "name",
5365
+
},
5366
+
],
5367
+
await this._ctx.connection()
5368
+
);
5369
+
5370
+
return response;
5371
+
};
5372
+
5373
+
/**
5374
+
* Objects served by this module.
5375
+
*/
5376
+
objects = async (): Promise<TypeDef[]> => {
5377
+
type objects = {
5378
+
id: TypeDefID;
5379
+
};
5380
+
5381
+
const response: Awaited<objects[]> = await computeQuery(
5382
+
[
5383
+
...this._queryTree,
5384
+
{
5385
+
operation: "objects",
5386
+
},
5387
+
{
5388
+
operation: "id",
5389
+
},
5390
+
],
5391
+
await this._ctx.connection()
5392
+
);
5393
+
5394
+
return response.map(
5395
+
(r) =>
5396
+
new TypeDef(
5397
+
{
5398
+
queryTree: [
5399
+
{
5400
+
operation: "loadTypeDefFromID",
5401
+
args: { id: r.id },
5402
+
},
5403
+
],
5404
+
ctx: this._ctx,
5405
+
},
5406
+
r.id
5407
+
)
5408
+
);
5409
+
};
5410
+
5411
+
/**
5412
+
* The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile.
5413
+
*/
5414
+
runtime = (): Container => {
5415
+
return new Container({
5416
+
queryTree: [
5417
+
...this._queryTree,
5418
+
{
5419
+
operation: "runtime",
5420
+
},
5421
+
],
5422
+
ctx: this._ctx,
5423
+
});
5424
+
};
5425
+
5426
+
/**
5427
+
* The SDK used by this module. Either a name of a builtin SDK or a module source ref string pointing to the SDK's implementation.
5428
+
*/
5429
+
sdk = async (): Promise<string> => {
5430
+
if (this._sdk) {
5431
+
return this._sdk;
5432
+
}
5433
+
5434
+
const response: Awaited<string> = await computeQuery(
5435
+
[
5436
+
...this._queryTree,
5437
+
{
5438
+
operation: "sdk",
5439
+
},
5440
+
],
5441
+
await this._ctx.connection()
5442
+
);
5443
+
5444
+
return response;
5445
+
};
5446
+
5447
+
/**
5448
+
* Serve a module's API in the current session.
5449
+
*
5450
+
* Note: this can only be called once per session. In the future, it could return a stream or service to remove the side effect.
5451
+
*/
5452
+
serve = async (): Promise<Void> => {
5453
+
if (this._serve) {
5454
+
return this._serve;
5455
+
}
5456
+
5457
+
const response: Awaited<Void> = await computeQuery(
5458
+
[
5459
+
...this._queryTree,
5460
+
{
5461
+
operation: "serve",
5462
+
},
5463
+
],
5464
+
await this._ctx.connection()
5465
+
);
5466
+
5467
+
return response;
5468
+
};
5469
+
5470
+
/**
5471
+
* The source for the module.
5472
+
*/
5473
+
source = (): ModuleSource => {
5474
+
return new ModuleSource({
5475
+
queryTree: [
5476
+
...this._queryTree,
5477
+
{
5478
+
operation: "source",
5479
+
},
5480
+
],
5481
+
ctx: this._ctx,
5482
+
});
5483
+
};
5484
+
5485
+
/**
5486
+
* Update the module configuration to use the given dependencies.
5487
+
* @param dependencies The dependency modules to install.
5488
+
*/
5489
+
withDependencies = (dependencies: ModuleDependency[]): Module_ => {
5490
+
return new Module_({
5491
+
queryTree: [
5492
+
...this._queryTree,
5493
+
{
5494
+
operation: "withDependencies",
5495
+
args: { dependencies },
5496
+
},
5497
+
],
5498
+
ctx: this._ctx,
5499
+
});
5500
+
};
5501
+
5502
+
/**
5503
+
* Retrieves the module with the given description
5504
+
* @param description The description to set
5505
+
*/
5506
+
withDescription = (description: string): Module_ => {
5507
+
return new Module_({
5508
+
queryTree: [
5509
+
...this._queryTree,
5510
+
{
5511
+
operation: "withDescription",
5512
+
args: { description },
5513
+
},
5514
+
],
5515
+
ctx: this._ctx,
5516
+
});
5517
+
};
5518
+
5519
+
/**
5520
+
* This module plus the given Interface type and associated functions
5521
+
*/
5522
+
withInterface = (iface: TypeDef): Module_ => {
5523
+
return new Module_({
5524
+
queryTree: [
5525
+
...this._queryTree,
5526
+
{
5527
+
operation: "withInterface",
5528
+
args: { iface },
5529
+
},
5530
+
],
5531
+
ctx: this._ctx,
5532
+
});
5533
+
};
5534
+
5535
+
/**
5536
+
* Update the module configuration to use the given name.
5537
+
* @param name The name to use.
5538
+
*/
5539
+
withName = (name: string): Module_ => {
5540
+
return new Module_({
5541
+
queryTree: [
5542
+
...this._queryTree,
5543
+
{
5544
+
operation: "withName",
5545
+
args: { name },
5546
+
},
5547
+
],
5548
+
ctx: this._ctx,
5549
+
});
5550
+
};
5551
+
5552
+
/**
5553
+
* This module plus the given Object type and associated functions.
5554
+
*/
5555
+
withObject = (object: TypeDef): Module_ => {
5556
+
return new Module_({
5557
+
queryTree: [
5558
+
...this._queryTree,
5559
+
{
5560
+
operation: "withObject",
5561
+
args: { object },
5562
+
},
5563
+
],
5564
+
ctx: this._ctx,
5565
+
});
5566
+
};
5567
+
5568
+
/**
5569
+
* Update the module configuration to use the given SDK.
5570
+
* @param sdk The SDK to use.
5571
+
*/
5572
+
withSDK = (sdk: string): Module_ => {
5573
+
return new Module_({
5574
+
queryTree: [
5575
+
...this._queryTree,
5576
+
{
5577
+
operation: "withSDK",
5578
+
args: { sdk },
5579
+
},
5580
+
],
5581
+
ctx: this._ctx,
5582
+
});
5583
+
};
5584
+
5585
+
/**
5586
+
* Retrieves the module with basic configuration loaded if present.
5587
+
* @param source The module source to initialize from.
5588
+
*/
5589
+
withSource = (source: ModuleSource): Module_ => {
5590
+
return new Module_({
5591
+
queryTree: [
5592
+
...this._queryTree,
5593
+
{
5594
+
operation: "withSource",
5595
+
args: { source },
5596
+
},
5597
+
],
5598
+
ctx: this._ctx,
5599
+
});
5600
+
};
5601
+
5602
+
/**
5603
+
* Call the provided function with current Module.
5604
+
*
5605
+
* This is useful for reusability and readability by not breaking the calling chain.
5606
+
*/
5607
+
with = (arg: (param: Module_) => Module_) => {
5608
+
return arg(this);
5609
+
};
5610
+
}
5611
+
5612
+
/**
5613
+
* The configuration of dependency of a module.
5614
+
*/
5615
+
export class ModuleDependency extends BaseClient {
5616
+
private readonly _id?: ModuleDependencyID = undefined;
5617
+
private readonly _name?: string = undefined;
5618
+
5619
+
/**
5620
+
* Constructor is used for internal usage only, do not create object from it.
5621
+
*/
5622
+
constructor(
5623
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5624
+
_id?: ModuleDependencyID,
5625
+
_name?: string
5626
+
) {
5627
+
super(parent);
5628
+
5629
+
this._id = _id;
5630
+
this._name = _name;
5631
+
}
5632
+
5633
+
/**
5634
+
* A unique identifier for this ModuleDependency.
5635
+
*/
5636
+
id = async (): Promise<ModuleDependencyID> => {
5637
+
if (this._id) {
5638
+
return this._id;
5639
+
}
5640
+
5641
+
const response: Awaited<ModuleDependencyID> = await computeQuery(
5642
+
[
5643
+
...this._queryTree,
5644
+
{
5645
+
operation: "id",
5646
+
},
5647
+
],
5648
+
await this._ctx.connection()
5649
+
);
5650
+
5651
+
return response;
5652
+
};
5653
+
5654
+
/**
5655
+
* The name of the dependency module.
5656
+
*/
5657
+
name = async (): Promise<string> => {
5658
+
if (this._name) {
5659
+
return this._name;
5660
+
}
5661
+
5662
+
const response: Awaited<string> = await computeQuery(
5663
+
[
5664
+
...this._queryTree,
5665
+
{
5666
+
operation: "name",
5667
+
},
5668
+
],
5669
+
await this._ctx.connection()
5670
+
);
5671
+
5672
+
return response;
5673
+
};
5674
+
5675
+
/**
5676
+
* The source for the dependency module.
5677
+
*/
5678
+
source = (): ModuleSource => {
5679
+
return new ModuleSource({
5680
+
queryTree: [
5681
+
...this._queryTree,
5682
+
{
5683
+
operation: "source",
5684
+
},
5685
+
],
5686
+
ctx: this._ctx,
5687
+
});
5688
+
};
5689
+
}
5690
+
5691
+
/**
5692
+
* The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.
5693
+
*/
5694
+
export class ModuleSource extends BaseClient {
5695
+
private readonly _id?: ModuleSourceID = undefined;
5696
+
private readonly _asString?: string = undefined;
5697
+
private readonly _kind?: ModuleSourceKind = undefined;
5698
+
private readonly _moduleName?: string = undefined;
5699
+
private readonly _subpath?: string = undefined;
5700
+
5701
+
/**
5702
+
* Constructor is used for internal usage only, do not create object from it.
5703
+
*/
5704
+
constructor(
5705
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5706
+
_id?: ModuleSourceID,
5707
+
_asString?: string,
5708
+
_kind?: ModuleSourceKind,
5709
+
_moduleName?: string,
5710
+
_subpath?: string
5711
+
) {
5712
+
super(parent);
5713
+
5714
+
this._id = _id;
5715
+
this._asString = _asString;
5716
+
this._kind = _kind;
5717
+
this._moduleName = _moduleName;
5718
+
this._subpath = _subpath;
5719
+
}
5720
+
5721
+
/**
5722
+
* A unique identifier for this ModuleSource.
5723
+
*/
5724
+
id = async (): Promise<ModuleSourceID> => {
5725
+
if (this._id) {
5726
+
return this._id;
5727
+
}
5728
+
5729
+
const response: Awaited<ModuleSourceID> = await computeQuery(
5730
+
[
5731
+
...this._queryTree,
5732
+
{
5733
+
operation: "id",
5734
+
},
5735
+
],
5736
+
await this._ctx.connection()
5737
+
);
5738
+
5739
+
return response;
5740
+
};
5741
+
5742
+
/**
5743
+
* If the source is a of kind git, the git source representation of it.
5744
+
*/
5745
+
asGitSource = (): GitModuleSource => {
5746
+
return new GitModuleSource({
5747
+
queryTree: [
5748
+
...this._queryTree,
5749
+
{
5750
+
operation: "asGitSource",
5751
+
},
5752
+
],
5753
+
ctx: this._ctx,
5754
+
});
5755
+
};
5756
+
5757
+
/**
5758
+
* If the source is of kind local, the local source representation of it.
5759
+
*/
5760
+
asLocalSource = (): LocalModuleSource => {
5761
+
return new LocalModuleSource({
5762
+
queryTree: [
5763
+
...this._queryTree,
5764
+
{
5765
+
operation: "asLocalSource",
5766
+
},
5767
+
],
5768
+
ctx: this._ctx,
5769
+
});
5770
+
};
5771
+
5772
+
/**
5773
+
* Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation
5774
+
*/
5775
+
asModule = (): Module_ => {
5776
+
return new Module_({
5777
+
queryTree: [
5778
+
...this._queryTree,
5779
+
{
5780
+
operation: "asModule",
5781
+
},
5782
+
],
5783
+
ctx: this._ctx,
5784
+
});
5785
+
};
5786
+
5787
+
/**
5788
+
* A human readable ref string representation of this module source.
5789
+
*/
5790
+
asString = async (): Promise<string> => {
5791
+
if (this._asString) {
5792
+
return this._asString;
5793
+
}
5794
+
5795
+
const response: Awaited<string> = await computeQuery(
5796
+
[
5797
+
...this._queryTree,
5798
+
{
5799
+
operation: "asString",
5800
+
},
5801
+
],
5802
+
await this._ctx.connection()
5803
+
);
5804
+
5805
+
return response;
5806
+
};
5807
+
5808
+
/**
5809
+
* The directory containing the actual module's source code, as determined from the root directory and subpath.
5810
+
* @param path The path from the source directory to select.
5811
+
*/
5812
+
directory = (path: string): Directory => {
5813
+
return new Directory({
5814
+
queryTree: [
5815
+
...this._queryTree,
5816
+
{
5817
+
operation: "directory",
5818
+
args: { path },
5819
+
},
5820
+
],
5821
+
ctx: this._ctx,
5822
+
});
5823
+
};
5824
+
5825
+
/**
5826
+
* The kind of source (e.g. local, git, etc.)
5827
+
*/
5828
+
kind = async (): Promise<ModuleSourceKind> => {
5829
+
if (this._kind) {
5830
+
return this._kind;
5831
+
}
5832
+
5833
+
const response: Awaited<ModuleSourceKind> = await computeQuery(
5834
+
[
5835
+
...this._queryTree,
5836
+
{
5837
+
operation: "kind",
5838
+
},
5839
+
],
5840
+
await this._ctx.connection()
5841
+
);
5842
+
5843
+
return response;
5844
+
};
5845
+
5846
+
/**
5847
+
* If set, the name of the module this source references
5848
+
*/
5849
+
moduleName = async (): Promise<string> => {
5850
+
if (this._moduleName) {
5851
+
return this._moduleName;
5852
+
}
5853
+
5854
+
const response: Awaited<string> = await computeQuery(
5855
+
[
5856
+
...this._queryTree,
5857
+
{
5858
+
operation: "moduleName",
5859
+
},
5860
+
],
5861
+
await this._ctx.connection()
5862
+
);
5863
+
5864
+
return response;
5865
+
};
5866
+
5867
+
/**
5868
+
* Resolve the provided module source arg as a dependency relative to this module source.
5869
+
* @param dep The dependency module source to resolve.
5870
+
*/
5871
+
resolveDependency = (dep: ModuleSource): ModuleSource => {
5872
+
return new ModuleSource({
5873
+
queryTree: [
5874
+
...this._queryTree,
5875
+
{
5876
+
operation: "resolveDependency",
5877
+
args: { dep },
5878
+
},
5879
+
],
5880
+
ctx: this._ctx,
5881
+
});
5882
+
};
5883
+
5884
+
/**
5885
+
* The root directory of the module source that contains its configuration and source code (which may be in a subdirectory of this root).
5886
+
*/
5887
+
rootDirectory = (): Directory => {
5888
+
return new Directory({
5889
+
queryTree: [
5890
+
...this._queryTree,
5891
+
{
5892
+
operation: "rootDirectory",
5893
+
},
5894
+
],
5895
+
ctx: this._ctx,
5896
+
});
5897
+
};
5898
+
5899
+
/**
5900
+
* The path to the module subdirectory containing the actual module's source code.
5901
+
*/
5902
+
subpath = async (): Promise<string> => {
5903
+
if (this._subpath) {
5904
+
return this._subpath;
5905
+
}
5906
+
5907
+
const response: Awaited<string> = await computeQuery(
5908
+
[
5909
+
...this._queryTree,
5910
+
{
5911
+
operation: "subpath",
5912
+
},
5913
+
],
5914
+
await this._ctx.connection()
5915
+
);
5916
+
5917
+
return response;
5918
+
};
5919
+
5920
+
/**
5921
+
* Call the provided function with current ModuleSource.
5922
+
*
5923
+
* This is useful for reusability and readability by not breaking the calling chain.
5924
+
*/
5925
+
with = (arg: (param: ModuleSource) => ModuleSource) => {
5926
+
return arg(this);
5927
+
};
5928
+
}
5929
+
5930
+
/**
5931
+
* A definition of a custom object defined in a Module.
5932
+
*/
5933
+
export class ObjectTypeDef extends BaseClient {
5934
+
private readonly _id?: ObjectTypeDefID = undefined;
5935
+
private readonly _description?: string = undefined;
5936
+
private readonly _name?: string = undefined;
5937
+
private readonly _sourceModuleName?: string = undefined;
5938
+
5939
+
/**
5940
+
* Constructor is used for internal usage only, do not create object from it.
5941
+
*/
5942
+
constructor(
5943
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
5944
+
_id?: ObjectTypeDefID,
5945
+
_description?: string,
5946
+
_name?: string,
5947
+
_sourceModuleName?: string
5948
+
) {
5949
+
super(parent);
5950
+
5951
+
this._id = _id;
5952
+
this._description = _description;
5953
+
this._name = _name;
5954
+
this._sourceModuleName = _sourceModuleName;
5955
+
}
5956
+
5957
+
/**
5958
+
* A unique identifier for this ObjectTypeDef.
5959
+
*/
5960
+
id = async (): Promise<ObjectTypeDefID> => {
5961
+
if (this._id) {
5962
+
return this._id;
5963
+
}
5964
+
5965
+
const response: Awaited<ObjectTypeDefID> = await computeQuery(
5966
+
[
5967
+
...this._queryTree,
5968
+
{
5969
+
operation: "id",
5970
+
},
5971
+
],
5972
+
await this._ctx.connection()
5973
+
);
5974
+
5975
+
return response;
5976
+
};
5977
+
5978
+
/**
5979
+
* The function used to construct new instances of this object, if any
5980
+
*/
5981
+
constructor_ = (): Function_ => {
5982
+
return new Function_({
5983
+
queryTree: [
5984
+
...this._queryTree,
5985
+
{
5986
+
operation: "constructor",
5987
+
},
5988
+
],
5989
+
ctx: this._ctx,
5990
+
});
5991
+
};
5992
+
5993
+
/**
5994
+
* The doc string for the object, if any.
5995
+
*/
5996
+
description = async (): Promise<string> => {
5997
+
if (this._description) {
5998
+
return this._description;
5999
+
}
6000
+
6001
+
const response: Awaited<string> = await computeQuery(
6002
+
[
6003
+
...this._queryTree,
6004
+
{
6005
+
operation: "description",
6006
+
},
6007
+
],
6008
+
await this._ctx.connection()
6009
+
);
6010
+
6011
+
return response;
6012
+
};
6013
+
6014
+
/**
6015
+
* Static fields defined on this object, if any.
6016
+
*/
6017
+
fields = async (): Promise<FieldTypeDef[]> => {
6018
+
type fields = {
6019
+
id: FieldTypeDefID;
6020
+
};
6021
+
6022
+
const response: Awaited<fields[]> = await computeQuery(
6023
+
[
6024
+
...this._queryTree,
6025
+
{
6026
+
operation: "fields",
6027
+
},
6028
+
{
6029
+
operation: "id",
6030
+
},
6031
+
],
6032
+
await this._ctx.connection()
6033
+
);
6034
+
6035
+
return response.map(
6036
+
(r) =>
6037
+
new FieldTypeDef(
6038
+
{
6039
+
queryTree: [
6040
+
{
6041
+
operation: "loadFieldTypeDefFromID",
6042
+
args: { id: r.id },
6043
+
},
6044
+
],
6045
+
ctx: this._ctx,
6046
+
},
6047
+
r.id
6048
+
)
6049
+
);
6050
+
};
6051
+
6052
+
/**
6053
+
* Functions defined on this object, if any.
6054
+
*/
6055
+
functions = async (): Promise<Function_[]> => {
6056
+
type functions = {
6057
+
id: FunctionID;
6058
+
};
6059
+
6060
+
const response: Awaited<functions[]> = await computeQuery(
6061
+
[
6062
+
...this._queryTree,
6063
+
{
6064
+
operation: "functions",
6065
+
},
6066
+
{
6067
+
operation: "id",
6068
+
},
6069
+
],
6070
+
await this._ctx.connection()
6071
+
);
6072
+
6073
+
return response.map(
6074
+
(r) =>
6075
+
new Function_(
6076
+
{
6077
+
queryTree: [
6078
+
{
6079
+
operation: "loadFunction_FromID",
6080
+
args: { id: r.id },
6081
+
},
6082
+
],
6083
+
ctx: this._ctx,
6084
+
},
6085
+
r.id
6086
+
)
6087
+
);
6088
+
};
6089
+
6090
+
/**
6091
+
* The name of the object.
6092
+
*/
6093
+
name = async (): Promise<string> => {
6094
+
if (this._name) {
6095
+
return this._name;
6096
+
}
6097
+
6098
+
const response: Awaited<string> = await computeQuery(
6099
+
[
6100
+
...this._queryTree,
6101
+
{
6102
+
operation: "name",
6103
+
},
6104
+
],
6105
+
await this._ctx.connection()
6106
+
);
6107
+
6108
+
return response;
6109
+
};
6110
+
6111
+
/**
6112
+
* If this ObjectTypeDef is associated with a Module, the name of the module. Unset otherwise.
6113
+
*/
6114
+
sourceModuleName = async (): Promise<string> => {
6115
+
if (this._sourceModuleName) {
6116
+
return this._sourceModuleName;
6117
+
}
6118
+
6119
+
const response: Awaited<string> = await computeQuery(
6120
+
[
6121
+
...this._queryTree,
6122
+
{
6123
+
operation: "sourceModuleName",
6124
+
},
6125
+
],
6126
+
await this._ctx.connection()
6127
+
);
6128
+
6129
+
return response;
6130
+
};
6131
+
}
6132
+
6133
+
/**
6134
+
* A port exposed by a container.
6135
+
*/
6136
+
export class Port extends BaseClient {
6137
+
private readonly _id?: PortID = undefined;
6138
+
private readonly _description?: string = undefined;
6139
+
private readonly _experimentalSkipHealthcheck?: boolean = undefined;
6140
+
private readonly _port?: number = undefined;
6141
+
private readonly _protocol?: NetworkProtocol = undefined;
6142
+
6143
+
/**
6144
+
* Constructor is used for internal usage only, do not create object from it.
6145
+
*/
6146
+
constructor(
6147
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
6148
+
_id?: PortID,
6149
+
_description?: string,
6150
+
_experimentalSkipHealthcheck?: boolean,
6151
+
_port?: number,
6152
+
_protocol?: NetworkProtocol
6153
+
) {
6154
+
super(parent);
6155
+
6156
+
this._id = _id;
6157
+
this._description = _description;
6158
+
this._experimentalSkipHealthcheck = _experimentalSkipHealthcheck;
6159
+
this._port = _port;
6160
+
this._protocol = _protocol;
6161
+
}
6162
+
6163
+
/**
6164
+
* A unique identifier for this Port.
6165
+
*/
6166
+
id = async (): Promise<PortID> => {
6167
+
if (this._id) {
6168
+
return this._id;
6169
+
}
6170
+
6171
+
const response: Awaited<PortID> = await computeQuery(
6172
+
[
6173
+
...this._queryTree,
6174
+
{
6175
+
operation: "id",
6176
+
},
6177
+
],
6178
+
await this._ctx.connection()
6179
+
);
6180
+
6181
+
return response;
6182
+
};
6183
+
6184
+
/**
6185
+
* The port description.
6186
+
*/
6187
+
description = async (): Promise<string> => {
6188
+
if (this._description) {
6189
+
return this._description;
6190
+
}
6191
+
6192
+
const response: Awaited<string> = await computeQuery(
6193
+
[
6194
+
...this._queryTree,
6195
+
{
6196
+
operation: "description",
6197
+
},
6198
+
],
6199
+
await this._ctx.connection()
6200
+
);
6201
+
6202
+
return response;
6203
+
};
6204
+
6205
+
/**
6206
+
* Skip the health check when run as a service.
6207
+
*/
6208
+
experimentalSkipHealthcheck = async (): Promise<boolean> => {
6209
+
if (this._experimentalSkipHealthcheck) {
6210
+
return this._experimentalSkipHealthcheck;
6211
+
}
6212
+
6213
+
const response: Awaited<boolean> = await computeQuery(
6214
+
[
6215
+
...this._queryTree,
6216
+
{
6217
+
operation: "experimentalSkipHealthcheck",
6218
+
},
6219
+
],
6220
+
await this._ctx.connection()
6221
+
);
6222
+
6223
+
return response;
6224
+
};
6225
+
6226
+
/**
6227
+
* The port number.
6228
+
*/
6229
+
port = async (): Promise<number> => {
6230
+
if (this._port) {
6231
+
return this._port;
6232
+
}
6233
+
6234
+
const response: Awaited<number> = await computeQuery(
6235
+
[
6236
+
...this._queryTree,
6237
+
{
6238
+
operation: "port",
6239
+
},
6240
+
],
6241
+
await this._ctx.connection()
6242
+
);
6243
+
6244
+
return response;
6245
+
};
6246
+
6247
+
/**
6248
+
* The transport layer protocol.
6249
+
*/
6250
+
protocol = async (): Promise<NetworkProtocol> => {
6251
+
if (this._protocol) {
6252
+
return this._protocol;
6253
+
}
6254
+
6255
+
const response: Awaited<NetworkProtocol> = await computeQuery(
6256
+
[
6257
+
...this._queryTree,
6258
+
{
6259
+
operation: "protocol",
6260
+
},
6261
+
],
6262
+
await this._ctx.connection()
6263
+
);
6264
+
6265
+
return response;
6266
+
};
6267
+
}
6268
+
6269
+
/**
6270
+
* The root of the DAG.
6271
+
*/
6272
+
export class Client extends BaseClient {
6273
+
private readonly _checkVersionCompatibility?: boolean = undefined;
6274
+
private readonly _defaultPlatform?: Platform = undefined;
6275
+
6276
+
/**
6277
+
* Constructor is used for internal usage only, do not create object from it.
6278
+
*/
6279
+
constructor(
6280
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
6281
+
_checkVersionCompatibility?: boolean,
6282
+
_defaultPlatform?: Platform
6283
+
) {
6284
+
super(parent);
6285
+
6286
+
this._checkVersionCompatibility = _checkVersionCompatibility;
6287
+
this._defaultPlatform = _defaultPlatform;
6288
+
}
6289
+
6290
+
/**
6291
+
* Retrieves a content-addressed blob.
6292
+
* @param digest Digest of the blob
6293
+
* @param size Size of the blob
6294
+
* @param mediaType Media type of the blob
6295
+
* @param uncompressed Digest of the uncompressed blob
6296
+
*/
6297
+
blob = (
6298
+
digest: string,
6299
+
size: number,
6300
+
mediaType: string,
6301
+
uncompressed: string
6302
+
): Directory => {
6303
+
return new Directory({
6304
+
queryTree: [
6305
+
...this._queryTree,
6306
+
{
6307
+
operation: "blob",
6308
+
args: { digest, size, mediaType, uncompressed },
6309
+
},
6310
+
],
6311
+
ctx: this._ctx,
6312
+
});
6313
+
};
6314
+
6315
+
/**
6316
+
* Constructs a cache volume for a given cache key.
6317
+
* @param key A string identifier to target this cache volume (e.g., "modules-cache").
6318
+
*/
6319
+
cacheVolume = (key: string): CacheVolume => {
6320
+
return new CacheVolume({
6321
+
queryTree: [
6322
+
...this._queryTree,
6323
+
{
6324
+
operation: "cacheVolume",
6325
+
args: { key },
6326
+
},
6327
+
],
6328
+
ctx: this._ctx,
6329
+
});
6330
+
};
6331
+
6332
+
/**
6333
+
* Checks if the current Dagger Engine is compatible with an SDK's required version.
6334
+
* @param version Version required by the SDK.
6335
+
*/
6336
+
checkVersionCompatibility = async (version: string): Promise<boolean> => {
6337
+
const response: Awaited<boolean> = await computeQuery(
6338
+
[
6339
+
...this._queryTree,
6340
+
{
6341
+
operation: "checkVersionCompatibility",
6342
+
args: { version },
6343
+
},
6344
+
],
6345
+
await this._ctx.connection()
6346
+
);
6347
+
6348
+
return response;
6349
+
};
6350
+
6351
+
/**
6352
+
* Creates a scratch container.
6353
+
*
6354
+
* Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
6355
+
* @param opts.id DEPRECATED: Use `loadContainerFromID` instead.
6356
+
* @param opts.platform Platform to initialize the container with.
6357
+
*/
6358
+
container = (opts?: ClientContainerOpts): Container => {
6359
+
return new Container({
6360
+
queryTree: [
6361
+
...this._queryTree,
6362
+
{
6363
+
operation: "container",
6364
+
args: { ...opts },
6365
+
},
6366
+
],
6367
+
ctx: this._ctx,
6368
+
});
6369
+
};
6370
+
6371
+
/**
6372
+
* The FunctionCall context that the SDK caller is currently executing in.
6373
+
*
6374
+
* If the caller is not currently executing in a function, this will return an error.
6375
+
*/
6376
+
currentFunctionCall = (): FunctionCall => {
6377
+
return new FunctionCall({
6378
+
queryTree: [
6379
+
...this._queryTree,
6380
+
{
6381
+
operation: "currentFunctionCall",
6382
+
},
6383
+
],
6384
+
ctx: this._ctx,
6385
+
});
6386
+
};
6387
+
6388
+
/**
6389
+
* The module currently being served in the session, if any.
6390
+
*/
6391
+
currentModule = (): CurrentModule => {
6392
+
return new CurrentModule({
6393
+
queryTree: [
6394
+
...this._queryTree,
6395
+
{
6396
+
operation: "currentModule",
6397
+
},
6398
+
],
6399
+
ctx: this._ctx,
6400
+
});
6401
+
};
6402
+
6403
+
/**
6404
+
* The TypeDef representations of the objects currently being served in the session.
6405
+
*/
6406
+
currentTypeDefs = async (): Promise<TypeDef[]> => {
6407
+
type currentTypeDefs = {
6408
+
id: TypeDefID;
6409
+
};
6410
+
6411
+
const response: Awaited<currentTypeDefs[]> = await computeQuery(
6412
+
[
6413
+
...this._queryTree,
6414
+
{
6415
+
operation: "currentTypeDefs",
6416
+
},
6417
+
{
6418
+
operation: "id",
6419
+
},
6420
+
],
6421
+
await this._ctx.connection()
6422
+
);
6423
+
6424
+
return response.map(
6425
+
(r) =>
6426
+
new TypeDef(
6427
+
{
6428
+
queryTree: [
6429
+
{
6430
+
operation: "loadTypeDefFromID",
6431
+
args: { id: r.id },
6432
+
},
6433
+
],
6434
+
ctx: this._ctx,
6435
+
},
6436
+
r.id
6437
+
)
6438
+
);
6439
+
};
6440
+
6441
+
/**
6442
+
* The default platform of the engine.
6443
+
*/
6444
+
defaultPlatform = async (): Promise<Platform> => {
6445
+
const response: Awaited<Platform> = await computeQuery(
6446
+
[
6447
+
...this._queryTree,
6448
+
{
6449
+
operation: "defaultPlatform",
6450
+
},
6451
+
],
6452
+
await this._ctx.connection()
6453
+
);
6454
+
6455
+
return response;
6456
+
};
6457
+
6458
+
/**
6459
+
* Creates an empty directory.
6460
+
* @param opts.id DEPRECATED: Use `loadDirectoryFromID` isntead.
6461
+
*/
6462
+
directory = (opts?: ClientDirectoryOpts): Directory => {
6463
+
return new Directory({
6464
+
queryTree: [
6465
+
...this._queryTree,
6466
+
{
6467
+
operation: "directory",
6468
+
args: { ...opts },
6469
+
},
6470
+
],
6471
+
ctx: this._ctx,
6472
+
});
6473
+
};
6474
+
6475
+
/**
6476
+
* @deprecated Use loadFileFromID instead.
6477
+
*/
6478
+
file = (id: FileID): File => {
6479
+
return new File({
6480
+
queryTree: [
6481
+
...this._queryTree,
6482
+
{
6483
+
operation: "file",
6484
+
args: { id },
6485
+
},
6486
+
],
6487
+
ctx: this._ctx,
6488
+
});
6489
+
};
6490
+
6491
+
/**
6492
+
* Creates a function.
6493
+
* @param name Name of the function, in its original format from the implementation language.
6494
+
* @param returnType Return type of the function.
6495
+
*/
6496
+
function_ = (name: string, returnType: TypeDef): Function_ => {
6497
+
return new Function_({
6498
+
queryTree: [
6499
+
...this._queryTree,
6500
+
{
6501
+
operation: "function",
6502
+
args: { name, returnType },
6503
+
},
6504
+
],
6505
+
ctx: this._ctx,
6506
+
});
6507
+
};
6508
+
6509
+
/**
6510
+
* Create a code generation result, given a directory containing the generated code.
6511
+
*/
6512
+
generatedCode = (code: Directory): GeneratedCode => {
6513
+
return new GeneratedCode({
6514
+
queryTree: [
6515
+
...this._queryTree,
6516
+
{
6517
+
operation: "generatedCode",
6518
+
args: { code },
6519
+
},
6520
+
],
6521
+
ctx: this._ctx,
6522
+
});
6523
+
};
6524
+
6525
+
/**
6526
+
* Queries a Git repository.
6527
+
* @param url URL of the git repository.
6528
+
*
6529
+
* Can be formatted as `https://{host}/{owner}/{repo}`, `git@{host}:{owner}/{repo}`.
6530
+
*
6531
+
* Suffix ".git" is optional.
6532
+
* @param opts.keepGitDir Set to true to keep .git directory.
6533
+
* @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
6534
+
* @param opts.sshKnownHosts Set SSH known hosts
6535
+
* @param opts.sshAuthSocket Set SSH auth socket
6536
+
*/
6537
+
git = (url: string, opts?: ClientGitOpts): GitRepository => {
6538
+
return new GitRepository({
6539
+
queryTree: [
6540
+
...this._queryTree,
6541
+
{
6542
+
operation: "git",
6543
+
args: { url, ...opts },
6544
+
},
6545
+
],
6546
+
ctx: this._ctx,
6547
+
});
6548
+
};
6549
+
6550
+
/**
6551
+
* Queries the host environment.
6552
+
*/
6553
+
host = (): Host => {
6554
+
return new Host({
6555
+
queryTree: [
6556
+
...this._queryTree,
6557
+
{
6558
+
operation: "host",
6559
+
},
6560
+
],
6561
+
ctx: this._ctx,
6562
+
});
6563
+
};
6564
+
6565
+
/**
6566
+
* Returns a file containing an http remote url content.
6567
+
* @param url HTTP url to get the content from (e.g., "https://docs.dagger.io").
6568
+
* @param opts.experimentalServiceHost A service which must be started before the URL is fetched.
6569
+
*/
6570
+
http = (url: string, opts?: ClientHttpOpts): File => {
6571
+
return new File({
6572
+
queryTree: [
6573
+
...this._queryTree,
6574
+
{
6575
+
operation: "http",
6576
+
args: { url, ...opts },
6577
+
},
6578
+
],
6579
+
ctx: this._ctx,
6580
+
});
6581
+
};
6582
+
6583
+
/**
6584
+
* Load a CacheVolume from its ID.
6585
+
*/
6586
+
loadCacheVolumeFromID = (id: CacheVolumeID): CacheVolume => {
6587
+
return new CacheVolume({
6588
+
queryTree: [
6589
+
...this._queryTree,
6590
+
{
6591
+
operation: "loadCacheVolumeFromID",
6592
+
args: { id },
6593
+
},
6594
+
],
6595
+
ctx: this._ctx,
6596
+
});
6597
+
};
6598
+
6599
+
/**
6600
+
* Load a Container from its ID.
6601
+
*/
6602
+
loadContainerFromID = (id: ContainerID): Container => {
6603
+
return new Container({
6604
+
queryTree: [
6605
+
...this._queryTree,
6606
+
{
6607
+
operation: "loadContainerFromID",
6608
+
args: { id },
6609
+
},
6610
+
],
6611
+
ctx: this._ctx,
6612
+
});
6613
+
};
6614
+
6615
+
/**
6616
+
* Load a CurrentModule from its ID.
6617
+
*/
6618
+
loadCurrentModuleFromID = (id: CurrentModuleID): CurrentModule => {
6619
+
return new CurrentModule({
6620
+
queryTree: [
6621
+
...this._queryTree,
6622
+
{
6623
+
operation: "loadCurrentModuleFromID",
6624
+
args: { id },
6625
+
},
6626
+
],
6627
+
ctx: this._ctx,
6628
+
});
6629
+
};
6630
+
6631
+
/**
6632
+
* Load a Directory from its ID.
6633
+
*/
6634
+
loadDirectoryFromID = (id: DirectoryID): Directory => {
6635
+
return new Directory({
6636
+
queryTree: [
6637
+
...this._queryTree,
6638
+
{
6639
+
operation: "loadDirectoryFromID",
6640
+
args: { id },
6641
+
},
6642
+
],
6643
+
ctx: this._ctx,
6644
+
});
6645
+
};
6646
+
6647
+
/**
6648
+
* Load a EnvVariable from its ID.
6649
+
*/
6650
+
loadEnvVariableFromID = (id: EnvVariableID): EnvVariable => {
6651
+
return new EnvVariable({
6652
+
queryTree: [
6653
+
...this._queryTree,
6654
+
{
6655
+
operation: "loadEnvVariableFromID",
6656
+
args: { id },
6657
+
},
6658
+
],
6659
+
ctx: this._ctx,
6660
+
});
6661
+
};
6662
+
6663
+
/**
6664
+
* Load a FieldTypeDef from its ID.
6665
+
*/
6666
+
loadFieldTypeDefFromID = (id: FieldTypeDefID): FieldTypeDef => {
6667
+
return new FieldTypeDef({
6668
+
queryTree: [
6669
+
...this._queryTree,
6670
+
{
6671
+
operation: "loadFieldTypeDefFromID",
6672
+
args: { id },
6673
+
},
6674
+
],
6675
+
ctx: this._ctx,
6676
+
});
6677
+
};
6678
+
6679
+
/**
6680
+
* Load a File from its ID.
6681
+
*/
6682
+
loadFileFromID = (id: FileID): File => {
6683
+
return new File({
6684
+
queryTree: [
6685
+
...this._queryTree,
6686
+
{
6687
+
operation: "loadFileFromID",
6688
+
args: { id },
6689
+
},
6690
+
],
6691
+
ctx: this._ctx,
6692
+
});
6693
+
};
6694
+
6695
+
/**
6696
+
* Load a FunctionArg from its ID.
6697
+
*/
6698
+
loadFunctionArgFromID = (id: FunctionArgID): FunctionArg => {
6699
+
return new FunctionArg({
6700
+
queryTree: [
6701
+
...this._queryTree,
6702
+
{
6703
+
operation: "loadFunctionArgFromID",
6704
+
args: { id },
6705
+
},
6706
+
],
6707
+
ctx: this._ctx,
6708
+
});
6709
+
};
6710
+
6711
+
/**
6712
+
* Load a FunctionCallArgValue from its ID.
6713
+
*/
6714
+
loadFunctionCallArgValueFromID = (
6715
+
id: FunctionCallArgValueID
6716
+
): FunctionCallArgValue => {
6717
+
return new FunctionCallArgValue({
6718
+
queryTree: [
6719
+
...this._queryTree,
6720
+
{
6721
+
operation: "loadFunctionCallArgValueFromID",
6722
+
args: { id },
6723
+
},
6724
+
],
6725
+
ctx: this._ctx,
6726
+
});
6727
+
};
6728
+
6729
+
/**
6730
+
* Load a FunctionCall from its ID.
6731
+
*/
6732
+
loadFunctionCallFromID = (id: FunctionCallID): FunctionCall => {
6733
+
return new FunctionCall({
6734
+
queryTree: [
6735
+
...this._queryTree,
6736
+
{
6737
+
operation: "loadFunctionCallFromID",
6738
+
args: { id },
6739
+
},
6740
+
],
6741
+
ctx: this._ctx,
6742
+
});
6743
+
};
6744
+
6745
+
/**
6746
+
* Load a Function from its ID.
6747
+
*/
6748
+
loadFunctionFromID = (id: FunctionID): Function_ => {
6749
+
return new Function_({
6750
+
queryTree: [
6751
+
...this._queryTree,
6752
+
{
6753
+
operation: "loadFunctionFromID",
6754
+
args: { id },
6755
+
},
6756
+
],
6757
+
ctx: this._ctx,
6758
+
});
6759
+
};
6760
+
6761
+
/**
6762
+
* Load a GeneratedCode from its ID.
6763
+
*/
6764
+
loadGeneratedCodeFromID = (id: GeneratedCodeID): GeneratedCode => {
6765
+
return new GeneratedCode({
6766
+
queryTree: [
6767
+
...this._queryTree,
6768
+
{
6769
+
operation: "loadGeneratedCodeFromID",
6770
+
args: { id },
6771
+
},
6772
+
],
6773
+
ctx: this._ctx,
6774
+
});
6775
+
};
6776
+
6777
+
/**
6778
+
* Load a GitModuleSource from its ID.
6779
+
*/
6780
+
loadGitModuleSourceFromID = (id: GitModuleSourceID): GitModuleSource => {
6781
+
return new GitModuleSource({
6782
+
queryTree: [
6783
+
...this._queryTree,
6784
+
{
6785
+
operation: "loadGitModuleSourceFromID",
6786
+
args: { id },
6787
+
},
6788
+
],
6789
+
ctx: this._ctx,
6790
+
});
6791
+
};
6792
+
6793
+
/**
6794
+
* Load a GitRef from its ID.
6795
+
*/
6796
+
loadGitRefFromID = (id: GitRefID): GitRef => {
6797
+
return new GitRef({
6798
+
queryTree: [
6799
+
...this._queryTree,
6800
+
{
6801
+
operation: "loadGitRefFromID",
6802
+
args: { id },
6803
+
},
6804
+
],
6805
+
ctx: this._ctx,
6806
+
});
6807
+
};
6808
+
6809
+
/**
6810
+
* Load a GitRepository from its ID.
6811
+
*/
6812
+
loadGitRepositoryFromID = (id: GitRepositoryID): GitRepository => {
6813
+
return new GitRepository({
6814
+
queryTree: [
6815
+
...this._queryTree,
6816
+
{
6817
+
operation: "loadGitRepositoryFromID",
6818
+
args: { id },
6819
+
},
6820
+
],
6821
+
ctx: this._ctx,
6822
+
});
6823
+
};
6824
+
6825
+
/**
6826
+
* Load a Host from its ID.
6827
+
*/
6828
+
loadHostFromID = (id: HostID): Host => {
6829
+
return new Host({
6830
+
queryTree: [
6831
+
...this._queryTree,
6832
+
{
6833
+
operation: "loadHostFromID",
6834
+
args: { id },
6835
+
},
6836
+
],
6837
+
ctx: this._ctx,
6838
+
});
6839
+
};
6840
+
6841
+
/**
6842
+
* Load a InputTypeDef from its ID.
6843
+
*/
6844
+
loadInputTypeDefFromID = (id: InputTypeDefID): InputTypeDef => {
6845
+
return new InputTypeDef({
6846
+
queryTree: [
6847
+
...this._queryTree,
6848
+
{
6849
+
operation: "loadInputTypeDefFromID",
6850
+
args: { id },
6851
+
},
6852
+
],
6853
+
ctx: this._ctx,
6854
+
});
6855
+
};
6856
+
6857
+
/**
6858
+
* Load a InterfaceTypeDef from its ID.
6859
+
*/
6860
+
loadInterfaceTypeDefFromID = (id: InterfaceTypeDefID): InterfaceTypeDef => {
6861
+
return new InterfaceTypeDef({
6862
+
queryTree: [
6863
+
...this._queryTree,
6864
+
{
6865
+
operation: "loadInterfaceTypeDefFromID",
6866
+
args: { id },
6867
+
},
6868
+
],
6869
+
ctx: this._ctx,
6870
+
});
6871
+
};
6872
+
6873
+
/**
6874
+
* Load a Label from its ID.
6875
+
*/
6876
+
loadLabelFromID = (id: LabelID): Label => {
6877
+
return new Label({
6878
+
queryTree: [
6879
+
...this._queryTree,
6880
+
{
6881
+
operation: "loadLabelFromID",
6882
+
args: { id },
6883
+
},
6884
+
],
6885
+
ctx: this._ctx,
6886
+
});
6887
+
};
6888
+
6889
+
/**
6890
+
* Load a ListTypeDef from its ID.
6891
+
*/
6892
+
loadListTypeDefFromID = (id: ListTypeDefID): ListTypeDef => {
6893
+
return new ListTypeDef({
6894
+
queryTree: [
6895
+
...this._queryTree,
6896
+
{
6897
+
operation: "loadListTypeDefFromID",
6898
+
args: { id },
6899
+
},
6900
+
],
6901
+
ctx: this._ctx,
6902
+
});
6903
+
};
6904
+
6905
+
/**
6906
+
* Load a LocalModuleSource from its ID.
6907
+
*/
6908
+
loadLocalModuleSourceFromID = (
6909
+
id: LocalModuleSourceID
6910
+
): LocalModuleSource => {
6911
+
return new LocalModuleSource({
6912
+
queryTree: [
6913
+
...this._queryTree,
6914
+
{
6915
+
operation: "loadLocalModuleSourceFromID",
6916
+
args: { id },
6917
+
},
6918
+
],
6919
+
ctx: this._ctx,
6920
+
});
6921
+
};
6922
+
6923
+
/**
6924
+
* Load a ModuleDependency from its ID.
6925
+
*/
6926
+
loadModuleDependencyFromID = (id: ModuleDependencyID): ModuleDependency => {
6927
+
return new ModuleDependency({
6928
+
queryTree: [
6929
+
...this._queryTree,
6930
+
{
6931
+
operation: "loadModuleDependencyFromID",
6932
+
args: { id },
6933
+
},
6934
+
],
6935
+
ctx: this._ctx,
6936
+
});
6937
+
};
6938
+
6939
+
/**
6940
+
* Load a Module from its ID.
6941
+
*/
6942
+
loadModuleFromID = (id: ModuleID): Module_ => {
6943
+
return new Module_({
6944
+
queryTree: [
6945
+
...this._queryTree,
6946
+
{
6947
+
operation: "loadModuleFromID",
6948
+
args: { id },
6949
+
},
6950
+
],
6951
+
ctx: this._ctx,
6952
+
});
6953
+
};
6954
+
6955
+
/**
6956
+
* Load a ModuleSource from its ID.
6957
+
*/
6958
+
loadModuleSourceFromID = (id: ModuleSourceID): ModuleSource => {
6959
+
return new ModuleSource({
6960
+
queryTree: [
6961
+
...this._queryTree,
6962
+
{
6963
+
operation: "loadModuleSourceFromID",
6964
+
args: { id },
6965
+
},
6966
+
],
6967
+
ctx: this._ctx,
6968
+
});
6969
+
};
6970
+
6971
+
/**
6972
+
* Load a ObjectTypeDef from its ID.
6973
+
*/
6974
+
loadObjectTypeDefFromID = (id: ObjectTypeDefID): ObjectTypeDef => {
6975
+
return new ObjectTypeDef({
6976
+
queryTree: [
6977
+
...this._queryTree,
6978
+
{
6979
+
operation: "loadObjectTypeDefFromID",
6980
+
args: { id },
6981
+
},
6982
+
],
6983
+
ctx: this._ctx,
6984
+
});
6985
+
};
6986
+
6987
+
/**
6988
+
* Load a Port from its ID.
6989
+
*/
6990
+
loadPortFromID = (id: PortID): Port => {
6991
+
return new Port({
6992
+
queryTree: [
6993
+
...this._queryTree,
6994
+
{
6995
+
operation: "loadPortFromID",
6996
+
args: { id },
6997
+
},
6998
+
],
6999
+
ctx: this._ctx,
7000
+
});
7001
+
};
7002
+
7003
+
/**
7004
+
* Load a Secret from its ID.
7005
+
*/
7006
+
loadSecretFromID = (id: SecretID): Secret => {
7007
+
return new Secret({
7008
+
queryTree: [
7009
+
...this._queryTree,
7010
+
{
7011
+
operation: "loadSecretFromID",
7012
+
args: { id },
7013
+
},
7014
+
],
7015
+
ctx: this._ctx,
7016
+
});
7017
+
};
7018
+
7019
+
/**
7020
+
* Load a Service from its ID.
7021
+
*/
7022
+
loadServiceFromID = (id: ServiceID): Service => {
7023
+
return new Service({
7024
+
queryTree: [
7025
+
...this._queryTree,
7026
+
{
7027
+
operation: "loadServiceFromID",
7028
+
args: { id },
7029
+
},
7030
+
],
7031
+
ctx: this._ctx,
7032
+
});
7033
+
};
7034
+
7035
+
/**
7036
+
* Load a Socket from its ID.
7037
+
*/
7038
+
loadSocketFromID = (id: SocketID): Socket => {
7039
+
return new Socket({
7040
+
queryTree: [
7041
+
...this._queryTree,
7042
+
{
7043
+
operation: "loadSocketFromID",
7044
+
args: { id },
7045
+
},
7046
+
],
7047
+
ctx: this._ctx,
7048
+
});
7049
+
};
7050
+
7051
+
/**
7052
+
* Load a Terminal from its ID.
7053
+
*/
7054
+
loadTerminalFromID = (id: TerminalID): Terminal => {
7055
+
return new Terminal({
7056
+
queryTree: [
7057
+
...this._queryTree,
7058
+
{
7059
+
operation: "loadTerminalFromID",
7060
+
args: { id },
7061
+
},
7062
+
],
7063
+
ctx: this._ctx,
7064
+
});
7065
+
};
7066
+
7067
+
/**
7068
+
* Load a TypeDef from its ID.
7069
+
*/
7070
+
loadTypeDefFromID = (id: TypeDefID): TypeDef => {
7071
+
return new TypeDef({
7072
+
queryTree: [
7073
+
...this._queryTree,
7074
+
{
7075
+
operation: "loadTypeDefFromID",
7076
+
args: { id },
7077
+
},
7078
+
],
7079
+
ctx: this._ctx,
7080
+
});
7081
+
};
7082
+
7083
+
/**
7084
+
* Create a new module.
7085
+
*/
7086
+
module_ = (): Module_ => {
7087
+
return new Module_({
7088
+
queryTree: [
7089
+
...this._queryTree,
7090
+
{
7091
+
operation: "module",
7092
+
},
7093
+
],
7094
+
ctx: this._ctx,
7095
+
});
7096
+
};
7097
+
7098
+
/**
7099
+
* Create a new module dependency configuration from a module source and name
7100
+
* @param source The source of the dependency
7101
+
* @param opts.name If set, the name to use for the dependency. Otherwise, once installed to a parent module, the name of the dependency module will be used by default.
7102
+
*/
7103
+
moduleDependency = (
7104
+
source: ModuleSource,
7105
+
opts?: ClientModuleDependencyOpts
7106
+
): ModuleDependency => {
7107
+
return new ModuleDependency({
7108
+
queryTree: [
7109
+
...this._queryTree,
7110
+
{
7111
+
operation: "moduleDependency",
7112
+
args: { source, ...opts },
7113
+
},
7114
+
],
7115
+
ctx: this._ctx,
7116
+
});
7117
+
};
7118
+
7119
+
/**
7120
+
* Create a new module source instance from a source ref string.
7121
+
* @param refString The string ref representation of the module source
7122
+
* @param opts.rootDirectory An explicitly set root directory for the module source. This is required to load local sources as modules; other source types implicitly encode the root directory and do not require this.
7123
+
* @param opts.stable If true, enforce that the source is a stable version for source kinds that support versioning.
7124
+
*/
7125
+
moduleSource = (
7126
+
refString: string,
7127
+
opts?: ClientModuleSourceOpts
7128
+
): ModuleSource => {
7129
+
return new ModuleSource({
7130
+
queryTree: [
7131
+
...this._queryTree,
7132
+
{
7133
+
operation: "moduleSource",
7134
+
args: { refString, ...opts },
7135
+
},
7136
+
],
7137
+
ctx: this._ctx,
7138
+
});
7139
+
};
7140
+
7141
+
/**
7142
+
* Creates a named sub-pipeline.
7143
+
* @param name Name of the sub-pipeline.
7144
+
* @param opts.description Description of the sub-pipeline.
7145
+
* @param opts.labels Labels to apply to the sub-pipeline.
7146
+
*/
7147
+
pipeline = (name: string, opts?: ClientPipelineOpts): Client => {
7148
+
return new Client({
7149
+
queryTree: [
7150
+
...this._queryTree,
7151
+
{
7152
+
operation: "pipeline",
7153
+
args: { name, ...opts },
7154
+
},
7155
+
],
7156
+
ctx: this._ctx,
7157
+
});
7158
+
};
7159
+
7160
+
/**
7161
+
* Reference a secret by name.
7162
+
*/
7163
+
secret = (name: string): Secret => {
7164
+
return new Secret({
7165
+
queryTree: [
7166
+
...this._queryTree,
7167
+
{
7168
+
operation: "secret",
7169
+
args: { name },
7170
+
},
7171
+
],
7172
+
ctx: this._ctx,
7173
+
});
7174
+
};
7175
+
7176
+
/**
7177
+
* Sets a secret given a user defined name to its plaintext and returns the secret.
7178
+
*
7179
+
* The plaintext value is limited to a size of 128000 bytes.
7180
+
* @param name The user defined name for this secret
7181
+
* @param plaintext The plaintext of the secret
7182
+
*/
7183
+
setSecret = (name: string, plaintext: string): Secret => {
7184
+
return new Secret({
7185
+
queryTree: [
7186
+
...this._queryTree,
7187
+
{
7188
+
operation: "setSecret",
7189
+
args: { name, plaintext },
7190
+
},
7191
+
],
7192
+
ctx: this._ctx,
7193
+
});
7194
+
};
7195
+
7196
+
/**
7197
+
* Loads a socket by its ID.
7198
+
* @deprecated Use loadSocketFromID instead.
7199
+
*/
7200
+
socket = (id: SocketID): Socket => {
7201
+
return new Socket({
7202
+
queryTree: [
7203
+
...this._queryTree,
7204
+
{
7205
+
operation: "socket",
7206
+
args: { id },
7207
+
},
7208
+
],
7209
+
ctx: this._ctx,
7210
+
});
7211
+
};
7212
+
7213
+
/**
7214
+
* Create a new TypeDef.
7215
+
*/
7216
+
typeDef = (): TypeDef => {
7217
+
return new TypeDef({
7218
+
queryTree: [
7219
+
...this._queryTree,
7220
+
{
7221
+
operation: "typeDef",
7222
+
},
7223
+
],
7224
+
ctx: this._ctx,
7225
+
});
7226
+
};
7227
+
7228
+
/**
7229
+
* Call the provided function with current Client.
7230
+
*
7231
+
* This is useful for reusability and readability by not breaking the calling chain.
7232
+
*/
7233
+
with = (arg: (param: Client) => Client) => {
7234
+
return arg(this);
7235
+
};
7236
+
}
7237
+
7238
+
/**
7239
+
* A reference to a secret value, which can be handled more safely than the value itself.
7240
+
*/
7241
+
export class Secret extends BaseClient {
7242
+
private readonly _id?: SecretID = undefined;
7243
+
private readonly _plaintext?: string = undefined;
7244
+
7245
+
/**
7246
+
* Constructor is used for internal usage only, do not create object from it.
7247
+
*/
7248
+
constructor(
7249
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
7250
+
_id?: SecretID,
7251
+
_plaintext?: string
7252
+
) {
7253
+
super(parent);
7254
+
7255
+
this._id = _id;
7256
+
this._plaintext = _plaintext;
7257
+
}
7258
+
7259
+
/**
7260
+
* A unique identifier for this Secret.
7261
+
*/
7262
+
id = async (): Promise<SecretID> => {
7263
+
if (this._id) {
7264
+
return this._id;
7265
+
}
7266
+
7267
+
const response: Awaited<SecretID> = await computeQuery(
7268
+
[
7269
+
...this._queryTree,
7270
+
{
7271
+
operation: "id",
7272
+
},
7273
+
],
7274
+
await this._ctx.connection()
7275
+
);
7276
+
7277
+
return response;
7278
+
};
7279
+
7280
+
/**
7281
+
* The value of this secret.
7282
+
*/
7283
+
plaintext = async (): Promise<string> => {
7284
+
if (this._plaintext) {
7285
+
return this._plaintext;
7286
+
}
7287
+
7288
+
const response: Awaited<string> = await computeQuery(
7289
+
[
7290
+
...this._queryTree,
7291
+
{
7292
+
operation: "plaintext",
7293
+
},
7294
+
],
7295
+
await this._ctx.connection()
7296
+
);
7297
+
7298
+
return response;
7299
+
};
7300
+
}
7301
+
7302
+
/**
7303
+
* A content-addressed service providing TCP connectivity.
7304
+
*/
7305
+
export class Service extends BaseClient {
7306
+
private readonly _id?: ServiceID = undefined;
7307
+
private readonly _endpoint?: string = undefined;
7308
+
private readonly _hostname?: string = undefined;
7309
+
private readonly _start?: ServiceID = undefined;
7310
+
private readonly _stop?: ServiceID = undefined;
7311
+
private readonly _up?: Void = undefined;
7312
+
7313
+
/**
7314
+
* Constructor is used for internal usage only, do not create object from it.
7315
+
*/
7316
+
constructor(
7317
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
7318
+
_id?: ServiceID,
7319
+
_endpoint?: string,
7320
+
_hostname?: string,
7321
+
_start?: ServiceID,
7322
+
_stop?: ServiceID,
7323
+
_up?: Void
7324
+
) {
7325
+
super(parent);
7326
+
7327
+
this._id = _id;
7328
+
this._endpoint = _endpoint;
7329
+
this._hostname = _hostname;
7330
+
this._start = _start;
7331
+
this._stop = _stop;
7332
+
this._up = _up;
7333
+
}
7334
+
7335
+
/**
7336
+
* A unique identifier for this Service.
7337
+
*/
7338
+
id = async (): Promise<ServiceID> => {
7339
+
if (this._id) {
7340
+
return this._id;
7341
+
}
7342
+
7343
+
const response: Awaited<ServiceID> = await computeQuery(
7344
+
[
7345
+
...this._queryTree,
7346
+
{
7347
+
operation: "id",
7348
+
},
7349
+
],
7350
+
await this._ctx.connection()
7351
+
);
7352
+
7353
+
return response;
7354
+
};
7355
+
7356
+
/**
7357
+
* Retrieves an endpoint that clients can use to reach this container.
7358
+
*
7359
+
* If no port is specified, the first exposed port is used. If none exist an error is returned.
7360
+
*
7361
+
* If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
7362
+
* @param opts.port The exposed port number for the endpoint
7363
+
* @param opts.scheme Return a URL with the given scheme, eg. http for http://
7364
+
*/
7365
+
endpoint = async (opts?: ServiceEndpointOpts): Promise<string> => {
7366
+
if (this._endpoint) {
7367
+
return this._endpoint;
7368
+
}
7369
+
7370
+
const response: Awaited<string> = await computeQuery(
7371
+
[
7372
+
...this._queryTree,
7373
+
{
7374
+
operation: "endpoint",
7375
+
args: { ...opts },
7376
+
},
7377
+
],
7378
+
await this._ctx.connection()
7379
+
);
7380
+
7381
+
return response;
7382
+
};
7383
+
7384
+
/**
7385
+
* Retrieves a hostname which can be used by clients to reach this container.
7386
+
*/
7387
+
hostname = async (): Promise<string> => {
7388
+
if (this._hostname) {
7389
+
return this._hostname;
7390
+
}
7391
+
7392
+
const response: Awaited<string> = await computeQuery(
7393
+
[
7394
+
...this._queryTree,
7395
+
{
7396
+
operation: "hostname",
7397
+
},
7398
+
],
7399
+
await this._ctx.connection()
7400
+
);
7401
+
7402
+
return response;
7403
+
};
7404
+
7405
+
/**
7406
+
* Retrieves the list of ports provided by the service.
7407
+
*/
7408
+
ports = async (): Promise<Port[]> => {
7409
+
type ports = {
7410
+
id: PortID;
7411
+
};
7412
+
7413
+
const response: Awaited<ports[]> = await computeQuery(
7414
+
[
7415
+
...this._queryTree,
7416
+
{
7417
+
operation: "ports",
7418
+
},
7419
+
{
7420
+
operation: "id",
7421
+
},
7422
+
],
7423
+
await this._ctx.connection()
7424
+
);
7425
+
7426
+
return response.map(
7427
+
(r) =>
7428
+
new Port(
7429
+
{
7430
+
queryTree: [
7431
+
{
7432
+
operation: "loadPortFromID",
7433
+
args: { id: r.id },
7434
+
},
7435
+
],
7436
+
ctx: this._ctx,
7437
+
},
7438
+
r.id
7439
+
)
7440
+
);
7441
+
};
7442
+
7443
+
/**
7444
+
* Start the service and wait for its health checks to succeed.
7445
+
*
7446
+
* Services bound to a Container do not need to be manually started.
7447
+
*/
7448
+
start = async (): Promise<Service> => {
7449
+
await computeQuery(
7450
+
[
7451
+
...this._queryTree,
7452
+
{
7453
+
operation: "start",
7454
+
},
7455
+
],
7456
+
await this._ctx.connection()
7457
+
);
7458
+
7459
+
return this;
7460
+
};
7461
+
7462
+
/**
7463
+
* Stop the service.
7464
+
* @param opts.kill Immediately kill the service without waiting for a graceful exit
7465
+
*/
7466
+
stop = async (opts?: ServiceStopOpts): Promise<Service> => {
7467
+
await computeQuery(
7468
+
[
7469
+
...this._queryTree,
7470
+
{
7471
+
operation: "stop",
7472
+
args: { ...opts },
7473
+
},
7474
+
],
7475
+
await this._ctx.connection()
7476
+
);
7477
+
7478
+
return this;
7479
+
};
7480
+
7481
+
/**
7482
+
* Creates a tunnel that forwards traffic from the caller's network to this service.
7483
+
* @param opts.ports List of frontend/backend port mappings to forward.
7484
+
*
7485
+
* Frontend is the port accepting traffic on the host, backend is the service port.
7486
+
* @param opts.random Bind each tunnel port to a random port on the host.
7487
+
*/
7488
+
up = async (opts?: ServiceUpOpts): Promise<Void> => {
7489
+
if (this._up) {
7490
+
return this._up;
7491
+
}
7492
+
7493
+
const response: Awaited<Void> = await computeQuery(
7494
+
[
7495
+
...this._queryTree,
7496
+
{
7497
+
operation: "up",
7498
+
args: { ...opts },
7499
+
},
7500
+
],
7501
+
await this._ctx.connection()
7502
+
);
7503
+
7504
+
return response;
7505
+
};
7506
+
}
7507
+
7508
+
/**
7509
+
* A Unix or TCP/IP socket that can be mounted into a container.
7510
+
*/
7511
+
export class Socket extends BaseClient {
7512
+
private readonly _id?: SocketID = undefined;
7513
+
7514
+
/**
7515
+
* Constructor is used for internal usage only, do not create object from it.
7516
+
*/
7517
+
constructor(
7518
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
7519
+
_id?: SocketID
7520
+
) {
7521
+
super(parent);
7522
+
7523
+
this._id = _id;
7524
+
}
7525
+
7526
+
/**
7527
+
* A unique identifier for this Socket.
7528
+
*/
7529
+
id = async (): Promise<SocketID> => {
7530
+
if (this._id) {
7531
+
return this._id;
7532
+
}
7533
+
7534
+
const response: Awaited<SocketID> = await computeQuery(
7535
+
[
7536
+
...this._queryTree,
7537
+
{
7538
+
operation: "id",
7539
+
},
7540
+
],
7541
+
await this._ctx.connection()
7542
+
);
7543
+
7544
+
return response;
7545
+
};
7546
+
}
7547
+
7548
+
/**
7549
+
* An interactive terminal that clients can connect to.
7550
+
*/
7551
+
export class Terminal extends BaseClient {
7552
+
private readonly _id?: TerminalID = undefined;
7553
+
private readonly _websocketEndpoint?: string = undefined;
7554
+
7555
+
/**
7556
+
* Constructor is used for internal usage only, do not create object from it.
7557
+
*/
7558
+
constructor(
7559
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
7560
+
_id?: TerminalID,
7561
+
_websocketEndpoint?: string
7562
+
) {
7563
+
super(parent);
7564
+
7565
+
this._id = _id;
7566
+
this._websocketEndpoint = _websocketEndpoint;
7567
+
}
7568
+
7569
+
/**
7570
+
* A unique identifier for this Terminal.
7571
+
*/
7572
+
id = async (): Promise<TerminalID> => {
7573
+
if (this._id) {
7574
+
return this._id;
7575
+
}
7576
+
7577
+
const response: Awaited<TerminalID> = await computeQuery(
7578
+
[
7579
+
...this._queryTree,
7580
+
{
7581
+
operation: "id",
7582
+
},
7583
+
],
7584
+
await this._ctx.connection()
7585
+
);
7586
+
7587
+
return response;
7588
+
};
7589
+
7590
+
/**
7591
+
* An http endpoint at which this terminal can be connected to over a websocket.
7592
+
*/
7593
+
websocketEndpoint = async (): Promise<string> => {
7594
+
if (this._websocketEndpoint) {
7595
+
return this._websocketEndpoint;
7596
+
}
7597
+
7598
+
const response: Awaited<string> = await computeQuery(
7599
+
[
7600
+
...this._queryTree,
7601
+
{
7602
+
operation: "websocketEndpoint",
7603
+
},
7604
+
],
7605
+
await this._ctx.connection()
7606
+
);
7607
+
7608
+
return response;
7609
+
};
7610
+
}
7611
+
7612
+
/**
7613
+
* A definition of a parameter or return type in a Module.
7614
+
*/
7615
+
export class TypeDef extends BaseClient {
7616
+
private readonly _id?: TypeDefID = undefined;
7617
+
private readonly _kind?: TypeDefKind = undefined;
7618
+
private readonly _optional?: boolean = undefined;
7619
+
7620
+
/**
7621
+
* Constructor is used for internal usage only, do not create object from it.
7622
+
*/
7623
+
constructor(
7624
+
parent?: { queryTree?: QueryTree[]; ctx: Context },
7625
+
_id?: TypeDefID,
7626
+
_kind?: TypeDefKind,
7627
+
_optional?: boolean
7628
+
) {
7629
+
super(parent);
7630
+
7631
+
this._id = _id;
7632
+
this._kind = _kind;
7633
+
this._optional = _optional;
7634
+
}
7635
+
7636
+
/**
7637
+
* A unique identifier for this TypeDef.
7638
+
*/
7639
+
id = async (): Promise<TypeDefID> => {
7640
+
if (this._id) {
7641
+
return this._id;
7642
+
}
7643
+
7644
+
const response: Awaited<TypeDefID> = await computeQuery(
7645
+
[
7646
+
...this._queryTree,
7647
+
{
7648
+
operation: "id",
7649
+
},
7650
+
],
7651
+
await this._ctx.connection()
7652
+
);
7653
+
7654
+
return response;
7655
+
};
7656
+
7657
+
/**
7658
+
* If kind is INPUT, the input-specific type definition. If kind is not INPUT, this will be null.
7659
+
*/
7660
+
asInput = (): InputTypeDef => {
7661
+
return new InputTypeDef({
7662
+
queryTree: [
7663
+
...this._queryTree,
7664
+
{
7665
+
operation: "asInput",
7666
+
},
7667
+
],
7668
+
ctx: this._ctx,
7669
+
});
7670
+
};
7671
+
7672
+
/**
7673
+
* If kind is INTERFACE, the interface-specific type definition. If kind is not INTERFACE, this will be null.
7674
+
*/
7675
+
asInterface = (): InterfaceTypeDef => {
7676
+
return new InterfaceTypeDef({
7677
+
queryTree: [
7678
+
...this._queryTree,
7679
+
{
7680
+
operation: "asInterface",
7681
+
},
7682
+
],
7683
+
ctx: this._ctx,
7684
+
});
7685
+
};
7686
+
7687
+
/**
7688
+
* If kind is LIST, the list-specific type definition. If kind is not LIST, this will be null.
7689
+
*/
7690
+
asList = (): ListTypeDef => {
7691
+
return new ListTypeDef({
7692
+
queryTree: [
7693
+
...this._queryTree,
7694
+
{
7695
+
operation: "asList",
7696
+
},
7697
+
],
7698
+
ctx: this._ctx,
7699
+
});
7700
+
};
7701
+
7702
+
/**
7703
+
* If kind is OBJECT, the object-specific type definition. If kind is not OBJECT, this will be null.
7704
+
*/
7705
+
asObject = (): ObjectTypeDef => {
7706
+
return new ObjectTypeDef({
7707
+
queryTree: [
7708
+
...this._queryTree,
7709
+
{
7710
+
operation: "asObject",
7711
+
},
7712
+
],
7713
+
ctx: this._ctx,
7714
+
});
7715
+
};
7716
+
7717
+
/**
7718
+
* The kind of type this is (e.g. primitive, list, object).
7719
+
*/
7720
+
kind = async (): Promise<TypeDefKind> => {
7721
+
if (this._kind) {
7722
+
return this._kind;
7723
+
}
7724
+
7725
+
const response: Awaited<TypeDefKind> = await computeQuery(
7726
+
[
7727
+
...this._queryTree,
7728
+
{
7729
+
operation: "kind",
7730
+
},
7731
+
],
7732
+
await this._ctx.connection()
7733
+
);
7734
+
7735
+
return response;
7736
+
};
7737
+
7738
+
/**
7739
+
* Whether this type can be set to null. Defaults to false.
7740
+
*/
7741
+
optional = async (): Promise<boolean> => {
7742
+
if (this._optional) {
7743
+
return this._optional;
7744
+
}
7745
+
7746
+
const response: Awaited<boolean> = await computeQuery(
7747
+
[
7748
+
...this._queryTree,
7749
+
{
7750
+
operation: "optional",
7751
+
},
7752
+
],
7753
+
await this._ctx.connection()
7754
+
);
7755
+
7756
+
return response;
7757
+
};
7758
+
7759
+
/**
7760
+
* Adds a function for constructing a new instance of an Object TypeDef, failing if the type is not an object.
7761
+
*/
7762
+
withConstructor = (function_: Function_): TypeDef => {
7763
+
return new TypeDef({
7764
+
queryTree: [
7765
+
...this._queryTree,
7766
+
{
7767
+
operation: "withConstructor",
7768
+
args: {
7769
+
function: function_,
7770
+
},
7771
+
},
7772
+
],
7773
+
ctx: this._ctx,
7774
+
});
7775
+
};
7776
+
7777
+
/**
7778
+
* Adds a static field for an Object TypeDef, failing if the type is not an object.
7779
+
* @param name The name of the field in the object
7780
+
* @param typeDef The type of the field
7781
+
* @param opts.description A doc string for the field, if any
7782
+
*/
7783
+
withField = (
7784
+
name: string,
7785
+
typeDef: TypeDef,
7786
+
opts?: TypeDefWithFieldOpts
7787
+
): TypeDef => {
7788
+
return new TypeDef({
7789
+
queryTree: [
7790
+
...this._queryTree,
7791
+
{
7792
+
operation: "withField",
7793
+
args: { name, typeDef, ...opts },
7794
+
},
7795
+
],
7796
+
ctx: this._ctx,
7797
+
});
7798
+
};
7799
+
7800
+
/**
7801
+
* Adds a function for an Object or Interface TypeDef, failing if the type is not one of those kinds.
7802
+
*/
7803
+
withFunction = (function_: Function_): TypeDef => {
7804
+
return new TypeDef({
7805
+
queryTree: [
7806
+
...this._queryTree,
7807
+
{
7808
+
operation: "withFunction",
7809
+
args: {
7810
+
function: function_,
7811
+
},
7812
+
},
7813
+
],
7814
+
ctx: this._ctx,
7815
+
});
7816
+
};
7817
+
7818
+
/**
7819
+
* Returns a TypeDef of kind Interface with the provided name.
7820
+
*/
7821
+
withInterface = (name: string, opts?: TypeDefWithInterfaceOpts): TypeDef => {
7822
+
return new TypeDef({
7823
+
queryTree: [
7824
+
...this._queryTree,
7825
+
{
7826
+
operation: "withInterface",
7827
+
args: { name, ...opts },
7828
+
},
7829
+
],
7830
+
ctx: this._ctx,
7831
+
});
7832
+
};
7833
+
7834
+
/**
7835
+
* Sets the kind of the type.
7836
+
*/
7837
+
withKind = (kind: TypeDefKind): TypeDef => {
7838
+
const metadata: Metadata = {
7839
+
kind: { is_enum: true },
7840
+
};
7841
+
7842
+
return new TypeDef({
7843
+
queryTree: [
7844
+
...this._queryTree,
7845
+
{
7846
+
operation: "withKind",
7847
+
args: { kind, __metadata: metadata },
7848
+
},
7849
+
],
7850
+
ctx: this._ctx,
7851
+
});
7852
+
};
7853
+
7854
+
/**
7855
+
* Returns a TypeDef of kind List with the provided type for its elements.
7856
+
*/
7857
+
withListOf = (elementType: TypeDef): TypeDef => {
7858
+
return new TypeDef({
7859
+
queryTree: [
7860
+
...this._queryTree,
7861
+
{
7862
+
operation: "withListOf",
7863
+
args: { elementType },
7864
+
},
7865
+
],
7866
+
ctx: this._ctx,
7867
+
});
7868
+
};
7869
+
7870
+
/**
7871
+
* Returns a TypeDef of kind Object with the provided name.
7872
+
*
7873
+
* Note that an object's fields and functions may be omitted if the intent is only to refer to an object. This is how functions are able to return their own object, or any other circular reference.
7874
+
*/
7875
+
withObject = (name: string, opts?: TypeDefWithObjectOpts): TypeDef => {
7876
+
return new TypeDef({
7877
+
queryTree: [
7878
+
...this._queryTree,
7879
+
{
7880
+
operation: "withObject",
7881
+
args: { name, ...opts },
7882
+
},
7883
+
],
7884
+
ctx: this._ctx,
7885
+
});
7886
+
};
7887
+
7888
+
/**
7889
+
* Sets whether this type can be set to null.
7890
+
*/
7891
+
withOptional = (optional: boolean): TypeDef => {
7892
+
return new TypeDef({
7893
+
queryTree: [
7894
+
...this._queryTree,
7895
+
{
7896
+
operation: "withOptional",
7897
+
args: { optional },
7898
+
},
7899
+
],
7900
+
ctx: this._ctx,
7901
+
});
7902
+
};
7903
+
7904
+
/**
7905
+
* Call the provided function with current TypeDef.
7906
+
*
7907
+
* This is useful for reusability and readability by not breaking the calling chain.
7908
+
*/
7909
+
with = (arg: (param: TypeDef) => TypeDef) => {
7910
+
return arg(this);
7911
+
};
7912
+
}
7913
+
7914
+
export const dag = new Client({ ctx: defaultContext });
+9
.fluentci/sdk/client.ts
+9
.fluentci/sdk/client.ts
+53
.fluentci/sdk/connect.ts
+53
.fluentci/sdk/connect.ts
···
1
+
import { Writable } from "node:stream";
2
+
import { Client } from "./client.gen.ts";
3
+
import { Context } from "./context.ts";
4
+
5
+
/**
6
+
* ConnectOpts defines option used to connect to an engine.
7
+
*/
8
+
export interface ConnectOpts {
9
+
/**
10
+
* Use to overwrite Dagger workdir
11
+
* @defaultValue process.cwd()
12
+
*/
13
+
Workdir?: string;
14
+
/**
15
+
* Enable logs output
16
+
* @example
17
+
* LogOutput
18
+
* ```ts
19
+
* connect(async (client: Client) => {
20
+
const source = await client.host().workdir().id()
21
+
...
22
+
}, {LogOutput: process.stdout})
23
+
```
24
+
*/
25
+
LogOutput?: Writable;
26
+
}
27
+
28
+
export type CallbackFct = (client: Client) => Promise<void>;
29
+
30
+
export interface ConnectParams {
31
+
port: number;
32
+
session_token: string;
33
+
}
34
+
35
+
/**
36
+
* connect runs GraphQL server and initializes a
37
+
* GraphQL client to execute query on it through its callback.
38
+
* This implementation is based on the existing Go SDK.
39
+
*/
40
+
export async function connect(
41
+
cb: CallbackFct,
42
+
_config: ConnectOpts = {}
43
+
): Promise<void> {
44
+
const ctx = new Context();
45
+
const client = new Client({ ctx: ctx });
46
+
47
+
// Initialize connection
48
+
await ctx.connection();
49
+
50
+
await cb(client).finally(() => {
51
+
ctx.close();
52
+
});
53
+
}
+53
.fluentci/sdk/context.ts
+53
.fluentci/sdk/context.ts
···
1
+
import { GraphQLClient } from "../deps.ts";
2
+
3
+
import { initDefaultContext } from "./builder.ts";
4
+
5
+
interface ContextConfig {
6
+
client?: GraphQLClient;
7
+
}
8
+
9
+
/**
10
+
* Context abstracts the connection to the engine.
11
+
*
12
+
* It's required to implement the default global SDK.
13
+
* Its purpose is to store and returns the connection to the graphQL API, if
14
+
* no connection is set, it can create its own.
15
+
*
16
+
* This is also useful for lazy evaluation with the default global client,
17
+
* this one should only run the engine if it actually executes something.
18
+
*/
19
+
export class Context {
20
+
private _client?: GraphQLClient;
21
+
22
+
constructor(config?: ContextConfig) {
23
+
this._client = config?.client;
24
+
}
25
+
26
+
/**
27
+
* Returns a GraphQL client connected to the engine.
28
+
*
29
+
* If no client is set, it will create one.
30
+
*/
31
+
public async connection(): Promise<GraphQLClient> {
32
+
if (!this._client) {
33
+
const defaultCtx = await initDefaultContext();
34
+
this._client = defaultCtx._client as GraphQLClient;
35
+
}
36
+
37
+
return this._client;
38
+
}
39
+
40
+
/**
41
+
* Close the connection and the engine if this one was started by the node
42
+
* SDK.
43
+
*/
44
+
public close(): void {
45
+
// Reset client, so it can restart a new connection if necessary
46
+
this._client = undefined;
47
+
}
48
+
}
49
+
50
+
/**
51
+
* Expose a default context for the global client
52
+
*/
53
+
export const defaultContext = new Context();
+244
.fluentci/sdk/utils.ts
+244
.fluentci/sdk/utils.ts
···
1
+
// deno-lint-ignore-file no-explicit-any
2
+
import {
3
+
ClientError,
4
+
gql,
5
+
GraphQLClient,
6
+
GraphQLRequestError,
7
+
TooManyNestedObjectsError,
8
+
UnknownDaggerError,
9
+
NotAwaitedRequestError,
10
+
ExecError,
11
+
} from "../deps.ts";
12
+
13
+
import { Metadata, QueryTree } from "./client.gen.ts";
14
+
15
+
/**
16
+
* Format argument into GraphQL query format.
17
+
*/
18
+
function buildArgs(args: any): string {
19
+
const metadata: Metadata = args.__metadata || {};
20
+
21
+
// Remove unwanted quotes
22
+
const formatValue = (key: string, value: string) => {
23
+
// Special treatment for enumeration, they must be inserted without quotes
24
+
if (metadata[key]?.is_enum) {
25
+
return JSON.stringify(value).replace(/['"]+/g, "");
26
+
}
27
+
28
+
return JSON.stringify(value).replace(
29
+
/\{"[a-zA-Z]+":|,"[a-zA-Z]+":/gi,
30
+
(str) => {
31
+
return str.replace(/"/g, "");
32
+
}
33
+
);
34
+
};
35
+
36
+
if (args === undefined || args === null) {
37
+
return "";
38
+
}
39
+
40
+
const formattedArgs = Object.entries(args).reduce(
41
+
(acc: any, [key, value]) => {
42
+
// Ignore internal metadata key
43
+
if (key === "__metadata") {
44
+
return acc;
45
+
}
46
+
47
+
if (value !== undefined && value !== null) {
48
+
acc.push(`${key}: ${formatValue(key, value as string)}`);
49
+
}
50
+
51
+
return acc;
52
+
},
53
+
[]
54
+
);
55
+
56
+
if (formattedArgs.length === 0) {
57
+
return "";
58
+
}
59
+
60
+
return `(${formattedArgs})`;
61
+
}
62
+
63
+
/**
64
+
* Find QueryTree, convert them into GraphQl query
65
+
* then compute and return the result to the appropriate field
66
+
*/
67
+
async function computeNestedQuery(
68
+
query: QueryTree[],
69
+
client: GraphQLClient
70
+
): Promise<void> {
71
+
// Check if there is a nested queryTree to be executed
72
+
const isQueryTree = (value: any) => value["_queryTree"] !== undefined;
73
+
74
+
// Check if there is a nested array of queryTree to be executed
75
+
const isArrayQueryTree = (value: any[]) =>
76
+
value.every((v) => v instanceof Object && isQueryTree(v));
77
+
78
+
// Prepare query tree for final query by computing nested queries
79
+
// and building it with their results.
80
+
const computeQueryTree = async (value: any): Promise<string> => {
81
+
// Resolve sub queries if operation's args is a subquery
82
+
for (const op of value["_queryTree"]) {
83
+
await computeNestedQuery([op], client);
84
+
}
85
+
86
+
// push an id that will be used by the container
87
+
return buildQuery([
88
+
...value["_queryTree"],
89
+
{
90
+
operation: "id",
91
+
},
92
+
]);
93
+
};
94
+
95
+
// Remove all undefined args and assert args type
96
+
const queryToExec = query.filter((q): q is Required<QueryTree> => !!q.args);
97
+
98
+
for (const q of queryToExec) {
99
+
await Promise.all(
100
+
// Compute nested query for single object
101
+
Object.entries(q.args).map(async ([key, value]: any) => {
102
+
if (value instanceof Object && isQueryTree(value)) {
103
+
// push an id that will be used by the container
104
+
const getQueryTree = await computeQueryTree(value);
105
+
106
+
q.args[key] = await compute(getQueryTree, client);
107
+
}
108
+
109
+
// Compute nested query for array of object
110
+
if (Array.isArray(value) && isArrayQueryTree(value)) {
111
+
const tmp: any = q.args[key];
112
+
113
+
for (let i = 0; i < value.length; i++) {
114
+
// push an id that will be used by the container
115
+
const getQueryTree = await computeQueryTree(value[i]);
116
+
117
+
tmp[i] = await compute(getQueryTree, client);
118
+
}
119
+
120
+
q.args[key] = tmp;
121
+
}
122
+
})
123
+
);
124
+
}
125
+
}
126
+
127
+
/**
128
+
* Convert the queryTree into a GraphQL query
129
+
* @param q
130
+
* @returns
131
+
*/
132
+
export function buildQuery(q: QueryTree[]): string {
133
+
const query = q.reduce((acc, { operation, args }, i) => {
134
+
const qLen = q.length;
135
+
136
+
acc += ` ${operation} ${args ? `${buildArgs(args)}` : ""} ${
137
+
qLen - 1 !== i ? "{" : "}".repeat(qLen - 1)
138
+
}`;
139
+
140
+
return acc;
141
+
}, "");
142
+
143
+
return `{${query} }`;
144
+
}
145
+
146
+
/**
147
+
* Convert querytree into a Graphql query then compute it
148
+
* @param q | QueryTree[]
149
+
* @param client | GraphQLClient
150
+
* @returns
151
+
*/
152
+
export async function computeQuery<T>(
153
+
q: QueryTree[],
154
+
client: GraphQLClient
155
+
): Promise<T> {
156
+
await computeNestedQuery(q, client);
157
+
158
+
const query = buildQuery(q);
159
+
160
+
return await compute(query, client);
161
+
}
162
+
163
+
/**
164
+
* Return a Graphql query result flattened
165
+
* @param response any
166
+
* @returns
167
+
*/
168
+
export function queryFlatten<T>(response: any): T {
169
+
// Recursion break condition
170
+
// If our response is not an object or an array we assume we reached the value
171
+
if (!(response instanceof Object) || Array.isArray(response)) {
172
+
return response;
173
+
}
174
+
175
+
const keys = Object.keys(response);
176
+
177
+
if (keys.length != 1) {
178
+
// Dagger is currently expecting to only return one value
179
+
// If the response is nested in a way were more than one object is nested inside throw an error
180
+
throw new TooManyNestedObjectsError(
181
+
"Too many nested objects inside graphql response",
182
+
{ response: response }
183
+
);
184
+
}
185
+
186
+
const nestedKey = keys[0];
187
+
188
+
return queryFlatten(response[nestedKey]);
189
+
}
190
+
191
+
/**
192
+
* Send a GraphQL document to the server
193
+
* return a flatten result
194
+
* @hidden
195
+
*/
196
+
export async function compute<T>(
197
+
query: string,
198
+
client: GraphQLClient
199
+
): Promise<T> {
200
+
let computeQuery: Awaited<T>;
201
+
try {
202
+
computeQuery = await client.request(
203
+
gql`
204
+
${query}
205
+
`
206
+
);
207
+
} catch (e: any) {
208
+
if (e instanceof ClientError) {
209
+
const msg = e.response.errors?.[0]?.message ?? `API Error`;
210
+
const ext = e.response.errors?.[0]?.extensions;
211
+
212
+
if (ext?._type === "EXEC_ERROR") {
213
+
throw new ExecError(msg, {
214
+
cmd: (ext.cmd as string[]) ?? [],
215
+
exitCode: (ext.exitCode as number) ?? -1,
216
+
stdout: (ext.stdout as string) ?? "",
217
+
stderr: (ext.stderr as string) ?? "",
218
+
});
219
+
}
220
+
221
+
throw new GraphQLRequestError(msg, {
222
+
request: e.request,
223
+
response: e.response,
224
+
cause: e,
225
+
});
226
+
}
227
+
228
+
// Looking for connection error in case the function has not been awaited.
229
+
if (e.errno === "ECONNREFUSED") {
230
+
throw new NotAwaitedRequestError(
231
+
"Encountered an error while requesting data via graphql through a synchronous call. Make sure the function called is awaited.",
232
+
{ cause: e }
233
+
);
234
+
}
235
+
236
+
// Just throw the unknown error
237
+
throw new UnknownDaggerError(
238
+
"Encountered an unknown error while requesting data via graphql",
239
+
{ cause: e }
240
+
);
241
+
}
242
+
243
+
return queryFlatten(computeQuery);
244
+
}
+2
-2
.fluentci/src/dagger/index.ts
+2
-2
.fluentci/src/dagger/index.ts
+138
-149
.fluentci/src/dagger/jobs.ts
+138
-149
.fluentci/src/dagger/jobs.ts
···
1
-
import Client, { connect } from "../../deps.ts";
2
-
import { buildRustFlags } from "./lib.ts";
1
+
import { dag } from "../../sdk/client.gen.ts";
2
+
import { buildRustFlags, getDirectory } from "./lib.ts";
3
3
4
4
export enum Job {
5
5
test = "test",
···
9
9
export const exclude = ["target", ".git", ".devbox", ".fluentci"];
10
10
11
11
export const test = async (src = ".", options: string[] = []) => {
12
-
await connect(async (client: Client) => {
13
-
const context = client.host().directory(src);
14
-
const ctr = client
15
-
.pipeline(Job.test)
16
-
.container()
17
-
.from("rust:latest")
18
-
.withDirectory("/app", context, { exclude })
19
-
.withWorkdir("/app")
20
-
.withMountedCache("/app/target", client.cacheVolume("target"))
21
-
.withMountedCache("/root/cargo/registry", client.cacheVolume("registry"))
22
-
.withExec(["cargo", "test", ...options]);
23
-
24
-
const result = await ctr.stdout();
12
+
const context = await getDirectory(src);
13
+
const ctr = dag
14
+
.pipeline(Job.test)
15
+
.container()
16
+
.from("rust:latest")
17
+
.withDirectory("/app", context, { exclude })
18
+
.withWorkdir("/app")
19
+
.withMountedCache("/app/target", dag.cacheVolume("target"))
20
+
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
21
+
.withExec(["cargo", "test", ...options]);
25
22
26
-
console.log(result);
27
-
});
28
-
return "done";
23
+
return ctr.stdout();
29
24
};
30
25
31
26
export const build = async (src = ".") => {
32
27
const rustflags = buildRustFlags();
33
-
await connect(async (client: Client) => {
34
-
const context = client.host().directory(src);
35
-
const ctr = client
36
-
.pipeline(Job.build)
37
-
.container()
38
-
.from("rust:1.76-bullseye")
39
-
.withExec(["dpkg", "--add-architecture", "armhf"])
40
-
.withExec(["dpkg", "--add-architecture", "arm64"])
41
-
.withExec(["apt-get", "update"])
42
-
.withExec([
43
-
"apt-get",
44
-
"install",
45
-
"-y",
46
-
"build-essential",
47
-
"libasound2-dev",
48
-
"protobuf-compiler",
49
-
])
50
-
.withExec([
51
-
"apt-get",
52
-
"install",
53
-
"-y",
54
-
"-qq",
55
-
"gcc-arm-linux-gnueabihf",
56
-
"libc6-armhf-cross",
57
-
"libc6-dev-armhf-cross",
58
-
"gcc-aarch64-linux-gnu",
59
-
"libc6-arm64-cross",
60
-
"libc6-dev-arm64-cross",
61
-
"libc6-armel-cross",
62
-
"libc6-dev-armel-cross",
63
-
"binutils-arm-linux-gnueabi",
64
-
"gcc-arm-linux-gnueabi",
65
-
"libncurses5-dev",
66
-
"bison",
67
-
"flex",
68
-
"libssl-dev",
69
-
"bc",
70
-
"pkg-config",
71
-
"libudev-dev",
72
-
])
73
-
.withExec(["mkdir", "-p", "/build/sysroot"])
74
-
.withExec([
75
-
"apt-get",
76
-
"download",
77
-
"libasound2:armhf",
78
-
"libasound2-dev:armhf",
79
-
"libasound2:arm64",
80
-
"libasound2-dev:arm64",
81
-
])
82
-
.withExec([
83
-
"dpkg",
84
-
"-x",
85
-
"libasound2-dev_1.2.4-1.1_arm64.deb",
86
-
"/build/sysroot/",
87
-
])
88
-
.withExec([
89
-
"dpkg",
90
-
"-x",
91
-
"libasound2_1.2.4-1.1_arm64.deb",
92
-
"/build/sysroot/",
93
-
])
94
-
.withExec([
95
-
"dpkg",
96
-
"-x",
97
-
"libasound2-dev_1.2.4-1.1_armhf.deb",
98
-
"/build/sysroot/",
99
-
])
100
-
.withExec([
101
-
"dpkg",
102
-
"-x",
103
-
"libasound2_1.2.4-1.1_armhf.deb",
104
-
"/build/sysroot/",
105
-
])
106
-
.withDirectory("/app", context, { exclude })
107
-
.withWorkdir("/app")
108
-
.withMountedCache("/app/target", client.cacheVolume("target"))
109
-
.withMountedCache("/root/cargo/registry", client.cacheVolume("registry"))
110
-
.withMountedCache("/assets", client.cacheVolume("gh-release-assets"))
111
-
.withEnvVariable("RUSTFLAGS", rustflags)
112
-
.withEnvVariable(
113
-
"PKG_CONFIG_ALLOW_CROSS",
114
-
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu" ? "1" : "0"
115
-
)
116
-
.withEnvVariable(
117
-
"C_INCLUDE_PATH",
118
-
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu"
119
-
? "/build/sysroot/usr/include"
120
-
: "/usr/include"
121
-
)
122
-
.withEnvVariable("TAG", Deno.env.get("TAG") || "latest")
123
-
.withEnvVariable(
124
-
"TARGET",
125
-
Deno.env.get("TARGET") || "x86_64-unknown-linux-gnu"
126
-
)
127
-
.withExec(["sh", "-c", "rustup target add $TARGET"])
128
-
.withExec(["sh", "-c", "cargo build --release --target $TARGET"])
129
-
.withExec(["sh", "-c", "cp target/${TARGET}/release/tunein ."])
130
-
.withExec([
131
-
"sh",
132
-
"-c",
133
-
"tar czvf /assets/tunein_${TAG}_${TARGET}.tar.gz tunein",
134
-
])
135
-
.withExec([
136
-
"sh",
137
-
"-c",
138
-
"shasum -a 256 /assets/tunein_${TAG}_${TARGET}.tar.gz > /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256",
139
-
])
140
-
.withExec(["sh", "-c", "cp /assets/tunein_${TAG}_${TARGET}.tar.gz ."])
141
-
.withExec([
142
-
"sh",
143
-
"-c",
144
-
"cp /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256 .",
145
-
]);
28
+
const context = await getDirectory(src);
29
+
const ctr = dag
30
+
.pipeline(Job.build)
31
+
.container()
32
+
.from("rust:1.76-bullseye")
33
+
.withExec(["dpkg", "--add-architecture", "armhf"])
34
+
.withExec(["dpkg", "--add-architecture", "arm64"])
35
+
.withExec(["apt-get", "update"])
36
+
.withExec([
37
+
"apt-get",
38
+
"install",
39
+
"-y",
40
+
"build-essential",
41
+
"libasound2-dev",
42
+
"protobuf-compiler",
43
+
])
44
+
.withExec([
45
+
"apt-get",
46
+
"install",
47
+
"-y",
48
+
"-qq",
49
+
"gcc-arm-linux-gnueabihf",
50
+
"libc6-armhf-cross",
51
+
"libc6-dev-armhf-cross",
52
+
"gcc-aarch64-linux-gnu",
53
+
"libc6-arm64-cross",
54
+
"libc6-dev-arm64-cross",
55
+
"libc6-armel-cross",
56
+
"libc6-dev-armel-cross",
57
+
"binutils-arm-linux-gnueabi",
58
+
"gcc-arm-linux-gnueabi",
59
+
"libncurses5-dev",
60
+
"bison",
61
+
"flex",
62
+
"libssl-dev",
63
+
"bc",
64
+
"pkg-config",
65
+
"libudev-dev",
66
+
])
67
+
.withExec(["mkdir", "-p", "/build/sysroot"])
68
+
.withExec([
69
+
"apt-get",
70
+
"download",
71
+
"libasound2:armhf",
72
+
"libasound2-dev:armhf",
73
+
"libasound2:arm64",
74
+
"libasound2-dev:arm64",
75
+
])
76
+
.withExec([
77
+
"dpkg",
78
+
"-x",
79
+
"libasound2-dev_1.2.4-1.1_arm64.deb",
80
+
"/build/sysroot/",
81
+
])
82
+
.withExec([
83
+
"dpkg",
84
+
"-x",
85
+
"libasound2_1.2.4-1.1_arm64.deb",
86
+
"/build/sysroot/",
87
+
])
88
+
.withExec([
89
+
"dpkg",
90
+
"-x",
91
+
"libasound2-dev_1.2.4-1.1_armhf.deb",
92
+
"/build/sysroot/",
93
+
])
94
+
.withExec([
95
+
"dpkg",
96
+
"-x",
97
+
"libasound2_1.2.4-1.1_armhf.deb",
98
+
"/build/sysroot/",
99
+
])
100
+
.withDirectory("/app", context, { exclude })
101
+
.withWorkdir("/app")
102
+
.withMountedCache("/app/target", dag.cacheVolume("target"))
103
+
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
104
+
.withMountedCache("/assets", dag.cacheVolume("gh-release-assets"))
105
+
.withEnvVariable("RUSTFLAGS", rustflags)
106
+
.withEnvVariable(
107
+
"PKG_CONFIG_ALLOW_CROSS",
108
+
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu" ? "1" : "0"
109
+
)
110
+
.withEnvVariable(
111
+
"C_INCLUDE_PATH",
112
+
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu"
113
+
? "/build/sysroot/usr/include"
114
+
: "/usr/include"
115
+
)
116
+
.withEnvVariable("TAG", Deno.env.get("TAG") || "latest")
117
+
.withEnvVariable(
118
+
"TARGET",
119
+
Deno.env.get("TARGET") || "x86_64-unknown-linux-gnu"
120
+
)
121
+
.withExec(["sh", "-c", "rustup target add $TARGET"])
122
+
.withExec(["sh", "-c", "cargo build --release --target $TARGET"])
123
+
.withExec(["sh", "-c", "cp target/${TARGET}/release/tunein ."])
124
+
.withExec([
125
+
"sh",
126
+
"-c",
127
+
"tar czvf /assets/tunein_${TAG}_${TARGET}.tar.gz tunein",
128
+
])
129
+
.withExec([
130
+
"sh",
131
+
"-c",
132
+
"shasum -a 256 /assets/tunein_${TAG}_${TARGET}.tar.gz > /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256",
133
+
])
134
+
.withExec(["sh", "-c", "cp /assets/tunein_${TAG}_${TARGET}.tar.gz ."])
135
+
.withExec([
136
+
"sh",
137
+
"-c",
138
+
"cp /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256 .",
139
+
]);
146
140
147
-
await ctr.stdout();
141
+
const exe = await ctr.file(
142
+
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`
143
+
);
144
+
await exe.export(
145
+
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`
146
+
);
148
147
149
-
const exe = await ctr.file(
150
-
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`
151
-
);
152
-
await exe.export(
153
-
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`
154
-
);
155
-
156
-
const sha = await ctr.file(
157
-
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get(
158
-
"TARGET"
159
-
)}.tar.gz.sha256`
160
-
);
161
-
await sha.export(
162
-
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz.sha256`
163
-
);
164
-
});
165
-
return "Done";
148
+
const sha = await ctr.file(
149
+
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz.sha256`
150
+
);
151
+
await sha.export(
152
+
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz.sha256`
153
+
);
154
+
return ctr.stdout();
166
155
};
167
156
168
157
export type JobExec = (src?: string) =>
+25
.fluentci/src/dagger/lib.ts
+25
.fluentci/src/dagger/lib.ts
···
1
+
import { dag } from "../../sdk/client.gen.ts";
2
+
import { Directory, DirectoryID } from "../../deps.ts";
3
+
4
+
export const getDirectory = async (
5
+
src: string | Directory | undefined = "."
6
+
) => {
7
+
if (src instanceof Directory) {
8
+
return src;
9
+
}
10
+
if (typeof src === "string") {
11
+
try {
12
+
const directory = dag.loadDirectoryFromID(src as DirectoryID);
13
+
await directory.id();
14
+
return directory;
15
+
} catch (_) {
16
+
return dag.host
17
+
? dag.host().directory(src)
18
+
: dag.currentModule().source().directory(src);
19
+
}
20
+
}
21
+
return dag.host
22
+
? dag.host().directory(src)
23
+
: dag.currentModule().source().directory(src);
24
+
};
25
+
1
26
export function buildRustFlags(): string {
2
27
let rustflags = "";
3
28
switch (Deno.env.get("TARGET")) {
+1
-6
.fluentci/src/dagger/pipeline.ts
+1
-6
.fluentci/src/dagger/pipeline.ts
···
1
-
import { uploadContext } from "../../deps.ts";
2
1
import * as jobs from "./jobs.ts";
3
2
4
-
const { build, test, exclude } = jobs;
3
+
const { build, test } = jobs;
5
4
6
5
export default async function pipeline(src = ".", args: string[] = []) {
7
-
if (Deno.env.has("FLUENTCI_SESSION_ID")) {
8
-
await uploadContext(src, exclude);
9
-
}
10
-
11
6
if (args.length > 0) {
12
7
await runSpecificJobs(args);
13
8
return;
-13
.fluentci/src/dagger/queries.ts
-13
.fluentci/src/dagger/queries.ts
-36
.fluentci/src/dagger/schema.ts
-36
.fluentci/src/dagger/schema.ts
···
1
-
import {
2
-
queryType,
3
-
makeSchema,
4
-
dirname,
5
-
join,
6
-
resolve,
7
-
stringArg,
8
-
nonNull,
9
-
} from "../../deps.ts";
10
-
11
-
import { test, build } from "./jobs.ts";
12
-
13
-
const Query = queryType({
14
-
definition(t) {
15
-
t.string("test", {
16
-
args: {
17
-
src: nonNull(stringArg()),
18
-
},
19
-
resolve: async (_root, args, _ctx) => await test(args.src),
20
-
});
21
-
t.string("build", {
22
-
args: {
23
-
src: nonNull(stringArg()),
24
-
},
25
-
resolve: async (_root, args, _ctx) => await build(args.src),
26
-
});
27
-
},
28
-
});
29
-
30
-
export const schema = makeSchema({
31
-
types: [Query],
32
-
outputs: {
33
-
schema: resolve(join(dirname(".."), dirname(".."), "schema.graphql")),
34
-
typegen: resolve(join(dirname(".."), dirname(".."), "gen", "nexus.ts")),
35
-
},
36
-
});