@dagger.io/dagger 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +72 -1
  2. package/dist/api/client.gen.d.ts +332 -126
  3. package/dist/api/client.gen.d.ts.map +1 -1
  4. package/dist/api/client.gen.js +355 -272
  5. package/dist/api/utils.d.ts +1 -1
  6. package/dist/api/utils.d.ts.map +1 -1
  7. package/dist/api/utils.js +63 -43
  8. package/dist/common/errors/DaggerSDKError.d.ts +32 -0
  9. package/dist/common/errors/DaggerSDKError.d.ts.map +1 -0
  10. package/dist/common/errors/DaggerSDKError.js +22 -0
  11. package/dist/common/errors/DockerImageRefValidationError.d.ts +22 -0
  12. package/dist/common/errors/DockerImageRefValidationError.d.ts.map +1 -0
  13. package/dist/common/errors/DockerImageRefValidationError.js +17 -0
  14. package/dist/common/errors/EngineSessionConnectParamsParseError.d.ts +21 -0
  15. package/dist/common/errors/EngineSessionConnectParamsParseError.d.ts.map +1 -0
  16. package/dist/common/errors/EngineSessionConnectParamsParseError.js +16 -0
  17. package/dist/common/errors/EngineSessionConnectionTimeoutError.d.ts +21 -0
  18. package/dist/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +1 -0
  19. package/dist/common/errors/EngineSessionConnectionTimeoutError.js +16 -0
  20. package/dist/common/errors/EngineSessionEOFErrorOptions.d.ts +16 -0
  21. package/dist/common/errors/EngineSessionEOFErrorOptions.d.ts.map +1 -0
  22. package/dist/common/errors/EngineSessionEOFErrorOptions.js +16 -0
  23. package/dist/common/errors/GraphQLRequestError.d.ts +27 -0
  24. package/dist/common/errors/GraphQLRequestError.d.ts.map +1 -0
  25. package/dist/common/errors/GraphQLRequestError.js +17 -0
  26. package/dist/common/errors/InitEngineSessionBinaryError.d.ts +13 -0
  27. package/dist/common/errors/InitEngineSessionBinaryError.d.ts.map +1 -0
  28. package/dist/common/errors/InitEngineSessionBinaryError.js +15 -0
  29. package/dist/common/errors/TooManyNestedObjectsError.d.ts +21 -0
  30. package/dist/common/errors/TooManyNestedObjectsError.d.ts.map +1 -0
  31. package/dist/common/errors/TooManyNestedObjectsError.js +16 -0
  32. package/dist/common/errors/UnknownDaggerError.d.ts +13 -0
  33. package/dist/common/errors/UnknownDaggerError.d.ts.map +1 -0
  34. package/dist/common/errors/UnknownDaggerError.js +15 -0
  35. package/dist/common/errors/errors-codes.d.ts +43 -0
  36. package/dist/common/errors/errors-codes.d.ts.map +1 -0
  37. package/dist/common/errors/errors-codes.js +35 -0
  38. package/dist/common/errors/index.d.ts +11 -0
  39. package/dist/common/errors/index.d.ts.map +1 -0
  40. package/dist/common/errors/index.js +10 -0
  41. package/dist/common/utils.d.ts +65 -0
  42. package/dist/common/utils.d.ts.map +1 -0
  43. package/dist/common/utils.js +2 -0
  44. package/dist/connect.d.ts +25 -3
  45. package/dist/connect.d.ts.map +1 -1
  46. package/dist/connect.js +29 -5
  47. package/dist/index.d.ts +1 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +0 -1
  50. package/dist/provisioning/{docker-provision/image.d.ts → bin.d.ts} +31 -29
  51. package/dist/provisioning/bin.d.ts.map +1 -0
  52. package/dist/provisioning/bin.js +328 -0
  53. package/dist/provisioning/default.d.ts +1 -1
  54. package/dist/provisioning/default.d.ts.map +1 -1
  55. package/dist/provisioning/default.js +1 -2
  56. package/dist/provisioning/engineconn.d.ts +1 -1
  57. package/dist/provisioning/engineconn.d.ts.map +1 -1
  58. package/dist/provisioning/index.d.ts +1 -2
  59. package/dist/provisioning/index.d.ts.map +1 -1
  60. package/dist/provisioning/index.js +1 -2
  61. package/package.json +19 -15
  62. package/dist/provisioning/bin/bin.d.ts +0 -21
  63. package/dist/provisioning/bin/bin.d.ts.map +0 -1
  64. package/dist/provisioning/bin/bin.js +0 -112
  65. package/dist/provisioning/bin/index.d.ts +0 -2
  66. package/dist/provisioning/bin/index.d.ts.map +0 -1
  67. package/dist/provisioning/bin/index.js +0 -1
  68. package/dist/provisioning/docker-provision/image.d.ts.map +0 -1
  69. package/dist/provisioning/docker-provision/image.js +0 -269
  70. package/dist/provisioning/docker-provision/index.d.ts +0 -2
  71. package/dist/provisioning/docker-provision/index.d.ts.map +0 -1
  72. package/dist/provisioning/docker-provision/index.js +0 -1
  73. package/dist/provisioning/http/http.d.ts +0 -14
  74. package/dist/provisioning/http/http.d.ts.map +0 -1
  75. package/dist/provisioning/http/http.js +0 -33
  76. package/dist/provisioning/http/index.d.ts +0 -2
  77. package/dist/provisioning/http/index.d.ts.map +0 -1
  78. package/dist/provisioning/http/index.js +0 -1
  79. package/dist/provisioning/provisioner.d.ts +0 -11
  80. package/dist/provisioning/provisioner.d.ts.map +0 -1
  81. package/dist/provisioning/provisioner.js +0 -26
@@ -1,7 +1,3 @@
1
- /**
2
- * This file was auto-generated by `cloak clientgen`.
3
- * Do not make direct changes to the file.
4
- */
5
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -11,16 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
12
8
  });
13
9
  };
10
+ /**
11
+ * This file was auto-generated by `client-gen`.
12
+ * Do not make direct changes to the file.
13
+ */
14
14
  import { GraphQLClient } from "graphql-request";
