@dagger.io/dagger 0.11.9 → 0.12.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.
Files changed (55) hide show
  1. package/dist/api/client.gen.d.ts +382 -71
  2. package/dist/api/client.gen.d.ts.map +1 -1
  3. package/dist/api/client.gen.js +790 -106
  4. package/dist/connect.d.ts.map +1 -1
  5. package/dist/connect.js +1 -2
  6. package/dist/entrypoint/invoke.d.ts.map +1 -1
  7. package/dist/entrypoint/invoke.js +7 -3
  8. package/dist/entrypoint/load.d.ts +3 -2
  9. package/dist/entrypoint/load.d.ts.map +1 -1
  10. package/dist/entrypoint/load.js +9 -1
  11. package/dist/entrypoint/register.d.ts.map +1 -1
  12. package/dist/entrypoint/register.js +40 -10
  13. package/dist/introspector/decorators/decorators.d.ts +5 -1
  14. package/dist/introspector/decorators/decorators.d.ts.map +1 -1
  15. package/dist/introspector/decorators/decorators.js +4 -0
  16. package/dist/introspector/registry/registry.d.ts +8 -2
  17. package/dist/introspector/registry/registry.d.ts.map +1 -1
  18. package/dist/introspector/registry/registry.js +11 -1
  19. package/dist/introspector/scanner/abtractions/argument.d.ts +23 -2
  20. package/dist/introspector/scanner/abtractions/argument.d.ts.map +1 -1
  21. package/dist/introspector/scanner/abtractions/argument.js +71 -38
  22. package/dist/introspector/scanner/abtractions/constructor.d.ts +3 -2
  23. package/dist/introspector/scanner/abtractions/constructor.d.ts.map +1 -1
  24. package/dist/introspector/scanner/abtractions/constructor.js +17 -19
  25. package/dist/introspector/scanner/abtractions/enum.d.ts +33 -0
  26. package/dist/introspector/scanner/abtractions/enum.d.ts.map +1 -0
  27. package/dist/introspector/scanner/abtractions/enum.js +73 -0
  28. package/dist/introspector/scanner/abtractions/enumValue.d.ts +24 -0
  29. package/dist/introspector/scanner/abtractions/enumValue.d.ts.map +1 -0
  30. package/dist/introspector/scanner/abtractions/enumValue.js +51 -0
  31. package/dist/introspector/scanner/abtractions/method.d.ts +19 -3
  32. package/dist/introspector/scanner/abtractions/method.d.ts.map +1 -1
  33. package/dist/introspector/scanner/abtractions/method.js +61 -33
  34. package/dist/introspector/scanner/abtractions/module.d.ts +12 -4
  35. package/dist/introspector/scanner/abtractions/module.d.ts.map +1 -1
  36. package/dist/introspector/scanner/abtractions/module.js +58 -14
  37. package/dist/introspector/scanner/abtractions/object.d.ts +17 -2
  38. package/dist/introspector/scanner/abtractions/object.d.ts.map +1 -1
  39. package/dist/introspector/scanner/abtractions/object.js +57 -33
  40. package/dist/introspector/scanner/abtractions/property.d.ts +11 -2
  41. package/dist/introspector/scanner/abtractions/property.d.ts.map +1 -1
  42. package/dist/introspector/scanner/abtractions/property.js +49 -30
  43. package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts +8 -0
  44. package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts.map +1 -0
  45. package/dist/introspector/scanner/abtractions/typeToTypedef.js +76 -0
  46. package/dist/introspector/scanner/scan.d.ts +0 -12
  47. package/dist/introspector/scanner/scan.d.ts.map +1 -1
  48. package/dist/introspector/scanner/typeDefs.d.ts +8 -53
  49. package/dist/introspector/scanner/typeDefs.d.ts.map +1 -1
  50. package/dist/introspector/scanner/utils.d.ts +1 -1
  51. package/dist/introspector/scanner/utils.d.ts.map +1 -1
  52. package/dist/introspector/scanner/utils.js +15 -7
  53. package/dist/provisioning/default.d.ts +1 -1
  54. package/dist/provisioning/default.js +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../connect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAK9C,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACxB,GAAG,GAAE,WAAgB,iBAiBtB;AAED;;GAEG;AACH,wBAAgB,KAAK,SAEpB;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,EAAE,EAAE,WAAW,EACf,MAAM,GAAE,WAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../connect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAI9C,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACxB,GAAG,GAAE,WAAgB,iBAiBtB;AAED;;GAEG;AACH,wBAAgB,KAAK,SAEpB;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,EAAE,EAAE,WAAW,EACf,MAAM,GAAE,WAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
