@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,14 +1,34 @@
1
1
  import ts from "typescript";
2
2
  import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
3
- import { isFunction } from "../utils.js";
3
+ import { object } from "../../decorators/decorators.js";
4
4
  import { Constructor } from "./constructor.js";
5
- import { Method } from "./method.js";
5
+ import { Method, isMethodDecorated } from "./method.js";
6
6
  import { Property } from "./property.js";
7
+ export const OBJECT_DECORATOR = object.name;
8
+ /**
9
+ * Return true if the given class declaration has the decorator @obj() on
10
+ * top of its declaration.
11
+ * @param object
12
+ */
13
+ export function isObjectDecorated(object) {
14
+ return (ts.getDecorators(object)?.find((d) => {
15
+ if (ts.isCallExpression(d.expression)) {
16
+ return d.expression.expression.getText() === OBJECT_DECORATOR;
17
+ }
18
+ return false;
19
+ }) !== undefined);
20
+ }
7
21
  export class DaggerObject {
8
22
  checker;
9
23
  class;
10
24
  symbol;
11
25
  file;
26
+ // Preloaded values.
27
+ _name;
28
+ _description;
29
+ _classConstructor;
30
+ _methods;
31
+ _properties;
12
32
  /**
13
33
  *
14
34
  * @param checker The checker to use to introspect the class.
@@ -29,14 +49,44 @@ export class DaggerObject {
29
49
  throw new UnknownDaggerError(`could not get class symbol: ${classDeclaration.name.getText()}`, {});
30
50
  }
31
51
  this.symbol = classSymbol;
52
+ // Preload values to optimize introspection.
53
+ this._name = this.loadName();
54
+ this._description = this.loadDescription();
55
+ this._classConstructor = this.loadConstructor();
56
+ this._methods = this.loadMethods();
57
+ this._properties = this.loadProperties();
32
58
  }
33
59
  get name() {
34
- return this.symbol.getName();
60
+ return this._name;
35
61
  }
36
62
  get description() {
37
- return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
63
+ return this._description;
38
64
  }
39
65
  get _constructor() {
66
+ return this._classConstructor;
67
+ }
68
+ get methods() {
69
+ return this._methods;
70
+ }
71
+ get properties() {
72
+ return this._properties;
73
+ }
74
+ toJSON() {
75
+ return {
76
+ name: this.name,
77
+ description: this.description,
78
+ constructor: this._constructor,
79
+ methods: this.methods,
80
+ properties: this.properties,
81
+ };
82
+ }
83
+ loadName() {
84
+ return this.symbol.getName();
85
+ }
86
+ loadDescription() {
87
+ return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
88
+ }
89
+ loadConstructor() {
40
90
  const constructor = this.class.members.find((member) => {
41
91
  if (ts.isConstructorDeclaration(member)) {
42
92
  return true;
@@ -47,16 +97,16 @@ export class DaggerObject {
47
97
  }
48
98
  return new Constructor(this.checker, constructor);
49
99
  }
50
- get methods() {
100
+ loadMethods() {
51
101
  return this.class.members
52
- .filter((member) => ts.isMethodDeclaration(member) && isFunction(member))
102
+ .filter((member) => ts.isMethodDeclaration(member) && isMethodDecorated(member))
53
103
  .reduce((acc, member) => {
54
104
  const method = new Method(this.checker, member);
55
105
  acc[method.alias ?? method.name] = method;
56
106
  return acc;
57
107
  }, {});
58
108
  }
59
- get properties() {
109
+ loadProperties() {
60
110
  return this.class.members
61
111
  .filter((member) => ts.isPropertyDeclaration(member))
62
112
  .reduce((acc, member) => {
@@ -65,30 +115,4 @@ export class DaggerObject {
65
115
  return acc;
66
116
  }, {});
67
117
  }
68
- // TODO(TomChv): replace with `ToJson` method
69
- // after the refactor is complete.
70
- get typeDef() {
71
- return {
72
- name: this.name,
73
- description: this.description,
74
- constructor: this._constructor?.typeDef,
75
- methods: Object.entries(this.methods).reduce((acc, [name, method]) => {
76
- acc[name] = method.typeDef;
77
- return acc;
78
- }, {}),
79
- fields: Object.entries(this.properties).reduce((acc, [name, property]) => {
80
- acc[name] = property.typeDef;
81
- return acc;
82
- }, {}),
83
- };
84
- }
85
- toJSON() {
86
- return {
87
- name: this.name,
88
- description: this.description,
89
- constructor: this._constructor,
90
- methods: this.methods,
91
- properties: this.properties,
92
- };
93
- }
94
118
  }
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import { TypeDefKind } from "../../../api/client.gen.js";
3
- import { FieldTypeDef, TypeDef } from "../typeDefs.js";
3
+ import { TypeDef } from "../typeDefs.js";
4
4
  export type Properties = {
5
5
  [name: string]: Property;
6
6
  };
@@ -15,6 +15,11 @@ export declare class Property {
15
15
  private checker;
16
16
  private property;
17
17
  private decorator;
18
+ private _name;
19
+ private _description;
20
+ private _alias;
21
+ private _type;
22
+ private _isExposed;
18
23
  /**
19
24
  *
20
25
  * @param checker Checker to use to introspect the property.
@@ -34,7 +39,6 @@ export declare class Property {
34
39
  */
35
40
  get type(): TypeDef<TypeDefKind>;
36
41
  get isExposed(): boolean;
37
- get typeDef(): FieldTypeDef;
38
42
  toJSON(): {
39
43
  name: string;
40
44
  description: string;
@@ -42,5 +46,10 @@ export declare class Property {
42
46
  type: TypeDef<TypeDefKind>;
43
47
  isExposed: boolean;
44
48
  };
49
+ private loadName;
50
+ private loadDescription;
51
+ private loadAlias;
52
+ private loadType;
53
+ private loadIsExposed;
45
54
  }
46
55
  //# sourceMappingURL=property.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAKtD,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;AAErD;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,QAAQ,CAAwB;IAExC,OAAO,CAAC,SAAS,CAA0B;IAE3C;;;;;;OAMG;gBACS,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,mBAAmB;IAuBrE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAIxB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAa9B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAc/B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,IAAI,OAAO,IAAI,YAAY,CAQ1B;IAED,MAAM;;;;;;;CASP"}
1
+ {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAMxC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;AAErD;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,QAAQ,CAAwB;IAExC,OAAO,CAAC,SAAS,CAA0B;IAG3C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;;;OAMG;gBACS,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,mBAAmB;IAiCrE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAE/B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,MAAM;;;;;;;IAUN,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,QAAQ;IAgBhB,OAAO,CAAC,aAAa;CAGtB"}
@@ -1,7 +1,9 @@
1
1
  import ts from "typescript";
2
2
  import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
3
- import { typeToTypedef } from "../utils.js";
4
- const PROPERTY_DECORATOR = "field";
3
+ import { field, func } from "../../decorators/decorators.js";
4
+ import { typeToTypedef } from "./typeToTypedef.js";
5
+ const DEPRECATED_PROPERTY_DECORATOR = field.name;
6
+ const PROPERTY_DECORATOR = func.name;
5
7
  /**
6
8
  * Property is an abstraction of a class property.
7
9
  *
@@ -13,6 +15,12 @@ export class Property {
13
15
  checker;
14
16
  property;
15
17
  decorator;
18
+ // Preloaded values.
19
+ _name;
20
+ _description;
21
+ _alias;
22
+ _type;
23
+ _isExposed;
16
24
  /**
17
25
  *
18
26
  * @param checker Checker to use to introspect the property.
@@ -30,21 +38,55 @@ export class Property {
30
38
  this.symbol = propertySymbol;
31
39
  this.decorator = ts.getDecorators(property)?.find((d) => {
32
40
  if (ts.isCallExpression(d.expression)) {
33
- return d.expression.expression.getText() === PROPERTY_DECORATOR;
41
+ return (d.expression.expression.getText() === PROPERTY_DECORATOR ||
42
+ d.expression.expression.getText() === DEPRECATED_PROPERTY_DECORATOR);
34
43
  }
35
44
  return false;
36
45
  });
46
+ // Preload values to optimize introspection
47
+ this._name = this.loadName();
48
+ this._description = this.loadDescription();
49
+ this._alias = this.loadAlias();
50
+ this._type = this.loadType();
51
+ this._isExposed = this.loadIsExposed();
37
52
  }
38
53
  get name() {
39
- return this.property.name.getText();
54
+ return this._name;
40
55
  }
41
56
  get description() {
42
- return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
57
+ return this._description;
43
58
  }
44
59
  /**
45
60
  * Return the alias of the property if it has one.
46
61
  */
47
62
  get alias() {
63
+ return this._alias;
64
+ }
65
+ /**
66
+ * Return the type of the property in a Dagger TypeDef format.
67
+ */
68
+ get type() {
69
+ return this._type;
70
+ }
71
+ get isExposed() {
72
+ return this._isExposed;
73
+ }
74
+ toJSON() {
75
+ return {
76
+ name: this.name,
77
+ description: this.description,
78
+ alias: this.alias,
79
+ type: this.type,
80
+ isExposed: this.isExposed,
81
+ };
82
+ }
83
+ loadName() {
84
+ return this.symbol.getName();
85
+ }
86
+ loadDescription() {
87
+ return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
88
+ }
89
+ loadAlias() {
48
90
  if (!this.decorator) {
49
91
  return undefined;
50
92
  }
@@ -55,37 +97,14 @@ export class Property {
55
97
  }
56
98
  return JSON.parse(aliasArg.getText().replace(/'/g, '"'));
57
99
  }
58
- /**
59
- * Return the type of the property in a Dagger TypeDef format.
60
- */
61
- get type() {
100
+ loadType() {
62
101
  if (!this.symbol.valueDeclaration) {
63
102
  throw new UnknownDaggerError("could not find symbol value declaration", {});
64
103
  }
65
104
  const type = this.checker.getTypeOfSymbolAtLocation(this.symbol, this.symbol.valueDeclaration);
66
105
  return typeToTypedef(this.checker, type);
67
106
  }
68
- get isExposed() {
107
+ loadIsExposed() {
69
108
  return this.decorator !== undefined;
70
109
  }
71
- // TODO(TomChv): replace with `ToJson` method
72
- // after the refactor is complete.
73
- get typeDef() {
74
- return {
75
- name: this.name,
76
- description: this.description,
77
- alias: this.alias,
78
- typeDef: this.type,
79
- isExposed: this.isExposed,
80
- };
81
- }
82
- toJSON() {
83
- return {
84
- name: this.name,
85
- description: this.description,
86
- alias: this.alias,
87
- type: this.type,
88
- isExposed: this.isExposed,
89
- };
90
- }
91
110
  }
@@ -0,0 +1,8 @@
1
+ import ts from "typescript";
2
+ import { TypeDefKind } from "../../../api/client.gen.js";
3
+ import { TypeDef } from "../typeDefs.js";
4
+ /**
5
+ * Convert a type into a Dagger Typedef using dynamic typing.
6
+ */
7
+ export declare function typeToTypedef(checker: ts.TypeChecker, type: ts.Type): TypeDef<TypeDefKind>;
8
+ //# sourceMappingURL=typeToTypedef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeToTypedef.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/typeToTypedef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAGxC;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,CAuFtB"}
@@ -0,0 +1,76 @@
1
+ import ts from "typescript";
2
+ import { TypeDefKind } from "../../../api/client.gen.js";
3
+ import { isEnumDecorated } from "./enum.js";
4
+ /**
5
+ * Convert a type into a Dagger Typedef using dynamic typing.
6
+ */
7
+ export function typeToTypedef(checker, type) {
8
+ const symbol = type.getSymbol();
9
+ const symbolName = symbol?.name;
10
+ const symbolDeclaration = symbol?.valueDeclaration;
11
+ if (symbolName === "Promise") {
12
+ const typeArgs = checker.getTypeArguments(type);
13
+ if (typeArgs.length > 0) {
14
+ return typeToTypedef(checker, typeArgs[0]);
15
+ }
16
+ }
17
+ if (symbolName === "Array") {
18
+ const typeArgs = checker.getTypeArguments(type);
19
+ if (typeArgs.length === 0) {
20
+ throw new Error("Generic array not supported");
21
+ }
22
+ return {
23
+ kind: TypeDefKind.ListKind,
24
+ typeDef: typeToTypedef(checker, typeArgs[0]),
25
+ };
26
+ }
27
+ const strType = checker.typeToString(type);
28
+ switch (strType) {
29
+ case "string":
30
+ return { kind: TypeDefKind.StringKind };
31
+ case "number":
32
+ return { kind: TypeDefKind.IntegerKind };
33
+ case "boolean":
34
+ return { kind: TypeDefKind.BooleanKind };
35
+ case "void":
36
+ return { kind: TypeDefKind.VoidKind };
37
+ // Intercept primitive types and throw error in this case
38
+ case "String":
39
+ throw new Error("Use of primitive String type detected, did you mean string?");
40
+ case "Number":
41
+ throw new Error("Use of primitive Number type detected, did you mean number?");
42
+ case "Boolean":
43
+ throw new Error("Use of primitive Boolean type detected, did you mean boolean?");
44
+ default:
45
+ if (symbolName &&
46
+ type.isClassOrInterface() &&
47
+ symbolDeclaration &&
48
+ ts.isClassDeclaration(symbolDeclaration)) {
49
+ if (isEnumDecorated(symbolDeclaration)) {
50
+ return {
51
+ kind: TypeDefKind.EnumKind,
52
+ name: symbolName,
53
+ };
54
+ }
55
+ return {
56
+ kind: TypeDefKind.ObjectKind,
57
+ name: symbolName,
58
+ };
59
+ }
60
+ if (symbol?.getFlags() !== undefined &&
61
+ (symbol.getFlags() & ts.SymbolFlags.Enum) !== 0) {
62
+ return {
63
+ kind: TypeDefKind.EnumKind,
64
+ name: strType,
65
+ };
66
+ }
67
+ // If it's a union, then it's a scalar type
68
+ if (type.isUnionOrIntersection()) {
69
+ return {
70
+ kind: TypeDefKind.ScalarKind,
71
+ name: strType,
72
+ };
73
+ }
74
+ throw new Error(`Unsupported type ${strType}`);
75
+ }
76
+ }
@@ -1,16 +1,4 @@
1
1
  import { DaggerModule } from "./abtractions/module.js";
2
- import { ClassTypeDef, FunctionTypedef } from "./typeDefs.js";
3
- export type ScanResult = {
4
- module: {
5
- description?: string;
6
- };
7
- classes: {
8
- [name: string]: ClassTypeDef;
9
- };
10
- functions: {
11
- [name: string]: FunctionTypedef;
12
- };
13
- };
14
2
  /**
15
3
  * Scan the list of TypeScript File using the TypeScript compiler API.
16
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/scan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE7D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAA;IACzC,SAAS,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAA;CAC/C,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,SAAK,GAAG,YAAY,CAenE"}
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/scan.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,SAAK,GAAG,YAAY,CAenE"}
@@ -12,6 +12,13 @@ export type ObjectTypeDef = BaseTypeDef & {
12
12
  kind: TypeDefKind.ObjectKind;
13
13
  name: string;
14
14
  };
15
+ /**
16
+ * Extends the base type def if it's an enum to add its name.
17
+ */
18
+ export type EnumTypeDef = BaseTypeDef & {
19
+ kind: TypeDefKind.EnumKind;
20
+ name: string;
21
+ };
15
22
  /**
16
23
  * Extends the base typedef if it's a scalar to add its name and real type.
17
24
  */
@@ -34,57 +41,5 @@ export type ListTypeDef = BaseTypeDef & {
34
41
  * If it's type of kind object, it transforms the BaseTypeDef into an ObjectTypeDef.
35
42
  * If it's a type of kind list, it transforms the BaseTypeDef into a ListTypeDef.
36
43
  */
37
- export type TypeDef<T extends BaseTypeDef["kind"]> = T extends TypeDefKind.ScalarKind ? ScalarTypeDef : T extends TypeDefKind.ObjectKind ? ObjectTypeDef : T extends TypeDefKind.ListKind ? ListTypeDef : BaseTypeDef;
38
- /**
39
- * The type of field in a class
40
- */
41
- export type FieldTypeDef = {
42
- name: string;
43
- alias?: string;
44
- description: string;
45
- typeDef: TypeDef<TypeDefKind>;
46
- isExposed: boolean;
47
- };
48
- /**
49
- * The type of function argument in a method or function.
50
- */
51
- export type FunctionArgTypeDef = {
52
- name: string;
53
- description: string;
54
- optional: boolean;
55
- defaultValue?: string;
56
- isVariadic: boolean;
57
- typeDef: TypeDef<TypeDefKind>;
58
- };
59
- /**
60
- * The type of function, it can be a method from a class or an actual function.
61
- */
62
- export type FunctionTypedef = {
63
- name: string;
64
- description: string;
65
- alias?: string;
66
- args: {
67
- [name: string]: FunctionArgTypeDef;
68
- };
69
- returnType: TypeDef<TypeDefKind>;
70
- };
71
- export type ConstructorTypeDef = {
72
- args: {
73
- [name: string]: FunctionArgTypeDef;
74
- };
75
- };
76
- /**
77
- * A type of Class.
78
- */
79
- export type ClassTypeDef = {
80
- name: string;
81
- description: string;
82
- fields: {
83
- [name: string]: FieldTypeDef;
84
- };
85
- constructor?: ConstructorTypeDef;
86
- methods: {
87
- [name: string]: FunctionTypedef;
88
- };
89
- };
44
+ export type TypeDef<T extends BaseTypeDef["kind"]> = T extends TypeDefKind.ScalarKind ? ScalarTypeDef : T extends TypeDefKind.ObjectKind ? ObjectTypeDef : T extends TypeDefKind.ListKind ? ListTypeDef : T extends TypeDefKind.EnumKind ? EnumTypeDef : BaseTypeDef;
90
45
  //# sourceMappingURL=typeDefs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeDefs.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/typeDefs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAErD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CAC9B,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,IAC/C,CAAC,SAAS,WAAW,CAAC,UAAU,GAC5B,aAAa,GACb,CAAC,SAAS,WAAW,CAAC,UAAU,GAC9B,aAAa,GACb,CAAC,SAAS,WAAW,CAAC,QAAQ,GAC5B,WAAW,GACX,WAAW,CAAA;AAErB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7B,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAE,CAAA;IAC5C,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAE,CAAA;CAC7C,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;KAAE,CAAA;IACxC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAA;CAC7C,CAAA"}
1
+ {"version":3,"file":"typeDefs.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/typeDefs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAErD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CAC9B,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,IAC/C,CAAC,SAAS,WAAW,CAAC,UAAU,GAC5B,aAAa,GACb,CAAC,SAAS,WAAW,CAAC,UAAU,GAC9B,aAAa,GACb,CAAC,SAAS,WAAW,CAAC,QAAQ,GAC5B,WAAW,GACX,CAAC,SAAS,WAAW,CAAC,QAAQ,GAC5B,WAAW,GACX,WAAW,CAAA"}
@@ -9,7 +9,7 @@ import { TypeDef } from "./typeDefs.js";
9
9
  export declare function isObject(object: ts.ClassDeclaration): boolean;
10
10
  export declare function toPascalCase(input: string): string;
11
11
  /**
12
- * Return true if the given method has the decorator @fct() on top
12
+ * Return true if the given method has the decorator @func() on top
13
13
  * of its declaration.
14
14
  *
15
15
  * @param method The method to check
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAU7D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,CAgDtB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAU7D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,CA8DtB"}
@@ -31,7 +31,7 @@ export function toPascalCase(input) {
31
31
  return pascalCase;
32
32
  }
33
33
  /**
34
- * Return true if the given method has the decorator @fct() on top
34
+ * Return true if the given method has the decorator @func() on top
35
35
  * of its declaration.
36
36
  *
37
37
  * @param method The method to check
@@ -64,12 +64,6 @@ export function typeToTypedef(checker, type) {
64
64
  typeDef: typeToTypedef(checker, typeArgs[0]),
65
65
  };
66
66
  }
67
- if (type.symbol?.name && type.isClassOrInterface()) {
68
- return {
69
- kind: TypeDefKind.ObjectKind,
70
- name: type.symbol.name,
71
- };
72
- }
73
67
  const strType = checker.typeToString(type);
74
68
  switch (strType) {
75
69
  case "string":
@@ -80,7 +74,21 @@ export function typeToTypedef(checker, type) {
80
74
  return { kind: TypeDefKind.BooleanKind };
81
75
  case "void":
82
76
  return { kind: TypeDefKind.VoidKind };
77
+ // Intercept primitive types and throw error in this case
78
+ case "String":
79
+ throw new Error("Use of primitive String type detected, did you mean string?");
80
+ case "Number":
81
+ throw new Error("Use of primitive Number type detected, did you mean number?");
82
+ case "Boolean":
83
+ throw new Error("Use of primitive Boolean type detected, did you mean boolean?");
83
84
  default:
85
+ // If it's a class or interface, it's an object
86
+ if (type.symbol?.name && type.isClassOrInterface()) {
87
+ return {
88
+ kind: TypeDefKind.ObjectKind,
89
+ name: strType,
90
+ };
91
+ }
84
92
  // If it's a union, then it's a scalar type
85
93
  if (type.isUnionOrIntersection()) {
86
94
  return {
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.11.9";
1
+ export declare const CLI_VERSION = "0.12.0";
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.11.9";
2
+ export const CLI_VERSION = "0.12.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dagger.io/dagger",
3
- "version": "0.11.9",
3
+ "version": "0.12.0",
4
4
  "author": "hello@dagger.io",
5
5
  "license": "Apache-2.0",
6
6
  "types": "./dist/index.d.ts",