15
- import { queryBuilder } from "./utils.js";
15
+ import { computeQuery } from "./utils.js";
16
16
  class BaseClient {
17
17
  /**
18
18
  * @hidden
19
19
  */
20
- constructor({ queryTree, host } = {}) {
20
+ constructor({ queryTree, host, sessionToken } = {}) {
21
21
  this._queryTree = queryTree || [];
22
22
  this.clientHost = host || "127.0.0.1:8080";
23
- this.client = new GraphQLClient(`http://${host}/query`);
23
+ this.sessionToken = sessionToken || "";
24
+ this.client = new GraphQLClient(`http://${host}/query`, {
25
+ headers: {
26
+ Authorization: "Basic " + Buffer.from(sessionToken + ":").toString("base64"),
27
+ },
28
+ });
24
29
  }
25
30
  /**
26
31
  * @hidden
@@ -30,58 +35,61 @@ class BaseClient {
30
35
  }
31
36
  }
32
37
  /**
33
- * A directory whose contents persist across runs
38
+ * A directory whose contents persist across runs.
34
39
  */
35
40
  export class CacheVolume extends BaseClient {
36
41
  id() {
37
42
  return __awaiter(this, void 0, void 0, function* () {
38
- this._queryTree = [
43
+ const response = yield computeQuery([
39
44
  ...this._queryTree,
40
45
  {
41
46
  operation: "id",
42
47
  },
43
- ];
44
- const response = yield queryBuilder(this._queryTree, this.client);
48
+ ], this.client);
45
49
  return response;
46
50
  });
47
51
  }
48
52
  }
49
53
  /**
50
- * An OCI-compatible container, also known as a docker container
54
+ * An OCI-compatible container, also known as a docker container.
51
55
  */
52
56
  export class Container extends BaseClient {
53
57
  /**
54
- * Initialize this container from a Dockerfile build
58
+ * Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.
59
+ * @param context Directory context used by the Dockerfile.
60
+ * @param opts.dockerfile Path to the Dockerfile to use.
61
+ Defaults to './Dockerfile'.
62
+ * @param opts.buildArgs Additional build arguments.
55
63
  */
56
- build(context, dockerfile) {
64
+ build(context, opts) {
57
65
  return new Container({
58
66
  queryTree: [
59
67
  ...this._queryTree,
60
68
  {
61
69
  operation: "build",
62
- args: { context, dockerfile },
70
+ args: Object.assign({ context }, opts),
63
71
  },
64
72
  ],
65
73
  host: this.clientHost,
74
+ sessionToken: this.sessionToken,
66
75
  });
67
76
  }
68
77
  /**
69
- * Default arguments for future commands
78
+ * Retrieves default arguments for future commands.
70
79
  */
71
80
  defaultArgs() {
72
81
  return __awaiter(this, void 0, void 0, function* () {
73
- this._queryTree = [
82
+ const response = yield computeQuery([
74
83
  ...this._queryTree,
75
84
  {
76
85
  operation: "defaultArgs",
77
86
  },
78
- ];
79
- const response = yield queryBuilder(this._queryTree, this.client);
87
+ ], this.client);
80
88
  return response;
81
89
  });
82
90
  }
83
91
  /**
84
- * Retrieve a directory at the given path. Mounts are included.
92
+ * Retrieves a directory at the given path. Mounts are included.
85
93
  */
86
94
  directory(path) {
87
95
  return new Directory({
@@ -93,75 +101,74 @@ export class Container extends BaseClient {
93
101
  },
94
102
  ],
95
103
  host: this.clientHost,
104
+ sessionToken: this.sessionToken,
96
105
  });
97
106
  }
98
107
  /**
99
- * Entrypoint to be prepended to the arguments of all commands
108
+ * Retrieves entrypoint to be prepended to the arguments of all commands.
100
109
  */
101
110
  entrypoint() {
102
111
  return __awaiter(this, void 0, void 0, function* () {
103
- this._queryTree = [
112
+ const response = yield computeQuery([
104
113
  ...this._queryTree,
105
114
  {
106
115
  operation: "entrypoint",
107
116
  },
108
- ];
109
- const response = yield queryBuilder(this._queryTree, this.client);
117
+ ], this.client);
110
118
  return response;
111
119
  });
112
120
  }
113
121
  /**
114
- * The value of the specified environment variable
122
+ * Retrieves the value of the specified environment variable.
115
123
  */
116
124
  envVariable(name) {
117
125
  return __awaiter(this, void 0, void 0, function* () {
118
- this._queryTree = [
126
+ const response = yield computeQuery([
119
127
  ...this._queryTree,
120
128
  {
121
129
  operation: "envVariable",
122
130
  args: { name },
123
131
  },
124
- ];
125
- const response = yield queryBuilder(this._queryTree, this.client);
132
+ ], this.client);
126
133
  return response;
127
134
  });
128
135
  }
129
136
  /**
130
- * A list of environment variables passed to commands
137
+ * Retrieves the list of environment variables passed to commands.
131
138
  */
132
139
  envVariables() {
133
140
  return __awaiter(this, void 0, void 0, function* () {
134
- this._queryTree = [
141
+ const response = yield computeQuery([
135
142
  ...this._queryTree,
136
143
  {
137
144
  operation: "envVariables",
138
145
  },
139
- ];
140
- const response = yield queryBuilder(this._queryTree, this.client);
146
+ ], this.client);
141
147
  return response;
142
148
  });
143
149
  }
144
150
  /**
145
- * This container after executing the specified command inside it
146
- *
151
+ * Retrieves this container after executing the specified command inside it.
152
+ * @param opts.args Command to run instead of the container's default command.
153
+ * @param opts.stdin Content to write to the command's standard input before closing.
154
+ * @param opts.redirectStdout Redirect the command's standard output to a file in the container.
155
+ * @param opts.redirectStderr Redirect the command's standard error to a file in the container.
156
+ * @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
157
+ Do not use this option unless you trust the command being executed.
158
+ The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
147
159
  * @deprecated Replaced by withExec.
148
160
  */
149
- exec(args, stdin, redirectStdout, redirectStderr, experimentalPrivilegedNesting) {
161
+ exec(opts) {
150
162
  return new Container({
151
163
  queryTree: [
152
164
  ...this._queryTree,
153
165
  {
154
166
  operation: "exec",
155
- args: {
156
- args,
157
- stdin,
158
- redirectStdout,
159
- redirectStderr,
160
- experimentalPrivilegedNesting,
161
- },
167
+ args: Object.assign({}, opts),
162
168
  },
163
169
  ],
164
170
  host: this.clientHost,
171
+ sessionToken: this.sessionToken,
165
172
  });
166
173
  }
167
174
  /**
@@ -170,34 +177,37 @@ export class Container extends BaseClient {
170
177
  */
171
178
  exitCode() {
172
179
  return __awaiter(this, void 0, void 0, function* () {
173
- this._queryTree = [
180
+ const response = yield computeQuery([
174
181
  ...this._queryTree,
175
182
  {
176
183
  operation: "exitCode",
177
184
  },
178
- ];
179
- const response = yield queryBuilder(this._queryTree, this.client);
185
+ ], this.client);
180
186
  return response;
181
187
  });
182
188
  }
183
189
  /**
184
- * Write the container as an OCI tarball to the destination file path on the host
190
+ * Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants.
191
+ * Return true on success.
192
+ * @param path Host's destination path.
193
+ Path can be relative to the engine's workdir or absolute.
194
+ * @param opts.platformVariants Identifiers for other platform specific containers.
195
+ Used for multi-platform image.
185
196
  */
186
- export(path, platformVariants) {
197
+ export(path, opts) {
187
198
  return __awaiter(this, void 0, void 0, function* () {
188
- this._queryTree = [
199
+ const response = yield computeQuery([
189
200
  ...this._queryTree,
190
201
  {
191
202
  operation: "export",
192
- args: { path, platformVariants },
203
+ args: Object.assign({ path }, opts),
193
204
  },
194
- ];
195
- const response = yield queryBuilder(this._queryTree, this.client);
205
+ ], this.client);
196
206
  return response;
197
207
  });
198
208
  }
199
209
  /**
200
- * Retrieve a file at the given path. Mounts are included.
210
+ * Retrieves a file at the given path. Mounts are included.
201
211
  */
202
212
  file(path) {
203
213
  return new File({
@@ -209,10 +219,13 @@ export class Container extends BaseClient {
209
219
  },
210
220
  ],
211
221
  host: this.clientHost,
222
+ sessionToken: this.sessionToken,
212
223
  });
213
224
  }
214
225
  /**
215
- * Initialize this container from the base image published at the given address
226
+ * Initializes this container from the base image published at the given address.
227
+ * @param address Image's address from its registry.
228
+ Formatted as {host}/{user}/{repo}:{tag} (e.g. docker.io/dagger/dagger:main).
216
229
  */
217
230
  from(address) {
218
231
  return new Container({
@@ -224,11 +237,11 @@ export class Container extends BaseClient {
224
237
  },
225
238
  ],
226
239
  host: this.clientHost,
240
+ sessionToken: this.sessionToken,
227
241
  });
228
242
  }
229
243
  /**
230
- * This container's root filesystem. Mounts are not included.
231
- *
244
+ * Retrieves this container's root filesystem. Mounts are not included.
232
245
  * @deprecated Replaced by rootfs.
233
246
  */
234
247
  fs() {
@@ -240,71 +253,72 @@ export class Container extends BaseClient {
240
253
  },
241
254
  ],
242
255
  host: this.clientHost,
256
+ sessionToken: this.sessionToken,
243
257
  });
244
258
  }
245
259
  /**
246
- * A unique identifier for this container
260
+ * A unique identifier for this container.
247
261
  */
248
262
  id() {
249
263
  return __awaiter(this, void 0, void 0, function* () {
250
- this._queryTree = [
264
+ const response = yield computeQuery([
251
265
  ...this._queryTree,
252
266
  {
253
267
  operation: "id",
254
268
  },
255
- ];
256
- const response = yield queryBuilder(this._queryTree, this.client);
269
+ ], this.client);
257
270
  return response;
258
271
  });
259
272
  }
