@dagger.io/dagger 0.0.1-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 (213) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +88 -0
  3. package/dist/src/api/client.gen.d.ts +6123 -0
  4. package/dist/src/api/client.gen.d.ts.map +1 -0
  5. package/dist/src/api/client.gen.js +8494 -0
  6. package/dist/src/common/context.d.ts +12 -0
  7. package/dist/src/common/context.d.ts.map +1 -0
  8. package/dist/src/common/context.js +22 -0
  9. package/dist/src/common/errors/DaggerSDKError.d.ts +32 -0
  10. package/dist/src/common/errors/DaggerSDKError.d.ts.map +1 -0
  11. package/dist/src/common/errors/DaggerSDKError.js +26 -0
  12. package/dist/src/common/errors/DockerImageRefValidationError.d.ts +22 -0
  13. package/dist/src/common/errors/DockerImageRefValidationError.d.ts.map +1 -0
  14. package/dist/src/common/errors/DockerImageRefValidationError.js +21 -0
  15. package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts +21 -0
  16. package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts.map +1 -0
  17. package/dist/src/common/errors/EngineSessionConnectParamsParseError.js +20 -0
  18. package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts +21 -0
  19. package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +1 -0
  20. package/dist/src/common/errors/EngineSessionConnectionTimeoutError.js +20 -0
  21. package/dist/src/common/errors/EngineSessionErrorOptions.d.ts +16 -0
  22. package/dist/src/common/errors/EngineSessionErrorOptions.d.ts.map +1 -0
  23. package/dist/src/common/errors/EngineSessionErrorOptions.js +16 -0
  24. package/dist/src/common/errors/ExecError.d.ts +42 -0
  25. package/dist/src/common/errors/ExecError.d.ts.map +1 -0
  26. package/dist/src/common/errors/ExecError.js +40 -0
  27. package/dist/src/common/errors/FunctionNotFound.d.ts +7 -0
  28. package/dist/src/common/errors/FunctionNotFound.d.ts.map +1 -0
  29. package/dist/src/common/errors/FunctionNotFound.js +9 -0
  30. package/dist/src/common/errors/GraphQLRequestError.d.ts +31 -0
  31. package/dist/src/common/errors/GraphQLRequestError.d.ts.map +1 -0
  32. package/dist/src/common/errors/GraphQLRequestError.js +30 -0
  33. package/dist/src/common/errors/InitEngineSessionBinaryError.d.ts +13 -0
  34. package/dist/src/common/errors/InitEngineSessionBinaryError.d.ts.map +1 -0
  35. package/dist/src/common/errors/InitEngineSessionBinaryError.js +15 -0
  36. package/dist/src/common/errors/IntrospectionError.d.ts +7 -0
  37. package/dist/src/common/errors/IntrospectionError.d.ts.map +1 -0
  38. package/dist/src/common/errors/IntrospectionError.js +9 -0
  39. package/dist/src/common/errors/NotAwaitedRequestError.d.ts +13 -0
  40. package/dist/src/common/errors/NotAwaitedRequestError.d.ts.map +1 -0
  41. package/dist/src/common/errors/NotAwaitedRequestError.js +15 -0
  42. package/dist/src/common/errors/TooManyNestedObjectsError.d.ts +21 -0
  43. package/dist/src/common/errors/TooManyNestedObjectsError.d.ts.map +1 -0
  44. package/dist/src/common/errors/TooManyNestedObjectsError.js +20 -0
  45. package/dist/src/common/errors/UnknownDaggerError.d.ts +13 -0
  46. package/dist/src/common/errors/UnknownDaggerError.d.ts.map +1 -0
  47. package/dist/src/common/errors/UnknownDaggerError.js +15 -0
  48. package/dist/src/common/errors/errors-codes.d.ts +55 -0
  49. package/dist/src/common/errors/errors-codes.d.ts.map +1 -0
  50. package/dist/src/common/errors/errors-codes.js +47 -0
  51. package/dist/src/common/errors/index.d.ts +15 -0
  52. package/dist/src/common/errors/index.d.ts.map +1 -0
  53. package/dist/src/common/errors/index.js +14 -0
  54. package/dist/src/common/graphql/client.d.ts +3 -0
  55. package/dist/src/common/graphql/client.d.ts.map +1 -0
  56. package/dist/src/common/graphql/client.js +58 -0
  57. package/dist/src/common/graphql/compute_query.d.ts +37 -0
  58. package/dist/src/common/graphql/compute_query.d.ts.map +1 -0
  59. package/dist/src/common/graphql/compute_query.js +171 -0
  60. package/dist/src/common/graphql/connect.d.ts +8 -0
  61. package/dist/src/common/graphql/connect.d.ts.map +1 -0
  62. package/dist/src/common/graphql/connect.js +22 -0
  63. package/dist/src/common/graphql/connection.d.ts +14 -0
  64. package/dist/src/common/graphql/connection.d.ts.map +1 -0
  65. package/dist/src/common/graphql/connection.js +23 -0
  66. package/dist/src/common/utils.d.ts +70 -0
  67. package/dist/src/common/utils.d.ts.map +1 -0
  68. package/dist/src/common/utils.js +6 -0
  69. package/dist/src/connect.d.ts +28 -0
  70. package/dist/src/connect.d.ts.map +1 -0
  71. package/dist/src/connect.js +64 -0
  72. package/dist/src/connectOpts.d.ts +24 -0
  73. package/dist/src/connectOpts.d.ts.map +1 -0
  74. package/dist/src/connectOpts.js +1 -0
  75. package/dist/src/index.d.ts +11 -0
  76. package/dist/src/index.d.ts.map +1 -0
  77. package/dist/src/index.js +13 -0
  78. package/dist/src/module/decorators.d.ts +52 -0
  79. package/dist/src/module/decorators.d.ts.map +1 -0
  80. package/dist/src/module/decorators.js +55 -0
  81. package/dist/src/module/entrypoint/context.d.ts +8 -0
  82. package/dist/src/module/entrypoint/context.d.ts.map +1 -0
  83. package/dist/src/module/entrypoint/context.js +1 -0
  84. package/dist/src/module/entrypoint/entrypoint.d.ts +2 -0
  85. package/dist/src/module/entrypoint/entrypoint.d.ts.map +1 -0
  86. package/dist/src/module/entrypoint/entrypoint.js +92 -0
  87. package/dist/src/module/entrypoint/introspection_entrypoint.d.ts +2 -0
  88. package/dist/src/module/entrypoint/introspection_entrypoint.d.ts.map +1 -0
  89. package/dist/src/module/entrypoint/introspection_entrypoint.js +52 -0
  90. package/dist/src/module/entrypoint/invoke.d.ts +14 -0
  91. package/dist/src/module/entrypoint/invoke.d.ts.map +1 -0
  92. package/dist/src/module/entrypoint/invoke.js +66 -0
  93. package/dist/src/module/entrypoint/load.d.ts +53 -0
  94. package/dist/src/module/entrypoint/load.d.ts.map +1 -0
  95. package/dist/src/module/entrypoint/load.js +237 -0
  96. package/dist/src/module/entrypoint/register.d.ts +33 -0
  97. package/dist/src/module/entrypoint/register.d.ts.map +1 -0
  98. package/dist/src/module/entrypoint/register.js +227 -0
  99. package/dist/src/module/executor.d.ts +28 -0
  100. package/dist/src/module/executor.d.ts.map +1 -0
  101. package/dist/src/module/executor.js +171 -0
  102. package/dist/src/module/introspector/case_convertor.d.ts +2 -0
  103. package/dist/src/module/introspector/case_convertor.d.ts.map +1 -0
  104. package/dist/src/module/introspector/case_convertor.js +15 -0
  105. package/dist/src/module/introspector/dagger_module/argument.d.ts +50 -0
  106. package/dist/src/module/introspector/dagger_module/argument.d.ts.map +1 -0
  107. package/dist/src/module/introspector/dagger_module/argument.js +118 -0
  108. package/dist/src/module/introspector/dagger_module/constructor.d.ts +18 -0
  109. package/dist/src/module/introspector/dagger_module/constructor.d.ts.map +1 -0
  110. package/dist/src/module/introspector/dagger_module/constructor.js +38 -0
  111. package/dist/src/module/introspector/dagger_module/decorator.d.ts +8 -0
  112. package/dist/src/module/introspector/dagger_module/decorator.d.ts.map +1 -0
  113. package/dist/src/module/introspector/dagger_module/decorator.js +7 -0
  114. package/dist/src/module/introspector/dagger_module/enum.d.ts +41 -0
  115. package/dist/src/module/introspector/dagger_module/enum.d.ts.map +1 -0
  116. package/dist/src/module/introspector/dagger_module/enum.js +63 -0
  117. package/dist/src/module/introspector/dagger_module/enumBase.d.ts +19 -0
  118. package/dist/src/module/introspector/dagger_module/enumBase.d.ts.map +1 -0
  119. package/dist/src/module/introspector/dagger_module/enumBase.js +1 -0
  120. package/dist/src/module/introspector/dagger_module/enumClass.d.ts +41 -0
  121. package/dist/src/module/introspector/dagger_module/enumClass.d.ts.map +1 -0
  122. package/dist/src/module/introspector/dagger_module/enumClass.js +69 -0
  123. package/dist/src/module/introspector/dagger_module/function.d.ts +39 -0
  124. package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -0
  125. package/dist/src/module/introspector/dagger_module/function.js +102 -0
  126. package/dist/src/module/introspector/dagger_module/index.d.ts +15 -0
  127. package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -0
  128. package/dist/src/module/introspector/dagger_module/index.js +14 -0
  129. package/dist/src/module/introspector/dagger_module/interface.d.ts +25 -0
  130. package/dist/src/module/introspector/dagger_module/interface.d.ts.map +1 -0
  131. package/dist/src/module/introspector/dagger_module/interface.js +56 -0
  132. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts +35 -0
  133. package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts.map +1 -0
  134. package/dist/src/module/introspector/dagger_module/interfaceFunction.js +92 -0
  135. package/dist/src/module/introspector/dagger_module/locatable.d.ts +12 -0
  136. package/dist/src/module/introspector/dagger_module/locatable.d.ts.map +1 -0
  137. package/dist/src/module/introspector/dagger_module/locatable.js +14 -0
  138. package/dist/src/module/introspector/dagger_module/module.d.ts +118 -0
  139. package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -0
  140. package/dist/src/module/introspector/dagger_module/module.js +316 -0
  141. package/dist/src/module/introspector/dagger_module/object.d.ts +46 -0
  142. package/dist/src/module/introspector/dagger_module/object.d.ts.map +1 -0
  143. package/dist/src/module/introspector/dagger_module/object.js +113 -0
  144. package/dist/src/module/introspector/dagger_module/objectBase.d.ts +32 -0
  145. package/dist/src/module/introspector/dagger_module/objectBase.d.ts.map +1 -0
  146. package/dist/src/module/introspector/dagger_module/objectBase.js +1 -0
  147. package/dist/src/module/introspector/dagger_module/property.d.ts +36 -0
  148. package/dist/src/module/introspector/dagger_module/property.d.ts.map +1 -0
  149. package/dist/src/module/introspector/dagger_module/property.js +82 -0
  150. package/dist/src/module/introspector/dagger_module/reference.d.ts +13 -0
  151. package/dist/src/module/introspector/dagger_module/reference.d.ts.map +1 -0
  152. package/dist/src/module/introspector/dagger_module/reference.js +33 -0
  153. package/dist/src/module/introspector/dagger_module/typeObject.d.ts +49 -0
  154. package/dist/src/module/introspector/dagger_module/typeObject.d.ts.map +1 -0
  155. package/dist/src/module/introspector/dagger_module/typeObject.js +87 -0
  156. package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts +34 -0
  157. package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts.map +1 -0
  158. package/dist/src/module/introspector/dagger_module/typeObjectProperty.js +60 -0
  159. package/dist/src/module/introspector/index.d.ts +3 -0
  160. package/dist/src/module/introspector/index.d.ts.map +1 -0
  161. package/dist/src/module/introspector/index.js +19 -0
  162. package/dist/src/module/introspector/typedef.d.ts +52 -0
  163. package/dist/src/module/introspector/typedef.d.ts.map +1 -0
  164. package/dist/src/module/introspector/typedef.js +1 -0
  165. package/dist/src/module/introspector/typescript_module/ast.d.ts +64 -0
  166. package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -0
  167. package/dist/src/module/introspector/typescript_module/ast.js +476 -0
  168. package/dist/src/module/introspector/typescript_module/declarations.d.ts +15 -0
  169. package/dist/src/module/introspector/typescript_module/declarations.d.ts.map +1 -0
  170. package/dist/src/module/introspector/typescript_module/declarations.js +10 -0
  171. package/dist/src/module/introspector/typescript_module/index.d.ts +4 -0
  172. package/dist/src/module/introspector/typescript_module/index.d.ts.map +1 -0
  173. package/dist/src/module/introspector/typescript_module/index.js +3 -0
  174. package/dist/src/module/introspector/typescript_module/location.d.ts +6 -0
  175. package/dist/src/module/introspector/typescript_module/location.d.ts.map +1 -0
  176. package/dist/src/module/introspector/typescript_module/location.js +1 -0
  177. package/dist/src/module/introspector/typescript_module/typedef_utils.d.ts +5 -0
  178. package/dist/src/module/introspector/typescript_module/typedef_utils.d.ts.map +1 -0
  179. package/dist/src/module/introspector/typescript_module/typedef_utils.js +26 -0
  180. package/dist/src/module/introspector/utils/files.d.ts +5 -0
  181. package/dist/src/module/introspector/utils/files.d.ts.map +1 -0
  182. package/dist/src/module/introspector/utils/files.js +28 -0
  183. package/dist/src/module/registry.d.ts +109 -0
  184. package/dist/src/module/registry.d.ts.map +1 -0
  185. package/dist/src/module/registry.js +123 -0
  186. package/dist/src/provisioning/bin.d.ts +77 -0
  187. package/dist/src/provisioning/bin.d.ts.map +1 -0
  188. package/dist/src/provisioning/bin.js +353 -0
  189. package/dist/src/provisioning/default.d.ts +2 -0
  190. package/dist/src/provisioning/default.d.ts.map +1 -0
  191. package/dist/src/provisioning/default.js +2 -0
  192. package/dist/src/provisioning/engineconn.d.ts +30 -0
  193. package/dist/src/provisioning/engineconn.d.ts.map +1 -0
  194. package/dist/src/provisioning/engineconn.js +1 -0
  195. package/dist/src/provisioning/index.d.ts +4 -0
  196. package/dist/src/provisioning/index.d.ts.map +1 -0
  197. package/dist/src/provisioning/index.js +14 -0
  198. package/dist/src/telemetry/index.d.ts +3 -0
  199. package/dist/src/telemetry/index.d.ts.map +1 -0
  200. package/dist/src/telemetry/index.js +2 -0
  201. package/dist/src/telemetry/init.d.ts +21 -0
  202. package/dist/src/telemetry/init.d.ts.map +1 -0
  203. package/dist/src/telemetry/init.js +86 -0
  204. package/dist/src/telemetry/live_processor.d.ts +12 -0
  205. package/dist/src/telemetry/live_processor.d.ts.map +1 -0
  206. package/dist/src/telemetry/live_processor.js +13 -0
  207. package/dist/src/telemetry/telemetry.d.ts +16 -0
  208. package/dist/src/telemetry/telemetry.d.ts.map +1 -0
  209. package/dist/src/telemetry/telemetry.js +38 -0
  210. package/dist/src/telemetry/tracer.d.ts +32 -0
  211. package/dist/src/telemetry/tracer.d.ts.map +1 -0
  212. package/dist/src/telemetry/tracer.js +54 -0
  213. package/package.json +74 -0
