@dagger.io/dagger 0.8.8 → 0.9.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.
@@ -157,13 +157,11 @@ export class Container extends BaseClient {
157
157
  /**
158
158
  * Constructor is used for internal usage only, do not create object from it.
159
159
  */
160
- constructor(parent, _id, _endpoint, _envVariable, _export, _hostname, _imageRef, _label, _platform, _publish, _shellEndpoint, _stderr, _stdout, _sync, _user, _workdir) {
160
+ constructor(parent, _id, _envVariable, _export, _imageRef, _label, _platform, _publish, _shellEndpoint, _stderr, _stdout, _sync, _user, _workdir) {
161
161
  super(parent);
162
162
  this._id = undefined;
163
- this._endpoint = undefined;
164
163
  this._envVariable = undefined;
165
164
  this._export = undefined;
166
- this._hostname = undefined;
167
165
  this._imageRef = undefined;
168
166
  this._label = undefined;
169
167
  this._platform = undefined;
@@ -175,10 +173,8 @@ export class Container extends BaseClient {
175
173
  this._user = undefined;
176
174
  this._workdir = undefined;
177
175
  this._id = _id;
178
- this._endpoint = _endpoint;
179
176
  this._envVariable = _envVariable;
180
177
  this._export = _export;
181
- this._hostname = _hostname;
182
178
  this._imageRef = _imageRef;
183
179
  this._label = _label;
184
180
  this._platform = _platform;
@@ -207,6 +203,53 @@ export class Container extends BaseClient {
207
203
  return response;
208
204
  });
209
205
  }
206
+ /**
207
+ * Turn the container into a Service.
208
+ *
209
+ * Be sure to set any exposed ports before this conversion.
210
+ */
211
+ asService() {
212
+ return new Service({
213
+ queryTree: [
214
+ ...this._queryTree,
215
+ {
216
+ operation: "asService",
217
+ },
218
+ ],
219
+ host: this.clientHost,
220
+ sessionToken: this.sessionToken,
221
+ });
222
+ }
223
+ /**
224
+ * Returns a File representing the container serialized to a tarball.
225
+ * @param opts.platformVariants Identifiers for other platform specific containers.
226
+ * Used for multi-platform image.
227
+ * @param opts.forcedCompression Force each layer of the image to use the specified compression algorithm.
228
+ * If this is unset, then if a layer already has a compressed blob in the engine's
229
+ * cache, that will be used (this can result in a mix of compression algorithms for
230
+ * different layers). If this is unset and a layer has no compressed blob in the
231
+ * engine's cache, then it will be compressed using Gzip.
232
+ * @param opts.mediaTypes Use the specified media types for the image's layers. Defaults to OCI, which
233
+ * is largely compatible with most recent container runtimes, but Docker may be needed
234
+ * for older runtimes without OCI support.
235
+ */
236
+ asTarball(opts) {
237
+ const metadata = {
238
+ forcedCompression: { is_enum: true },
239
+ mediaTypes: { is_enum: true },
240
+ };
241
+ return new File({
242
+ queryTree: [
243
+ ...this._queryTree,
244
+ {
245
+ operation: "asTarball",
246
+ args: Object.assign(Object.assign({}, opts), { __metadata: metadata }),
247
+ },
248
+ ],
249
+ host: this.clientHost,
250
+ sessionToken: this.sessionToken,
251
+ });
252
+ }
210
253
  /**
211
254
  * Initializes this container from a Dockerfile build.
212
255
  * @param context Directory context used by the Dockerfile.
@@ -269,32 +312,6 @@ export class Container extends BaseClient {
269
312
  sessionToken: this.sessionToken,
270
313
  });
271
314
  }
272
- /**
273
- * Retrieves an endpoint that clients can use to reach this container.
274
- *
275
- * If no port is specified, the first exposed port is used. If none exist an error is returned.
276
- *
277
- * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
278
- *
279
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
280
- * @param opts.port The exposed port number for the endpoint
281
- * @param opts.scheme Return a URL with the given scheme, eg. http for http://
282
- */
283
- endpoint(opts) {
284
- return __awaiter(this, void 0, void 0, function* () {
285
- if (this._endpoint) {
286
- return this._endpoint;
287
- }
288
- const response = yield computeQuery([
289
- ...this._queryTree,
290
- {
291
- operation: "endpoint",
292
- args: Object.assign({}, opts),
293
- },
294
- ], this.client);
295
- return response;
296
- });
297
- }
298
315
  /**
299
316
  * Retrieves entrypoint to be prepended to the arguments of all commands.
300
317
  */
@@ -391,8 +408,6 @@ export class Container extends BaseClient {
391
408
  *
392
409
  * This includes ports already exposed by the image, even if not
393
410
  * explicitly added with dagger.
394
- *
395
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
396
411
  */
397
412
  exposedPorts() {
398
413
  return __awaiter(this, void 0, void 0, function* () {
@@ -450,25 +465,6 @@ export class Container extends BaseClient {
450
465
  sessionToken: this.sessionToken,
451
466
  });
452
467
  }
453
- /**
454
- * Retrieves a hostname which can be used by clients to reach this container.
455
- *
456
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
457
- */
458
- hostname() {
459
- return __awaiter(this, void 0, void 0, function* () {
460
- if (this._hostname) {
461
- return this._hostname;
462
- }
463
- const response = yield computeQuery([
464
- ...this._queryTree,
465
- {
466
- operation: "hostname",
467
- },
468
- ], this.client);
469
- return response;
470
- });
471
- }
472
468
  /**
473
469
  * The unique image reference which can only be retrieved immediately after the 'Container.From' call.
474
470
  */
@@ -857,8 +853,6 @@ export class Container extends BaseClient {
857
853
  * Exposed ports serve two purposes:
858
854
  * - For health checks and introspection, when running services
859
855
  * - For setting the EXPOSE OCI field when publishing the container
860
- *
861
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
862
856
  * @param port Port number to expose
863
857
  * @param opts.protocol Transport layer network protocol
864
858
  * @param opts.description Optional port description
@@ -1150,8 +1144,6 @@ export class Container extends BaseClient {
1150
1144
  * The service will be reachable from the container via the provided hostname alias.
1151
1145
  *
1152
1146
  * The service dependency will also convey to any files or directories produced by the container.
1153
- *
1154
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
1155
1147
  * @param alias A name that can be used to reach the service from the container
1156
1148
  * @param service Identifier of the service container
1157
1149
  */
@@ -1244,8 +1236,6 @@ export class Container extends BaseClient {
1244
1236
  }
1245
1237
  /**
1246
1238
  * Unexpose a previously exposed port.
1247
- *
1248
- * Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
1249
1239
  * @param port Port number to unexpose
1250
1240
  * @param opts.protocol Port protocol to unexpose
1251
1241
  */
@@ -1423,10 +1413,6 @@ export class Directory extends BaseClient {
1423
1413
  *
1424
1414
  * If not set, the module source code is loaded from the root of the
1425
1415
  * directory.
1426
- * @param opts.runtime A pre-built runtime container to use instead of building one from the
1427
- * source code. This is useful for bootstrapping.
1428
- *
1429
- * You should ignore this unless you're building a Dagger SDK.
1430
1416
  */
1431
1417
  asModule(opts) {
1432
1418
  return new Module_({
@@ -1552,6 +1538,22 @@ export class Directory extends BaseClient {
1552
1538
  sessionToken: this.sessionToken,
1553
1539
  });
1554
1540
  }
1541
+ /**
1542
+ * Returns a list of files and directories that matche the given pattern.
1543
+ * @param pattern Pattern to match (e.g., "*.md").
1544
+ */
1545
+ glob(pattern) {
1546
+ return __awaiter(this, void 0, void 0, function* () {
1547
+ const response = yield computeQuery([
1548
+ ...this._queryTree,
1549
+ {
1550
+ operation: "glob",
1551
+ args: { pattern },
1552
+ },
1553
+ ], this.client);
1554
+ return response;
1555
+ });
1556
+ }
1555
1557
  /**
1556
1558
  * Creates a named sub-pipeline
1557
1559
  * @param name Pipeline name.
@@ -1988,14 +1990,12 @@ export class Function_ extends BaseClient {
1988
1990
  /**
1989
1991
  * Constructor is used for internal usage only, do not create object from it.
1990
1992
  */
1991
- constructor(parent, _id, _call, _description, _name) {
1993
+ constructor(parent, _id, _description, _name) {
1992
1994
  super(parent);
1993
1995
  this._id = undefined;
1994
- this._call = undefined;
1995
1996
  this._description = undefined;
1996
1997
  this._name = undefined;
1997
1998
  this._id = _id;
1998
- this._call = _call;
1999
1999
  this._description = _description;
2000
2000
  this._name = _name;
2001
2001
  }
@@ -2027,38 +2027,14 @@ export class Function_ extends BaseClient {
2027
2027
  operation: "args",
2028
2028
  },
2029
2029
  {
2030
- operation: "defaultValue description name",
2030
+ operation: "id",
2031
2031
  },
2032
2032
  ], this.client);
2033
2033
  return response.map((r) => new FunctionArg({
2034
2034
  queryTree: this.queryTree,
2035
2035
  host: this.clientHost,
2036
2036
  sessionToken: this.sessionToken,
2037
- }, r.defaultValue, r.description, r.name));
2038
- });
2039
- }
2040
- /**
2041
- * Execute this function using dynamic input+output types.
2042
- *
2043
- * Typically, it's preferable to invoke a function using a type
2044
- * safe graphql query rather than using this call field. However,
2045
- * call is useful for some advanced use cases where dynamically
2046
- * loading arbitrary modules and invoking functions in them is
2047
- * required.
2048
- */
2049
- call(opts) {
2050
- return __awaiter(this, void 0, void 0, function* () {
2051
- if (this._call) {
2052
- return this._call;
2053
- }
2054
- const response = yield computeQuery([
2055
- ...this._queryTree,
2056
- {
2057
- operation: "call",
2058
- args: Object.assign({}, opts),
2059
- },
2060
- ], this.client);
2061
- return response;
2037
+ }, r.id));
2062
2038
  });
2063
2039
  }
2064
2040
  /**
@@ -2165,15 +2141,34 @@ export class FunctionArg extends BaseClient {
2165
2141
  /**
2166
2142
  * Constructor is used for internal usage only, do not create object from it.
2167
2143
  */
2168
- constructor(parent, _defaultValue, _description, _name) {
2144
+ constructor(parent, _id, _defaultValue, _description, _name) {
2169
2145
  super(parent);
2146
+ this._id = undefined;
2170
2147
  this._defaultValue = undefined;
2171
2148
  this._description = undefined;
2172
2149
  this._name = undefined;
2150
+ this._id = _id;
2173
2151
  this._defaultValue = _defaultValue;
2174
2152
  this._description = _description;
2175
2153
  this._name = _name;
2176
2154
  }
2155
+ /**
2156
+ * The ID of the argument
2157
+ */
2158
+ id() {
2159
+ return __awaiter(this, void 0, void 0, function* () {
2160
+ if (this._id) {
2161
+ return this._id;
2162
+ }
2163
+ const response = yield computeQuery([
2164
+ ...this._queryTree,
2165
+ {
2166
+ operation: "id",
2167
+ },
2168
+ ], this.client);
2169
+ return response;
2170
+ });
2171
+ }
2177
2172
  /**
2178
2173
  * A default value to use for this argument when not explicitly set by the caller, if any
2179
2174
  */
@@ -2462,22 +2457,6 @@ export class GeneratedCode extends BaseClient {
2462
2457
  return response;
2463
2458
  });
2464
2459
  }