260
273
  /**
261
- * List of paths where a directory is mounted
274
+ * Retrieves the list of paths where a directory is mounted.
262
275
  */
263
276
  mounts() {
264
277
  return __awaiter(this, void 0, void 0, function* () {
265
- this._queryTree = [
278
+ const response = yield computeQuery([
266
279
  ...this._queryTree,
267
280
  {
268
281
  operation: "mounts",
269
282
  },
270
- ];
271
- const response = yield queryBuilder(this._queryTree, this.client);
283
+ ], this.client);
272
284
  return response;
273
285
  });
274
286
  }
275
287
  /**
276
- * The platform this container executes and publishes as
288
+ * The platform this container executes and publishes as.
277
289
  */
278
290
  platform() {
279
291
  return __awaiter(this, void 0, void 0, function* () {
280
- this._queryTree = [
292
+ const response = yield computeQuery([
281
293
  ...this._queryTree,
282
294
  {
283
295
  operation: "platform",
284
296
  },
285
- ];
286
- const response = yield queryBuilder(this._queryTree, this.client);
297
+ ], this.client);
287
298
  return response;
288
299
  });
289
300
  }
290
301
  /**
291
- * Publish this container as a new image, returning a fully qualified ref
302
+ * Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref.
303
+ * @param address Registry's address to publish the image to.
304
+ Formatted as {host}/{user}/{repo}:{tag} (e.g. docker.io/dagger/dagger:main).
305
+ * @param opts.platformVariants Identifiers for other platform specific containers.
306
+ Used for multi-platform image.
292
307
  */
293
- publish(address, platformVariants) {
308
+ publish(address, opts) {
294
309
  return __awaiter(this, void 0, void 0, function* () {
295
- this._queryTree = [
310
+ const response = yield computeQuery([
296
311
  ...this._queryTree,
297
312
  {
298
313
  operation: "publish",
299
- args: { address, platformVariants },
314
+ args: Object.assign({ address }, opts),
300
315
  },
301
- ];
302
- const response = yield queryBuilder(this._queryTree, this.client);
316
+ ], this.client);
303
317
  return response;
304
318
  });
305
319
  }
306
320
  /**
307
- * This container's root filesystem. Mounts are not included.
321
+ * Retrieves this container's root filesystem. Mounts are not included.
308
322
  */
309
323
  rootfs() {
310
324
  return new Directory({
@@ -315,6 +329,7 @@ export class Container extends BaseClient {
315
329
  },
316
330
  ],
317
331
  host: this.clientHost,
332
+ sessionToken: this.sessionToken,
318
333
  });
319
334
  }
320
335
  /**
@@ -323,13 +338,12 @@ export class Container extends BaseClient {
323
338
  */
324
339
  stderr() {
325
340
  return __awaiter(this, void 0, void 0, function* () {
326
- this._queryTree = [
341
+ const response = yield computeQuery([
327
342
  ...this._queryTree,
328
343
  {
329
344
  operation: "stderr",
330
345
  },
331
- ];
332
- const response = yield queryBuilder(this._queryTree, this.client);
346
+ ], this.client);
333
347
  return response;
334
348
  });
335
349
  }
@@ -339,63 +353,63 @@ export class Container extends BaseClient {
339
353
  */
340
354
  stdout() {
341
355
  return __awaiter(this, void 0, void 0, function* () {
342
- this._queryTree = [
356
+ const response = yield computeQuery([
343
357
  ...this._queryTree,
344
358
  {
345
359
  operation: "stdout",
346
360
  },
347
- ];
348
- const response = yield queryBuilder(this._queryTree, this.client);
361
+ ], this.client);
349
362
  return response;
350
363
  });
351
364
  }
352
365
  /**
353
- * The user to be set for all commands
366
+ * Retrieves the user to be set for all commands.
354
367
  */
355
368
  user() {
356
369
  return __awaiter(this, void 0, void 0, function* () {
357
- this._queryTree = [
370
+ const response = yield computeQuery([
358
371
  ...this._queryTree,
359
372
  {
360
373
  operation: "user",
361
374
  },
362
- ];
363
- const response = yield queryBuilder(this._queryTree, this.client);
375
+ ], this.client);
364
376
  return response;
365
377
  });
366
378
  }
367
379
  /**
368
- * Configures default arguments for future commands
380
+ * Configures default arguments for future commands.
369
381
  */
370
- withDefaultArgs(args) {
382
+ withDefaultArgs(opts) {
371
383
  return new Container({
372
384
  queryTree: [
373
385
  ...this._queryTree,
374
386
  {
375
387
  operation: "withDefaultArgs",
376
- args: { args },
388
+ args: Object.assign({}, opts),
377
389
  },
378
390
  ],
379
391
  host: this.clientHost,
392
+ sessionToken: this.sessionToken,
380
393
  });
381
394
  }
382
395
  /**
383
- * This container plus a directory written at the given path
396
+ * Retrieves this container plus a directory written at the given path.
384
397
  */
385
- withDirectory(path, directory, exclude, include) {
398
+ withDirectory(path, directory, opts) {
386
399
  return new Container({
387
400
  queryTree: [
388
401
  ...this._queryTree,
389
402
  {
390
403
  operation: "withDirectory",
391
- args: { path, directory, exclude, include },
404
+ args: Object.assign({ path, directory }, opts),
392
405
  },
393
406
  ],
394
407
  host: this.clientHost,
408
+ sessionToken: this.sessionToken,
395
409
  });
396
410
  }
397
411
  /**
398
- * This container but with a different command entrypoint
412
+ * Retrieves this container but with a different command entrypoint.
399
413
  */
400
414
  withEntrypoint(args) {
401
415
  return new Container({
@@ -407,10 +421,11 @@ export class Container extends BaseClient {
407
421
  },
408
422
  ],
409
423
  host: this.clientHost,
424
+ sessionToken: this.sessionToken,
410
425
  });
411
426
  }
412
427
  /**
413
- * This container plus the given environment variable
428
+ * Retrieves this container plus the given environment variable.
414
429
  */
415
430
  withEnvVariable(name, value) {
416
431
  return new Container({
@@ -422,32 +437,34 @@ export class Container extends BaseClient {
422
437
  },
423
438
  ],
424
439
  host: this.clientHost,
440
+ sessionToken: this.sessionToken,
425
441
  });
426
442
  }
427
443
  /**
428
- * This container after executing the specified command inside it
444
+ * Retrieves this container after executing the specified command inside it.
445
+ * @param args Command to run instead of the container's default command.
446
+ * @param opts.stdin Content to write to the command's standard input before closing.
447
+ * @param opts.redirectStdout Redirect the command's standard output to a file in the container.
448
+ * @param opts.redirectStderr Redirect the command's standard error to a file in the container.
449
+ * @param opts.experimentalPrivilegedNesting Provide dagger access to the executed command.
450
+ Do not use this option unless you trust the command being executed.
451
+ The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
429
452
  */
430
- withExec(args, stdin, redirectStdout, redirectStderr, experimentalPrivilegedNesting) {
453
+ withExec(args, opts) {
431
454
  return new Container({
432
455
  queryTree: [
433
456
  ...this._queryTree,
434
457
  {
435
458
  operation: "withExec",
436
- args: {
437
- args,
438
- stdin,
439
- redirectStdout,
440
- redirectStderr,
441
- experimentalPrivilegedNesting,
442
- },
459
+ args: Object.assign({ args }, opts),
443
460
  },
444
461
  ],
445
462
  host: this.clientHost,
463
+ sessionToken: this.sessionToken,
446
464
  });
447
465
  }
448
466
  /**
449
- * Initialize this container from this DirectoryID
450
- *
467
+ * Initializes this container from this DirectoryID.
451
468
  * @deprecated Replaced by withRootfs.
452
469
  */
453
470
  withFS(id) {
@@ -460,40 +477,43 @@ export class Container extends BaseClient {
460
477
  },
461
478
  ],
462
479
  host: this.clientHost,
480
+ sessionToken: this.sessionToken,
463
481
  });
