@dagger.io/dagger 0.18.17 → 0.18.18

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.
@@ -542,6 +542,13 @@ export class Binding extends BaseClient {
542
542
  const ctx = this._ctx.select("asCacheVolume");
543
543
  return new CacheVolume(ctx);
544
544
  };
545
+ /**
546
+ * Retrieve the binding value, as type Changeset
547
+ */
548
+ asChangeset = () => {
549
+ const ctx = this._ctx.select("asChangeset");
550
+ return new Changeset(ctx);
551
+ };
545
552
  /**
546
553
  * Retrieve the binding value, as type Cloud
547
554
  */
@@ -570,6 +577,13 @@ export class Binding extends BaseClient {
570
577
  const ctx = this._ctx.select("asEnv");
571
578
  return new Env(ctx);
572
579
  };
580
+ /**
581
+ * Retrieve the binding value, as type EnvFile
582
+ */
583
+ asEnvFile = () => {
584
+ const ctx = this._ctx.select("asEnvFile");
585
+ return new EnvFile(ctx);
586
+ };
573
587
  /**
574
588
  * Retrieve the binding value, as type File
575
589
  */
@@ -741,6 +755,92 @@ export class CacheVolume extends BaseClient {
741
755
  return response;
742
756
  };
743
757
  }
758
+ /**
759
+ * A comparison between two directories representing changes that can be applied.
760
+ */
761
+ export class Changeset extends BaseClient {
762
+ _id = undefined;
763
+ _sync = undefined;
764
+ /**
765
+ * Constructor is used for internal usage only, do not create object from it.
766
+ */
767
+ constructor(ctx, _id, _sync) {
768
+ super(ctx);
769
+ this._id = _id;
770
+ this._sync = _sync;
771
+ }
772
+ /**
773
+ * A unique identifier for this Changeset.
774
+ */
775
+ id = async () => {
776
+ if (this._id) {
777
+ return this._id;
778
+ }
779
+ const ctx = this._ctx.select("id");
780
+ const response = await ctx.execute();
781
+ return response;
782
+ };
783
+ /**
784
+ * Files and directories that were added in the newer directory.
785
+ */
786
+ addedPaths = async () => {
787
+ const ctx = this._ctx.select("addedPaths");
788
+ const response = await ctx.execute();
789
+ return response;
790
+ };
791
+ /**
792
+ * The newer/upper snapshot.
793
+ */
794
+ after = () => {
795
+ const ctx = this._ctx.select("after");
796
+ return new Directory(ctx);
797
+ };
798
+ /**
799
+ * Return a Git-compatible patch of the changes
800
+ */
801
+ asPatch = () => {
802
+ const ctx = this._ctx.select("asPatch");
803
+ return new File(ctx);
804
+ };
805
+ /**
806
+ * The older/lower snapshot to compare against.
807
+ */
808
+ before = () => {
809
+ const ctx = this._ctx.select("before");
810
+ return new Directory(ctx);
811
+ };
812
+ /**
813
+ * Return a snapshot containing only the created and modified files
814
+ */
815
+ layer = () => {
816
+ const ctx = this._ctx.select("layer");
817
+ return new Directory(ctx);
818
+ };
819
+ /**
820
+ * Files and directories that existed before and were updated in the newer directory.
821
+ */
822
+ modifiedPaths = async () => {
823
+ const ctx = this._ctx.select("modifiedPaths");
824
+ const response = await ctx.execute();
825
+ return response;
826
+ };
827
+ /**
828
+ * Files and directories that were removed. Directories are indicated by a trailing slash, and their child paths are not included.
829
+ */
830
+ removedPaths = async () => {
831
+ const ctx = this._ctx.select("removedPaths");
832
+ const response = await ctx.execute();
833
+ return response;
834
+ };
835
+ /**
836
+ * Force evaluation in the engine.
837
+ */
838
+ sync = async () => {
839
+ const ctx = this._ctx.select("sync");
840
+ const response = await ctx.execute();
841
+ return new Client(ctx.copy()).loadChangesetFromID(response);
842
+ };
843
+ }
744
844
  /**
745
845
  * Dagger Cloud configuration and state
746
846
  */