2465
- /**
2466
- * Set the directory containing the generated code
2467
- */
2468
- withCode(code) {
2469
- return new GeneratedCode({
2470
- queryTree: [
2471
- ...this._queryTree,
2472
- {
2473
- operation: "withCode",
2474
- args: { code },
2475
- },
2476
- ],
2477
- host: this.clientHost,
2478
- sessionToken: this.sessionToken,
2479
- });
2480
- }
2481
2460
  /**
2482
2461
  * Set the list of paths to mark generated in version control
2483
2462
  */
@@ -2526,8 +2505,27 @@ export class GitRef extends BaseClient {
2526
2505
  /**
2527
2506
  * Constructor is used for internal usage only, do not create object from it.
2528
2507
  */
2529
- constructor(parent) {
2508
+ constructor(parent, _commit) {
2530
2509
  super(parent);
2510
+ this._commit = undefined;
2511
+ this._commit = _commit;
2512
+ }
2513
+ /**
2514
+ * The resolved commit id at this ref.
2515
+ */
2516
+ commit() {
2517
+ return __awaiter(this, void 0, void 0, function* () {
2518
+ if (this._commit) {
2519
+ return this._commit;
2520
+ }
2521
+ const response = yield computeQuery([
2522
+ ...this._queryTree,
2523
+ {
2524
+ operation: "commit",
2525
+ },
2526
+ ], this.client);
2527
+ return response;
2528
+ });
2531
2529
  }
2532
2530
  /**
2533
2531
  * The filesystem tree at this ref.
@@ -2654,6 +2652,29 @@ export class Host extends BaseClient {
2654
2652
  sessionToken: this.sessionToken,
2655
2653
  });
2656
2654
  }
2655
+ /**
2656
+ * Creates a service that forwards traffic to a specified address via the host.
2657
+ * @param ports Ports to expose via the service, forwarding through the host network.
2658
+ *
2659
+ * If a port's frontend is unspecified or 0, it defaults to the same as the
2660
+ * backend port.
2661
+ *
2662
+ * An empty set of ports is not valid; an error will be returned.
2663
+ * @param opts.host Upstream host to forward traffic to.
2664
+ */
2665
+ service(ports, opts) {
2666
+ return new Service({
2667
+ queryTree: [
2668
+ ...this._queryTree,
2669
+ {
2670
+ operation: "service",
2671
+ args: Object.assign({ ports }, opts),
2672
+ },
2673
+ ],
2674
+ host: this.clientHost,
2675
+ sessionToken: this.sessionToken,
2676
+ });
2677
+ }
2657
2678
  /**
2658
2679
  * Sets a secret given a user-defined name and the file path on the host, and returns the secret.
2659
2680
  * The file is limited to a size of 512000 bytes.
@@ -2673,6 +2694,37 @@ export class Host extends BaseClient {
2673
2694
  sessionToken: this.sessionToken,
2674
2695
  });
2675
2696
  }
2697
+ /**
2698
+ * Creates a tunnel that forwards traffic from the host to a service.
2699
+ * @param service Service to send traffic from the tunnel.
2700
+ * @param opts.native Map each service port to the same port on the host, as if the service were
2701
+ * running natively.
2702
+ *
2703
+ * Note: enabling may result in port conflicts.
2704
+ * @param opts.ports Configure explicit port forwarding rules for the tunnel.
2705
+ *
2706
+ * If a port's frontend is unspecified or 0, a random port will be chosen by
2707
+ * the host.
2708
+ *
2709
+ * If no ports are given, all of the service's ports are forwarded. If native
2710
+ * is true, each port maps to the same port on the host. If native is false,
2711
+ * each port maps to a random port chosen by the host.
2712
+ *
2713
+ * If ports are given and native is true, the ports are additive.
2714
+ */
2715
+ tunnel(service, opts) {
2716
+ return new Service({
2717
+ queryTree: [
2718
+ ...this._queryTree,
2719
+ {
2720
+ operation: "tunnel",
2721
+ args: Object.assign({ service }, opts),
2722
+ },
2723
+ ],
2724
+ host: this.clientHost,
2725
+ sessionToken: this.sessionToken,
2726
+ });
2727
+ }
2676
2728
  /**
2677
2729
  * Accesses a Unix socket on the host.
2678
2730
  * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
@@ -2770,20 +2822,18 @@ export class Module_ extends BaseClient {
2770
2822
  /**
2771
2823
  * Constructor is used for internal usage only, do not create object from it.
2772
2824
  */
2773
- constructor(parent, _id, _description, _name, _sdk, _sdkRuntime, _serve, _sourceDirectorySubPath) {
2825
+ constructor(parent, _id, _description, _name, _sdk, _serve, _sourceDirectorySubPath) {
2774
2826
  super(parent);
2775
2827
  this._id = undefined;
2776
2828
  this._description = undefined;
2777
2829
  this._name = undefined;
2778
2830
  this._sdk = undefined;
2779
- this._sdkRuntime = undefined;
2780
2831
  this._serve = undefined;
2781
2832
  this._sourceDirectorySubPath = undefined;
2782
2833
  this._id = _id;
2783
2834
  this._description = _description;
2784
2835
  this._name = _name;
2785
2836
  this._sdk = _sdk;
2786
- this._sdkRuntime = _sdkRuntime;
2787
2837
  this._serve = _serve;
2788
2838
  this._sourceDirectorySubPath = _sourceDirectorySubPath;
2789
2839
  }
@@ -2910,7 +2960,7 @@ export class Module_ extends BaseClient {
2910
2960
  });
2911
2961
  }
2912
2962
  /**
2913
- * The SDK used by this module
2963
+ * The SDK used by this module. Either a name of a builtin SDK or a module ref pointing to the SDK's implementation.
2914
2964
  */
2915
2965
  sdk() {
2916
2966
  return __awaiter(this, void 0, void 0, function* () {
@@ -2926,29 +2976,12 @@ export class Module_ extends BaseClient {
2926
2976
  return response;
2927
2977
  });
2928
2978
  }
2929
- /**
2930
- * The SDK runtime module image ref.
2931
- */
2932
- sdkRuntime() {
2933
- return __awaiter(this, void 0, void 0, function* () {
2934
- if (this._sdkRuntime) {
2935
- return this._sdkRuntime;
2936
- }
2937
- const response = yield computeQuery([
2938
- ...this._queryTree,
2939
- {
2940
- operation: "sdkRuntime",
2941
- },
2942
- ], this.client);
2943
- return response;
2944
- });
2945
- }
2946
2979
  /**
2947
2980
  * Serve a module's API in the current session.
2948
2981
  * Note: this can only be called once per session.
2949
2982
  * In the future, it could return a stream or service to remove the side effect.
2950
2983
  */
2951
- serve(opts) {
2984
+ serve() {
2952
2985
  return __awaiter(this, void 0, void 0, function* () {
2953
2986
  if (this._serve) {
2954
2987
  return this._serve;
@@ -2957,7 +2990,6 @@ export class Module_ extends BaseClient {
2957
2990
  ...this._queryTree,
2958
2991
  {
2959
2992
  operation: "serve",
2960
- args: Object.assign({}, opts),
2961
2993
  },
2962
2994
  ], this.client);
2963
2995
  return response;
@@ -3021,80 +3053,65 @@ export class Module_ extends BaseClient {
3021
3053
  }
3022
3054
  }
3023
3055
  /**
3024
- * A definition of a custom object defined in a Module.
3056
+ * Static configuration for a module (e.g. parsed contents of dagger.json)
3025
3057
  */
3026
- export class ObjectTypeDef extends BaseClient {
3058
+ export class ModuleConfig extends BaseClient {
3027
3059
  /**
3028
3060
  * Constructor is used for internal usage only, do not create object from it.
3029
3061
  */
3030
- constructor(parent, _description, _name) {
3062
+ constructor(parent, _name, _root, _sdk) {
3031
3063
  super(parent);
3032
- this._description = undefined;
3033
3064
  this._name = undefined;
3034
- this._description = _description;
3065
+ this._root = undefined;
3066
+ this._sdk = undefined;
3035
3067
  this._name = _name;
3068
+ this._root = _root;
3069
+ this._sdk = _sdk;
3036
3070
  }
3037
3071
  /**
3038
- * The doc string for the object, if any
3072
+ * Modules that this module depends on.
3039
3073
  */
3040
- description() {
3074
+ dependencies() {
3041
3075
  return __awaiter(this, void 0, void 0, function* () {
3042
- if (this._description) {
3043
- return this._description;
3044
- }
3045
3076
  const response = yield computeQuery([
3046
3077
  ...this._queryTree,
3047
3078
  {
3048
- operation: "description",
3079
+ operation: "dependencies",
3049
3080
  },
3050
3081
  ], this.client);
3051
3082
  return response;
3052
3083
  });
3053
3084
  }
3054
3085
  /**
3055
- * Static fields defined on this object, if any
3086
+ * Exclude these file globs when loading the module root.
3056
3087
  */
3057
- fields() {
3088
+ exclude() {
3058
3089
  return __awaiter(this, void 0, void 0, function* () {
3059
3090
  const response = yield computeQuery([
3060
3091
  ...this._queryTree,
3061
3092
  {
3062
- operation: "fields",
3063
- },
3064
- {
3065
- operation: "description name",
3093
+ operation: "exclude",
3066
3094
  },
3067
3095
  ], this.client);
3068
- return response.map((r) => new FieldTypeDef({
3069
- queryTree: this.queryTree,
3070
- host: this.clientHost,
3071
- sessionToken: this.sessionToken,
3072
- }, r.description, r.name));
3096
+ return response;
3073
3097
  });
3074
3098
  }
3075
3099
  /**
3076
- * Functions defined on this object, if any
3100
+ * Include only these file globs when loading the module root.
3077
3101
  */
3078
- functions() {
3102
+ include() {
3079
3103
  return __awaiter(this, void 0, void 0, function* () {
3080
3104
  const response = yield computeQuery([
3081
3105
  ...this._queryTree,
3082
3106
  {
3083
- operation: "functions",
3084
- },
3085
- {
3086
- operation: "id",
3107
+ operation: "include",
3087
3108
  },
3088
3109
  ], this.client);
3089
- return response.map((r) => new Function_({
3090
- queryTree: this.queryTree,
3091
- host: this.clientHost,
3092
- sessionToken: this.sessionToken,
3093
- }, r.id));
3110
+ return response;
3094
3111
  });
3095
3112
  }
3096
3113
  /**
3097
- * The name of the object
3114
+ * The name of the module.
3098
3115
  */
3099
3116
  name() {
3100
3117
  return __awaiter(this, void 0, void 0, function* () {
@@ -3110,25 +3127,150 @@ export class ObjectTypeDef extends BaseClient {
3110
3127
  return response;
3111
3128
  });
3112
3129
  }
3113
- }
3114
- /**
3115
- * A port exposed by a container.
3116
- */
3117
- export class Port extends BaseClient {
3118
3130
  /**
3119
- * Constructor is used for internal usage only, do not create object from it.
3131
+ * The root directory of the module's project, which may be above the module source code.
3120
3132
  */
3121
- constructor(parent, _description, _port, _protocol) {
3122
- super(parent);
3123
- this._description = undefined;
3124
- this._port = undefined;
3125
- this._protocol = undefined;
3126
- this._description = _description;
3127
- this._port = _port;
3128
- this._protocol = _protocol;
3129
- }
3130
- /**
3131
- * The port description.
3133
+ root() {
3134
+ return __awaiter(this, void 0, void 0, function* () {
3135
+ if (this._root) {
3136
+ return this._root;
3137
+ }
3138
+ const response = yield computeQuery([
3139
+ ...this._queryTree,
3140
+ {
3141
+ operation: "root",
3142
+ },
3143
+ ], this.client);
3144
+ return response;
3145
+ });
3146
+ }
3147
+ /**
3148
+ * Either the name of a built-in SDK ('go', 'python', etc.) OR a module reference pointing to the SDK's module implementation.
3149
+ */
3150
+ sdk() {
3151
+ return __awaiter(this, void 0, void 0, function* () {
3152
+ if (this._sdk) {
3153
+ return this._sdk;
3154
+ }
3155
+ const response = yield computeQuery([
3156
+ ...this._queryTree,
3157
+ {
3158
+ operation: "sdk",
3159
+ },
3160
+ ], this.client);
3161
+ return response;
3162
+ });
3163
+ }
3164
+ }
3165
+ /**
3166
+ * A definition of a custom object defined in a Module.
3167
+ */
3168
+ export class ObjectTypeDef extends BaseClient {
3169
+ /**
3170
+ * Constructor is used for internal usage only, do not create object from it.
3171
+ */
3172
+ constructor(parent, _description, _name) {
3173
+ super(parent);
3174
+ this._description = undefined;
3175
+ this._name = undefined;
3176
+ this._description = _description;
3177
+ this._name = _name;
3178
+ }
3179
+ /**
3180
+ * The doc string for the object, if any
3181
+ */
3182
+ description() {
3183
+ return __awaiter(this, void 0, void 0, function* () {
3184
+ if (this._description) {
3185
+ return this._description;
3186
+ }
3187
+ const response = yield computeQuery([
3188
+ ...this._queryTree,
3189
+ {
3190
+ operation: "description",
3191
+ },
3192
+ ], this.client);
3193
+ return response;
3194
+ });
3195
+ }
3196
+ /**
3197
+ * Static fields defined on this object, if any
3198
+ */
3199
+ fields() {
3200
+ return __awaiter(this, void 0, void 0, function* () {
3201
+ const response = yield computeQuery([
3202
+ ...this._queryTree,
3203
+ {
3204
+ operation: "fields",
3205
+ },
3206
+ {
3207
+ operation: "description name",
3208
+ },
3209
+ ], this.client);
3210
+ return response.map((r) => new FieldTypeDef({
3211
+ queryTree: this.queryTree,
3212
+ host: this.clientHost,
3213
+ sessionToken: this.sessionToken,
3214
+ }, r.description, r.name));
3215
+ });
3216
+ }
3217
+ /**
3218
+ * Functions defined on this object, if any
3219
+ */
3220
+ functions() {
3221
+ return __awaiter(this, void 0, void 0, function* () {
3222
+ const response = yield computeQuery([
3223
+ ...this._queryTree,
3224
+ {
3225
+ operation: "functions",
3226
+ },
3227
+ {
3228
+ operation: "id",
3229
+ },
3230
+ ], this.client);
3231
+ return response.map((r) => new Function_({
3232
+ queryTree: this.queryTree,
3233
+ host: this.clientHost,
3234
+ sessionToken: this.sessionToken,
3235
+ }, r.id));
3236
+ });
3237
+ }
3238
+ /**
3239
+ * The name of the object
3240
+ */
3241
+ name() {
3242
+ return __awaiter(this, void 0, void 0, function* () {
3243
+ if (this._name) {
3244
+ return this._name;
3245
+ }
3246
+ const response = yield computeQuery([
3247
+ ...this._queryTree,
3248
+ {
3249
+ operation: "name",
3250
+ },
3251
+ ], this.client);
3252
+ return response;
3253
+ });
3254
+ }
3255
+ }
3256
+ /**
3257
+ * A port exposed by a container.
3258
+ */
3259
+ export class Port extends BaseClient {
3260
+ /**
3261
+ * Constructor is used for internal usage only, do not create object from it.
3262
+ */
3263
+ constructor(parent, _description, _port, _protocol) {
3264
+ super(parent);
3265
+ this._description = undefined;
3266
+ this._port = undefined;
3267
+ this._protocol = undefined;
3268
+ this._description = _description;
3269
+ this._port = _port;
3270
+ this._protocol = _protocol;
3271
+ }
3272
+ /**
3273
+ * The port description.
3132
3274
  */
3133
3275
  description() {
3134
3276
  return __awaiter(this, void 0, void 0, function* () {
@@ -3224,11 +3366,10 @@ export class Client extends BaseClient {
3224
3366
  });
3225
3367
  }
3226
3368
  /**
3227
- * Loads a container from ID.
3369
+ * Creates a scratch container or loads one by ID.
3228
3370
  *
3229
- * Null ID returns an empty container (scratch).
3230
- * Optional platform argument initializes new containers to execute and publish as that platform.
3231
- * Platform defaults to that of the builder's host.
3371
+ * Optional platform argument initializes new containers to execute and publish
3372
+ * as that platform. Platform defaults to that of the builder's host.
3232
3373
  */
3233
3374
  container(opts) {
3234
3375
  return new Container({
@@ -3290,7 +3431,7 @@ export class Client extends BaseClient {
3290
3431
  });
3291
3432
  }
3292
3433
  /**
3293
- * Load a directory by ID. No argument produces an empty directory.
3434
+ * Creates an empty directory or loads one by ID.
3294
3435
  */
3295
3436
  directory(opts) {
3296
3437
  return new Directory({
@@ -3307,6 +3448,7 @@ export class Client extends BaseClient {
3307
3448
  }
3308
3449
  /**
3309
3450
  * Loads a file by ID.
3451
+ * @deprecated Use loadFileFromID instead.
3310
3452
  */
3311
3453
  file(id) {
3312
3454
  return new File({
@@ -3322,15 +3464,15 @@ export class Client extends BaseClient {
3322
3464
  });
3323
3465
  }
3324
3466
  /**
3325
- * Load a function by ID
3467
+ * Create a function.
3326
3468
  */
3327
- function_(id) {
3469
+ function_(name, returnType) {
3328
3470
  return new Function_({
3329
3471
  queryTree: [
3330
3472
  ...this._queryTree,
3331
3473
  {
3332
3474
  operation: "function",
3333
- args: { id },
3475
+ args: { name, returnType },
3334
3476
  },
3335
3477
  ],
3336
3478
  host: this.clientHost,
@@ -3338,15 +3480,16 @@ export class Client extends BaseClient {
3338
3480
  });
3339
3481
  }
3340
3482
  /**
3341
- * Load GeneratedCode by ID, or create a new one if id is unset.
3483
+ * Create a code generation result, given a directory containing the generated
3484
+ * code.
3342
3485
  */
3343
- generatedCode(opts) {
3486
+ generatedCode(code) {
3344
3487
  return new GeneratedCode({
3345
3488
  queryTree: [
3346
3489
  ...this._queryTree,
3347
3490
  {
3348
3491
  operation: "generatedCode",
3349
- args: Object.assign({}, opts),
3492
+ args: { code },
3350
3493
  },
3351
3494
  ],
3352
3495
  host: this.clientHost,
@@ -3356,9 +3499,11 @@ export class Client extends BaseClient {
3356
3499
  /**
3357
3500
  * Queries a git repository.
3358
3501
  * @param url Url of the git repository.
3359
- * Can be formatted as https://{host}/{owner}/{repo}, git@{host}/{owner}/{repo}
3502
+ * Can be formatted as https://{host}/{owner}/{repo}, git@{host}:{owner}/{repo}
3360
3503
  * Suffix ".git" is optional.
3361
3504
  * @param opts.keepGitDir Set to true to keep .git directory.
3505
+ * @param opts.sshKnownHosts Set SSH known hosts
3506
+ * @param opts.sshAuthSocket Set SSH auth socket
3362
3507
  * @param opts.experimentalServiceHost A service which must be started before the repo is fetched.
3363
3508
  */
3364
3509
  git(url, opts) {
@@ -3408,15 +3553,206 @@ export class Client extends BaseClient {
3408
3553
  });
3409
3554
  }
3410
3555
  /**
3411
- * Load a module by ID, or create a new one if id is unset.
3556
+ * Load a CacheVolume from its ID.
3557
+ */
3558
+ loadCacheVolumeFromID(id) {
3559
+ return new CacheVolume({
3560
+ queryTree: [
3561
+ ...this._queryTree,
3562
+ {
3563
+ operation: "loadCacheVolumeFromID",
3564
+ args: { id },
3565
+ },
3566
+ ],
3567
+ host: this.clientHost,
3568
+ sessionToken: this.sessionToken,
3569
+ });
3570
+ }
3571
+ /**
3572
+ * Loads a container from an ID.
3573
+ */
3574
+ loadContainerFromID(id) {
3575
+ return new Container({
3576
+ queryTree: [
3577
+ ...this._queryTree,
3578
+ {
3579
+ operation: "loadContainerFromID",
3580
+ args: { id },
3581
+ },
3582
+ ],
3583
+ host: this.clientHost,
3584
+ sessionToken: this.sessionToken,
3585
+ });
3586
+ }
3587
+ /**
3588
+ * Load a Directory from its ID.
3589
+ */
3590
+ loadDirectoryFromID(id) {
3591
+ return new Directory({
3592
+ queryTree: [
3593
+ ...this._queryTree,
3594
+ {
3595
+ operation: "loadDirectoryFromID",
3596
+ args: { id },
3597
+ },
3598
+ ],
3599
+ host: this.clientHost,
3600
+ sessionToken: this.sessionToken,
3601
+ });
3602
+ }
3603
+ /**
3604
+ * Load a File from its ID.
3605
+ */
3606
+ loadFileFromID(id) {
3607
+ return new File({
3608
+ queryTree: [
3609
+ ...this._queryTree,
3610
+ {
3611
+ operation: "loadFileFromID",
3612
+ args: { id },
3613
+ },
3614
+ ],
3615
+ host: this.clientHost,
3616
+ sessionToken: this.sessionToken,
3617
+ });
3618
+ }
3619
+ /**
3620
+ * Load a function argument by ID.
3621
+ */
3622
+ loadFunctionArgFromID(id) {
3623
+ return new FunctionArg({
3624
+ queryTree: [
3625
+ ...this._queryTree,
3626
+ {
3627
+ operation: "loadFunctionArgFromID",
3628
+ args: { id },
3629
+ },
3630
+ ],
3631
+ host: this.clientHost,
3632
+ sessionToken: this.sessionToken,
3633
+ });
3634
+ }
3635
+ /**
3636
+ * Load a function by ID.
3637
+ */
3638
+ loadFunctionFromID(id) {
3639
+ return new Function_({
3640
+ queryTree: [
3641
+ ...this._queryTree,
3642
+ {
3643
+ operation: "loadFunctionFromID",
3644
+ args: { id },
3645
+ },
3646
+ ],
3647
+ host: this.clientHost,
3648
+ sessionToken: this.sessionToken,
3649
+ });
3650
+ }
3651
+ /**
3652
+ * Load a GeneratedCode by ID.
3653
+ */
3654
+ loadGeneratedCodeFromID(id) {
3655
+ return new GeneratedCode({
3656
+ queryTree: [
3657
+ ...this._queryTree,
3658
+ {
3659
+ operation: "loadGeneratedCodeFromID",
3660
+ args: { id },
3661
+ },
3662
+ ],
3663
+ host: this.clientHost,
3664
+ sessionToken: this.sessionToken,
3665
+ });
3666
+ }
3667
+ /**
3668
+ * Load a module by ID.
3412
3669
  */
3413
- module_(opts) {
3670
+ loadModuleFromID(id) {
3671
+ return new Module_({
3672
+ queryTree: [
3673
+ ...this._queryTree,
3674
+ {
3675
+ operation: "loadModuleFromID",
3676
+ args: { id },
3677
+ },
3678
+ ],
3679
+ host: this.clientHost,
3680
+ sessionToken: this.sessionToken,
3681
+ });
3682
+ }
3683
+ /**
3684
+ * Load a Secret from its ID.
3685
+ */
3686
+ loadSecretFromID(id) {
3687
+ return new Secret({
3688
+ queryTree: [
3689
+ ...this._queryTree,
3690
+ {
3691
+ operation: "loadSecretFromID",
3692
+ args: { id },
3693
+ },
3694
+ ],
3695
+ host: this.clientHost,
3696
+ sessionToken: this.sessionToken,
3697
+ });
3698
+ }
3699
+ /**
3700
+ * Loads a service from ID.
3701
+ */
3702
+ loadServiceFromID(id) {
3703
+ return new Service({
3704
+ queryTree: [
3705
+ ...this._queryTree,
3706
+ {
3707
+ operation: "loadServiceFromID",
3708
+ args: { id },
3709
+ },
3710
+ ],
3711
+ host: this.clientHost,
3712
+ sessionToken: this.sessionToken,
3713
+ });
3714
+ }
3715
+ /**
3716
+ * Load a Socket from its ID.
3717
+ */
3718
+ loadSocketFromID(id) {
3719
+ return new Socket({
3720
+ queryTree: [
3721
+ ...this._queryTree,
3722
+ {
3723
+ operation: "loadSocketFromID",
3724
+ args: { id },
3725
+ },
3726
+ ],
3727
+ host: this.clientHost,
3728
+ sessionToken: this.sessionToken,
3729
+ });
3730
+ }
3731
+ /**
3732
+ * Load a TypeDef by ID.
3733
+ */
3734
+ loadTypeDefFromID(id) {
3735
+ return new TypeDef({
3736
+ queryTree: [
3737
+ ...this._queryTree,
3738
+ {
3739
+ operation: "loadTypeDefFromID",
3740
+ args: { id },
3741
+ },
3742
+ ],
3743
+ host: this.clientHost,
3744
+ sessionToken: this.sessionToken,
3745
+ });
3746
+ }
3747
+ /**
3748
+ * Create a new module.
3749
+ */
3750
+ module_() {
3414
3751
  return new Module_({
3415
3752
  queryTree: [
3416
3753
  ...this._queryTree,
3417
3754
  {
3418
3755
  operation: "module",
3419
- args: Object.assign({}, opts),
3420
3756
  },
3421
3757
  ],
3422
3758
  host: this.clientHost,
@@ -3424,15 +3760,15 @@ export class Client extends BaseClient {
3424
3760
  });
3425
3761
  }
3426
3762
  /**
3427
- * Create a new function from the provided definition.
3763
+ * Load the static configuration for a module from the given source directory and optional subpath.
3428
3764
  */
3429
- newFunction(name, returnType) {
3430
- return new Function_({
3765
+ moduleConfig(sourceDirectory, opts) {
3766
+ return new ModuleConfig({
3431
3767
  queryTree: [
3432
3768
  ...this._queryTree,
3433
3769
  {
3434
- operation: "newFunction",
3435
- args: { name, returnType },
3770
+ operation: "moduleConfig",
3771
+ args: Object.assign({ sourceDirectory }, opts),
3436
3772
  },
3437
3773
  ],
3438
3774
  host: this.clientHost,
@@ -3460,6 +3796,7 @@ export class Client extends BaseClient {
3460
3796
  }
3461
3797
  /**
3462
3798
  * Loads a secret from its ID.
3799
+ * @deprecated Use loadSecretFromID instead
3463
3800
  */
3464
3801
  secret(id) {
3465
3802
  return new Secret({
@@ -3495,6 +3832,7 @@ export class Client extends BaseClient {
3495
3832
  }
3496
3833
  /**
3497
3834
  * Loads a socket by its ID.
3835
+ * @deprecated Use loadSocketFromID instead.
3498
3836
  */
3499
3837
  socket(opts) {
3500
3838
  return new Socket({
@@ -3509,13 +3847,15 @@ export class Client extends BaseClient {
3509
3847
  sessionToken: this.sessionToken,
3510
3848
  });
3511
3849
  }
3512
- typeDef(opts) {
3850
+ /**
3851
+ * Create a new TypeDef.
3852
+ */
3853
+ typeDef() {
3513
3854
  return new TypeDef({
3514
3855
  queryTree: [
3515
3856
  ...this._queryTree,
3516
3857
  {
3517
3858
  operation: "typeDef",
3518
- args: Object.assign({}, opts),
3519
3859
  },
3520
3860
  ],
3521
3861
  host: this.clientHost,
@@ -3580,6 +3920,133 @@ export class Secret extends BaseClient {
3580
3920
  });
3581
3921
  }
3582
3922
  }
3923
+ export class Service extends BaseClient {
3924
+ /**
3925
+ * Constructor is used for internal usage only, do not create object from it.
3926
+ */
3927
+ constructor(parent, _id, _endpoint, _hostname, _start, _stop) {
3928
+ super(parent);
3929
+ this._id = undefined;
3930
+ this._endpoint = undefined;
3931
+ this._hostname = undefined;
3932
+ this._start = undefined;
3933
+ this._stop = undefined;
3934
+ this._id = _id;
3935
+ this._endpoint = _endpoint;
3936
+ this._hostname = _hostname;
3937
+ this._start = _start;
3938
+ this._stop = _stop;
3939
+ }
3940
+ /**
3941
+ * A unique identifier for this service.
3942
+ */
3943
+ id() {
3944
+ return __awaiter(this, void 0, void 0, function* () {
3945
+ if (this._id) {
3946
+ return this._id;
3947
+ }
3948
+ const response = yield computeQuery([
3949
+ ...this._queryTree,
3950
+ {
3951
+ operation: "id",
3952
+ },
3953
+ ], this.client);
3954
+ return response;
3955
+ });
3956
+ }
3957
+ /**
3958
+ * Retrieves an endpoint that clients can use to reach this container.
3959
+ *
3960
+ * If no port is specified, the first exposed port is used. If none exist an error is returned.
3961
+ *
3962
+ * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
3963
+ * @param opts.port The exposed port number for the endpoint
3964
+ * @param opts.scheme Return a URL with the given scheme, eg. http for http://
3965
+ */
3966
+ endpoint(opts) {
3967
+ return __awaiter(this, void 0, void 0, function* () {
3968
+ if (this._endpoint) {
3969
+ return this._endpoint;
3970
+ }
3971
+ const response = yield computeQuery([
3972
+ ...this._queryTree,
3973
+ {
3974
+ operation: "endpoint",
3975
+ args: Object.assign({}, opts),
3976
+ },
3977
+ ], this.client);
3978
+ return response;
3979
+ });
3980
+ }
3981
+ /**
3982
+ * Retrieves a hostname which can be used by clients to reach this container.
3983
+ */
3984
+ hostname() {
3985
+ return __awaiter(this, void 0, void 0, function* () {
3986
+ if (this._hostname) {
3987
+ return this._hostname;
3988
+ }
3989
+ const response = yield computeQuery([
3990
+ ...this._queryTree,
3991
+ {
3992
+ operation: "hostname",
3993
+ },
3994
+ ], this.client);
3995
+ return response;
3996
+ });
3997
+ }
3998
+ /**
3999
+ * Retrieves the list of ports provided by the service.
4000
+ */
4001
+ ports() {
4002
+ return __awaiter(this, void 0, void 0, function* () {
4003
+ const response = yield computeQuery([
4004
+ ...this._queryTree,
4005
+ {
4006
+ operation: "ports",
4007
+ },
4008
+ {
4009
+ operation: "description port protocol",
4010
+ },
4011
+ ], this.client);
4012
+ return response.map((r) => new Port({
4013
+ queryTree: this.queryTree,
4014
+ host: this.clientHost,
4015
+ sessionToken: this.sessionToken,
4016
+ }, r.description, r.port, r.protocol));
4017
+ });
4018
+ }
4019
+ /**
4020
+ * Start the service and wait for its health checks to succeed.
4021
+ *
4022
+ * Services bound to a Container do not need to be manually started.
4023
+ */
4024
+ start() {
4025
+ return __awaiter(this, void 0, void 0, function* () {
4026
+ yield computeQuery([
4027
+ ...this._queryTree,
4028
+ {
4029
+ operation: "start",
4030
+ },
4031
+ ], this.client);
4032
+ return this;
4033
+ });
4034
+ }
4035
+ /**
4036
+ * Stop the service.
4037
+ */
4038
+ stop() {
4039
+ return __awaiter(this, void 0, void 0, function* () {
4040
+ yield computeQuery([
4041
+ ...this._queryTree,
4042
+ {
4043
+ operation: "stop",
4044
+ },
4045
+ ], this.client);
4046
+ return this;
4047
+ });
4048
+ }
4049
+ }
3583
4050
  export class Socket extends BaseClient {
3584
4051
  /**
3585
4052
  * Constructor is used for internal usage only, do not create object from it.