464
482
  }
465
483
  /**
466
- * This container plus the contents of the given file copied to the given path
484
+ * Retrieves this container plus the contents of the given file copied to the given path.
467
485
  */
468
- withFile(path, source) {
486
+ withFile(path, source, opts) {
469
487
  return new Container({
470
488
  queryTree: [
471
489
  ...this._queryTree,
472
490
  {
473
491
  operation: "withFile",
474
- args: { path, source },
492
+ args: Object.assign({ path, source }, opts),
475
493
  },
476
494
  ],
477
495
  host: this.clientHost,
496
+ sessionToken: this.sessionToken,
478
497
  });
479
498
  }
480
499
  /**
481
- * This container plus a cache volume mounted at the given path
500
+ * Retrieves this container plus a cache volume mounted at the given path.
482
501
  */
483
- withMountedCache(path, cache, source) {
502
+ withMountedCache(path, cache, opts) {
484
503
  return new Container({
485
504
  queryTree: [
486
505
  ...this._queryTree,
487
506
  {
488
507
  operation: "withMountedCache",
489
- args: { path, cache, source },
508
+ args: Object.assign({ path, cache }, opts),
490
509
  },
491
510
  ],
492
511
  host: this.clientHost,
512
+ sessionToken: this.sessionToken,
493
513
  });
494
514
  }
495
515
  /**
496
- * This container plus a directory mounted at the given path
516
+ * Retrieves this container plus a directory mounted at the given path.
497
517
  */
498
518
  withMountedDirectory(path, source) {
499
519
  return new Container({
@@ -505,10 +525,11 @@ export class Container extends BaseClient {
505
525
  },
506
526
  ],
507
527
  host: this.clientHost,
528
+ sessionToken: this.sessionToken,
508
529
  });
509
530
  }
510
531
  /**
511
- * This container plus a file mounted at the given path
532
+ * Retrieves this container plus a file mounted at the given path.
512
533
  */
513
534
  withMountedFile(path, source) {
514
535
  return new Container({
@@ -520,10 +541,11 @@ export class Container extends BaseClient {
520
541
  },
521
542
  ],
522
543
  host: this.clientHost,
544
+ sessionToken: this.sessionToken,
523
545
  });
524
546
  }
525
547
  /**
526
- * This container plus a secret mounted into a file at the given path
548
+ * Retrieves this container plus a secret mounted into a file at the given path.
527
549
  */
528
550
  withMountedSecret(path, source) {
529
551
  return new Container({
@@ -535,10 +557,11 @@ export class Container extends BaseClient {
535
557
  },
536
558
  ],
537
559
  host: this.clientHost,
560
+ sessionToken: this.sessionToken,
538
561
  });
539
562
  }
540
563
  /**
541
- * This container plus a temporary directory mounted at the given path
564
+ * Retrieves this container plus a temporary directory mounted at the given path.
542
565
  */
543
566
  withMountedTemp(path) {
544
567
  return new Container({
@@ -550,25 +573,27 @@ export class Container extends BaseClient {
550
573
  },
551
574
  ],
552
575
  host: this.clientHost,
576
+ sessionToken: this.sessionToken,
553
577
  });
554
578
  }
555
579
  /**
556
- * This container plus a new file written at the given path
580
+ * Retrieves this container plus a new file written at the given path.
557
581
  */
558
- withNewFile(path, contents) {
582
+ withNewFile(path, opts) {
559
583
  return new Container({
560
584
  queryTree: [
561
585
  ...this._queryTree,
562
586
  {
563
587
  operation: "withNewFile",
564
- args: { path, contents },
588
+ args: Object.assign({ path }, opts),
565
589
  },
566
590
  ],
567
591
  host: this.clientHost,
592
+ sessionToken: this.sessionToken,
568
593
  });
569
594
  }
570
595
  /**
571
- * Initialize this container from this DirectoryID
596
+ * Initializes this container from this DirectoryID.
572
597
  */
573
598
  withRootfs(id) {
574
599
  return new Container({
@@ -580,10 +605,11 @@ export class Container extends BaseClient {
580
605
  },
581
606
  ],
582
607
  host: this.clientHost,
608
+ sessionToken: this.sessionToken,
583
609
  });
584
610
  }
585
611
  /**
586
- * This container plus an env variable containing the given secret
612
+ * Retrieves this container plus an env variable containing the given secret.
587
613
  */
588
614
  withSecretVariable(name, secret) {
589
615
  return new Container({
@@ -595,10 +621,11 @@ export class Container extends BaseClient {
595
621
  },
596
622
  ],
597
623
  host: this.clientHost,
624
+ sessionToken: this.sessionToken,
598
625
  });
599
626
  }
600
627
  /**
601
- * This container plus a socket forwarded to the given Unix socket path
628
+ * Retrieves this container plus a socket forwarded to the given Unix socket path.
602
629
  */
603
630
  withUnixSocket(path, source) {
604
631
  return new Container({
@@ -610,10 +637,11 @@ export class Container extends BaseClient {
610
637
  },
611
638
  ],
612
639
  host: this.clientHost,
640
+ sessionToken: this.sessionToken,
613
641
  });
614
642
  }
615
643
  /**
616
- * This container but with a different command user
644
+ * Retrieves this containers with a different command user.
617
645
  */
618
646
  withUser(name) {
619
647
  return new Container({
@@ -625,10 +653,11 @@ export class Container extends BaseClient {
625
653
  },
626
654
  ],
627
655
  host: this.clientHost,
656
+ sessionToken: this.sessionToken,
628
657
  });
629
658
  }
630
659
  /**
631
- * This container but with a different working directory
660
+ * Retrieves this container with a different working directory.
632
661
  */
633
662
  withWorkdir(path) {
634
663
  return new Container({
@@ -640,10 +669,11 @@ export class Container extends BaseClient {
640
669
  },
641
670
  ],
642
671
  host: this.clientHost,
672
+ sessionToken: this.sessionToken,
643
673
  });
644
674
  }
645
675
  /**
646
- * This container minus the given environment variable
676
+ * Retrieves this container minus the given environment variable.
647
677
  */
648
678
  withoutEnvVariable(name) {
649
679
  return new Container({
@@ -655,10 +685,11 @@ export class Container extends BaseClient {
655
685
  },
656
686
  ],
657
687
  host: this.clientHost,
688
+ sessionToken: this.sessionToken,
658
689
  });
659
690
  }
660
691
  /**
661
- * This container after unmounting everything at the given path.
692
+ * Retrieves this container after unmounting everything at the given path.
662
693
  */
663
694
  withoutMount(path) {
664
695
  return new Container({
@@ -670,10 +701,11 @@ export class Container extends BaseClient {
670
701
  },
671
702
  ],
672
703
  host: this.clientHost,
704
+ sessionToken: this.sessionToken,
673
705
  });
674
706
  }
675
707
  /**
676
- * This container with a previously added Unix socket removed
708
+ * Retrieves this container with a previously added Unix socket removed.
677
709
  */
678
710
  withoutUnixSocket(path) {
679
711
  return new Container({
@@ -685,30 +717,30 @@ export class Container extends BaseClient {
685
717
  },
686
718
  ],
687
719
  host: this.clientHost,
720
+ sessionToken: this.sessionToken,
688
721
  });
689
722
  }
690
723
  /**
691
- * The working directory for all commands
724
+ * Retrieves the working directory for all commands.
692
725
  */
693
726
  workdir() {
694
727
  return __awaiter(this, void 0, void 0, function* () {
695
- this._queryTree = [
728
+ const response = yield computeQuery([
696
729
  ...this._queryTree,
697
730
  {
698
731
  operation: "workdir",
699
732
  },
700
- ];
701
- const response = yield queryBuilder(this._queryTree, this.client);
733
+ ], this.client);
702
734
  return response;
703
735
  });
704
736
  }
705
737
  }
706
738
  /**
707
- * A directory
739
+ * A directory.
708
740
  */