package/dist/connect.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as opentelemetry from "@opentelemetry/api";
2
2
  import { Client } from "./api/client.gen.js";
3
3
  import { Context, defaultContext } from "./context/context.js";
4
- import { CLI_VERSION } from "./provisioning/index.js";
5
4
  import * as telemetry from "./telemetry/telemetry.js";
6
5
  /**
7
6
  * connection executes the given function using the default global Dagger client.
@@ -56,7 +55,7 @@ export async function connect(cb, config = {}) {
56
55
  await ctx.connection(config);
57
56
  // Warning shall be throw if versions are not compatible
58
57
  try {
59
- await client.checkVersionCompatibility(CLI_VERSION);
58
+ await client.version();
60
59
  }
61
60
  catch (e) {
62
61
  console.error("failed to check version compatibility:", e);
@@ -1 +1 @@
1
- {"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../entrypoint/invoke.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAcxC;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,gBAgChE"}
1
+ {"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../entrypoint/invoke.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAcxC;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,gBAoChE"}
@@ -13,7 +13,7 @@ function isConstructor(method) {
13
13
  * @param fnArgs The arguments of the function to call.
14
14
  */
15
15
  export async function invoke(module, ctx) {
16
- let object = loadInvokedObject(module, ctx.parentName);
16
+ const object = loadInvokedObject(module, ctx.parentName);
17
17
  if (!object) {
18
18
  throw new Error(`could not find object ${ctx.parentName}`);
19
19
  }
@@ -25,12 +25,16 @@ export async function invoke(module, ctx) {
25
25
  const parentState = await loadParentState(registry, object, ctx);
26
26
  let result = await registry.getResult(object.name, method.name, parentState, args);
27
27
  if (result) {
28
+ let returnType;
28
29
  // Handle alias serialization by getting the return type to load
29
30
  // if the function called isn't a constructor.
30
31
  if (!isConstructor(method)) {
31
- object = loadObjectReturnType(module, object, method);
32
+ returnType = loadObjectReturnType(module, object, method);
32
33
  }
33
- result = await loadResult(result, module, object);
34
+ else {
35
+ returnType = object;
36
+ }
37
+ result = await loadResult(result, module, returnType);
34
38
  }
35
39
  return result;
36
40
  }
@@ -1,6 +1,7 @@
1
1
  import { TypeDefKind } from "../api/client.gen.js";
2
2
  import { Args, Registry } from "../introspector/registry/registry.js";
3
3
  import { Constructor } from "../introspector/scanner/abtractions/constructor.js";
4
+ import { DaggerEnum } from "../introspector/scanner/abtractions/enum.js";
4
5
  import { Method } from "../introspector/scanner/abtractions/method.js";
5
6
  import { DaggerModule } from "../introspector/scanner/abtractions/module.js";
6
7
  import { DaggerObject } from "../introspector/scanner/abtractions/object.js";
@@ -50,6 +51,6 @@ export declare function loadValue(registry: Registry, value: any, type: TypeDef<
50
51
  * @param object The current object to load the return type from.
51
52
  * @param method The method to load the return type from.
52
53
  */
53
- export declare function loadObjectReturnType(module: DaggerModule, object: DaggerObject, method: Method): DaggerObject;
54
- export declare function loadResult(result: any, module: DaggerModule, object: DaggerObject): Promise<any>;
54
+ export declare function loadObjectReturnType(module: DaggerModule, object: DaggerObject, method: Method): DaggerObject | DaggerEnum;
55
+ export declare function loadResult(result: any, module: DaggerModule, object: DaggerObject | DaggerEnum): Promise<any>;
55
56
  //# sourceMappingURL=load.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../entrypoint/load.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,+CAA+C,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,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Y,EACpB,MAAM,EAAE,YAAY,GAAG,UAAU,GAChC,OAAO,CAAC,GAAG,CAAC,CA0Ed"}
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { dag, TypeDefKind } from "../api/client.gen.js";
3
+ import { DaggerEnum } from "../introspector/scanner/abtractions/enum.js";
4
+ import { DaggerObject } from "../introspector/scanner/abtractions/object.js";
3
5
  /**
4
6
  * Import all given typescript files so that trigger their decorators
5
7
  * and register their class and functions inside the Registry.
@@ -108,6 +110,7 @@ export async function loadValue(registry, value, type) {
108
110
  case TypeDefKind.BooleanKind:
109
111
  case TypeDefKind.VoidKind:
110
112
  case TypeDefKind.ScalarKind:
113
+ case TypeDefKind.EnumKind:
111
114
  return value;
112
115
  default:
113
116
  throw new Error(`unsupported type ${type.kind}`);
@@ -136,6 +139,8 @@ export function loadObjectReturnType(module, object, method) {
136
139
  }
137
140
  case TypeDefKind.ObjectKind:
138
141
  return module.objects[retType.name];
142
+ case TypeDefKind.EnumKind:
143
+ return module.enums[retType.name];
139
144
  default:
140
145
  return object;
141
146
  }
@@ -151,7 +156,7 @@ export async function loadResult(result, module, object) {
151
156
  return result;
152
157
  }
153
158
  // Handle objects
154
- if (typeof result === "object") {
159
+ if (typeof result === "object" && object instanceof DaggerObject) {
155
160
  const state = {};
156
161
  for (const [key, value] of Object.entries(result)) {
157
162
  const property = Object.values(object.properties).find((p) => p.name === key);
@@ -185,6 +190,9 @@ export async function loadResult(result, module, object) {
185
190
  }
186
191
  return state;
187
192
  }
193
+ if (typeof result === "object" && object instanceof DaggerEnum) {
194
+ return result;
195
+ }
188
196
  // Handle primitive types
189
197
  return result;
190
198
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAGT,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAW5E;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,QAAQ,CAAC,CA8CnB"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAGT,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAA;AAS5E;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,QAAQ,CAAC,CA6DnB"}
@@ -17,22 +17,34 @@ export async function register(files, module) {
17
17
  });
18
18
  // Register all functions (methods) to this object
19
19
  Object.values(object.methods).forEach((method) => {
20
- typeDef = typeDef.withFunction(addFunction(method.typeDef));
20
+ typeDef = typeDef.withFunction(addFunction(method));
21
21
  });
22
22
  // Register all fields that belong to this object
23
23
  Object.values(object.properties).forEach((field) => {
24
24
  if (field.isExposed) {
25
- typeDef = typeDef.withField(field.alias ?? field.name, addTypeDef(field.typeDef.typeDef), {
25
+ typeDef = typeDef.withField(field.alias ?? field.name, addTypeDef(field.type), {
26
26
  description: field.description,
27
27
  });
28
28
  }
29
29
  });
30
30
  if (object._constructor) {
31
- typeDef = typeDef.withConstructor(addConstructor(object._constructor.typeDef, typeDef));
31
+ typeDef = typeDef.withConstructor(addConstructor(object._constructor, typeDef));
32
32
  }
33
33
  // Add it to the module object
34
34
  mod = mod.withObject(typeDef);
35
35
  });
36
+ // Register all enums defined by this modules
37
+ Object.values(module.enums).forEach((enum_) => {
38
+ let typeDef = dag.typeDef().withEnum(enum_.name, {
39
+ description: enum_.description,
40
+ });
41
+ Object.values(enum_.values).forEach((value) => {
42
+ typeDef = typeDef.withEnumValue(value.value, {
43
+ description: value.description,
44
+ });
45
+ });
46
+ mod = mod.withEnum(typeDef);
47
+ });
36
48
  // Call ID to actually execute the registration
37
49
  return await mod.id();
38
50
  }
@@ -40,7 +52,7 @@ export async function register(files, module) {
40
52
  * Bind a constructor to the given object.
41
53
  */
42
54
  function addConstructor(constructor, owner) {
43
- return dag.function_("", owner).with(addArg(constructor.args));
55
+ return dag.function_("", owner).with(addArg(constructor.arguments));
44
56
  }
45
57
  /**
46
58
  * Create a function in the Dagger API.
@@ -49,7 +61,7 @@ function addFunction(fct) {
49
61
  return dag
50
62
  .function_(fct.alias ?? fct.name, addTypeDef(fct.returnType))
51
63
  .withDescription(fct.description)
52
- .with(addArg(fct.args));
64
+ .with(addArg(fct.arguments));
53
65
  }
54
66
  /**
55
67
  * Register all arguments in the function.
@@ -60,13 +72,23 @@ function addArg(args) {
60
72
  const opts = {
61
73
  description: arg.description,
62
74
  };
63
- if (arg.defaultValue) {
64
- opts.defaultValue = arg.defaultValue;
65
- }
66
- let typeDef = addTypeDef(arg.typeDef);
67
- if (arg.optional) {
75
+ let typeDef = addTypeDef(arg.type);
76
+ if (arg.isOptional) {
68
77
  typeDef = typeDef.withOptional(true);
69
78
  }
79
+ // We do not set the default value if it's not a primitive type, we let TypeScript
80
+ // resolve the default value during the runtime instead.
81
+ // If it has a default value but is not primitive, we set the value as optional
82
+ // to workaround the fact that the API isn't aware of the default value and will
83
+ // expect it to be set as required input.
84
+ if (arg.defaultValue) {
85
+ if (isPrimitiveType(arg.type)) {
86
+ opts.defaultValue = arg.defaultValue;
87
+ }
88
+ else {
89
+ typeDef = typeDef.withOptional(true);
90
+ }
91
+ }
70
92
  fct = fct.withArg(arg.name, typeDef, opts);
71
93
  });
72
94
  return fct;
@@ -92,7 +114,15 @@ function addTypeDef(type) {
92
114
  return dag.typeDef().withListOf(addTypeDef(type.typeDef));
93
115
  case TypeDefKind.VoidKind:
94
116
  return dag.typeDef().withKind(type.kind).withOptional(true);
117
+ case TypeDefKind.EnumKind:
118
+ return dag.typeDef().withEnum(type.name);
95
119
  default:
96
120
  return dag.typeDef().withKind(type.kind);
97
121
  }
98
122
  }
123
+ function isPrimitiveType(type) {
124
+ return (type.kind === TypeDefKind.BooleanKind ||
125
+ type.kind === TypeDefKind.IntegerKind ||
126
+ type.kind === TypeDefKind.StringKind ||
127
+ type.kind === TypeDefKind.EnumKind);
128
+ }
@@ -1,4 +1,8 @@
1
1
  export declare const object: () => <T extends import("../registry/registry.js").Class>(constructor: T) => T;
2
- export declare const func: (alias?: string | undefined) => (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
2
+ export declare const func: (alias?: string | undefined) => (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor | undefined) => void;
3
+ /**
4
+ * @deprecated In favor of `@func`
5
+ */
3
6
  export declare const field: (alias?: string | undefined) => (target: object, propertyKey: string) => void;
7
+ export declare const enumType: () => <T extends import("../registry/registry.js").Class>(constructor: T) => T;
4
8
  //# sourceMappingURL=decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../introspector/decorators/decorators.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,gFAAkB,CAAA;AACrC,eAAO,MAAM,IAAI,wHAAgB,CAAA;AACjC,eAAO,MAAM,KAAK,+EAAiB,CAAA"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../introspector/decorators/decorators.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,gFAAkB,CAAA;AACrC,eAAO,MAAM,IAAI,qIAAgB,CAAA;AACjC;;GAEG;AACH,eAAO,MAAM,KAAK,+EAAiB,CAAA;AACnC,eAAO,MAAM,QAAQ,gFAAoB,CAAA"}
@@ -4,4 +4,8 @@
4
4
  import { registry } from "../registry/registry.js";
5
5
  export const object = registry.object;
6
6
  export const func = registry.func;
7
+ /**
8
+ * @deprecated In favor of `@func`
9
+ */
7
10
  export const field = registry.field;
11
+ export const enumType = registry.enumType;
@@ -13,7 +13,7 @@ export type Args = Record<string, unknown>;
13
13
  *
14
14
  * The decorator @object store the class into the Registry, but also all the
15
15
  * users method's name.
16
- * It doesn't consider the `@func` or `field` decorators because this is
16
+ * It doesn't consider the `@func` decorator because this is
17
17
  * used by the Dagger API to know what to expose or not.
18
18
  * This might lead to unnecessary data register into the registry, but
19
19
  * we use map as datastructure to optimize the searching process
@@ -27,10 +27,16 @@ export declare class Registry {
27
27
  *
28
28
  */
29
29
  object: () => <T extends Class>(constructor: T) => T;
30
+ /**
31
+ * The definition of the @enum decorator that should be on top of any
32
+ * class module that must be exposed to the Dagger API as enumeration.
33
+ */
34
+ enumType: () => <T extends Class>(constructor: T) => T;
30
35
  /**
31
36
  * The definition of @field decorator that should be on top of any
32
37
  * class' property that must be exposed to the Dagger API.
33
38
  *
39
+ * @deprecated In favor of `@func`
34
40
  * @param alias The alias to use for the field when exposed on the API.
35
41
  */
36
42
  field: (alias?: string) => ((target: object, propertyKey: string) => void);
@@ -38,7 +44,7 @@ export declare class Registry {
38
44
  * The definition of @func decorator that should be on top of any
39
45
  * class' method that must be exposed to the Dagger API.
40
46
  */
41
- func: (alias?: string) => ((target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void);
47
+ func: (alias?: string) => ((target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void);
42
48
  /**
43
49
  * Build a class that is part of the module itself so you can
44
50
  * access its sub functions.
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../introspector/registry/registry.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAA;AAIzB,MAAM,MAAM,KAAK,GAAG;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAE/C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAU1C;;;;;;;;;;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AAK,WAAY,MAAM,KAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,CAIxE;IAED;;;OAGG;IACH,IAAI,WACM,MAAM,KACb,CAAC,CACF,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,CAAC,EAAE,kBAAkB,KAC5B,IAAI,CAAC,CAUT;IAED;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG;IAY7C;;;;;;;;;;OAUG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,GAAG,CAAC;CAiChB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAiB,CAAA"}
@@ -9,7 +9,7 @@ import { UnknownDaggerError } from "../../common/errors/UnknownDaggerError.js";
9
9
  *
10
10
  * The decorator @object store the class into the Registry, but also all the
11
11
  * users method's name.
12
- * It doesn't consider the `@func` or `field` decorators because this is
12
+ * It doesn't consider the `@func` decorator because this is
13
13
  * used by the Dagger API to know what to expose or not.
14
14
  * This might lead to unnecessary data register into the registry, but
15
15
  * we use map as datastructure to optimize the searching process
@@ -28,10 +28,20 @@ export class Registry {
28
28
  return constructor;
29
29
  };
30
30
  };
31
+ /**
32
+ * The definition of the @enum decorator that should be on top of any
33
+ * class module that must be exposed to the Dagger API as enumeration.
34
+ */
35
+ enumType = () => {
36
+ return (constructor) => {
37
+ return constructor;
38
+ };
39
+ };
31
40
  /**
32
41
  * The definition of @field decorator that should be on top of any
33
42
  * class' property that must be exposed to the Dagger API.
34
43
  *
44
+ * @deprecated In favor of `@func`
35
45
  * @param alias The alias to use for the field when exposed on the API.
36
46
  */
37
47
  field = (alias) => {
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import { TypeDefKind } from "../../../api/client.gen.js";
3
- import { FunctionArgTypeDef, TypeDef } from "../typeDefs.js";
3
+ import { TypeDef } from "../typeDefs.js";
4
4
  export type Arguments = {
5
5
  [name: string]: Argument;
6
6
  };
@@ -14,6 +14,13 @@ export declare class Argument {
14
14
  private symbol;
15
15
  private checker;
16
16
  private param;
17
+ private _name;
18
+ private _description;
19
+ private _type;
20
+ private _defaultValue;
21
+ private _isOptional;
22
+ private _isNullable;
23
+ private _isVariadic;
17
24
  /**
18
25
  * Create a new Argument instance.
19
26
  *
@@ -49,7 +56,6 @@ export declare class Argument {
49
56
  */
50
57
  get isNullable(): boolean;
51
58
  get isVariadic(): boolean;
52
- get typeDef(): FunctionArgTypeDef;
53
59
  toJSON(): {
54
60
  name: string;
55
61
  description: string;
@@ -59,6 +65,21 @@ export declare class Argument {
59
65
  isOptional: boolean;
60
66
  defaultValue: string | undefined;
61
67
  };
68
+ private loadName;
69
+ private loadDescription;
70
+ private loadType;
71
+ private loadDefaultValue;
72
+ /**
73
+ * Return true if the parameter is optional.
74
+ *
75
+ * A parameter is considered optional if:
76
+ * - It has a question token (e.g. `foo?: <type>`).
77
+ * - It's variadic (e.g. `...foo: <type>[]`).
78
+ * - It's nullable (e.g. `foo: <type> | null`).
79
+ */
80
+ private loadIsOptional;
81
+ private loadIsNullable;
82
+ private loadIsVariadic;
62
83
  /**
63
84
  * The TypeScript Compiler API returns the raw default value as it is written
64
85
  * by the user.
@@ -1 +1 @@
1
- {"version":3,"file":"argument.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/argument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG5D,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;A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C,aAAa,CAAoB;IACzC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;;;OAQG;gBACS,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM;IAgCrD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAE/B;IAED,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED;;;;;;;OAOG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;;;OAMG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,MAAM;;;;;;;;;IAYN,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,QAAQ;IAgBhB,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAItB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,kBAAkB;CAU3B"}
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
3
- import { typeToTypedef } from "../utils.js";
3
+ import { typeToTypedef } from "./typeToTypedef.js";
4
4
  /**
5
5
  * Argument is an abstraction of a function argument.
6
6
  *
@@ -11,6 +11,14 @@ export class Argument {
11
11
  symbol;
12
12
  checker;
13
13
  param;
14
+ // Preloaded values.
15
+ _name;
16
+ _description;
17
+ _type;
18
+ _defaultValue;
19
+ _isOptional;
20
+ _isNullable;
21
+ _isVariadic;
14
22
  /**
15
23
  * Create a new Argument instance.
16
24
  *
@@ -32,24 +40,79 @@ export class Argument {
32
40
  throw new UnknownDaggerError(`the declaration of symbol ${this.symbol.name} isn't a parameter`, {});
33
41
  }
34
42
  this.param = parameterDeclaration;
43
+ // Preload to optimize the introspection.
44
+ this._name = this.loadName();
45
+ this._description = this.loadDescription();
46
+ this._type = this.loadType();
47
+ this._defaultValue = this.loadDefaultValue();
48
+ this._isNullable = this.loadIsNullable();
49
+ this._isVariadic = this.loadIsVariadic();
50
+ this._isOptional = this.loadIsOptional();
35
51
  }
36
52
  get name() {
37
- return this.symbol.getName();
53
+ return this._name;
38
54
  }
39
55
  get description() {
40
- return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
56
+ return this._description;
41
57
  }
42
58
  /**
43
59
  * Return the type of the argument in a Dagger TypeDef format.
44
60
  */
45
61
  get type() {
62
+ return this._type;
63
+ }
64
+ get defaultValue() {
65
+ return this._defaultValue;
66
+ }
67
+ /**
68
+ * Return true if the parameter is optional.
69
+ *
70
+ * A parameter is considered optional if he fits one of the following:
71
+ * - It has a question token (e.g. `foo?: <type>`).
72
+ * - It's variadic (e.g. `...foo: <type>[]`).
73
+ * - It's nullable (e.g. `foo: <type> | null`).
74
+ */
75
+ get isOptional() {
76
+ return this._isOptional;
77
+ }
78
+ /**
79
+ * Return true if the parameter is nullable.
80
+ *
81
+ * A parameter is considered nullable if itstype is a union type with `null`
82
+ * on the list of types.
83
+ * Example: `foo: string | null`.
84
+ */
85
+ get isNullable() {
86
+ return this._isNullable;
87
+ }
88
+ get isVariadic() {
89
+ return this._isVariadic;
90
+ }
91
+ toJSON() {
92
+ return {
93
+ name: this.name,
94
+ description: this.description,
95
+ type: this.type,
96
+ isVariadic: this.isVariadic,
97
+ isNullable: this.isNullable,
98
+ isOptional: this.isOptional,
99
+ defaultValue: this.defaultValue,
100
+ };
101
+ }
102
+ loadName() {
103
+ return this.symbol.getName();
104
+ }
105
+ loadDescription() {
106
+ return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
107
+ }
108
+ loadType() {
46
109
  if (!this.symbol.valueDeclaration) {
47
110
  throw new UnknownDaggerError("could not find symbol value declaration", {});
48
111
  }
49
112
  const type = this.checker.getTypeOfSymbolAtLocation(this.symbol, this.symbol.valueDeclaration);
50
113
  return typeToTypedef(this.checker, type);
51
114
  }
52
- get defaultValue() {
115
+ loadDefaultValue() {
53
116
  if (this.param.initializer === undefined) {
54
117
  return undefined;
55
118
  }
@@ -58,24 +121,17 @@ export class Argument {
58
121
  /**
59
122
  * Return true if the parameter is optional.
60
123
  *
61
- * A parameter is considered optional if he fits one of the following:
124
+ * A parameter is considered optional if:
62
125
  * - It has a question token (e.g. `foo?: <type>`).
63
126
  * - It's variadic (e.g. `...foo: <type>[]`).
64
127
  * - It's nullable (e.g. `foo: <type> | null`).
65
128
  */
66
- get isOptional() {
129
+ loadIsOptional() {
67
130
  return (this.param.questionToken !== undefined ||
68
131
  this.isVariadic ||
69
132
  this.isNullable);
70
133
  }
71
- /**
72
- * Return true if the parameter is nullable.
73
- *
74
- * A parameter is considered nullable if itstype is a union type with `null`
75
- * on the list of types.
76
- * Example: `foo: string | null`.
77
- */
78
- get isNullable() {
134
+ loadIsNullable() {
79
135
  if (!this.param.type) {
80
136
  return false;
81
137
  }
@@ -88,32 +144,9 @@ export class Argument {
88
144
  }
89
145
  return false;
90
146
  }
91
- get isVariadic() {
147
+ loadIsVariadic() {
92
148
  return this.param.dotDotDotToken !== undefined;
93
149
  }
94
- // TODO(TomChv): replace with `ToJson` method
95
- // after the refactor is complete.
96
- get typeDef() {
97
- return {
98
- name: this.name,
99
- description: this.description,
100
- optional: this.isOptional,
101
- defaultValue: this.defaultValue,
102
- isVariadic: this.isVariadic,
103
- typeDef: this.type,
104
- };
105
- }
106
- toJSON() {
107
- return {
108
- name: this.name,
109
- description: this.description,
110
- type: this.type,
111
- isVariadic: this.isVariadic,
112
- isNullable: this.isNullable,
113
- isOptional: this.isOptional,
114
- defaultValue: this.defaultValue,
115
- };
116
- }
117
150
  /**
118
151
  * The TypeScript Compiler API returns the raw default value as it is written
119
152
  * by the user.
@@ -1,16 +1,17 @@
1
1
  import ts from "typescript";
2
- import { ConstructorTypeDef } from "../typeDefs.js";
3
2
  import { Arguments } from "./argument.js";
4
3
  export declare class Constructor {
5
4
  private checker;
6
5
  private declaration;
6
+ private _name;
7
+ private _arguments;
7
8
  constructor(checker: ts.TypeChecker, declaration: ts.ConstructorDeclaration);
8
9
  get name(): string;
9
10
  get arguments(): Arguments;
10
- get typeDef(): ConstructorTypeDef;
11
11
  toJSON(): {
12
12
  args: Arguments;
13
13
  };
14
14
  getArgOrder(): string[];
15
+ private loadArguments;
15
16
  }
16
17
  //# sourceMappingURL=constructor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,kBAAkB,EAAsB,MAAM,gBAAgB,CAAA;AACvE,OAAO,EAAY,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnD,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,WAAW,CAA2B;gBAElC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,sBAAsB;IAK3E,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,SAAS,IAAI,SAAS,CAgBzB;IAID,IAAI,OAAO,IAAI,kBAAkB,CAWhC;IAED,MAAM;;;IAMN,WAAW,IAAI,MAAM,EAAE;CAGxB"}
1
+ {"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAY,SAAS,EAAE,MAAM,eAAe,CAAA;AAEnD,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,WAAW,CAA2B;IAG9C,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,UAAU,CAAW;gBAEjB,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,sBAAsB;IAQ3E,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,MAAM;;;IAMN,WAAW,IAAI,MAAM,EAAE;IAIvB,OAAO,CAAC,aAAa;CAiBtB"}
@@ -3,14 +3,30 @@ import { Argument } from "./argument.js";
3
3
  export class Constructor {
4
4
  checker;
5
5
  declaration;
6
+ // Preloaded values.
7
+ _name = "";
8
+ _arguments;
6
9
  constructor(checker, declaration) {
7
10
  this.checker = checker;
8
11
  this.declaration = declaration;
12
+ // Preload values.
13
+ this._arguments = this.loadArguments();
9
14
  }
10
15
  get name() {
11
- return "";
16
+ return this._name;
12
17
  }
13
18
  get arguments() {
19
+ return this._arguments;
20
+ }
21
+ toJSON() {
22
+ return {
23
+ args: this.arguments,
24
+ };
25
+ }
26
+ getArgOrder() {
27
+ return Object.keys(this.arguments);
28
+ }
29
+ loadArguments() {
14
30
  return this.declaration.parameters.reduce((acc, param) => {
15
31
  const symbol = this.checker.getSymbolAtLocation(param.name);
16
32
  if (!symbol) {
@@ -21,22 +37,4 @@ export class Constructor {
21
37
  return acc;
22
38
  }, {});
23
39
  }
24
- // TODO(TomChv): replace with `ToJson` method
25
- // after the refactor is complete.
26
- get typeDef() {
27
- return {
28
- args: Object.entries(this.arguments).reduce((acc, [name, arg]) => {
29
- acc[name] = arg.typeDef;
30
- return acc;
31
- }, {}),
32
- };
33
- }
34
- toJSON() {
35
- return {
36
- args: this.arguments,
37
- };
38
- }
39
- getArgOrder() {
40
- return Object.keys(this.arguments);
41
- }
42
40
  }