@dagger.io/dagger 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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_({
@@ -2027,14 +2013,14 @@ export class Function_ extends BaseClient {
2027
2013
  operation: "args",
2028
2014
  },
2029
2015
  {
2030
- operation: "defaultValue description name",
2016
+ operation: "id",
2031
2017
  },
2032
2018
  ], this.client);
2033
2019
  return response.map((r) => new FunctionArg({
2034
2020
  queryTree: this.queryTree,
2035
2021
  host: this.clientHost,
2036
2022
  sessionToken: this.sessionToken,
2037
- }, r.defaultValue, r.description, r.name));
2023
+ }, r.id));
2038
2024
  });
2039
2025
  }
2040
2026
  /**
@@ -2165,15 +2151,34 @@ export class FunctionArg extends BaseClient {
2165
2151
  /**
2166
2152
  * Constructor is used for internal usage only, do not create object from it.
2167
2153
  */
2168
- constructor(parent, _defaultValue, _description, _name) {
2154
+ constructor(parent, _id, _defaultValue, _description, _name) {
2169
2155
  super(parent);
2156
+ this._id = undefined;
2170
2157
  this._defaultValue = undefined;
2171
2158
  this._description = undefined;
2172
2159
  this._name = undefined;
2160
+ this._id = _id;
2173
2161
  this._defaultValue = _defaultValue;
2174
2162
  this._description = _description;
2175
2163
  this._name = _name;
2176
2164
  }
2165
+ /**
2166
+ * The ID of the argument
2167
+ */
2168
+ id() {
2169
+ return __awaiter(this, void 0, void 0, function* () {
2170
+ if (this._id) {
2171
+ return this._id;
2172
+ }
2173
+ const response = yield computeQuery([
2174
+ ...this._queryTree,
2175
+ {
2176
+ operation: "id",
2177
+ },
2178
+ ], this.client);
2179
+ return response;
2180
+ });
2181
+ }
2177
2182
  /**
2178
2183
  * A default value to use for this argument when not explicitly set by the caller, if any
2179
2184
  */
@@ -2462,22 +2467,6 @@ export class GeneratedCode extends BaseClient {
2462
2467
  return response;
2463
2468
  });
2464
2469
  }
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
2470
  /**
2482
2471
  * Set the list of paths to mark generated in version control
2483
2472
  */
@@ -2654,6 +2643,29 @@ export class Host extends BaseClient {
2654
2643
  sessionToken: this.sessionToken,
2655
2644
  });
2656
2645
  }