709
741
  export class Directory extends BaseClient {
710
742
  /**
711
- * The difference between this directory and an another directory
743
+ * Gets the difference between this directory and an another directory.
712
744
  */
713
745
  diff(other) {
714
746
  return new Directory({
@@ -720,10 +752,11 @@ export class Directory extends BaseClient {
720
752
  },
721
753
  ],
722
754
  host: this.clientHost,
755
+ sessionToken: this.sessionToken,
723
756
  });
724
757
  }
725
758
  /**
726
- * Retrieve a directory at the given path
759
+ * Retrieves a directory at the given path.
727
760
  */
728
761
  directory(path) {
729
762
  return new Directory({
@@ -735,57 +768,59 @@ export class Directory extends BaseClient {
735
768
  },
736
769
  ],
737
770
  host: this.clientHost,
771
+ sessionToken: this.sessionToken,
738
772
  });
739
773
  }
740
774
  /**
741
- * Build a new Docker container from this directory
775
+ * Builds a new Docker container from this directory.
776
+ * @param opts.dockerfile Path to the Dockerfile to use.
777
+ Defaults to './Dockerfile'.
742
778
  */
743
- dockerBuild(dockerfile, platform) {
779
+ dockerBuild(opts) {
744
780
  return new Container({
745
781
  queryTree: [
746
782
  ...this._queryTree,
747
783
  {
748
784
  operation: "dockerBuild",
749
- args: { dockerfile, platform },
785
+ args: Object.assign({}, opts),
750
786
  },
751
787
  ],
752
788
  host: this.clientHost,
789
+ sessionToken: this.sessionToken,
753
790
  });
754
791
  }
755
792
  /**
756
- * Return a list of files and directories at the given path
793
+ * Returns a list of files and directories at the given path.
757
794
  */
758
- entries(path) {
795
+ entries(opts) {
759
796
  return __awaiter(this, void 0, void 0, function* () {
760
- this._queryTree = [
797
+ const response = yield computeQuery([
761
798
  ...this._queryTree,
762
799
  {
763
800
  operation: "entries",
764
- args: { path },
801
+ args: Object.assign({}, opts),
765
802
  },
766
- ];
767
- const response = yield queryBuilder(this._queryTree, this.client);
803
+ ], this.client);
768
804
  return response;
769
805
  });
770
806
  }
771
807
  /**
772
- * Write the contents of the directory to a path on the host
808
+ * Writes the contents of the directory to a path on the host.
773
809
  */
774
810
  export(path) {
775
811
  return __awaiter(this, void 0, void 0, function* () {
776
- this._queryTree = [
812
+ const response = yield computeQuery([
777
813
  ...this._queryTree,
778
814
  {
779
815
  operation: "export",
780
816
  args: { path },
781
817
  },
782
- ];
783
- const response = yield queryBuilder(this._queryTree, this.client);
818
+ ], this.client);
784
819
  return response;
785
820
  });
786
821
  }
787
822
  /**
788
- * Retrieve a file at the given path
823
+ * Retrieves a file at the given path.
789
824
  */
790
825
  file(path) {
791
826
  return new File({
@@ -797,20 +832,20 @@ export class Directory extends BaseClient {
797
832
  },
798
833
  ],
799
834
  host: this.clientHost,
835
+ sessionToken: this.sessionToken,
800
836
  });
801
837
  }
802
838
  /**
803
- * The content-addressed identifier of the directory
839
+ * The content-addressed identifier of the directory.
804
840
  */
805
841
  id() {
806
842
  return __awaiter(this, void 0, void 0, function* () {
807
- this._queryTree = [
843
+ const response = yield computeQuery([
808
844
  ...this._queryTree,
809
845
  {
810
846
  operation: "id",
811
847
  },
812
- ];
813
- const response = yield queryBuilder(this._queryTree, this.client);
848
+ ], this.client);
814
849
  return response;
815
850
  });
816
851
  }
@@ -827,70 +862,95 @@ export class Directory extends BaseClient {
827
862
  },
828
863
  ],
829
864
  host: this.clientHost,
865
+ sessionToken: this.sessionToken,
830
866
  });
831
867
  }
832
868
  /**
833
- * This directory plus a directory written at the given path
869
+ * Retrieves this directory plus a directory written at the given path.
870
+ * @param opts.exclude Exclude artifacts that match the given pattern.
871
+ (e.g. ["node_modules/", ".git*"]).
872
+ * @param opts.include Include only artifacts that match the given pattern.
873
+ (e.g. ["app/", "package.*"]).
834
874
  */