@@ -1874,17 +1974,19 @@ export class Directory extends BaseClient {
1874
1974
  _digest = undefined;
1875
1975
  _exists = undefined;
1876
1976
  _export = undefined;
1977
+ _findUp = undefined;
1877
1978
  _name = undefined;
1878
1979
  _sync = undefined;
1879
1980
  /**
1880
1981
  * Constructor is used for internal usage only, do not create object from it.
1881
1982
  */
1882
- constructor(ctx, _id, _digest, _exists, _export, _name, _sync) {
1983
+ constructor(ctx, _id, _digest, _exists, _export, _findUp, _name, _sync) {
1883
1984
  super(ctx);
1884
1985
  this._id = _id;
1885
1986
  this._digest = _digest;
1886
1987
  this._exists = _exists;
1887
1988
  this._export = _export;
1989
+ this._findUp = _findUp;
1888
1990
  this._name = _name;
1889
1991
  this._sync = _sync;
1890
1992
  }
@@ -1926,6 +2028,29 @@ export class Directory extends BaseClient {
1926
2028
  const ctx = this._ctx.select("asModuleSource", { ...opts });
1927
2029
  return new ModuleSource(ctx);
1928
2030
  };
2031
+ /**
2032
+ * Return the difference between this directory and another directory, typically an older snapshot.
2033
+ *
2034
+ * The difference is encoded as a changeset, which also tracks removed files, and can be applied to other directories.
2035
+ * @param from The base directory snapshot to compare against
2036
+ */
2037
+ changes = (from) => {
2038
+ const ctx = this._ctx.select("changes", { from });
2039
+ return new Changeset(ctx);
2040
+ };
2041
+ /**
2042
+ * Change the owner of the directory contents recursively.
2043
+ * @param path Path of the directory to change ownership of (e.g., "/").
2044
+ * @param owner A user:group to set for the mounted directory and its contents.
2045
+ *
2046
+ * The user and group must be an ID (1000:1000), not a name (foo:bar).
2047
+ *
2048
+ * If the group is omitted, it defaults to the same as the user.
2049
+ */
2050
+ chown = (path, owner) => {
2051
+ const ctx = this._ctx.select("chown", { path, owner });
2052
+ return new Directory(ctx);
2053
+ };
1929
2054
  /**
1930
2055
  * Return the difference between this directory and an another directory. The difference is encoded as a directory.
1931
2056
  * @param other The directory to compare against
@@ -2030,6 +2155,19 @@ export class Directory extends BaseClient {
2030
2155
  const ctx = this._ctx.select("filter", { ...opts });
2031
2156
  return new Directory(ctx);
2032
2157
  };
2158
+ /**
2159
+ * Search up the directory tree for a file or directory, and return its path. If no match, return null
2160
+ * @param name The name of the file or directory to search for
2161
+ * @param start The path to start the search from
2162
+ */
2163
+ findUp = async (name, start) => {
2164
+ if (this._findUp) {
2165
+ return this._findUp;
2166
+ }
2167
+ const ctx = this._ctx.select("findUp", { name, start });
2168
+ const response = await ctx.execute();
2169
+ return response;
2170
+ };
2033
2171
  /**
2034
2172
  * Returns a list of files and directories that matche the given pattern.
2035
2173
  * @param pattern Pattern to match (e.g., "*.md").
@@ -2090,12 +2228,25 @@ export class Directory extends BaseClient {
2090
2228
  const ctx = this._ctx.select("terminal", { ...opts });
2091
2229
  return new Directory(ctx);
2092
2230
  };
2231
+ /**
2232
+ * Return a directory with changes from another directory applied to it.
2233
+ * @param changes Changes to apply to the directory
2234
+ */
2235
+ withChanges = (changes) => {
2236
+ const ctx = this._ctx.select("withChanges", { changes });
2237
+ return new Directory(ctx);
2238
+ };
2093
2239
  /**
2094
2240
  * Return a snapshot with a directory added
2095
2241
  * @param path Location of the written directory (e.g., "/src/").
2096
2242
  * @param directory Identifier of the directory to copy.
2097
2243
  * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
2098
2244
  * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
2245
+ * @param opts.owner A user:group to set for the copied directory and its contents.
2246
+ *
2247
+ * The user and group must be an ID (1000:1000), not a name (foo:bar).
2248
+ *
2249
+ * If the group is omitted, it defaults to the same as the user.
2099
2250
  */
2100
2251
  withDirectory = (path, directory, opts) => {
2101
2252
  const ctx = this._ctx.select("withDirectory", { path, directory, ...opts });
@@ -2106,6 +2257,11 @@ export class Directory extends BaseClient {
2106
2257
  * @param path Location of the copied file (e.g., "/file.txt").
2107
2258
  * @param source Identifier of the file to copy.
2108
2259
  * @param opts.permissions Permission given to the copied file (e.g., 0600).
2260
+ * @param opts.owner A user:group to set for the copied directory and its contents.
2261
+ *
2262
+ * The user and group must be an ID (1000:1000), not a name (foo:bar).
2263
+ *
2264
+ * If the group is omitted, it defaults to the same as the user.
2109
2265
  */
2110
2266
  withFile = (path, source, opts) => {
2111
2267
  const ctx = this._ctx.select("withFile", { path, source, ...opts });
@@ -2149,6 +2305,15 @@ export class Directory extends BaseClient {
2149
2305
  const ctx = this._ctx.select("withPatch", { patch });
2150
2306
  return new Directory(ctx);
2151
2307
  };
2308
+ /**
2309
+ * Retrieves this directory with the given Git-compatible patch file applied.
2310
+ * @param patch File containing the patch to apply
2311
+ * @experimental
2312
+ */
2313
+ withPatchFile = (patch) => {
2314
+ const ctx = this._ctx.select("withPatchFile", { patch });
2315
+ return new Directory(ctx);
2316
+ };
2152
2317
  /**
2153
2318
  * Return a snapshot with a symlink
2154
2319
  * @param target Location of the file or directory to link to (e.g., "/existing/file").
@@ -2718,6 +2883,29 @@ export class Env extends BaseClient {
2718
2883
  const ctx = this._ctx.select("withCacheVolumeOutput", { name, description });
2719
2884
  return new Env(ctx);
2720
2885
  };
2886
+ /**
2887
+ * Create or update a binding of type Changeset in the environment
2888
+ * @param name The name of the binding
2889
+ * @param value The Changeset value to assign to the binding
2890
+ * @param description The purpose of the input
2891
+ */
2892
+ withChangesetInput = (name, value, description) => {
2893
+ const ctx = this._ctx.select("withChangesetInput", {
2894
+ name,
2895
+ value,
2896
+ description,
2897
+ });
2898
+ return new Env(ctx);
2899
+ };
2900
+ /**
2901
+ * Declare a desired Changeset output to be assigned in the environment
2902
+ * @param name The name of the binding
2903
+ * @param description A description of the desired value of the binding
2904
+ */
2905
+ withChangesetOutput = (name, description) => {
2906
+ const ctx = this._ctx.select("withChangesetOutput", { name, description });
2907
+ return new Env(ctx);
2908
+ };
2721
2909
  /**
2722
2910
  * Create or update a binding of type Cloud in the environment
2723
2911
  * @param name The name of the binding
@@ -2783,6 +2971,29 @@ export class Env extends BaseClient {
2783
2971
  const ctx = this._ctx.select("withDirectoryOutput", { name, description });
2784
2972
  return new Env(ctx);
2785
2973
  };
2974
+ /**
2975
+ * Create or update a binding of type EnvFile in the environment
2976
+ * @param name The name of the binding
2977
+ * @param value The EnvFile value to assign to the binding
2978
+ * @param description The purpose of the input
2979
+ */
2980
+ withEnvFileInput = (name, value, description) => {
2981
+ const ctx = this._ctx.select("withEnvFileInput", {
2982
+ name,
2983
+ value,
2984
+ description,
2985
+ });
2986
+ return new Env(ctx);
2987
+ };
2988
+ /**
2989
+ * Declare a desired EnvFile output to be assigned in the environment
2990
+ * @param name The name of the binding
2991
+ * @param description A description of the desired value of the binding
2992
+ */
2993
+ withEnvFileOutput = (name, description) => {
2994
+ const ctx = this._ctx.select("withEnvFileOutput", { name, description });
2995
+ return new Env(ctx);
2996
+ };
2786
2997
  /**
2787
2998
  * Create or update a binding of type Env in the environment
2788
2999
  * @param name The name of the binding
@@ -3140,6 +3351,98 @@ export class Env extends BaseClient {
3140
3351
  return arg(this);
3141
3352
  };
3142
3353
  }
3354
+ /**
3355
+ * A collection of environment variables.
3356
+ */
3357
+ export class EnvFile extends BaseClient {
3358
+ _id = undefined;
3359
+ _exists = undefined;
3360
+ _get = undefined;
3361
+ /**
3362
+ * Constructor is used for internal usage only, do not create object from it.
3363
+ */
3364
+ constructor(ctx, _id, _exists, _get) {
3365
+ super(ctx);
3366
+ this._id = _id;
3367
+ this._exists = _exists;
3368
+ this._get = _get;
3369
+ }
3370
+ /**
3371
+ * A unique identifier for this EnvFile.
3372
+ */
3373
+ id = async () => {
3374
+ if (this._id) {
3375
+ return this._id;
3376
+ }
3377
+ const ctx = this._ctx.select("id");
3378
+ const response = await ctx.execute();
3379
+ return response;
3380
+ };
3381
+ /**
3382
+ * Return as a file
3383
+ */
3384
+ asFile = () => {
3385
+ const ctx = this._ctx.select("asFile");
3386
+ return new File(ctx);
3387
+ };
3388
+ /**
3389
+ * Check if a variable exists
3390
+ * @param name Variable name
3391
+ */
3392
+ exists = async (name) => {
3393
+ if (this._exists) {
3394
+ return this._exists;
3395
+ }
3396
+ const ctx = this._ctx.select("exists", { name });
3397
+ const response = await ctx.execute();
3398
+ return response;
3399
+ };
3400
+ /**
3401
+ * Lookup a variable (last occurrence wins) and return its value, or an empty string
3402
+ * @param name Variable name
3403
+ */
3404
+ get = async (name) => {
3405
+ if (this._get) {
3406
+ return this._get;
3407
+ }
3408
+ const ctx = this._ctx.select("get", { name });
3409
+ const response = await ctx.execute();
3410
+ return response;
3411
+ };
3412
+ /**
3413
+ * Return all variables
3414
+ */
3415
+ variables = async () => {
3416
+ const ctx = this._ctx.select("variables").select("id");
3417
+ const response = await ctx.execute();
3418
+ return response.map((r) => new Client(ctx.copy()).loadEnvVariableFromID(r.id));
3419
+ };
3420
+ /**
3421
+ * Add a variable
3422
+ * @param name Variable name
3423
+ * @param value Variable value
3424
+ */
3425
+ withVariable = (name, value) => {
3426
+ const ctx = this._ctx.select("withVariable", { name, value });
3427
+ return new EnvFile(ctx);
3428
+ };
3429
+ /**
3430
+ * Remove all occurrences of the named variable
3431
+ * @param name Variable name
3432
+ */
3433
+ withoutVariable = (name) => {
3434
+ const ctx = this._ctx.select("withoutVariable", { name });
3435
+ return new EnvFile(ctx);
3436
+ };
3437
+ /**
3438
+ * Call the provided function with current EnvFile.
3439
+ *
3440
+ * This is useful for reusability and readability by not breaking the calling chain.
3441
+ */
3442
+ with = (arg) => {
3443
+ return arg(this);
3444
+ };
3445
+ }
3143
3446
  /**
3144
3447
  * An environment variable name and value.
3145
3448
  */
@@ -3397,6 +3700,26 @@ export class File extends BaseClient {
3397
3700
  const response = await ctx.execute();
3398
3701
  return response;
3399
3702
  };
3703
+ /**
3704
+ * Parse as an env file
3705
+ * @param opts.expand Replace "${VAR}" or "$VAR" with the value of other vars
3706
+ */
3707
+ asEnvFile = (opts) => {
3708
+ const ctx = this._ctx.select("asEnvFile", { ...opts });
3709
+ return new EnvFile(ctx);
3710
+ };
3711
+ /**
3712
+ * Change the owner of the file recursively.
3713
+ * @param owner A user:group to set for the file.
3714
+ *
3715
+ * The user and group must be an ID (1000:1000), not a name (foo:bar).
3716
+ *
3717
+ * If the group is omitted, it defaults to the same as the user.
3718
+ */
3719
+ chown = (owner) => {
3720
+ const ctx = this._ctx.select("chown", { owner });
3721
+ return new File(ctx);
3722
+ };
3400
3723
  /**
3401
3724
  * Retrieves the contents of the file.
3402
3725
  * @param opts.offsetLines Start reading after this line
@@ -4169,12 +4492,14 @@ export class GitRepository extends BaseClient {
4169
4492
  */
4170
4493
  export class Host extends BaseClient {
4171
4494
  _id = undefined;
4495
+ _findUp = undefined;
4172
4496
  /**
4173
4497
  * Constructor is used for internal usage only, do not create object from it.
4174
4498
  */
4175
- constructor(ctx, _id) {
4499
+ constructor(ctx, _id, _findUp) {
4176
4500
  super(ctx);
4177
4501
  this._id = _id;
4502
+ this._findUp = _findUp;
4178
4503
  }
4179
4504
  /**
4180
4505
  * A unique identifier for this Host.
@@ -4201,7 +4526,7 @@ export class Host extends BaseClient {
4201
4526
  * @param opts.exclude Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
4202
4527
  * @param opts.include Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
4203
4528
  * @param opts.noCache If true, the directory will always be reloaded from the host.
4204
- * @param opts.noGitAutoIgnore Don't apply .gitignore filter rules inside the directory
4529
+ * @param opts.gitignore Apply .gitignore filter rules inside the directory
4205
4530
  */
4206
4531
  directory = (path, opts) => {
4207
4532
  const ctx = this._ctx.select("directory", { path, ...opts });
@@ -4216,6 +4541,18 @@ export class Host extends BaseClient {
4216
4541
  const ctx = this._ctx.select("file", { path, ...opts });
4217
4542
  return new File(ctx);
4218
4543
  };
4544
+ /**
4545
+ * Search for a file or directory by walking up the tree from system workdir. Return its relative path. If no match, return null
4546
+ * @param name name of the file or directory to search for
4547
+ */
4548
+ findUp = async (name, opts) => {
4549
+ if (this._findUp) {
4550
+ return this._findUp;
4551
+ }
4552
+ const ctx = this._ctx.select("findUp", { name, ...opts });
4553
+ const response = await ctx.execute();
4554
+ return response;
4555
+ };
4219
4556
  /**
4220
4557
  * Creates a service that forwards traffic to a specified address via the host.
4221
4558
  * @param ports Ports to expose via the service, forwarding through the host network.
@@ -5821,6 +6158,14 @@ export class Client extends BaseClient {
5821
6158
  const ctx = this._ctx.select("env", { ...opts });
5822
6159
  return new Env(ctx);
5823
6160
  };
6161
+ /**
6162
+ * Initialize an environment file
6163
+ * @param opts.expand Replace "${VAR}" or "$VAR" with the value of other vars
6164
+ */
6165
+ envFile = (opts) => {
6166
+ const ctx = this._ctx.select("envFile", { ...opts });
6167
+ return new EnvFile(ctx);
6168
+ };
5824
6169
  /**
5825
6170
  * Create a new error.
5826
6171
  * @param message A brief description of the error.
@@ -5924,6 +6269,13 @@ export class Client extends BaseClient {
5924
6269
  const ctx = this._ctx.select("loadCacheVolumeFromID", { id });
5925
6270
  return new CacheVolume(ctx);
5926
6271
  };
6272
+ /**
6273
+ * Load a Changeset from its ID.
6274
+ */
6275
+ loadChangesetFromID = (id) => {
6276
+ const ctx = this._ctx.select("loadChangesetFromID", { id });
6277
+ return new Changeset(ctx);
6278
+ };
5927
6279
  /**
5928
6280
  * Load a Cloud from its ID.
5929
6281
  */
@@ -5994,6 +6346,13 @@ export class Client extends BaseClient {
5994
6346
  const ctx = this._ctx.select("loadEnumValueTypeDefFromID", { id });
5995
6347
  return new EnumValueTypeDef(ctx);
5996
6348
  };
6349
+ /**
6350
+ * Load a EnvFile from its ID.
6351
+ */
6352
+ loadEnvFileFromID = (id) => {
6353
+ const ctx = this._ctx.select("loadEnvFileFromID", { id });
6354
+ return new EnvFile(ctx);
6355
+ };
5997
6356
  /**
5998
6357
  * Load a Env from its ID.
5999
6358
  */
@@ -8,6 +8,7 @@ export declare const log: (stack?: string) => {
8
8
  setLogStream(stream: import("stream")): /*elided*/ any;
9
9
  setLevelNoColor(): void;
10
10
  setLevelColor(): void;
11
+ enableFileAndLine(enable: boolean, isShortFile?: boolean): void;
11
12
  isLevelValid(level: "error" | "debug" | "info" | "warn" | "disable" | "success"): boolean;
12
13
  isAllowedLevel(level: "error" | "debug" | "info" | "warn" | "disable" | "success"): boolean;
13
14
  checkSetting(setting: {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACe,CAAA;AAEjD,wBAAgB,MAAM,IAAI,OAAO,CAGhC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACe,CAAA;AAEjD,wBAAgB,MAAM,IAAI,OAAO,CAGhC"}
@@ -106,6 +106,10 @@ export declare class DaggerModule {
106
106
  * If the type cannot be resolved or is not supported, we throw an error.
107
107
  */
108
108
  private resolveTypeAlias;
109
+ /**
110
+ * Find the classes in the AST. Returns only our main class if it exists
111
+ */
112
+ private findClasses;
109
113
  /**
110
114
  * Recursively propagate references to all objects properties and functions.
111
115
  */
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/module.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAKhC,OAAO,EAEL,GAAG,EAGJ,MAAM,+BAA+B,CAAA;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAmB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAInD;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAuEd,IAAI,EAAE,MAAM;IACnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAxEb;;;;;;;;;;;;;;;;;;;OAmBG;IACI,OAAO,EAAE,iBAAiB,CAAK;IAEtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,KAAK,EAAE,eAAe,CAAK;IAElC;;;;;;;;;;OAUG;IACI,UAAU,EAAE,gBAAgB,CAAK;IAEjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAEtC,OAAO,CAAC,UAAU,CAKjB;gBAGQ,IAAI,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,GAAG;IAkClB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,iBAAiB;IAkIzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB;IAsExB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,cAAc;IAgBtB,MAAM;;;;;;;CASP"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/module.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAKhC,OAAO,EAEL,GAAG,EAGJ,MAAM,+BAA+B,CAAA;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EAAmB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAInD;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAuEd,IAAI,EAAE,MAAM;IACnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAxEb;;;;;;;;;;;;;;;;;;;OAmBG;IACI,OAAO,EAAE,iBAAiB,CAAK;IAEtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,KAAK,EAAE,eAAe,CAAK;IAElC;;;;;;;;;;OAUG;IACI,UAAU,EAAE,gBAAgB,CAAK;IAEjC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAEtC,OAAO,CAAC,UAAU,CAKjB;gBAGQ,IAAI,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,GAAG;IA8BlB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,iBAAiB;IAkIzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,gBAAgB;IAsExB;;OAEG;IACH,OAAO,CAAC,WAAW;IA2BnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,cAAc;IAgBtB,MAAM;;;;;;;CASP"}
@@ -93,20 +93,22 @@ export class DaggerModule {
93
93
  if (!mainModule) {
94
94
  console.warn(`could not find module entrypoint: class ${this.name} from import. Class should be exported to benefit from all features.`);
95
95
  }
96
- const mainObjectNode = this.ast.findResolvedNodeByName(this.name, ts.SyntaxKind.ClassDeclaration);
97
- if (!mainObjectNode) {
98
- throw new IntrospectionError(`could not find main object ${this.name} in module ${JSON.stringify(mainModule, null, 2) ?? ""} located at ${this.ast.files}`);
96
+ const classObjects = this.findClasses();
97
+ for (const classObject of classObjects) {
98
+ // This only applies to cloud. If this is the true main object, it is correct
99
+ // if this is a blueprint, the description will not matter in any situation
100
+ const mainFileContent = classObject.file.getFullText();
101
+ this.description = this.getDescription(mainFileContent);
102
+ const daggerObject = new DaggerObject(classObject.node, this.ast);
103
+ const objectName = classObject.node.name?.getText() || this.name;
104
+ this.objects[objectName] = daggerObject;
105
+ this.references[objectName] = {
106
+ kind: TypeDefKind.ObjectKind,
107
+ name: objectName,
108
+ };
109
+ this.resolveReferences(daggerObject.getReferences());
110
+ this.propagateReferences();
99
111
  }
100
- const mainFileContent = mainObjectNode.file.getFullText();
101
- this.description = this.getDescription(mainFileContent);
102
- const mainDaggerObject = new DaggerObject(mainObjectNode.node, this.ast);
103
- this.objects[this.name] = mainDaggerObject;
104
- this.references[this.name] = {
105
- kind: TypeDefKind.ObjectKind,
106
- name: this.name,
107
- };
108
- this.resolveReferences(mainDaggerObject.getReferences());
109
- this.propagateReferences();
110
112
  }
111
113
  /**
112
114
  * Find the reference of the module and register it to the module references.
@@ -271,6 +273,26 @@ export class DaggerModule {
271
273
  }
272
274
  throw new IntrospectionError(`could not resolve type reference for ${reference} at ${AST.getNodePosition(typeAlias.node)}`);
273
275
  }
276
+ /**
277
+ * Find the classes in the AST. Returns only our main class if it exists
278
+ */
279
+ findClasses() {
280
+ const allClassDeclarations = this.ast.findAllDeclarations(ts.SyntaxKind.ClassDeclaration);
281
+ const allClasses = [];
282
+ for (const classDecl of allClassDeclarations) {
283
+ const convertedDecl = classDecl;
284
+ // Check if the class matches this.name and return only that if so
285
+ if (convertedDecl.node.name &&
286
+ convertedDecl.node.name.getText() === this.name) {
287
+ return [convertedDecl];
288
+ }
289
+ // or we return all classes decorated with @object
290
+ if (this.ast.isNodeDecoratedWith(classDecl.node, OBJECT_DECORATOR)) {
291
+ allClasses.push(convertedDecl);
292
+ }
293
+ }
294
+ return allClasses;
295
+ }
274
296
  /**
275
297
  * Recursively propagate references to all objects properties and functions.
276
298
  */
@@ -24,6 +24,7 @@ export declare class AST {
24
24
  * what we're looking for.
25
25
  */
26
26
  kind: T): ResolvedNodeWithSymbol<T> | undefined;
27
+ findAllDeclarations<T extends keyof DeclarationsMap>(kind: T): ResolvedNodeWithSymbol<T>[];
27
28
  getTypeFromTypeAlias(typeAlias: ts.TypeAliasDeclaration): ts.Type;
28
29
  static getNodePosition(node: ts.Node): string;
29
30
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/ast.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAmB,MAAM,mBAAmB,CAAA;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAE9C,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,eAAe,IAAI;IACpE,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,EAAE,EAAE,CAAC,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,CAAC,UAAU,CAAA;CACp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,QAAQ,SAAI,GACX,CAAC,GAAG,SAAS;IA4BT,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYjD,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM;IAMvC,eAAe,CACpB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IA4DnC,OAAO,CAAC,yCAAyC;IAoB1C,4BAA4B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG;CAkDpE"}
@@ -63,6 +63,39 @@ export class AST {
63
63
  }
64
64
  return result;
65
65
  }
66
+ findAllDeclarations(kind) {
67
+ const results = [];
68
+ for (const sourceFile of this.sourceFiles) {
69
+ ts.forEachChild(sourceFile, (node) => {
70
+ // Skip if it's not from the client gen nor the user module
71
+ if (!sourceFile.fileName.endsWith(CLIENT_GEN_FILE) &&
72
+ !this.files.includes(sourceFile.fileName)) {
73
+ return;
74
+ }
75
+ if (kind !== undefined && node.kind === kind) {
76
+ const isDeclarationValid = isDeclarationOf[kind](node);
77
+ if (!isDeclarationValid)
78
+ return;
79
+ const convertedNode = node;
80
+ if (!convertedNode.name) {
81
+ return;
82
+ }
83
+ const symbol = this.checker.getSymbolAtLocation(convertedNode.name);
84
+ if (!symbol) {
85
+ console.debug(`missing symbol for ${convertedNode.name.getText()} at ${sourceFile.fileName}:${node.pos}`);
86
+ return;
87
+ }
88
+ results.push({
89
+ type: kind,
90
+ node: convertedNode,
91
+ symbol: symbol,
92
+ file: sourceFile,
93
+ });
94
+ }
95
+ });
96
+ }
97
+ return results;
98
+ }
66
99
  getTypeFromTypeAlias(typeAlias) {
67
100
  const symbol = this.getSymbolOrThrow(typeAlias.name);
68
101
  return this.checker.getDeclaredTypeOfSymbol(symbol);
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.18.17";
1
+ export declare const CLI_VERSION = "0.18.18";
2
2
  //# sourceMappingURL=default.d.ts.map
@@ -1,2 +1,2 @@
1
1
  // Code generated by dagger. DO NOT EDIT.
2
- export const CLI_VERSION = "0.18.17";
2
+ export const CLI_VERSION = "0.18.18";