@@ -0,0 +1,69 @@
1
+ import ts from "typescript";
2
+ import { IntrospectionError } from "../../../common/errors/index.js";
3
+ import { AST } from "../typescript_module/index.js";
4
+ import { Locatable } from "./locatable.js";
5
+ export class DaggerEnumClassValue extends Locatable {
6
+ node;
7
+ ast;
8
+ name;
9
+ value;
10
+ description;
11
+ deprecated;
12
+ symbol;
13
+ constructor(node, ast) {
14
+ super(node);
15
+ this.node = node;
16
+ this.ast = ast;
17
+ this.name = this.node.name.getText();
18
+ this.symbol = this.ast.getSymbolOrThrow(this.node.name);
19
+ const { description, deprecated } = this.ast.getSymbolDoc(this.symbol);
20
+ this.description = description;
21
+ this.deprecated = deprecated;
22
+ const initializer = this.node.initializer;
23
+ if (!initializer) {
24
+ throw new Error("Dagger enum value has no value set");
25
+ }
26
+ this.value = this.ast.resolveParameterDefaultValue(initializer);
27
+ }
28
+ toJSON() {
29
+ return {
30
+ name: this.name,
31
+ value: this.value,
32
+ description: this.description,
33
+ deprecated: this.deprecated,
34
+ };
35
+ }
36
+ }
37
+ export class DaggerEnumClass extends Locatable {
38
+ node;
39
+ ast;
40
+ name;
41
+ description;
42
+ values = {};
43
+ symbol;
44
+ constructor(node, ast) {
45
+ super(node);
46
+ this.node = node;
47
+ this.ast = ast;
48
+ if (!this.node.name) {
49
+ throw new IntrospectionError(`could not resolve name of enum at ${AST.getNodePosition(node)}.`);
50
+ }
51
+ this.name = this.node.name.getText();
52
+ this.symbol = this.ast.getSymbolOrThrow(this.node.name);
53
+ this.description = this.ast.getDocFromSymbol(this.symbol);
54
+ const properties = this.node.members;
55
+ for (const property of properties) {
56
+ if (ts.isPropertyDeclaration(property)) {
57
+ const value = new DaggerEnumClassValue(property, this.ast);
58
+ this.values[value.name] = value;
59
+ }
60
+ }
61
+ }
62
+ toJSON() {
63
+ return {
64
+ name: this.name,
65
+ description: this.description,
66
+ values: this.values,
67
+ };
68
+ }
69
+ }
@@ -0,0 +1,39 @@
1
+ import ts from "typescript";
2
+ import { TypeDefKind } from "../../../api/client.gen.js";
3
+ import { TypeDef } from "../typedef.js";
4
+ import { AST } from "../typescript_module/index.js";
5
+ import { DaggerArguments } from "./argument.js";
6
+ import { Locatable } from "./locatable.js";
7
+ import { References } from "./reference.js";
8
+ export type DaggerFunctions = {
9
+ [name: string]: DaggerFunction;
10
+ };
11
+ export declare class DaggerFunction extends Locatable {
12
+ private readonly node;
13
+ private readonly ast;
14
+ name: string;
15
+ description: string;
16
+ deprecated?: string;
17
+ private _returnTypeRef?;
18
+ returnType?: TypeDef<TypeDefKind>;
19
+ arguments: DaggerArguments;
20
+ alias: string | undefined;
21
+ cache: string | undefined;
22
+ isCheck: boolean;
23
+ private signature;
24
+ private symbol;
25
+ constructor(node: ts.MethodDeclaration, ast: AST);
26
+ private getReturnType;
27
+ getArgsOrder(): string[];
28
+ getReferences(): string[];
29
+ propagateReferences(references: References): void;
30
+ toJSON(): {
31
+ name: string;
32
+ description: string;
33
+ deprecated: string | undefined;
34
+ alias: string | undefined;
35
+ arguments: DaggerArguments;
36
+ returnType: TypeDef<TypeDefKind> | undefined;
37
+ };
38
+ }
39
+ //# sourceMappingURL=function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,GAAG,EAGJ,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAkB,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,CAAA;AAEhE,qBAAa,cAAe,SAAQ,SAAS;IAezC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAff,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,cAAc,CAAC,CAAQ;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACjC,SAAS,EAAE,eAAe,CAAK;IAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,OAAO,EAAE,OAAO,CAAQ;IAE/B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,iBAAiB,EAC1B,GAAG,EAAE,GAAG;IAuC3B,OAAO,CAAC,aAAa;IAWd,YAAY,IAAI,MAAM,EAAE;IAIxB,aAAa,IAAI,MAAM,EAAE;IAoBzB,mBAAmB,CAAC,UAAU,EAAE,UAAU;IAuB1C,MAAM;;;;;;;;CAUd"}
@@ -0,0 +1,102 @@
1
+ import { IntrospectionError } from "../../../common/errors/index.js";
2
+ import { AST, isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
3
+ import { DaggerArgument } from "./argument.js";
4
+ import { CHECK_DECORATOR, FUNCTION_DECORATOR } from "./decorator.js";
5
+ import { Locatable } from "./locatable.js";
6
+ export class DaggerFunction extends Locatable {
7
+ node;
8
+ ast;
9
+ name;
10
+ description;
11
+ deprecated;
12
+ _returnTypeRef;
13
+ returnType;
14
+ arguments = {};
15
+ alias;
16
+ cache;
17
+ isCheck = false;
18
+ signature;
19
+ symbol;
20
+ constructor(node, ast) {
21
+ super(node);
22
+ this.node = node;
23
+ this.ast = ast;
24
+ this.symbol = this.ast.getSymbolOrThrow(node.name);
25
+ this.signature = this.ast.getSignatureFromFunctionOrThrow(node);
26
+ this.name = this.node.name.getText();
27
+ const { description, deprecated } = this.ast.getSymbolDoc(this.symbol);
28
+ this.description = description;
29
+ this.deprecated = deprecated;
30
+ const functionArguments = this.ast.getDecoratorArgument(this.node, FUNCTION_DECORATOR, "object");
31
+ if (functionArguments) {
32
+ if (typeof functionArguments === "string") {
33
+ // previously only a single arg was accepted for alias, so if there's just
34
+ // a string we intrepret it that way for backward compatibility
35
+ this.alias = functionArguments;
36
+ }
37
+ else {
38
+ this.alias = functionArguments.alias;
39
+ this.cache = functionArguments.cache;
40
+ }
41
+ }
42
+ // Parse @check decorator
43
+ if (this.ast.isNodeDecoratedWith(this.node, CHECK_DECORATOR)) {
44
+ this.isCheck = true;
45
+ }
46
+ for (const parameter of this.node.parameters) {
47
+ this.arguments[parameter.name.getText()] = new DaggerArgument(parameter, this.ast);
48
+ }
49
+ this.returnType = this.getReturnType();
50
+ }
51
+ getReturnType() {
52
+ const type = this.signature.getReturnType();
53
+ const typedef = this.ast.tsTypeToTypeDef(this.node, type);
54
+ if (typedef === undefined || !isTypeDefResolved(typedef)) {
55
+ this._returnTypeRef = this.ast.typeToStringType(type);
56
+ }
57
+ return typedef;
58
+ }
59
+ getArgsOrder() {
60
+ return Object.keys(this.arguments);
61
+ }
62
+ getReferences() {
63
+ const references = [];
64
+ if (this._returnTypeRef &&
65
+ (this.returnType === undefined || !isTypeDefResolved(this.returnType))) {
66
+ references.push(this._returnTypeRef);
67
+ }
68
+ for (const argument of Object.values(this.arguments)) {
69
+ const reference = argument.getReference();
70
+ if (reference) {
71
+ references.push(reference);
72
+ }
73
+ }
74
+ return references;
75
+ }
76
+ propagateReferences(references) {
77
+ for (const argument of Object.values(this.arguments)) {
78
+ argument.propagateReferences(references);
79
+ }
80
+ if (!this._returnTypeRef) {
81
+ return;
82
+ }
83
+ if (this.returnType && isTypeDefResolved(this.returnType)) {
84
+ return;
85
+ }
86
+ const typeDef = references[this._returnTypeRef];
87
+ if (!typeDef) {
88
+ throw new IntrospectionError(`could not find type reference for ${this._returnTypeRef} at ${AST.getNodePosition(this.node)}.`);
89
+ }
90
+ this.returnType = resolveTypeDef(this.returnType, typeDef);
91
+ }
92
+ toJSON() {
93
+ return {
94
+ name: this.name,
95
+ description: this.description,
96
+ deprecated: this.deprecated,
97
+ alias: this.alias,
98
+ arguments: this.arguments,
99
+ returnType: this.returnType,
100
+ };
101
+ }
102
+ }
@@ -0,0 +1,15 @@
1
+ export * from "./constructor.js";
2
+ export * from "./argument.js";
3
+ export * from "./enum.js";
4
+ export * from "./enumBase.js";
5
+ export * from "./enumClass.js";
6
+ export * from "./function.js";
7
+ export * from "./module.js";
8
+ export * from "./object.js";
9
+ export * from "./objectBase.js";
10
+ export * from "./reference.js";
11
+ export * from "./typeObject.js";
12
+ export * from "./decorator.js";
13
+ export * from "./locatable.js";
14
+ export * from "./interface.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,14 @@
1
+ export * from "./constructor.js";
2
+ export * from "./argument.js";
3
+ export * from "./enum.js";
4
+ export * from "./enumBase.js";
5
+ export * from "./enumClass.js";
6
+ export * from "./function.js";
7
+ export * from "./module.js";
8
+ export * from "./object.js";
9
+ export * from "./objectBase.js";
10
+ export * from "./reference.js";
11
+ export * from "./typeObject.js";
12
+ export * from "./decorator.js";
13
+ export * from "./locatable.js";
14
+ export * from "./interface.js";
@@ -0,0 +1,25 @@
1
+ import ts from "typescript";
2
+ import { AST } from "../typescript_module/index.js";
3
+ import { DaggerInterfaceFunctions } from "./interfaceFunction.js";
4
+ import { Locatable } from "./locatable.js";
5
+ import { References } from "./reference.js";
6
+ export type DaggerInterfaces = {
7
+ [name: string]: DaggerInterface;
8
+ };
9
+ export declare class DaggerInterface extends Locatable {
10
+ private readonly node;
11
+ private readonly ast;
12
+ name: string;
13
+ description: string;
14
+ functions: DaggerInterfaceFunctions;
15
+ private symbol;
16
+ constructor(node: ts.InterfaceDeclaration, ast: AST);
17
+ getReferences(): string[];
18
+ propagateReferences(references: References): void;
19
+ toJSON(): {
20
+ name: string;
21
+ description: string;
22
+ functions: DaggerInterfaceFunctions;
23
+ };
24
+ }
25
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAEL,wBAAwB,EACzB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAA;AAElE,qBAAa,eAAgB,SAAQ,SAAS;IAO1C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAPf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,wBAAwB,CAAK;IAC/C,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAC7B,GAAG,EAAE,GAAG;IAoCpB,aAAa,IAAI,MAAM,EAAE;IAQzB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAMjD,MAAM;;;;;CAOd"}
@@ -0,0 +1,56 @@
1
+ import ts from "typescript";
2
+ import { IntrospectionError } from "../../../common/errors/index.js";
3
+ import { AST } from "../typescript_module/index.js";
4
+ import { DaggerInterfaceFunction, } from "./interfaceFunction.js";
5
+ import { Locatable } from "./locatable.js";
6
+ export class DaggerInterface extends Locatable {
7
+ node;
8
+ ast;
9
+ name;
10
+ description;
11
+ functions = {};
12
+ symbol;
13
+ constructor(node, ast) {
14
+ super(node);
15
+ this.node = node;
16
+ this.ast = ast;
17
+ if (!this.node.name) {
18
+ throw new IntrospectionError(`could not resolve name of interface at ${AST.getNodePosition(node)}`);
19
+ }
20
+ this.name = this.node.name.getText();
21
+ this.symbol = this.ast.getSymbolOrThrow(this.node.name);
22
+ this.description = this.ast.getDocFromSymbol(this.symbol);
23
+ for (const member of this.node.members) {
24
+ if (!ts.isPropertySignature(member) && !ts.isMethodSignature(member)) {
25
+ continue;
26
+ }
27
+ // Check if it's a function
28
+ if ((member.type && ts.isFunctionTypeNode(member.type)) ||
29
+ ts.isMethodSignature(member)) {
30
+ const daggerInterfaceFunction = new DaggerInterfaceFunction(member, this.ast);
31
+ this.functions[daggerInterfaceFunction.name] = daggerInterfaceFunction;
32
+ continue;
33
+ }
34
+ // TODO(TomChv): Add support for fields
35
+ }
36
+ }
37
+ getReferences() {
38
+ const references = [];
39
+ for (const fn of Object.values(this.functions)) {
40
+ references.push(...fn.getReferences());
41
+ }
42
+ return references.filter((v, i, arr) => arr.indexOf(v) === i);
43
+ }
44
+ propagateReferences(references) {
45
+ for (const fn of Object.values(this.functions)) {
46
+ fn.propagateReferences(references);
47
+ }
48
+ }
49
+ toJSON() {
50
+ return {
51
+ name: this.name,
52
+ description: this.description,
53
+ functions: this.functions,
54
+ };
55
+ }
56
+ }
@@ -0,0 +1,35 @@
1
+ import ts from "typescript";
2
+ import { TypeDefKind } from "../../../api/client.gen.js";
3
+ import { TypeDef } from "../typedef.js";
4
+ import { AST } from "../typescript_module/index.js";
5
+ import { DaggerArguments } from "./argument.js";
6
+ import { Locatable } from "./locatable.js";
7
+ import { References } from "./reference.js";
8
+ export type DaggerInterfaceFunctions = {
9
+ [name: string]: DaggerInterfaceFunction;
10
+ };
11
+ export declare class DaggerInterfaceFunction extends Locatable {
12
+ private readonly node;
13
+ private readonly ast;
14
+ name: string;
15
+ description: string;
16
+ deprecated?: string;
17
+ private _returnTypeRef?;
18
+ returnType?: TypeDef<TypeDefKind>;
19
+ arguments: DaggerArguments;
20
+ private symbol;
21
+ private signature?;
22
+ alias: undefined;
23
+ cache: undefined;
24
+ constructor(node: ts.PropertySignature | ts.MethodSignature, ast: AST);
25
+ getReferences(): string[];
26
+ propagateReferences(references: References): void;
27
+ toJSON(): {
28
+ name: string;
29
+ description: string;
30
+ deprecated: string | undefined;
31
+ arguments: DaggerArguments;
32
+ returnType: TypeDef<TypeDefKind> | undefined;
33
+ };
34
+ }
35
+ //# sourceMappingURL=interfaceFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaceFunction.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/interfaceFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,GAAG,EAGJ,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAkB,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,wBAAwB,GAAG;IACrC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,qBAAa,uBAAwB,SAAQ,SAAS;IAelD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAff,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,cAAc,CAAC,CAAQ;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACjC,SAAS,EAAE,eAAe,CAAK;IACtC,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,SAAS,CAAC,CAAc;IAGzB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,SAAS,CAAA;gBAGJ,IAAI,EAAE,EAAE,CAAC,iBAAiB,GAAG,EAAE,CAAC,eAAe,EAC/C,GAAG,EAAE,GAAG;IA6CpB,aAAa,IAAI,MAAM,EAAE;IAqBzB,mBAAmB,CAAC,UAAU,EAAE,UAAU;IAuB1C,MAAM;;;;;;;CASd"}
@@ -0,0 +1,92 @@
1
+ import ts from "typescript";
2
+ import { IntrospectionError } from "../../../common/errors/index.js";
3
+ import { AST, isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
4
+ import { DaggerArgument } from "./argument.js";
5
+ import { Locatable } from "./locatable.js";
6
+ export class DaggerInterfaceFunction extends Locatable {
7
+ node;
8
+ ast;
9
+ name;
10
+ description;
11
+ deprecated;
12
+ _returnTypeRef;
13
+ returnType;
14
+ arguments = {};
15
+ symbol;
16
+ signature;
17
+ // Just placeholders to be compatible with `Method` during registration
18
+ alias;
19
+ cache;
20
+ constructor(node, ast) {
21
+ super(node);
22
+ this.node = node;
23
+ this.ast = ast;
24
+ if (!this.node.name) {
25
+ throw new IntrospectionError(`could not resolve name of interface function at ${AST.getNodePosition(node)}`);
26
+ }
27
+ this.name = this.node.name.getText();
28
+ this.symbol = this.ast.getSymbolOrThrow(this.node.name);
29
+ const { description, deprecated } = this.ast.getSymbolDoc(this.symbol);
30
+ this.description = description;
31
+ this.deprecated = deprecated;
32
+ // If it's a method signature, we can directly use it to get the signature props
33
+ // If it's a property kind signature, we need to get the signature from the type
34
+ // Examle:
35
+ // interface Foo {
36
+ // bar(): void // <- this is a method signature
37
+ // baz: () => string // <- this is a property kind signature
38
+ // }
39
+ const nodeType = this.node.type && ts.isFunctionTypeNode(this.node.type)
40
+ ? this.node.type
41
+ : this.node;
42
+ const signature = this.ast.getSignatureFromFunctionOrThrow(nodeType);
43
+ for (const parameter of nodeType.parameters) {
44
+ this.arguments[parameter.name.getText()] = new DaggerArgument(parameter, this.ast);
45
+ }
46
+ const signatureReturnType = signature.getReturnType();
47
+ const typedef = this.ast.tsTypeToTypeDef(this.node, signatureReturnType);
48
+ if (typedef === undefined || !isTypeDefResolved(typedef)) {
49
+ this._returnTypeRef = this.ast.typeToStringType(signatureReturnType);
50
+ }
51
+ this.returnType = typedef;
52
+ }
53
+ getReferences() {
54
+ const references = [];
55
+ if (this._returnTypeRef &&
56
+ (this.returnType === undefined || !isTypeDefResolved(this.returnType))) {
57
+ references.push(this._returnTypeRef);
58
+ }
59
+ for (const argument of Object.values(this.arguments)) {
60
+ const reference = argument.getReference();
61
+ if (reference) {
62
+ references.push(reference);
63
+ }
64
+ }
65
+ return references;
66
+ }
67
+ propagateReferences(references) {
68
+ for (const argument of Object.values(this.arguments)) {
69
+ argument.propagateReferences(references);
70
+ }
71
+ if (!this._returnTypeRef) {
72
+ return;
73
+ }
74
+ if (this.returnType && isTypeDefResolved(this.returnType)) {
75
+ return;
76
+ }
77
+ const typeDef = references[this._returnTypeRef];
78
+ if (!typeDef) {
79
+ throw new IntrospectionError(`could not find type reference for ${this._returnTypeRef} at ${AST.getNodePosition(this.node)}.`);
80
+ }
81
+ this.returnType = resolveTypeDef(this.returnType, typeDef);
82
+ }
83
+ toJSON() {
84
+ return {
85
+ name: this.name,
86
+ description: this.description,
87
+ deprecated: this.deprecated,
88
+ arguments: this.arguments,
89
+ returnType: this.returnType,
90
+ };
91
+ }
92
+ }
@@ -0,0 +1,12 @@
1
+ import ts from "typescript";
2
+ import { Location } from "../typescript_module/index.js";
3
+ /**
4
+ * Locatable is a base class that any Dagger object can extend from to
5
+ * provide a location method.
6
+ */
7
+ export declare class Locatable {
8
+ private readonly __node;
9
+ constructor(__node: ts.Node);
10
+ getLocation(): Location;
11
+ }
12
+ //# sourceMappingURL=locatable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locatable.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/locatable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAO,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAE7D;;;GAGG;AACH,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,EAAE,CAAC,IAAI;IAE5C,WAAW,IAAI,QAAQ;CAGxB"}
@@ -0,0 +1,14 @@
1
+ import { AST } from "../typescript_module/index.js";
2
+ /**
3
+ * Locatable is a base class that any Dagger object can extend from to
4
+ * provide a location method.
5
+ */
6
+ export class Locatable {
7
+ __node;
8
+ constructor(__node) {
9
+ this.__node = __node;
10
+ }
11
+ getLocation() {
12
+ return AST.getNodeLocation(this.__node);
13
+ }
14
+ }
@@ -0,0 +1,118 @@
1
+ import Module from "node:module";
2
+ import { AST } from "../typescript_module/index.js";
3
+ import { DaggerEnumsBase } from "./enumBase.js";
4
+ import { DaggerInterfaces } from "./interface.js";
5
+ import { DaggerObjectsBase } from "./objectBase.js";
6
+ /**
7
+ * DaggerModule represents a TypeScript module with a set of files
8
+ * with Dagger object conversion and notation.
9
+ *
10
+ * It starts from the module entrypoint (the class named the same as the module) and
11
+ * then recursively resolve every references to other declared identifiers.
12
+ * After resolution, it propagates all the references to the modules declarations
13
+ * and finally it generates the final Dagger module representation.
14
+ */
15
+ export declare class DaggerModule {
16
+ name: string;
17
+ private userModule;
18
+ private ast;
19
+ /**
20
+ * An object is either a decorated class or a type alias object.
21
+ * Type alias objects cannot be decorated so they are resolved if referenced in the module.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * @object()
26
+ * export class MyObject {
27
+ * @func()
28
+ * public name: string
29
+ * }
30
+ * ```
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * export type Example = {
35
+ * name: string
36
+ * }
37
+ * ```
38
+ */
39
+ objects: DaggerObjectsBase;
40
+ /**
41
+ * An enum is typically a native TypeScript enum declared with the `enum` keyword.
42
+ * Decorated classes using `@enumType()` are still supported for backward compatibility.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * export enum Example {
47
+ * A = "a",
48
+ * B = "b",
49
+ * }
50
+ * ```
51
+ */
52
+ enums: DaggerEnumsBase;
53
+ /**
54
+ * An interface is declared using the `interface` keyword.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * export interface Example {
59
+ * foo: (): string
60
+ * asyncFoo: (): Promise<string>
61
+ * }
62
+ * ```
63
+ */
64
+ interfaces: DaggerInterfaces;
65
+ description: string | undefined;
66
+ private references;
67
+ constructor(name: string, userModule: Module[], ast: AST);
68
+ /**
69
+ * Find the reference of the module and register it to the module references.
70
+ *
71
+ * To do so, we check the user module to find a corresponding symbol (name) for each of
72
+ * typedef we support.
73
+ * This only applies for:
74
+ * - classes
75
+ * - enums
76
+ * - scalars
77
+ * - interfaces
78
+ *
79
+ * If the reference is an object, a class or an interface, recursively find the references of the object.
80
+ *
81
+ * *Note*: If a class is referenced but not exported and not decorated with `@object()`, we throw an error
82
+ * because we aim to be explicit. (TomChv: Should we change this behaviour?)
83
+ */
84
+ private resolveReferences;
85
+ /**
86
+ * Resolve type alias to the corresponding TypeDef.
87
+ * A type might refer to anything typeable in TypeScript but right now we supports:
88
+ * - `type Example = string`
89
+ * - `type Example = { prop: string}`
90
+ * - `type Example = number`
91
+ * - `type Example = boolean`
92
+ * - `type Example = void`
93
+ *
94
+ * If the reference is an object, we recursively resolve its references.
95
+ * If the type cannot be resolved or is not supported, we throw an error.
96
+ */
97
+ private resolveTypeAlias;
98
+ /**
99
+ * Find the classes in the AST. Returns only our main class if it exists
100
+ */
101
+ private findClasses;
102
+ /**
103
+ * Recursively propagate references to all objects properties and functions.
104
+ */
105
+ private propagateReferences;
106
+ /**
107
+ * Get the top level comment of the file that contains the module entrypoint.
108
+ */
109
+ private getDescription;
110
+ toJSON(): {
111
+ name: string;
112
+ description: string | undefined;
113
+ objects: DaggerObjectsBase;
114
+ enums: DaggerEnumsBase;
115
+ interfaces: DaggerInterfaces;
116
+ };
117
+ }
118
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +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,EACL,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;IA4Dd,IAAI,EAAE,MAAM;IACnB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IA7Db;;;;;;;;;;;;;;;;;;;OAmBG;IACI,OAAO,EAAE,iBAAiB,CAAK;IAEtC;;;;;;;;;;;OAWG;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;IAuBlB;;;;;;;;;;;;;;;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"}