835
- withDirectory(path, directory, exclude, include) {
875
+ withDirectory(path, directory, opts) {
836
876
  return new Directory({
837
877
  queryTree: [
838
878
  ...this._queryTree,
839
879
  {
840
880
  operation: "withDirectory",
841
- args: { path, directory, exclude, include },
881
+ args: Object.assign({ path, directory }, opts),
842
882
  },
843
883
  ],
844
884
  host: this.clientHost,
885
+ sessionToken: this.sessionToken,
845
886
  });
846
887
  }
847
888
  /**
848
- * This directory plus the contents of the given file copied to the given path
889
+ * Retrieves this directory plus the contents of the given file copied to the given path.
849
890
  */
850
- withFile(path, source) {
891
+ withFile(path, source, opts) {
851
892
  return new Directory({
852
893
  queryTree: [
853
894
  ...this._queryTree,
854
895
  {
855
896
  operation: "withFile",
856
- args: { path, source },
897
+ args: Object.assign({ path, source }, opts),
857
898
  },
858
899
  ],
859
900
  host: this.clientHost,
901
+ sessionToken: this.sessionToken,
860
902
  });
861
903
  }
862
904
  /**
863
- * This directory plus a new directory created at the given path
905
+ * Retrieves this directory plus a new directory created at the given path.
864
906
  */
865
- withNewDirectory(path) {
907
+ withNewDirectory(path, opts) {
866
908
  return new Directory({
867
909
  queryTree: [
868
910
  ...this._queryTree,
869
911
  {
870
912
  operation: "withNewDirectory",
871
- args: { path },
913
+ args: Object.assign({ path }, opts),
872
914
  },
873
915
  ],
874
916
  host: this.clientHost,
917
+ sessionToken: this.sessionToken,
875
918
  });
876
919
  }
877
920
  /**
878
- * This directory plus a new file written at the given path
921
+ * Retrieves this directory plus a new file written at the given path.
879
922
  */
880
- withNewFile(path, contents) {
923
+ withNewFile(path, contents, opts) {
881
924
  return new Directory({
882
925
  queryTree: [
883
926
  ...this._queryTree,
884
927
  {
885
928
  operation: "withNewFile",
886
- args: { path, contents },
929
+ args: Object.assign({ path, contents }, opts),
930
+ },
931
+ ],
932
+ host: this.clientHost,
933
+ sessionToken: this.sessionToken,
934
+ });
935
+ }
936
+ /**
937
+ * Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.
938
+ */
939
+ withTimestamps(timestamp) {
940
+ return new Directory({
941
+ queryTree: [
942
+ ...this._queryTree,
943
+ {
944
+ operation: "withTimestamps",
945
+ args: { timestamp },
887
946
  },
888
947
  ],
889
948
  host: this.clientHost,
949
+ sessionToken: this.sessionToken,
890
950
  });
891
951
  }
892
952
  /**
893
- * This directory with the directory at the given path removed
953
+ * Retrieves this directory with the directory at the given path removed.
894
954
  */
895
955
  withoutDirectory(path) {
896
956
  return new Directory({
@@ -902,10 +962,11 @@ export class Directory extends BaseClient {
902
962
  },
903
963
  ],
904
964
  host: this.clientHost,
965
+ sessionToken: this.sessionToken,
905
966
  });
906
967
  }
907
968
  /**
908
- * This directory with the file at the given path removed
969
+ * Retrieves this directory with the file at the given path removed.
909
970
  */
910
971
  withoutFile(path) {
911
972
  return new Directory({
@@ -917,94 +978,93 @@ export class Directory extends BaseClient {
917
978
  },
918
979
  ],
919
980
  host: this.clientHost,
981
+ sessionToken: this.sessionToken,
920
982
  });
921
983
  }
922
984
  }
923
985
  /**
924
- * EnvVariable is a simple key value object that represents an environment variable.
986
+ * A simple key value object that represents an environment variable.
925
987
  */
926
988
  export class EnvVariable extends BaseClient {
927
989
  /**
928
- * name is the environment variable name.
990
+ * The environment variable name.
929
991
  */
930
992
  name() {
931
993
  return __awaiter(this, void 0, void 0, function* () {
932
- this._queryTree = [
994
+ const response = yield computeQuery([
933
995
  ...this._queryTree,
934
996
  {
935
997
  operation: "name",
936
998
  },
937
- ];
938
- const response = yield queryBuilder(this._queryTree, this.client);
999
+ ], this.client);
939
1000
  return response;
940
1001
  });
941
1002
  }
942
1003
  /**
943
- * value is the environment variable value
1004
+ * The environment variable value.
944
1005
  */
945
1006
  value() {
946
1007
  return __awaiter(this, void 0, void 0, function* () {
947
- this._queryTree = [
1008
+ const response = yield computeQuery([
948
1009
  ...this._queryTree,
949
1010
  {
950
1011
  operation: "value",
951
1012
  },
952
- ];
953
- const response = yield queryBuilder(this._queryTree, this.client);
1013
+ ], this.client);
954
1014
  return response;
955
1015
  });
956
1016
  }
957
1017
  }
958
1018
  /**
959
- * A file
1019
+ * A file.
960
1020
  */
961
1021
  export class File extends BaseClient {
962
1022
  /**
963
- * The contents of the file
1023
+ * Retrieves the contents of the file.
964
1024
  */
965
1025
  contents() {
966
1026
  return __awaiter(this, void 0, void 0, function* () {
967
- this._queryTree = [
1027
+ const response = yield computeQuery([
968
1028
  ...this._queryTree,
969
1029
  {
970
1030
  operation: "contents",
971
1031
  },
972
- ];
973
- const response = yield queryBuilder(this._queryTree, this.client);
1032
+ ], this.client);
974
1033
  return response;
975
1034
  });
976
1035
  }
977
1036
  /**
978
- * Write the file to a file path on the host
1037
+ * Writes the file to a file path on the host.
979
1038
  */
980
1039
  export(path) {
981
1040
  return __awaiter(this, void 0, void 0, function* () {
982
- this._queryTree = [
1041
+ const response = yield computeQuery([
983
1042
  ...this._queryTree,
984
1043
  {
985
1044
  operation: "export",
986
1045
  args: { path },
987
1046
  },
988
- ];
989
- const response = yield queryBuilder(this._queryTree, this.client);
1047
+ ], this.client);
990
1048
  return response;
991
1049
  });
992
1050
  }
993
1051
  /**
994
- * The content-addressed identifier of the file
1052
+ * Retrieves the content-addressed identifier of the file.
995
1053
  */
996
1054
  id() {
997
1055
  return __awaiter(this, void 0, void 0, function* () {
998
- this._queryTree = [
1056
+ const response = yield computeQuery([
999
1057
  ...this._queryTree,
1000
1058
  {
1001
1059
  operation: "id",
1002
1060
  },
1003
- ];
1004
- const response = yield queryBuilder(this._queryTree, this.client);
1061
+ ], this.client);
1005
1062
  return response;
1006
1063
  });
1007
1064
  }
1065
+ /**
1066
+ * Retrieves a secret referencing the contents of this file.
1067
+ */
1008
1068
  secret() {
1009
1069
  return new Secret({
1010
1070
  queryTree: [
@@ -1014,65 +1074,81 @@ export class File extends BaseClient {
1014
1074
  },
1015
1075
  ],
1016
1076
  host: this.clientHost,
1077
+ sessionToken: this.sessionToken,
1017
1078
  });
1018
1079
  }
1019
1080
  /**
1020
- * The size of the file, in bytes
1081
+ * Gets the size of the file, in bytes.
1021
1082
  */
1022
1083
  size() {
1023
1084
  return __awaiter(this, void 0, void 0, function* () {
1024
- this._queryTree = [
1085
+ const response = yield computeQuery([
1025
1086
  ...this._queryTree,
1026
1087
  {
1027
1088
  operation: "size",
1028
1089
  },
1029
- ];
1030
- const response = yield queryBuilder(this._queryTree, this.client);
1090
+ ], this.client);
1031
1091
  return response;
1032
1092
  });
1033
1093
  }
1094
+ /**
1095
+ * Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.
1096
+ */
1097
+ withTimestamps(timestamp) {
1098
+ return new File({
1099
+ queryTree: [
1100
+ ...this._queryTree,
1101
+ {
1102
+ operation: "withTimestamps",
1103
+ args: { timestamp },
1104
+ },
1105
+ ],
1106
+ host: this.clientHost,
1107
+ sessionToken: this.sessionToken,
1108
+ });
1109
+ }
1034
1110
  }
1035
1111
  /**
1036
- * A git ref (tag or branch)
1112
+ * A git ref (tag, branch or commit).
1037
1113
  */
1038
1114
  export class GitRef extends BaseClient {
1039
1115
  /**
1040
- * The digest of the current value of this ref
1116
+ * The digest of the current value of this ref.
1041
1117
  */
1042
1118
  digest() {
1043
1119
  return __awaiter(this, void 0, void 0, function* () {
1044
- this._queryTree = [
1120
+ const response = yield computeQuery([
1045
1121
  ...this._queryTree,
1046
1122
  {
1047
1123
  operation: "digest",
1048
1124
  },
1049
- ];
1050
- const response = yield queryBuilder(this._queryTree, this.client);
1125
+ ], this.client);
1051
1126
  return response;
1052
1127
  });
1053
1128
  }
1054
1129
  /**
1055
- * The filesystem tree at this ref
1130
+ * The filesystem tree at this ref.
1056
1131
  */
1057
- tree(sshKnownHosts, sshAuthSocket) {
1132
+ tree(opts) {
1058
1133
  return new Directory({
1059
1134
  queryTree: [
1060
1135
  ...this._queryTree,
1061
1136
  {
1062
1137
  operation: "tree",
1063
- args: { sshKnownHosts, sshAuthSocket },
1138
+ args: Object.assign({}, opts),
1064
1139
  },
1065
1140
  ],
1066
1141
  host: this.clientHost,
1142
+ sessionToken: this.sessionToken,
1067
1143
  });
1068
1144
  }
1069
1145
  }
1070
1146
  /**
1071
- * A git repository
1147
+ * A git repository.
1072
1148
  */
1073
1149
  export class GitRepository extends BaseClient {
1074
1150
  /**
1075
- * Details on one branch
1151
+ * Returns details on one branch.
1076
1152
  */
1077
1153
  branch(name) {
1078
1154
  return new GitRef({
@@ -1084,25 +1160,25 @@ export class GitRepository extends BaseClient {
1084
1160
  },
1085
1161
  ],
1086
1162
  host: this.clientHost,
1163
+ sessionToken: this.sessionToken,
1087
1164
  });
1088
1165
  }
1089
1166
  /**
1090
- * List of branches on the repository
1167
+ * Lists of branches on the repository.
1091
1168
  */
1092
1169
  branches() {
1093
1170
  return __awaiter(this, void 0, void 0, function* () {
1094
- this._queryTree = [
1171
+ const response = yield computeQuery([
1095
1172
  ...this._queryTree,
1096
1173
  {
1097
1174
  operation: "branches",
1098
1175
  },
1099
- ];
1100
- const response = yield queryBuilder(this._queryTree, this.client);
1176
+ ], this.client);
1101
1177
  return response;
1102
1178
  });
1103
1179
  }
1104
1180
  /**
1105
- * Details on one commit
1181
+ * Returns details on one commit.
1106
1182
  */
1107
1183
  commit(id) {
1108
1184
  return new GitRef({
@@ -1114,10 +1190,11 @@ export class GitRepository extends BaseClient {
1114
1190
  },
1115
1191
  ],
1116
1192
  host: this.clientHost,
1193
+ sessionToken: this.sessionToken,
1117
1194
  });
1118
1195
  }
1119
1196
  /**
1120
- * Details on one tag
1197
+ * Returns details on one tag.
1121
1198
  */
1122
1199
  tag(name) {
1123
1200
  return new GitRef({
@@ -1129,45 +1206,46 @@ export class GitRepository extends BaseClient {
1129
1206
  },
1130
1207
  ],
1131
1208
  host: this.clientHost,
1209
+ sessionToken: this.sessionToken,
1132
1210
  });
1133
1211
  }