2646
+ /**
2647
+ * Creates a service that forwards traffic to a specified address via the host.
2648
+ * @param ports Ports to expose via the service, forwarding through the host network.
2649
+ *
2650
+ * If a port's frontend is unspecified or 0, it defaults to the same as the
2651
+ * backend port.
2652
+ *
2653
+ * An empty set of ports is not valid; an error will be returned.
2654
+ * @param opts.host Upstream host to forward traffic to.
2655
+ */
2656
+ service(ports, opts) {
2657
+ return new Service({
2658
+ queryTree: [
2659
+ ...this._queryTree,
2660
+ {
2661
+ operation: "service",
2662
+ args: Object.assign({ ports }, opts),
2663
+ },
2664
+ ],
2665
+ host: this.clientHost,
2666
+ sessionToken: this.sessionToken,
2667
+ });
2668
+ }
2657
2669
  /**
2658
2670
  * Sets a secret given a user-defined name and the file path on the host, and returns the secret.
2659
2671
  * The file is limited to a size of 512000 bytes.
@@ -2673,6 +2685,37 @@ export class Host extends BaseClient {
2673
2685
  sessionToken: this.sessionToken,
2674
2686
  });
2675
2687
  }
2688
+ /**
2689
+ * Creates a tunnel that forwards traffic from the host to a service.
2690
+ * @param service Service to send traffic from the tunnel.
2691
+ * @param opts.native Map each service port to the same port on the host, as if the service were
2692
+ * running natively.
2693
+ *
2694
+ * Note: enabling may result in port conflicts.
2695
+ * @param opts.ports Configure explicit port forwarding rules for the tunnel.
2696
+ *
2697
+ * If a port's frontend is unspecified or 0, a random port will be chosen by
2698
+ * the host.
2699
+ *
2700
+ * If no ports are given, all of the service's ports are forwarded. If native
2701
+ * is true, each port maps to the same port on the host. If native is false,
2702
+ * each port maps to a random port chosen by the host.
2703
+ *
2704
+ * If ports are given and native is true, the ports are additive.
2705
+ */
2706
+ tunnel(service, opts) {
2707
+ return new Service({
2708
+ queryTree: [
2709
+ ...this._queryTree,
2710
+ {
2711
+ operation: "tunnel",
2712
+ args: Object.assign({ service }, opts),
2713
+ },
2714
+ ],
2715
+ host: this.clientHost,
2716
+ sessionToken: this.sessionToken,
2717
+ });
2718
+ }
2676
2719
  /**
2677
2720
  * Accesses a Unix socket on the host.
2678
2721
  * @param path Location of the Unix socket (e.g., "/var/run/docker.sock").
@@ -2770,20 +2813,18 @@ export class Module_ extends BaseClient {
2770
2813
  /**
2771
2814
  * Constructor is used for internal usage only, do not create object from it.
2772
2815
  */
2773
- constructor(parent, _id, _description, _name, _sdk, _sdkRuntime, _serve, _sourceDirectorySubPath) {
2816
+ constructor(parent, _id, _description, _name, _sdk, _serve, _sourceDirectorySubPath) {
2774
2817
  super(parent);
2775
2818
  this._id = undefined;
2776
2819
  this._description = undefined;
2777
2820
  this._name = undefined;
2778
2821
  this._sdk = undefined;
2779
- this._sdkRuntime = undefined;
2780
2822
  this._serve = undefined;
2781
2823
  this._sourceDirectorySubPath = undefined;
2782
2824
  this._id = _id;
2783
2825
  this._description = _description;
2784
2826
  this._name = _name;
2785
2827
  this._sdk = _sdk;
2786
- this._sdkRuntime = _sdkRuntime;
2787
2828
  this._serve = _serve;
2788
2829
  this._sourceDirectorySubPath = _sourceDirectorySubPath;
2789
2830
  }
@@ -2910,7 +2951,7 @@ export class Module_ extends BaseClient {
2910
2951
  });
2911
2952
  }
2912
2953
  /**
2913
- * The SDK used by this module
2954
+ * The SDK used by this module. Either a name of a builtin SDK or a module ref pointing to the SDK's implementation.
2914
2955
  */