1134
1212
  /**
1135
- * List of tags on the repository
1213
+ * Lists of tags on the repository.
1136
1214
  */
1137
1215
  tags() {
1138
1216
  return __awaiter(this, void 0, void 0, function* () {
1139
- this._queryTree = [
1217
+ const response = yield computeQuery([
1140
1218
  ...this._queryTree,
1141
1219
  {
1142
1220
  operation: "tags",
1143
1221
  },
1144
- ];
1145
- const response = yield queryBuilder(this._queryTree, this.client);
1222
+ ], this.client);
1146
1223
  return response;
1147
1224
  });
1148
1225
  }
1149
1226
  }
1150
1227
  /**
1151
- * Information about the host execution environment
1228
+ * Information about the host execution environment.
1152
1229
  */
1153
1230
  export class Host extends BaseClient {
1154
1231
  /**
1155
- * Access a directory on the host
1232
+ * Accesses a directory on the host.
1156
1233
  */
1157
- directory(path, exclude, include) {
1234
+ directory(path, opts) {
1158
1235
  return new Directory({
1159
1236
  queryTree: [
1160
1237
  ...this._queryTree,
1161
1238
  {
1162
1239
  operation: "directory",
1163
- args: { path, exclude, include },
1240
+ args: Object.assign({ path }, opts),
1164
1241
  },
1165
1242
  ],
1166
1243
  host: this.clientHost,
1244
+ sessionToken: this.sessionToken,
1167
1245
  });
1168
1246
  }
1169
1247
  /**
1170
- * Access an environment variable on the host
1248
+ * Accesses an environment variable on the host.
1171
1249
  */
1172
1250
  envVariable(name) {
1173
1251
  return new HostVariable({
@@ -1179,10 +1257,11 @@ export class Host extends BaseClient {
1179
1257
  },
1180
1258
  ],
1181
1259
  host: this.clientHost,
1260
+ sessionToken: this.sessionToken,
1182
1261
  });
1183
1262
  }
1184
1263
  /**
1185
- * Access a Unix socket on the host
1264
+ * Accesses a Unix socket on the host.
1186
1265
  */
1187
1266
  unixSocket(path) {
1188
1267
  return new Socket({
@@ -1194,32 +1273,33 @@ export class Host extends BaseClient {
1194
1273
  },
1195
1274
  ],
1196
1275
  host: this.clientHost,
1276
+ sessionToken: this.sessionToken,
1197
1277
  });
1198
1278
  }
1199
1279
  /**
1200
- * The current working directory on the host
1201
- *
1280
+ * Retrieves the current working directory on the host.
1202
1281
  * @deprecated Use directory with path set to '.' instead.
1203
1282
  */
1204
- workdir(exclude, include) {
1283
+ workdir(opts) {
1205
1284
  return new Directory({
1206
1285
  queryTree: [
1207
1286
  ...this._queryTree,
1208
1287
  {
1209
1288
  operation: "workdir",
1210
- args: { exclude, include },
1289
+ args: Object.assign({}, opts),
1211
1290
  },
1212
1291
  ],
1213
1292
  host: this.clientHost,
1293
+ sessionToken: this.sessionToken,
1214
1294
  });
1215
1295
  }
1216
1296
  }
1217
1297
  /**
1218
- * An environment variable on the host environment
1298
+ * An environment variable on the host environment.
1219
1299
  */
1220
1300
  export class HostVariable extends BaseClient {
1221
1301
  /**
1222
- * A secret referencing the value of this variable
1302
+ * A secret referencing the value of this variable.
1223
1303
  */
1224
1304
  secret() {
1225
1305
  return new Secret({
@@ -1230,20 +1310,20 @@ export class HostVariable extends BaseClient {
1230
1310
  },
1231
1311
  ],
1232
1312
  host: this.clientHost,
1313
+ sessionToken: this.sessionToken,
1233
1314
  });
1234
1315
  }
1235
1316
  /**
1236
- * The value of this variable
1317
+ * The value of this variable.
1237
1318
  */
1238
1319
  value() {
1239
1320
  return __awaiter(this, void 0, void 0, function* () {
1240
- this._queryTree = [
1321
+ const response = yield computeQuery([
1241
1322
  ...this._queryTree,
1242
1323
  {
1243
1324
  operation: "value",
1244
1325
  },
1245
- ];
1246
- const response = yield queryBuilder(this._queryTree, this.client);
1326
+ ], this.client);
1247
1327
  return response;
1248
1328
  });
1249
1329
  }
@@ -1257,13 +1337,12 @@ export class Project extends BaseClient {
1257
1337
  */
1258
1338
  extensions() {
1259
1339
  return __awaiter(this, void 0, void 0, function* () {
1260
- this._queryTree = [
1340
+ const response = yield computeQuery([
1261
1341
  ...this._queryTree,
1262
1342
  {
1263
1343
  operation: "extensions",
1264
1344
  },
1265
- ];
1266
- const response = yield queryBuilder(this._queryTree, this.client);
1345
+ ], this.client);
1267
1346
  return response;
1268
1347
  });
1269
1348
  }
@@ -1279,6 +1358,7 @@ export class Project extends BaseClient {
1279
1358
  },
1280
1359
  ],
1281
1360
  host: this.clientHost,
1361
+ sessionToken: this.sessionToken,
1282
1362
  });
1283
1363
  }
1284
1364
  /**
@@ -1286,13 +1366,12 @@ export class Project extends BaseClient {
1286
1366
  */
1287
1367
  install() {
1288
1368
  return __awaiter(this, void 0, void 0, function* () {
1289
- this._queryTree = [
1369
+ const response = yield computeQuery([
1290
1370
  ...this._queryTree,
1291
1371
  {
1292
1372
  operation: "install",
1293
1373
  },
1294
- ];
1295
- const response = yield queryBuilder(this._queryTree, this.client);
1374
+ ], this.client);
1296
1375
  return response;
1297
1376
  });
1298
1377
  }
@@ -1301,13 +1380,12 @@ export class Project extends BaseClient {
1301
1380
  */
1302
1381
  name() {
1303
1382
  return __awaiter(this, void 0, void 0, function* () {
1304
- this._queryTree = [
1383
+ const response = yield computeQuery([
1305
1384
  ...this._queryTree,
1306
1385
  {
1307
1386
  operation: "name",
1308
1387
  },
1309
- ];
1310
- const response = yield queryBuilder(this._queryTree, this.client);
1388
+ ], this.client);
1311
1389
  return response;
1312
1390
  });
1313
1391
  }
@@ -1316,13 +1394,12 @@ export class Project extends BaseClient {
1316
1394
  */
1317
1395
  schema() {
1318
1396
  return __awaiter(this, void 0, void 0, function* () {
1319
- this._queryTree = [
1397
+ const response = yield computeQuery([
1320
1398
  ...this._queryTree,
1321
1399
  {
1322
1400
  operation: "schema",
1323
1401
  },
1324
- ];
1325
- const response = yield queryBuilder(this._queryTree, this.client);
1402
+ ], this.client);
1326
1403
  return response;
1327
1404
  });
1328
1405
  }
@@ -1331,20 +1408,20 @@ export class Project extends BaseClient {
1331
1408
  */
1332
1409
  sdk() {
1333
1410
  return __awaiter(this, void 0, void 0, function* () {
1334
- this._queryTree = [
1411
+ const response = yield computeQuery([
1335
1412
  ...this._queryTree,
1336
1413
  {
1337
1414
  operation: "sdk",
1338
1415
  },
1339
- ];
1340
- const response = yield queryBuilder(this._queryTree, this.client);
1416
+ ], this.client);
1341
1417
  return response;
1342
1418
  });
1343
1419
  }
1344
1420
  }
1345
1421
  export default class Client extends BaseClient {
1346
1422
  /**
1347
- * Construct a cache volume for a given cache key
1423
+ * Constructs a cache volume for a given cache key.
1424
+ * @param key A string identifier to target this cache volume (e.g. "myapp-cache").
1348
1425
  */
1349
1426
  cacheVolume(key) {
1350
1427
  return new CacheVolume({
@@ -1356,23 +1433,25 @@ export default class Client extends BaseClient {
1356
1433
  },
1357
1434
  ],
1358
1435
  host: this.clientHost,
1436
+ sessionToken: this.sessionToken,
1359
1437
  });
1360
1438
  }
1361
1439
  /**
1362
- * Load a container from ID.
1440
+ * Loads a container from ID.
1363
1441
  * Null ID returns an empty container (scratch).
1364
1442
  * Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
1365
1443
  */
1366
- container(id, platform) {
1444
+ container(opts) {
1367
1445
  return new Container({
1368
1446
  queryTree: [
1369
1447
  ...this._queryTree,
1370
1448
  {
1371
1449
  operation: "container",
1372
- args: { id, platform },
1450
+ args: Object.assign({}, opts),
1373
1451
  },
1374
1452
  ],
1375
1453
  host: this.clientHost,
1454
+ sessionToken: this.sessionToken,
1376
1455
  });
1377
1456
  }
1378
1457
  /**
@@ -1380,33 +1459,33 @@ export default class Client extends BaseClient {
1380
1459
  */
1381
1460
  defaultPlatform() {
1382
1461
  return __awaiter(this, void 0, void 0, function* () {
1383
- this._queryTree = [
1462
+ const response = yield computeQuery([
1384
1463
  ...this._queryTree,
1385
1464
  {
1386
1465
  operation: "defaultPlatform",
1387
1466
  },
1388
- ];
1389
- const response = yield queryBuilder(this._queryTree, this.client);
1467
+ ], this.client);
1390
1468
  return response;
1391
1469
  });
1392
1470
  }
1393
1471
  /**
1394
1472
  * Load a directory by ID. No argument produces an empty directory.
1395
1473
  */
1396
- directory(id) {
1474
+ directory(opts) {
1397
1475
  return new Directory({
1398
1476
  queryTree: [
1399
1477
  ...this._queryTree,
1400
1478
  {
1401
1479
  operation: "directory",
1402
- args: { id },
1480
+ args: Object.assign({}, opts),
1403
1481
  },
1404
1482
  ],
1405
1483
  host: this.clientHost,
1484
+ sessionToken: this.sessionToken,
1406
1485
  });
1407
1486
  }
1408
1487
  /**
1409
- * Load a file by ID
1488
+ * Loads a file by ID.
1410
1489
  */
1411
1490
  file(id) {
1412
1491
  return new File({
@@ -1418,25 +1497,27 @@ export default class Client extends BaseClient {
1418
1497
  },
1419
1498
  ],
1420
1499
  host: this.clientHost,
1500
+ sessionToken: this.sessionToken,
1421
1501
  });
1422
1502
  }
1423
1503
  /**
1424
- * Query a git repository
1504
+ * Queries a git repository.
1425
1505
  */
1426
- git(url, keepGitDir) {
1506
+ git(url, opts) {
1427
1507
  return new GitRepository({
1428
1508
  queryTree: [
1429
1509
  ...this._queryTree,
1430
1510
  {
1431
1511
  operation: "git",
1432
- args: { url, keepGitDir },
1512
+ args: Object.assign({ url }, opts),
1433
1513
  },
1434
1514
  ],
1435
1515
  host: this.clientHost,
1516
+ sessionToken: this.sessionToken,
1436
1517
  });
1437
1518
  }
1438
1519
  /**
1439
- * Query the host environment
1520
+ * Queries the host environment.
1440
1521
  */
1441
1522
  host() {
1442
1523
  return new Host({
@@ -1447,10 +1528,11 @@ export default class Client extends BaseClient {
1447
1528
  },
1448
1529
  ],
1449
1530
  host: this.clientHost,
1531
+ sessionToken: this.sessionToken,
1450
1532
  });
1451
1533
  }
1452
1534
  /**
1453
- * An http remote
1535
+ * Returns a file containing an http remote url content.
1454
1536
  */
1455
1537
  http(url) {
1456
1538
  return new File({
@@ -1462,6 +1544,7 @@ export default class Client extends BaseClient {
1462
1544
  },
1463
1545
  ],
1464
1546
  host: this.clientHost,
1547
+ sessionToken: this.sessionToken,
1465
1548
  });
1466
1549
  }
1467
1550
  /**
@@ -1477,10 +1560,11 @@ export default class Client extends BaseClient {
1477
1560
  },
1478
1561
  ],
1479
1562
  host: this.clientHost,
1563
+ sessionToken: this.sessionToken,
1480
1564
  });
1481
1565
  }
1482
1566
  /**
1483
- * Load a secret from its ID
1567
+ * Loads a secret from its ID.
1484
1568
  */
1485
1569
  secret(id) {
1486
1570
  return new Secret({
@@ -1492,72 +1576,71 @@ export default class Client extends BaseClient {
1492
1576
  },
1493
1577
  ],
1494
1578
  host: this.clientHost,
1579
+ sessionToken: this.sessionToken,
1495
1580
  });
1496
1581
  }
1497
1582
  /**
1498
- * Load a socket by ID
1583
+ * Loads a socket by its ID.
1499
1584
  */
1500
- socket(id) {
1585
+ socket(opts) {
1501
1586
  return new Socket({
1502
1587
  queryTree: [
1503
1588
  ...this._queryTree,
1504
1589
  {
1505
1590
  operation: "socket",
1506
- args: { id },
1591
+ args: Object.assign({}, opts),
1507
1592
  },
1508
1593
  ],
1509
1594
  host: this.clientHost,
1595
+ sessionToken: this.sessionToken,
1510
1596
  });
1511
1597
  }
1512
1598
  }
1513
1599
  /**
1514
- * A reference to a secret value, which can be handled more safely than the value itself
1600
+ * A reference to a secret value, which can be handled more safely than the value itself.
1515
1601
  */
1516
1602
  export class Secret extends BaseClient {
1517
1603
  /**
1518
- * The identifier for this secret
1604
+ * The identifier for this secret.
1519
1605
  */
1520
1606
  id() {
1521
1607
  return __awaiter(this, void 0, void 0, function* () {
1522
- this._queryTree = [
1608
+ const response = yield computeQuery([
1523
1609
  ...this._queryTree,
1524
1610
  {
1525
1611
  operation: "id",
1526
1612
  },
1527
- ];
1528
- const response = yield queryBuilder(this._queryTree, this.client);
1613
+ ], this.client);
1529
1614
  return response;
1530
1615
  });
1531
1616
  }
1532
1617
  /**
1533
- * The value of this secret
1618
+ * The value of this secret.
1534
1619
  */
1535
1620
  plaintext() {
1536
1621
  return __awaiter(this, void 0, void 0, function* () {
1537
- this._queryTree = [
1622
+ const response = yield computeQuery([
1538
1623
  ...this._queryTree,
1539
1624
  {
1540
1625
  operation: "plaintext",
1541
1626
  },
1542
- ];
1543
- const response = yield queryBuilder(this._queryTree, this.client);
1627
+ ], this.client);
1544
1628
  return response;
1545
1629
  });
1546
1630
  }
1547
1631
  }
1548
1632
  export class Socket extends BaseClient {
1549
1633
  /**
1550
- * The content-addressed identifier of the socket
1634
+ * The content-addressed identifier of the socket.
1551
1635
  */
1552
1636
  id() {
1553
1637
  return __awaiter(this, void 0, void 0, function* () {
1554
- this._queryTree = [
1638
+ const response = yield computeQuery([
1555
1639
  ...this._queryTree,
1556
1640
  {
1557
1641
  operation: "id",
1558
1642
  },
1559
- ];
1560
- const response = yield queryBuilder(this._queryTree, this.client);
1643
+ ], this.client);
1561
1644
  return response;
1562
1645
  });
1563
1646
  }