2915
2956
  sdk() {
2916
2957
  return __awaiter(this, void 0, void 0, function* () {
@@ -2926,29 +2967,12 @@ export class Module_ extends BaseClient {
2926
2967
  return response;
2927
2968
  });
2928
2969
  }
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
2970
  /**
2947
2971
  * Serve a module's API in the current session.
2948
2972
  * Note: this can only be called once per session.
2949
2973
  * In the future, it could return a stream or service to remove the side effect.
2950
2974
  */
2951
- serve(opts) {
2975
+ serve() {
2952
2976
  return __awaiter(this, void 0, void 0, function* () {
2953
2977
  if (this._serve) {
2954
2978
  return this._serve;
@@ -2957,7 +2981,6 @@ export class Module_ extends BaseClient {
2957
2981
  ...this._queryTree,
2958
2982
  {
2959
2983
  operation: "serve",
2960
- args: Object.assign({}, opts),
2961
2984
  },
2962
2985
  ], this.client);
2963
2986
  return response;
@@ -3020,6 +3043,116 @@ export class Module_ extends BaseClient {
3020
3043
  return arg(this);
3021
3044
  }
3022
3045
  }
3046
+ /**
3047
+ * Static configuration for a module (e.g. parsed contents of dagger.json)
3048
+ */
3049
+ export class ModuleConfig extends BaseClient {
3050
+ /**
3051
+ * Constructor is used for internal usage only, do not create object from it.
3052
+ */
3053
+ constructor(parent, _name, _root, _sdk) {
3054
+ super(parent);
3055
+ this._name = undefined;
3056
+ this._root = undefined;
3057
+ this._sdk = undefined;
3058
+ this._name = _name;
3059
+ this._root = _root;
3060
+ this._sdk = _sdk;
3061
+ }
3062
+ /**
3063
+ * Modules that this module depends on.
3064
+ */
3065
+ dependencies() {
3066
+ return __awaiter(this, void 0, void 0, function* () {
3067
+ const response = yield computeQuery([
3068
+ ...this._queryTree,
3069
+ {
3070
+ operation: "dependencies",
3071
+ },
3072
+ ], this.client);
3073
+ return response;
3074
+ });
3075
+ }
3076
+ /**
3077
+ * Exclude these file globs when loading the module root.
3078
+ */
3079
+ exclude() {
3080
+ return __awaiter(this, void 0, void 0, function* () {
3081
+ const response = yield computeQuery([
3082
+ ...this._queryTree,
3083
+ {
3084
+ operation: "exclude",
3085
+ },
3086
+ ], this.client);
3087
+ return response;
3088
+ });
3089
+ }
3090
+ /**
3091
+ * Include only these file globs when loading the module root.
3092
+ */
3093
+ include() {
3094
+ return __awaiter(this, void 0, void 0, function* () {
3095
+ const response = yield computeQuery([
3096
+ ...this._queryTree,
3097
+ {
3098
+ operation: "include",
3099
+ },
3100
+ ], this.client);
3101
+ return response;
3102
+ });
3103
+ }
3104
+ /**
3105
+ * The name of the module.
3106
+ */
3107
+ name() {
3108
+ return __awaiter(this, void 0, void 0, function* () {
3109
+ if (this._name) {
3110
+ return this._name;
3111
+ }
3112
+ const response = yield computeQuery([
3113
+ ...this._queryTree,
3114
+ {
3115
+ operation: "name",
3116
+ },
3117
+ ], this.client);
3118
+ return response;
3119
+ });
3120
+ }
3121
+ /**
3122
+ * The root directory of the module's project, which may be above the module source code.
3123
+ */
3124
+ root() {
3125
+ return __awaiter(this, void 0, void 0, function* () {
3126
+ if (this._root) {
3127
+ return this._root;
3128
+ }
3129
+ const response = yield computeQuery([
3130
+ ...this._queryTree,
3131
+ {
3132
+ operation: "root",
3133
+ },
3134
+ ], this.client);
3135
+ return response;
3136
+ });
3137
+ }
3138
+ /**
3139
+ * Either the name of a built-in SDK ('go', 'python', etc.) OR a module reference pointing to the SDK's module implementation.
3140
+ */
3141
+ sdk() {
3142
+ return __awaiter(this, void 0, void 0, function* () {
3143
+ if (this._sdk) {
3144
+ return this._sdk;
3145
+ }
3146
+ const response = yield computeQuery([
3147
+ ...this._queryTree,
3148
+ {
3149
+ operation: "sdk",
3150
+ },
3151
+ ], this.client);
3152
+ return response;
3153
+ });
3154
+ }
3155
+ }
3023
3156
  /**
3024
3157
  * A definition of a custom object defined in a Module.
3025
3158
  */
@@ -3224,11 +3357,10 @@ export class Client extends BaseClient {
3224
3357
  });
3225
3358
  }
3226
3359
  /**
3227
- * Loads a container from ID.
3360
+ * Creates a scratch container or loads one by ID.
3228
3361
  *
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.
3362
+ * Optional platform argument initializes new containers to execute and publish
3363
+ * as that platform. Platform defaults to that of the builder's host.
3232
3364
  */
3233
3365
  container(opts) {
3234
3366
  return new Container({
@@ -3290,7 +3422,7 @@ export class Client extends BaseClient {
3290
3422
  });
3291
3423
  }
3292
3424
  /**
3293
- * Load a directory by ID. No argument produces an empty directory.
3425
+ * Creates an empty directory or loads one by ID.
3294
3426
  */
3295
3427
  directory(opts) {
3296
3428
  return new Directory({
@@ -3307,6 +3439,7 @@ export class Client extends BaseClient {
3307
3439
  }
3308
3440
  /**
3309
3441
  * Loads a file by ID.
3442
+ * @deprecated Use loadFileFromID instead.
3310
3443
  */
3311
3444
  file(id) {
3312
3445
  return new File({
@@ -3322,15 +3455,15 @@ export class Client extends BaseClient {
3322
3455
  });
3323
3456
  }
3324
3457
  /**
3325
- * Load a function by ID
3458
+ * Create a function.
3326
3459
  */
3327
- function_(id) {
3460
+ function_(name, returnType) {
3328
3461
  return new Function_({
3329
3462
  queryTree: [
3330
3463
  ...this._queryTree,
3331
3464
  {
3332
3465
  operation: "function",
3333
- args: { id },
3466
+ args: { name, returnType },
3334
3467
  },
3335
3468
  ],
3336
3469
  host: this.clientHost,
@@ -3338,15 +3471,16 @@ export class Client extends BaseClient {
3338
3471
  });
3339
3472
  }
3340
3473
  /**
3341
- * Load GeneratedCode by ID, or create a new one if id is unset.
3474
+ * Create a code generation result, given a directory containing the generated
3475
+ * code.
3342
3476
  */
3343
- generatedCode(opts) {
3477
+ generatedCode(code) {
3344
3478
  return new GeneratedCode({
3345
3479
  queryTree: [
3346
3480
  ...this._queryTree,
3347
3481
  {
3348
3482
  operation: "generatedCode",
3349
- args: Object.assign({}, opts),
3483
+ args: { code },
3350
3484
  },
3351
3485
  ],
3352
3486
  host: this.clientHost,
@@ -3408,15 +3542,206 @@ export class Client extends BaseClient {
3408
3542
  });
3409
3543
  }
3410
3544
  /**
3411
- * Load a module by ID, or create a new one if id is unset.
3545
+ * Load a CacheVolume from its ID.
3412
3546
  */
3413
- module_(opts) {
3547
+ loadCacheVolumeFromID(id) {
3548
+ return new CacheVolume({
3549
+ queryTree: [
3550
+ ...this._queryTree,
3551
+ {
3552
+ operation: "loadCacheVolumeFromID",
3553
+ args: { id },
3554
+ },
3555
+ ],
3556
+ host: this.clientHost,
3557
+ sessionToken: this.sessionToken,
3558
+ });
3559
+ }
3560
+ /**
3561
+ * Loads a container from an ID.
3562
+ */
3563
+ loadContainerFromID(id) {
3564
+ return new Container({
3565
+ queryTree: [
3566
+ ...this._queryTree,
3567
+ {
3568
+ operation: "loadContainerFromID",
3569
+ args: { id },
3570
+ },
3571
+ ],
3572
+ host: this.clientHost,
3573
+ sessionToken: this.sessionToken,
3574
+ });
3575
+ }
3576
+ /**
3577
+ * Load a Directory from its ID.
3578
+ */
3579
+ loadDirectoryFromID(id) {
3580
+ return new Directory({
3581
+ queryTree: [
3582
+ ...this._queryTree,
3583
+ {
3584
+ operation: "loadDirectoryFromID",
3585
+ args: { id },
3586
+ },
3587
+ ],
3588
+ host: this.clientHost,
3589
+ sessionToken: this.sessionToken,
3590
+ });
3591
+ }
3592
+ /**
3593
+ * Load a File from its ID.
3594
+ */
3595
+ loadFileFromID(id) {
3596
+ return new File({
3597
+ queryTree: [
3598
+ ...this._queryTree,
3599
+ {
3600
+ operation: "loadFileFromID",
3601
+ args: { id },
3602
+ },
3603
+ ],
3604
+ host: this.clientHost,
3605
+ sessionToken: this.sessionToken,
3606
+ });
3607
+ }
3608
+ /**
3609
+ * Load a function argument by ID.
3610
+ */
3611
+ loadFunctionArgFromID(id) {
3612
+ return new FunctionArg({
3613
+ queryTree: [
3614
+ ...this._queryTree,
3615
+ {
3616
+ operation: "loadFunctionArgFromID",
3617
+ args: { id },
3618
+ },
3619
+ ],
3620
+ host: this.clientHost,
3621
+ sessionToken: this.sessionToken,
3622
+ });
3623
+ }
3624
+ /**
3625
+ * Load a function by ID.
3626
+ */
3627
+ loadFunctionFromID(id) {
3628
+ return new Function_({
3629
+ queryTree: [
3630
+ ...this._queryTree,
3631
+ {
3632
+ operation: "loadFunctionFromID",
3633
+ args: { id },
3634
+ },
3635
+ ],
3636
+ host: this.clientHost,
3637
+ sessionToken: this.sessionToken,
3638
+ });
3639
+ }
3640
+ /**
3641
+ * Load a GeneratedCode by ID.
3642
+ */
3643
+ loadGeneratedCodeFromID(id) {
3644
+ return new GeneratedCode({
3645
+ queryTree: [
3646
+ ...this._queryTree,
3647
+ {
3648
+ operation: "loadGeneratedCodeFromID",
3649
+ args: { id },
3650
+ },
3651
+ ],
3652
+ host: this.clientHost,
3653
+ sessionToken: this.sessionToken,
3654
+ });
3655
+ }
3656
+ /**
3657
+ * Load a module by ID.
3658
+ */
3659
+ loadModuleFromID(id) {
3660
+ return new Module_({
3661
+ queryTree: [
3662
+ ...this._queryTree,
3663
+ {
3664
+ operation: "loadModuleFromID",
3665
+ args: { id },
3666
+ },
3667
+ ],
3668
+ host: this.clientHost,
3669
+ sessionToken: this.sessionToken,
3670
+ });
3671
+ }
3672
+ /**
3673
+ * Load a Secret from its ID.
3674
+ */
3675
+ loadSecretFromID(id) {
3676
+ return new Secret({
3677
+ queryTree: [
3678
+ ...this._queryTree,
3679
+ {
3680
+ operation: "loadSecretFromID",
3681
+ args: { id },
3682
+ },
3683
+ ],
3684
+ host: this.clientHost,
3685
+ sessionToken: this.sessionToken,
3686
+ });
3687
+ }
3688
+ /**
3689
+ * Loads a service from ID.
3690
+ */
3691
+ loadServiceFromID(id) {
3692
+ return new Service({
3693
+ queryTree: [
3694
+ ...this._queryTree,
3695
+ {
3696
+ operation: "loadServiceFromID",
3697
+ args: { id },
3698
+ },
3699
+ ],
3700
+ host: this.clientHost,
3701
+ sessionToken: this.sessionToken,
3702
+ });
3703
+ }
3704
+ /**
3705
+ * Load a Socket from its ID.
3706
+ */
3707
+ loadSocketFromID(id) {
3708
+ return new Socket({
3709
+ queryTree: [
3710
+ ...this._queryTree,
3711
+ {
3712
+ operation: "loadSocketFromID",
3713
+ args: { id },
3714
+ },
3715
+ ],
3716
+ host: this.clientHost,
3717
+ sessionToken: this.sessionToken,
3718
+ });
3719
+ }
3720
+ /**
3721
+ * Load a TypeDef by ID.
3722
+ */
3723
+ loadTypeDefFromID(id) {
3724
+ return new TypeDef({
3725
+ queryTree: [
3726
+ ...this._queryTree,
3727
+ {
3728
+ operation: "loadTypeDefFromID",
3729
+ args: { id },
3730
+ },
3731
+ ],
3732
+ host: this.clientHost,
3733
+ sessionToken: this.sessionToken,
3734
+ });
3735
+ }
3736
+ /**
3737
+ * Create a new module.
3738
+ */
3739
+ module_() {
3414
3740
  return new Module_({
3415
3741
  queryTree: [
3416
3742
  ...this._queryTree,
3417
3743
  {
3418
3744
  operation: "module",
3419
- args: Object.assign({}, opts),
3420
3745
  },
3421
3746
  ],
3422
3747
  host: this.clientHost,
@@ -3424,15 +3749,15 @@ export class Client extends BaseClient {
3424
3749
  });
3425
3750
  }
3426
3751
  /**
3427
- * Create a new function from the provided definition.
3752
+ * Load the static configuration for a module from the given source directory and optional subpath.
3428
3753
  */
3429
- newFunction(name, returnType) {
3430
- return new Function_({
3754
+ moduleConfig(sourceDirectory, opts) {
3755
+ return new ModuleConfig({
3431
3756
  queryTree: [
3432
3757
  ...this._queryTree,
3433
3758
  {
3434
- operation: "newFunction",
3435
- args: { name, returnType },
3759
+ operation: "moduleConfig",
3760
+ args: Object.assign({ sourceDirectory }, opts),
3436
3761
  },
3437
3762
  ],
3438
3763
  host: this.clientHost,
@@ -3460,6 +3785,7 @@ export class Client extends BaseClient {
3460
3785
  }
3461
3786
  /**
3462
3787
  * Loads a secret from its ID.
3788
+ * @deprecated Use loadSecretFromID instead
3463
3789
  */
3464
3790
  secret(id) {
3465
3791
  return new Secret({
@@ -3495,6 +3821,7 @@ export class Client extends BaseClient {
3495
3821
  }
3496
3822
  /**
3497
3823
  * Loads a socket by its ID.
3824
+ * @deprecated Use loadSocketFromID instead.
3498
3825
  */
3499
3826
  socket(opts) {
3500
3827
  return new Socket({
@@ -3509,13 +3836,15 @@ export class Client extends BaseClient {
3509
3836
  sessionToken: this.sessionToken,
3510
3837
  });
3511
3838
  }
3512
- typeDef(opts) {
3839
+ /**
3840
+ * Create a new TypeDef.
3841
+ */
3842
+ typeDef() {
3513
3843
  return new TypeDef({
3514
3844
  queryTree: [
3515
3845
  ...this._queryTree,
3516
3846
  {
3517
3847
  operation: "typeDef",
3518
- args: Object.assign({}, opts),
3519
3848
  },
3520
3849
  ],
3521
3850
  host: this.clientHost,
@@ -3580,6 +3909,133 @@ export class Secret extends BaseClient {
3580
3909
  });
3581
3910
  }
3582
3911
  }
3912
+ export class Service extends BaseClient {
3913
+ /**
3914
+ * Constructor is used for internal usage only, do not create object from it.
3915
+ */
3916
+ constructor(parent, _id, _endpoint, _hostname, _start, _stop) {
3917
+ super(parent);
3918
+ this._id = undefined;
3919
+ this._endpoint = undefined;
3920
+ this._hostname = undefined;
3921
+ this._start = undefined;
3922
+ this._stop = undefined;
3923
+ this._id = _id;
3924
+ this._endpoint = _endpoint;
3925
+ this._hostname = _hostname;
3926
+ this._start = _start;
3927
+ this._stop = _stop;
3928
+ }
3929
+ /**
3930
+ * A unique identifier for this service.
3931
+ */
3932
+ id() {
3933
+ return __awaiter(this, void 0, void 0, function* () {
3934
+ if (this._id) {
3935
+ return this._id;
3936
+ }
3937
+ const response = yield computeQuery([
3938
+ ...this._queryTree,
3939
+ {
3940
+ operation: "id",
3941
+ },
3942
+ ], this.client);
3943
+ return response;
3944
+ });
3945
+ }
3946
+ /**
3947
+ * Retrieves an endpoint that clients can use to reach this container.
3948
+ *
3949
+ * If no port is specified, the first exposed port is used. If none exist an error is returned.
3950
+ *
3951
+ * If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
3952
+ * @param opts.port The exposed port number for the endpoint
3953
+ * @param opts.scheme Return a URL with the given scheme, eg. http for http://
3954
+ */
3955
+ endpoint(opts) {
3956
+ return __awaiter(this, void 0, void 0, function* () {
3957
+ if (this._endpoint) {
3958
+ return this._endpoint;
3959
+ }
3960
+ const response = yield computeQuery([
3961
+ ...this._queryTree,
3962
+ {
3963
+ operation: "endpoint",
3964
+ args: Object.assign({}, opts),
3965
+ },
3966
+ ], this.client);
3967
+ return response;
3968
+ });
3969
+ }
3970
+ /**
3971
+ * Retrieves a hostname which can be used by clients to reach this container.
3972
+ */
3973
+ hostname() {
3974
+ return __awaiter(this, void 0, void 0, function* () {
3975
+ if (this._hostname) {
3976
+ return this._hostname;
3977
+ }
3978
+ const response = yield computeQuery([
3979
+ ...this._queryTree,
3980
+ {
3981
+ operation: "hostname",
3982
+ },
3983
+ ], this.client);
3984
+ return response;
3985
+ });
3986
+ }
3987
+ /**
3988
+ * Retrieves the list of ports provided by the service.
3989
+ */
3990
+ ports() {
3991
+ return __awaiter(this, void 0, void 0, function* () {
3992
+ const response = yield computeQuery([
3993
+ ...this._queryTree,
3994
+ {
3995
+ operation: "ports",
3996
+ },
3997
+ {
3998
+ operation: "description port protocol",
3999
+ },
4000
+ ], this.client);
4001
+ return response.map((r) => new Port({
4002
+ queryTree: this.queryTree,
4003
+ host: this.clientHost,
4004
+ sessionToken: this.sessionToken,
4005
+ }, r.description, r.port, r.protocol));
4006
+ });
4007
+ }
4008
+ /**
4009
+ * Start the service and wait for its health checks to succeed.
4010
+ *
4011
+ * Services bound to a Container do not need to be manually started.
4012
+ */
4013
+ start() {
4014
+ return __awaiter(this, void 0, void 0, function* () {
4015
+ yield computeQuery([
4016
+ ...this._queryTree,
4017
+ {
4018
+ operation: "start",
4019
+ },
4020
+ ], this.client);
4021
+ return this;
4022
+ });
4023
+ }
4024
+ /**
4025
+ * Stop the service.
4026
+ */
4027
+ stop() {
4028
+ return __awaiter(this, void 0, void 0, function* () {
4029
+ yield computeQuery([
4030
+ ...this._queryTree,
4031
+ {
4032
+ operation: "stop",
4033
+ },
4034
+ ], this.client);
4035
+ return this;
4036
+ });
4037
+ }
4038
+ }
3583
4039
  export class Socket extends BaseClient {
3584
4040
  /**
3585
4041
  * Constructor is used for internal usage only, do not create object from it.