@dagger.io/dagger 0.13.7 → 0.15.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.
- package/dist/{api → src/api}/client.gen.d.ts +304 -370
- package/dist/src/api/client.gen.d.ts.map +1 -0
- package/dist/{api → src/api}/client.gen.js +1385 -3821
- package/dist/src/common/context.d.ts +12 -0
- package/dist/src/common/context.d.ts.map +1 -0
- package/dist/src/common/context.js +22 -0
- package/dist/{common → src/common}/errors/DaggerSDKError.d.ts +1 -1
- package/dist/src/common/errors/DaggerSDKError.d.ts.map +1 -0
- package/dist/src/common/errors/DockerImageRefValidationError.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionErrorOptions.d.ts.map +1 -0
- package/dist/{common → src/common}/errors/ExecError.d.ts +0 -1
- package/dist/src/common/errors/ExecError.d.ts.map +1 -0
- package/dist/{common → src/common}/errors/ExecError.js +0 -3
- package/dist/src/common/errors/FunctionNotFound.d.ts.map +1 -0
- package/dist/src/common/errors/GraphQLRequestError.d.ts.map +1 -0
- package/dist/src/common/errors/InitEngineSessionBinaryError.d.ts.map +1 -0
- package/dist/src/common/errors/IntrospectionError.d.ts +7 -0
- package/dist/src/common/errors/IntrospectionError.d.ts.map +1 -0
- package/dist/src/common/errors/IntrospectionError.js +9 -0
- package/dist/src/common/errors/NotAwaitedRequestError.d.ts.map +1 -0
- package/dist/src/common/errors/TooManyNestedObjectsError.d.ts.map +1 -0
- package/dist/src/common/errors/UnknownDaggerError.d.ts.map +1 -0
- package/dist/{common → src/common}/errors/errors-codes.d.ts +4 -0
- package/dist/src/common/errors/errors-codes.d.ts.map +1 -0
- package/dist/{common → src/common}/errors/errors-codes.js +4 -0
- package/dist/{common → src/common}/errors/index.d.ts +2 -0
- package/dist/src/common/errors/index.d.ts.map +1 -0
- package/dist/{common → src/common}/errors/index.js +2 -0
- package/dist/src/common/graphql/client.d.ts.map +1 -0
- package/dist/{api/utils.d.ts → src/common/graphql/compute_query.d.ts} +10 -2
- package/dist/src/common/graphql/compute_query.d.ts.map +1 -0
- package/dist/{api/utils.js → src/common/graphql/compute_query.js} +4 -4
- package/dist/src/common/graphql/connect.d.ts +8 -0
- package/dist/src/common/graphql/connect.d.ts.map +1 -0
- package/dist/src/common/graphql/connect.js +22 -0
- package/dist/src/common/graphql/connection.d.ts +14 -0
- package/dist/src/common/graphql/connection.d.ts.map +1 -0
- package/dist/src/common/graphql/connection.js +23 -0
- package/dist/{common → src/common}/utils.d.ts +4 -4
- package/dist/src/common/utils.d.ts.map +1 -0
- package/dist/{connect.d.ts → src/connect.d.ts} +0 -4
- package/dist/src/connect.d.ts.map +1 -0
- package/dist/{connect.js → src/connect.js} +21 -23
- package/dist/src/connectOpts.d.ts.map +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +5 -5
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/{introspector/decorators → src/module}/decorators.d.ts +3 -3
- package/dist/src/module/decorators.d.ts.map +1 -0
- package/dist/{introspector/decorators → src/module}/decorators.js +1 -1
- package/dist/{entrypoint → src/module/entrypoint}/context.d.ts +1 -1
- package/dist/src/module/entrypoint/context.d.ts.map +1 -0
- package/dist/src/module/entrypoint/entrypoint.d.ts +2 -0
- package/dist/src/module/entrypoint/entrypoint.d.ts.map +1 -0
- package/dist/{entrypoint → src/module/entrypoint}/entrypoint.js +7 -16
- package/dist/{entrypoint → src/module/entrypoint}/invoke.d.ts +2 -2
- package/dist/src/module/entrypoint/invoke.d.ts.map +1 -0
- package/dist/{entrypoint → src/module/entrypoint}/invoke.js +2 -2
- package/dist/{entrypoint → src/module/entrypoint}/load.d.ts +6 -11
- package/dist/src/module/entrypoint/load.d.ts.map +1 -0
- package/dist/{entrypoint → src/module/entrypoint}/load.js +15 -5
- package/dist/src/module/entrypoint/register.d.ts +7 -0
- package/dist/src/module/entrypoint/register.d.ts.map +1 -0
- package/dist/{entrypoint → src/module/entrypoint}/register.js +3 -3
- package/dist/{introspector/executor → src/module}/executor.d.ts +4 -2
- package/dist/src/module/executor.d.ts.map +1 -0
- package/dist/src/module/executor.js +45 -0
- package/dist/src/module/introspector/case_convertor.d.ts +2 -0
- package/dist/src/module/introspector/case_convertor.d.ts.map +1 -0
- package/dist/src/module/introspector/case_convertor.js +17 -0
- package/dist/src/module/introspector/dagger_module/argument.d.ts +47 -0
- package/dist/src/module/introspector/dagger_module/argument.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/argument.js +109 -0
- package/dist/src/module/introspector/dagger_module/constructor.d.ts +18 -0
- package/dist/src/module/introspector/dagger_module/constructor.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/constructor.js +38 -0
- package/dist/src/module/introspector/dagger_module/decorator.d.ts +7 -0
- package/dist/src/module/introspector/dagger_module/decorator.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/decorator.js +6 -0
- package/dist/src/module/introspector/dagger_module/enum.d.ts +37 -0
- package/dist/src/module/introspector/dagger_module/enum.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enum.js +55 -0
- package/dist/src/module/introspector/dagger_module/enumBase.d.ts +17 -0
- package/dist/src/module/introspector/dagger_module/enumBase.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enumClass.d.ts +37 -0
- package/dist/src/module/introspector/dagger_module/enumClass.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enumClass.js +61 -0
- package/dist/src/module/introspector/dagger_module/function.d.ts +35 -0
- package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/function.js +86 -0
- package/dist/src/module/introspector/dagger_module/index.d.ts +13 -0
- package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/index.js +12 -0
- package/dist/src/module/introspector/dagger_module/module.d.ts +110 -0
- package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/module.js +275 -0
- package/dist/src/module/introspector/dagger_module/object.d.ts +29 -0
- package/dist/src/module/introspector/dagger_module/object.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/object.js +91 -0
- package/dist/src/module/introspector/dagger_module/objectBase.d.ts +29 -0
- package/dist/src/module/introspector/dagger_module/objectBase.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/property.d.ts +33 -0
- package/dist/src/module/introspector/dagger_module/property.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/property.js +76 -0
- package/dist/src/module/introspector/dagger_module/reference.d.ts +13 -0
- package/dist/src/module/introspector/dagger_module/reference.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/reference.js +33 -0
- package/dist/src/module/introspector/dagger_module/typeObject.d.ts +25 -0
- package/dist/src/module/introspector/dagger_module/typeObject.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/typeObject.js +58 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts +31 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.js +54 -0
- package/dist/src/module/introspector/index.d.ts +3 -0
- package/dist/src/module/introspector/index.d.ts.map +1 -0
- package/dist/src/module/introspector/index.js +16 -0
- package/dist/{introspector/scanner/typeDefs.d.ts → src/module/introspector/typedef.d.ts} +1 -1
- package/dist/src/module/introspector/typedef.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/ast.d.ts +42 -0
- package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/ast.js +254 -0
- package/dist/src/module/introspector/typescript_module/declarations.d.ts +15 -0
- package/dist/src/module/introspector/typescript_module/declarations.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/declarations.js +10 -0
- package/dist/src/module/introspector/typescript_module/explorer.d.ts +4 -0
- package/dist/src/module/introspector/typescript_module/explorer.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/explorer.js +16 -0
- package/dist/src/module/introspector/typescript_module/index.d.ts +4 -0
- package/dist/src/module/introspector/typescript_module/index.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/index.js +3 -0
- package/dist/src/module/introspector/typescript_module/typedef_utils.d.ts +5 -0
- package/dist/src/module/introspector/typescript_module/typedef_utils.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/typedef_utils.js +26 -0
- package/dist/src/module/introspector/utils/files.d.ts.map +1 -0
- package/dist/{introspector → src/module/introspector}/utils/files.js +1 -1
- package/dist/src/module/registry.d.ts.map +1 -0
- package/dist/{introspector/registry → src/module}/registry.js +1 -1
- package/dist/src/provisioning/bin.d.ts.map +1 -0
- package/dist/{provisioning → src/provisioning}/bin.js +1 -1
- package/dist/src/provisioning/default.d.ts +2 -0
- package/dist/src/provisioning/default.d.ts.map +1 -0
- package/dist/{provisioning → src/provisioning}/default.js +1 -1
- package/dist/src/provisioning/engineconn.d.ts +30 -0
- package/dist/src/provisioning/engineconn.d.ts.map +1 -0
- package/dist/src/provisioning/engineconn.js +1 -0
- package/dist/src/provisioning/index.d.ts +4 -0
- package/dist/src/provisioning/index.d.ts.map +1 -0
- package/dist/src/provisioning/index.js +14 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/init.d.ts.map +1 -0
- package/dist/src/telemetry/telemetry.d.ts.map +1 -0
- package/dist/src/telemetry/tracer.d.ts.map +1 -0
- package/package.json +5 -4
- package/dist/api/client.gen.d.ts.map +0 -1
- package/dist/api/utils.d.ts.map +0 -1
- package/dist/common/errors/DaggerSDKError.d.ts.map +0 -1
- package/dist/common/errors/DockerImageRefValidationError.d.ts.map +0 -1
- package/dist/common/errors/EngineSessionConnectParamsParseError.d.ts.map +0 -1
- package/dist/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +0 -1
- package/dist/common/errors/EngineSessionErrorOptions.d.ts.map +0 -1
- package/dist/common/errors/ExecError.d.ts.map +0 -1
- package/dist/common/errors/FunctionNotFound.d.ts.map +0 -1
- package/dist/common/errors/GraphQLRequestError.d.ts.map +0 -1
- package/dist/common/errors/InitEngineSessionBinaryError.d.ts.map +0 -1
- package/dist/common/errors/NotAwaitedRequestError.d.ts.map +0 -1
- package/dist/common/errors/TooManyNestedObjectsError.d.ts.map +0 -1
- package/dist/common/errors/UnknownDaggerError.d.ts.map +0 -1
- package/dist/common/errors/errors-codes.d.ts.map +0 -1
- package/dist/common/errors/index.d.ts.map +0 -1
- package/dist/common/utils.d.ts.map +0 -1
- package/dist/connect.d.ts.map +0 -1
- package/dist/connectOpts.d.ts.map +0 -1
- package/dist/context/builder.d.ts +0 -9
- package/dist/context/builder.d.ts.map +0 -1
- package/dist/context/builder.js +0 -34
- package/dist/context/context.d.ts +0 -40
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js +0 -53
- package/dist/entrypoint/context.d.ts.map +0 -1
- package/dist/entrypoint/entrypoint.d.ts +0 -2
- package/dist/entrypoint/entrypoint.d.ts.map +0 -1
- package/dist/entrypoint/invoke.d.ts.map +0 -1
- package/dist/entrypoint/load.d.ts.map +0 -1
- package/dist/entrypoint/register.d.ts +0 -7
- package/dist/entrypoint/register.d.ts.map +0 -1
- package/dist/graphql/client.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -7
- package/dist/introspector/decorators/decorators.d.ts.map +0 -1
- package/dist/introspector/executor/executor.d.ts.map +0 -1
- package/dist/introspector/executor/executor.js +0 -32
- package/dist/introspector/registry/registry.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/argument.d.ts +0 -104
- package/dist/introspector/scanner/abtractions/argument.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/argument.js +0 -207
- package/dist/introspector/scanner/abtractions/constructor.d.ts +0 -17
- package/dist/introspector/scanner/abtractions/constructor.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/constructor.js +0 -40
- package/dist/introspector/scanner/abtractions/enum.d.ts +0 -33
- package/dist/introspector/scanner/abtractions/enum.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/enum.js +0 -73
- package/dist/introspector/scanner/abtractions/enumValue.d.ts +0 -24
- package/dist/introspector/scanner/abtractions/enumValue.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/enumValue.js +0 -51
- package/dist/introspector/scanner/abtractions/method.d.ts +0 -67
- package/dist/introspector/scanner/abtractions/method.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/method.js +0 -132
- package/dist/introspector/scanner/abtractions/module.d.ts +0 -26
- package/dist/introspector/scanner/abtractions/module.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/module.js +0 -103
- package/dist/introspector/scanner/abtractions/object.d.ts +0 -52
- package/dist/introspector/scanner/abtractions/object.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/object.js +0 -118
- package/dist/introspector/scanner/abtractions/property.d.ts +0 -55
- package/dist/introspector/scanner/abtractions/property.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/property.js +0 -110
- package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts +0 -8
- package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts.map +0 -1
- package/dist/introspector/scanner/abtractions/typeToTypedef.js +0 -85
- package/dist/introspector/scanner/scan.d.ts +0 -14
- package/dist/introspector/scanner/scan.d.ts.map +0 -1
- package/dist/introspector/scanner/scan.js +0 -26
- package/dist/introspector/scanner/typeDefs.d.ts.map +0 -1
- package/dist/introspector/scanner/utils.d.ts +0 -22
- package/dist/introspector/scanner/utils.d.ts.map +0 -1
- package/dist/introspector/scanner/utils.js +0 -101
- package/dist/introspector/utils/files.d.ts.map +0 -1
- package/dist/provisioning/bin.d.ts.map +0 -1
- package/dist/provisioning/default.d.ts +0 -2
- package/dist/provisioning/default.d.ts.map +0 -1
- package/dist/provisioning/engineconn.d.ts +0 -28
- package/dist/provisioning/engineconn.d.ts.map +0 -1
- package/dist/provisioning/index.d.ts +0 -4
- package/dist/provisioning/index.d.ts.map +0 -1
- package/dist/provisioning/index.js +0 -3
- package/dist/telemetry/attributes.d.ts +0 -2
- package/dist/telemetry/attributes.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/init.d.ts.map +0 -1
- package/dist/telemetry/telemetry.d.ts.map +0 -1
- package/dist/telemetry/tracer.d.ts.map +0 -1
- /package/dist/{common → src/common}/errors/DaggerSDKError.js +0 -0
- /package/dist/{common → src/common}/errors/DockerImageRefValidationError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/DockerImageRefValidationError.js +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionConnectParamsParseError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionConnectParamsParseError.js +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionConnectionTimeoutError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionConnectionTimeoutError.js +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionErrorOptions.d.ts +0 -0
- /package/dist/{common → src/common}/errors/EngineSessionErrorOptions.js +0 -0
- /package/dist/{common → src/common}/errors/FunctionNotFound.d.ts +0 -0
- /package/dist/{common → src/common}/errors/FunctionNotFound.js +0 -0
- /package/dist/{common → src/common}/errors/GraphQLRequestError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/GraphQLRequestError.js +0 -0
- /package/dist/{common → src/common}/errors/InitEngineSessionBinaryError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/InitEngineSessionBinaryError.js +0 -0
- /package/dist/{common → src/common}/errors/NotAwaitedRequestError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/NotAwaitedRequestError.js +0 -0
- /package/dist/{common → src/common}/errors/TooManyNestedObjectsError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/TooManyNestedObjectsError.js +0 -0
- /package/dist/{common → src/common}/errors/UnknownDaggerError.d.ts +0 -0
- /package/dist/{common → src/common}/errors/UnknownDaggerError.js +0 -0
- /package/dist/{graphql → src/common/graphql}/client.d.ts +0 -0
- /package/dist/{graphql → src/common/graphql}/client.js +0 -0
- /package/dist/{common → src/common}/utils.js +0 -0
- /package/dist/{connectOpts.d.ts → src/connectOpts.d.ts} +0 -0
- /package/dist/{connectOpts.js → src/connectOpts.js} +0 -0
- /package/dist/{entrypoint → src/module/entrypoint}/context.js +0 -0
- /package/dist/{introspector/scanner/typeDefs.js → src/module/introspector/dagger_module/enumBase.js} +0 -0
- /package/dist/{provisioning/engineconn.js → src/module/introspector/dagger_module/objectBase.js} +0 -0
- /package/dist/{telemetry/attributes.js → src/module/introspector/typedef.js} +0 -0
- /package/dist/{introspector → src/module/introspector}/utils/files.d.ts +0 -0
- /package/dist/{introspector/registry → src/module}/registry.d.ts +0 -0
- /package/dist/{provisioning → src/provisioning}/bin.d.ts +0 -0
- /package/dist/{telemetry → src/telemetry}/index.d.ts +0 -0
- /package/dist/{telemetry → src/telemetry}/index.js +0 -0
- /package/dist/{telemetry → src/telemetry}/init.d.ts +0 -0
- /package/dist/{telemetry → src/telemetry}/init.js +0 -0
- /package/dist/{telemetry → src/telemetry}/telemetry.d.ts +0 -0
- /package/dist/{telemetry → src/telemetry}/telemetry.js +0 -0
- /package/dist/{telemetry → src/telemetry}/tracer.d.ts +0 -0
- /package/dist/{telemetry → src/telemetry}/tracer.js +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
3
|
+
import { AST } from "../typescript_module/index.js";
|
|
4
|
+
import { DaggerConstructor } from "./constructor.js";
|
|
5
|
+
import { FUNCTION_DECORATOR, OBJECT_DECORATOR } from "./decorator.js";
|
|
6
|
+
import { DaggerFunction } from "./function.js";
|
|
7
|
+
import { DaggerProperty } from "./property.js";
|
|
8
|
+
export class DaggerObject {
|
|
9
|
+
node;
|
|
10
|
+
ast;
|
|
11
|
+
name;
|
|
12
|
+
description;
|
|
13
|
+
_constructor = undefined;
|
|
14
|
+
methods = {};
|
|
15
|
+
properties = {};
|
|
16
|
+
symbol;
|
|
17
|
+
kind() {
|
|
18
|
+
return "class";
|
|
19
|
+
}
|
|
20
|
+
constructor(node, ast) {
|
|
21
|
+
this.node = node;
|
|
22
|
+
this.ast = ast;
|
|
23
|
+
if (!this.node.name) {
|
|
24
|
+
throw new IntrospectionError(`could not resolve name of class at ${AST.getNodePosition(node)}.`);
|
|
25
|
+
}
|
|
26
|
+
this.name = this.node.name.getText();
|
|
27
|
+
if (!this.ast.isNodeDecoratedWith(node, OBJECT_DECORATOR)) {
|
|
28
|
+
throw new IntrospectionError(`class ${this.name} at ${AST.getNodePosition(node)} is used by the module but not exposed with a dagger decorator.`);
|
|
29
|
+
}
|
|
30
|
+
const modifiers = ts.getCombinedModifierFlags(this.node);
|
|
31
|
+
if (!(modifiers & ts.ModifierFlags.Export)) {
|
|
32
|
+
console.warn(`missing export in class ${this.name} at ${AST.getNodePosition(node)} but it's used by the module.`);
|
|
33
|
+
}
|
|
34
|
+
this.symbol = this.ast.getSymbolOrThrow(this.node.name);
|
|
35
|
+
this.description = this.ast.getDocFromSymbol(this.symbol);
|
|
36
|
+
for (const member of this.node.members) {
|
|
37
|
+
if (ts.isPropertyDeclaration(member)) {
|
|
38
|
+
const property = new DaggerProperty(member, this.ast);
|
|
39
|
+
this.properties[property.alias ?? property.name] = property;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (ts.isConstructorDeclaration(member)) {
|
|
43
|
+
this._constructor = new DaggerConstructor(member, this.ast);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (ts.isMethodDeclaration(member) &&
|
|
47
|
+
this.ast.isNodeDecoratedWith(member, FUNCTION_DECORATOR)) {
|
|
48
|
+
const daggerFunction = new DaggerFunction(member, this.ast);
|
|
49
|
+
this.methods[daggerFunction.alias ?? daggerFunction.name] =
|
|
50
|
+
daggerFunction;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getReferences() {
|
|
56
|
+
const references = [];
|
|
57
|
+
if (this._constructor) {
|
|
58
|
+
references.push(...this._constructor.getReferences());
|
|
59
|
+
}
|
|
60
|
+
for (const property of Object.values(this.properties)) {
|
|
61
|
+
const ref = property.getReference();
|
|
62
|
+
if (ref) {
|
|
63
|
+
references.push(ref);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const fn of Object.values(this.methods)) {
|
|
67
|
+
references.push(...fn.getReferences());
|
|
68
|
+
}
|
|
69
|
+
return references.filter((v, i, arr) => arr.indexOf(v) === i);
|
|
70
|
+
}
|
|
71
|
+
propagateReferences(references) {
|
|
72
|
+
if (this._constructor) {
|
|
73
|
+
this._constructor.propagateReferences(references);
|
|
74
|
+
}
|
|
75
|
+
for (const property of Object.values(this.properties)) {
|
|
76
|
+
property.propagateReferences(references);
|
|
77
|
+
}
|
|
78
|
+
for (const fn of Object.values(this.methods)) {
|
|
79
|
+
fn.propagateReferences(references);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
toJSON() {
|
|
83
|
+
return {
|
|
84
|
+
name: this.name,
|
|
85
|
+
description: this.description,
|
|
86
|
+
constructor: this._constructor,
|
|
87
|
+
methods: this.methods,
|
|
88
|
+
properties: this.properties,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
2
|
+
import { TypeDef } from "../typedef.js";
|
|
3
|
+
import { DaggerConstructor } from "./constructor.js";
|
|
4
|
+
import { DaggerFunctions } from "./function.js";
|
|
5
|
+
import { References } from "./reference.js";
|
|
6
|
+
export interface DaggerObjectPropertyBase {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
alias?: string;
|
|
10
|
+
isExposed: boolean;
|
|
11
|
+
type?: TypeDef<TypeDefKind>;
|
|
12
|
+
propagateReferences(references: References): void;
|
|
13
|
+
}
|
|
14
|
+
export type DaggerObjectPropertiesBase = {
|
|
15
|
+
[name: string]: DaggerObjectPropertyBase;
|
|
16
|
+
};
|
|
17
|
+
export interface DaggerObjectBase {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
_constructor: DaggerConstructor | undefined;
|
|
21
|
+
methods: DaggerFunctions;
|
|
22
|
+
properties: DaggerObjectPropertiesBase;
|
|
23
|
+
kind(): "class" | "object";
|
|
24
|
+
propagateReferences(references: References): void;
|
|
25
|
+
}
|
|
26
|
+
export type DaggerObjectsBase = {
|
|
27
|
+
[name: string]: DaggerObjectBase;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=objectBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectBase.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/objectBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAE3B,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;CAClD;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAAA;CACzC,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAA;IAC3C,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,0BAA0B,CAAA;IAEtC,IAAI,IAAI,OAAO,GAAG,QAAQ,CAAA;IAE1B,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;CAClD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { DaggerObjectPropertyBase } from "./objectBase.js";
|
|
6
|
+
import { References } from "./reference.js";
|
|
7
|
+
export type DaggerProperties = {
|
|
8
|
+
[name: string]: DaggerProperty;
|
|
9
|
+
};
|
|
10
|
+
export declare class DaggerProperty implements DaggerObjectPropertyBase {
|
|
11
|
+
private readonly node;
|
|
12
|
+
private readonly ast;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
alias: string | undefined;
|
|
16
|
+
isExposed: boolean;
|
|
17
|
+
private symbol;
|
|
18
|
+
private _typeRef?;
|
|
19
|
+
type?: TypeDef<TypeDefKind>;
|
|
20
|
+
constructor(node: ts.PropertyDeclaration, ast: AST);
|
|
21
|
+
private getAlias;
|
|
22
|
+
private getType;
|
|
23
|
+
getReference(): string | undefined;
|
|
24
|
+
propagateReferences(references: References): void;
|
|
25
|
+
toJSON(): {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
alias: string | undefined;
|
|
29
|
+
type: TypeDef<TypeDefKind> | undefined;
|
|
30
|
+
isExposed: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/property.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;AAEtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,CAAA;AAEjE,qBAAa,cAAe,YAAW,wBAAwB;IAW3D,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAXf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAEzB,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,QAAQ,CAAC,CAAQ;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;gBAGf,IAAI,EAAE,EAAE,CAAC,mBAAmB,EAC5B,GAAG,EAAE,GAAG;IAmB3B,OAAO,CAAC,QAAQ;IAsBhB,OAAO,CAAC,OAAO;IAWR,YAAY,IAAI,MAAM,GAAG,SAAS;IAWlC,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAmBjD,MAAM;;;;;;;CASd"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
2
|
+
import { AST, isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
|
|
3
|
+
import { FIELD_DECORATOR, FUNCTION_DECORATOR } from "./decorator.js";
|
|
4
|
+
export class DaggerProperty {
|
|
5
|
+
node;
|
|
6
|
+
ast;
|
|
7
|
+
name;
|
|
8
|
+
description;
|
|
9
|
+
alias;
|
|
10
|
+
isExposed;
|
|
11
|
+
symbol;
|
|
12
|
+
_typeRef;
|
|
13
|
+
type;
|
|
14
|
+
constructor(node, ast) {
|
|
15
|
+
this.node = node;
|
|
16
|
+
this.ast = ast;
|
|
17
|
+
if (!this.node.name) {
|
|
18
|
+
throw new IntrospectionError(`could not resolve name of class at ${AST.getNodePosition(node)}.`);
|
|
19
|
+
}
|
|
20
|
+
this.symbol = this.ast.getSymbolOrThrow(this.node.name);
|
|
21
|
+
this.name = this.node.name.getText();
|
|
22
|
+
this.isExposed =
|
|
23
|
+
this.ast.isNodeDecoratedWith(this.node, FUNCTION_DECORATOR) ||
|
|
24
|
+
this.ast.isNodeDecoratedWith(this.node, FIELD_DECORATOR);
|
|
25
|
+
this.description = this.ast.getDocFromSymbol(this.symbol);
|
|
26
|
+
this.alias = this.getAlias();
|
|
27
|
+
this.type = this.getType();
|
|
28
|
+
}
|
|
29
|
+
getAlias() {
|
|
30
|
+
let alias = this.ast.getDecoratorArgument(this.node, FUNCTION_DECORATOR, "string");
|
|
31
|
+
if (alias) {
|
|
32
|
+
return JSON.parse(alias.replace(/'/g, '"'));
|
|
33
|
+
}
|
|
34
|
+
alias = this.ast.getDecoratorArgument(this.node, FIELD_DECORATOR, "string");
|
|
35
|
+
if (alias) {
|
|
36
|
+
return JSON.parse(alias.replace(/'/g, '"'));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
getType() {
|
|
40
|
+
const type = this.ast.checker.getTypeAtLocation(this.node);
|
|
41
|
+
const typedef = this.ast.tsTypeToTypeDef(this.node, type);
|
|
42
|
+
if (typedef === undefined || !isTypeDefResolved(typedef)) {
|
|
43
|
+
this._typeRef = this.ast.typeToStringType(type);
|
|
44
|
+
}
|
|
45
|
+
return typedef;
|
|
46
|
+
}
|
|
47
|
+
getReference() {
|
|
48
|
+
if (this._typeRef &&
|
|
49
|
+
(this.type === undefined || !isTypeDefResolved(this.type))) {
|
|
50
|
+
return this._typeRef;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
propagateReferences(references) {
|
|
55
|
+
if (!this._typeRef) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (this.type && isTypeDefResolved(this.type)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const typeDef = references[this._typeRef];
|
|
62
|
+
if (!typeDef) {
|
|
63
|
+
throw new IntrospectionError(`could not find type reference for ${this._typeRef} at ${AST.getNodePosition(this.node)}.`);
|
|
64
|
+
}
|
|
65
|
+
this.type = resolveTypeDef(this.type, typeDef);
|
|
66
|
+
}
|
|
67
|
+
toJSON() {
|
|
68
|
+
return {
|
|
69
|
+
name: this.name,
|
|
70
|
+
description: this.description,
|
|
71
|
+
alias: this.alias,
|
|
72
|
+
type: this.type,
|
|
73
|
+
isExposed: this.isExposed,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
2
|
+
import { TypeDef } from "../typedef.js";
|
|
3
|
+
export type References = {
|
|
4
|
+
[name: string]: TypeDef<TypeDefKind>;
|
|
5
|
+
};
|
|
6
|
+
export type ReferencableType = TypeDef<TypeDefKind.ObjectKind> | TypeDef<TypeDefKind.EnumKind> | TypeDef<TypeDefKind.ScalarKind>;
|
|
7
|
+
export declare function isKindArray(type: TypeDef<TypeDefKind>): type is TypeDef<TypeDefKind.ListKind>;
|
|
8
|
+
export declare function isKindObject(type: TypeDef<TypeDefKind>): type is TypeDef<TypeDefKind.ObjectKind>;
|
|
9
|
+
export declare function isKindEnum(type: TypeDef<TypeDefKind>): type is TypeDef<TypeDefKind.EnumKind>;
|
|
10
|
+
export declare function isKindScalar(type: TypeDef<TypeDefKind>): type is TypeDef<TypeDefKind.ScalarKind>;
|
|
11
|
+
export declare function isReferencableTypeDef(type: TypeDef<TypeDefKind>): boolean;
|
|
12
|
+
export declare function getTypeDefArrayBaseType(type: TypeDef<TypeDefKind>): TypeDef<TypeDefKind>;
|
|
13
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAAE,CAAA;AAEjE,MAAM,MAAM,gBAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,GAC/B,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,GAC7B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;AAEnC,wBAAgB,WAAW,CACzB,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAEvC;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAEzC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAEvC;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAEzC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAazE;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,OAAO,CAAC,WAAW,CAAC,CAMtB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
2
|
+
export function isKindArray(type) {
|
|
3
|
+
return type.kind === TypeDefKind.ListKind;
|
|
4
|
+
}
|
|
5
|
+
export function isKindObject(type) {
|
|
6
|
+
return type.kind === TypeDefKind.ObjectKind;
|
|
7
|
+
}
|
|
8
|
+
export function isKindEnum(type) {
|
|
9
|
+
return type.kind === TypeDefKind.EnumKind;
|
|
10
|
+
}
|
|
11
|
+
export function isKindScalar(type) {
|
|
12
|
+
return type.kind === TypeDefKind.ScalarKind;
|
|
13
|
+
}
|
|
14
|
+
export function isReferencableTypeDef(type) {
|
|
15
|
+
switch (type.kind) {
|
|
16
|
+
case TypeDefKind.ObjectKind:
|
|
17
|
+
return true;
|
|
18
|
+
case TypeDefKind.EnumKind:
|
|
19
|
+
return true;
|
|
20
|
+
case TypeDefKind.ScalarKind:
|
|
21
|
+
return true;
|
|
22
|
+
case TypeDefKind.ListKind:
|
|
23
|
+
return isReferencableTypeDef(getTypeDefArrayBaseType(type));
|
|
24
|
+
default:
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function getTypeDefArrayBaseType(type) {
|
|
29
|
+
if (isKindArray(type)) {
|
|
30
|
+
return getTypeDefArrayBaseType(type.typeDef);
|
|
31
|
+
}
|
|
32
|
+
return type;
|
|
33
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { AST } from "../typescript_module/index.js";
|
|
3
|
+
import { DaggerObjectBase } from "./objectBase.js";
|
|
4
|
+
import { References } from "./reference.js";
|
|
5
|
+
import { DaggerObjectTypeProperties } from "./typeObjectProperty.js";
|
|
6
|
+
export declare class DaggerTypeObject implements DaggerObjectBase {
|
|
7
|
+
private readonly node;
|
|
8
|
+
private readonly ast;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
_constructor: undefined;
|
|
12
|
+
methods: {};
|
|
13
|
+
properties: DaggerObjectTypeProperties;
|
|
14
|
+
private symbol;
|
|
15
|
+
kind(): "class" | "object";
|
|
16
|
+
constructor(node: ts.TypeAliasDeclaration, ast: AST);
|
|
17
|
+
getReferences(): string[];
|
|
18
|
+
propagateReferences(references: References): void;
|
|
19
|
+
toJSON(): {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
properties: DaggerObjectTypeProperties;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=typeObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeObject.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/typeObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EACL,0BAA0B,EAE3B,MAAM,yBAAyB,CAAA;AAEhC,qBAAa,gBAAiB,YAAW,gBAAgB;IAcrD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAdf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,YAAY;IACxB,OAAO,KAAK;IACZ,UAAU,EAAE,0BAA0B,CAAK;IAElD,OAAO,CAAC,MAAM,CAAW;IAEzB,IAAI,IAAI,OAAO,GAAG,QAAQ;gBAKP,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAC7B,GAAG,EAAE,GAAG;IA2BpB,aAAa,IAAI,MAAM,EAAE;IAazB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAMxD,MAAM;;;;;CAOP"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
3
|
+
import { AST } from "../typescript_module/index.js";
|
|
4
|
+
import { DaggerObjectTypeProperty, } from "./typeObjectProperty.js";
|
|
5
|
+
export class DaggerTypeObject {
|
|
6
|
+
node;
|
|
7
|
+
ast;
|
|
8
|
+
name;
|
|
9
|
+
description;
|
|
10
|
+
_constructor = undefined;
|
|
11
|
+
methods = {};
|
|
12
|
+
properties = {};
|
|
13
|
+
symbol;
|
|
14
|
+
kind() {
|
|
15
|
+
return "object";
|
|
16
|
+
}
|
|
17
|
+
constructor(node, ast) {
|
|
18
|
+
this.node = node;
|
|
19
|
+
this.ast = ast;
|
|
20
|
+
if (!this.node.name) {
|
|
21
|
+
throw new IntrospectionError(`could not resolve name of enum at ${AST.getNodePosition(node)}.`);
|
|
22
|
+
}
|
|
23
|
+
this.name = this.node.name.getText();
|
|
24
|
+
this.symbol = this.ast.getSymbolOrThrow(this.node.name);
|
|
25
|
+
this.description = this.ast.getDocFromSymbol(this.symbol);
|
|
26
|
+
const type = this.ast.getTypeFromTypeAlias(this.node);
|
|
27
|
+
if (type.flags & ts.TypeFlags.Object) {
|
|
28
|
+
const objectType = type;
|
|
29
|
+
const properties = objectType.getProperties();
|
|
30
|
+
for (const property of properties) {
|
|
31
|
+
const daggerProperty = new DaggerObjectTypeProperty(this.node, property, this.ast);
|
|
32
|
+
this.properties[daggerProperty.name] = daggerProperty;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getReferences() {
|
|
37
|
+
const references = [];
|
|
38
|
+
for (const property of Object.values(this.properties)) {
|
|
39
|
+
const ref = property.getReference();
|
|
40
|
+
if (ref) {
|
|
41
|
+
references.push(ref);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return references.filter((v, i, arr) => arr.indexOf(v) === i);
|
|
45
|
+
}
|
|
46
|
+
propagateReferences(references) {
|
|
47
|
+
for (const property of Object.values(this.properties)) {
|
|
48
|
+
property.propagateReferences(references);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
toJSON() {
|
|
52
|
+
return {
|
|
53
|
+
name: this.name,
|
|
54
|
+
description: this.description,
|
|
55
|
+
properties: this.properties,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { DaggerObjectPropertyBase } from "./objectBase.js";
|
|
6
|
+
import { References } from "./reference.js";
|
|
7
|
+
export type DaggerObjectTypeProperties = {
|
|
8
|
+
[name: string]: DaggerObjectTypeProperty;
|
|
9
|
+
};
|
|
10
|
+
export declare class DaggerObjectTypeProperty implements DaggerObjectPropertyBase {
|
|
11
|
+
private readonly node;
|
|
12
|
+
private readonly symbol;
|
|
13
|
+
private readonly ast;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
alias: undefined;
|
|
17
|
+
isExposed: boolean;
|
|
18
|
+
private _typeRef?;
|
|
19
|
+
type?: TypeDef<TypeDefKind>;
|
|
20
|
+
constructor(node: ts.TypeAliasDeclaration, symbol: ts.Symbol, ast: AST);
|
|
21
|
+
getReference(): string | undefined;
|
|
22
|
+
propagateReferences(references: References): void;
|
|
23
|
+
toJSON(): {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
alias: undefined;
|
|
27
|
+
type: TypeDef<TypeDefKind> | undefined;
|
|
28
|
+
isExposed: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=typeObjectProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeObjectProperty.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/typeObjectProperty.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,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,CAAA;CACzC,CAAA;AAED,qBAAa,wBAAyB,YAAW,wBAAwB;IAUrE,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAXf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,YAAY;IACjB,SAAS,EAAE,OAAO,CAAO;IAEhC,OAAO,CAAC,QAAQ,CAAC,CAAQ;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;gBAGf,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAC7B,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,GAAG,EAAE,GAAG;IAepB,YAAY,IAAI,MAAM,GAAG,SAAS;IAWlC,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAmBjD,MAAM;;;;;;;CASd"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
2
|
+
import { isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
|
|
3
|
+
export class DaggerObjectTypeProperty {
|
|
4
|
+
node;
|
|
5
|
+
symbol;
|
|
6
|
+
ast;
|
|
7
|
+
name;
|
|
8
|
+
description;
|
|
9
|
+
alias = undefined;
|
|
10
|
+
isExposed = true;
|
|
11
|
+
_typeRef;
|
|
12
|
+
type;
|
|
13
|
+
constructor(node, symbol, ast) {
|
|
14
|
+
this.node = node;
|
|
15
|
+
this.symbol = symbol;
|
|
16
|
+
this.ast = ast;
|
|
17
|
+
this.name = symbol.name;
|
|
18
|
+
this.description = this.ast.getDocFromSymbol(this.symbol);
|
|
19
|
+
const type = this.ast.checker.getTypeOfSymbolAtLocation(this.symbol, this.node);
|
|
20
|
+
this.type = this.ast.tsTypeToTypeDef(this.node, type);
|
|
21
|
+
if (this.type === undefined || !isTypeDefResolved(this.type)) {
|
|
22
|
+
this._typeRef = this.ast.typeToStringType(type);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getReference() {
|
|
26
|
+
if (this._typeRef &&
|
|
27
|
+
(this.type === undefined || !isTypeDefResolved(this.type))) {
|
|
28
|
+
return this._typeRef;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
propagateReferences(references) {
|
|
33
|
+
if (!this._typeRef) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.type && isTypeDefResolved(this.type)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const typeDef = references[this._typeRef];
|
|
40
|
+
if (!typeDef) {
|
|
41
|
+
throw new IntrospectionError(`could not find type reference for ${this._typeRef}.`);
|
|
42
|
+
}
|
|
43
|
+
this.type = resolveTypeDef(this.type, typeDef);
|
|
44
|
+
}
|
|
45
|
+
toJSON() {
|
|
46
|
+
return {
|
|
47
|
+
name: this.name,
|
|
48
|
+
description: this.description,
|
|
49
|
+
alias: this.alias,
|
|
50
|
+
type: this.type,
|
|
51
|
+
isExposed: this.isExposed,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/module/introspector/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,SAAK,yBAc1D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IntrospectionError } from "../../common/errors/index.js";
|
|
2
|
+
import { load } from "../entrypoint/load.js";
|
|
3
|
+
import { convertToPascalCase } from "./case_convertor.js";
|
|
4
|
+
import { DaggerModule } from "./dagger_module/index.js";
|
|
5
|
+
import { AST } from "./typescript_module/index.js";
|
|
6
|
+
export async function scan(files, moduleName = "") {
|
|
7
|
+
if (files.length === 0) {
|
|
8
|
+
throw new IntrospectionError("no files to introspect found");
|
|
9
|
+
}
|
|
10
|
+
const formattedModuleName = convertToPascalCase(moduleName);
|
|
11
|
+
const userModule = await load(files);
|
|
12
|
+
// Interpret the given typescript source files.
|
|
13
|
+
const ast = new AST(files, userModule);
|
|
14
|
+
const module = new DaggerModule(formattedModuleName, userModule, ast);
|
|
15
|
+
return module;
|
|
16
|
+
}
|
|
@@ -42,4 +42,4 @@ export type ListTypeDef = BaseTypeDef & {
|
|
|
42
42
|
* If it's a type of kind list, it transforms the BaseTypeDef into a ListTypeDef.
|
|
43
43
|
*/
|
|
44
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;
|
|
45
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=typedef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedef.d.ts","sourceRoot":"","sources":["../../../../src/module/introspector/typedef.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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Module from "node:module";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
4
|
+
import { DaggerDecorators } from "../dagger_module/index.js";
|
|
5
|
+
import { TypeDef } from "../typedef.js";
|
|
6
|
+
import { DeclarationsMap } from "./declarations.js";
|
|
7
|
+
export declare const CLIENT_GEN_FILE = "client.gen.ts";
|
|
8
|
+
export type ResolvedNodeWithSymbol<T extends keyof DeclarationsMap> = {
|
|
9
|
+
type: T;
|
|
10
|
+
node: DeclarationsMap[T];
|
|
11
|
+
symbol: ts.Symbol;
|
|
12
|
+
file: ts.SourceFile;
|
|
13
|
+
};
|
|
14
|
+
export declare class AST {
|
|
15
|
+
readonly files: string[];
|
|
16
|
+
private readonly userModule;
|
|
17
|
+
checker: ts.TypeChecker;
|
|
18
|
+
private readonly sourceFiles;
|
|
19
|
+
constructor(files: string[], userModule: Module[]);
|
|
20
|
+
findResolvedNodeByName<T extends keyof DeclarationsMap>(name: string,
|
|
21
|
+
/**
|
|
22
|
+
* Optionally look for a specific node kind if we already know
|
|
23
|
+
* what we're looking for.
|
|
24
|
+
*/
|
|
25
|
+
kind: T): ResolvedNodeWithSymbol<T> | undefined;
|
|
26
|
+
getTypeFromTypeAlias(typeAlias: ts.TypeAliasDeclaration): ts.Type;
|
|
27
|
+
static getNodePosition(node: ts.Node): string;
|
|
28
|
+
getDocFromSymbol(symbol: ts.Symbol): string;
|
|
29
|
+
getSymbolOrThrow(node: ts.Node): ts.Symbol;
|
|
30
|
+
getSignatureFromFunctionOrThrow(node: ts.SignatureDeclaration): ts.Signature;
|
|
31
|
+
getSymbol(node: ts.Node): ts.Symbol | undefined;
|
|
32
|
+
isNodeDecoratedWith(node: ts.HasDecorators, daggerDecorator: DaggerDecorators): boolean;
|
|
33
|
+
getDecoratorArgument<T>(node: ts.HasDecorators, daggerDecorator: DaggerDecorators, type: "string" | "object", position?: number): T | undefined;
|
|
34
|
+
unwrapTypeStringFromPromise(type: string): string;
|
|
35
|
+
unwrapTypeStringFromArray(type: string): string;
|
|
36
|
+
stringTypeToUnwrappedType(type: string): string;
|
|
37
|
+
typeToStringType(type: ts.Type): string;
|
|
38
|
+
tsTypeToTypeDef(node: ts.Node, type: ts.Type): TypeDef<TypeDefKind> | undefined;
|
|
39
|
+
private resolveParameterDefaultValueTypeReference;
|
|
40
|
+
resolveParameterDefaultValue(expression: ts.Expression): any;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/ast.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAmB,MAAM,mBAAmB,CAAA;AAGpE,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAE9C,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,eAAe,IAAI;IACpE,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,EAAE,EAAE,CAAC,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,CAAC,UAAU,CAAA;CACpB,CAAA;AAED,qBAAa,GAAG;aAMI,KAAK,EAAE,MAAM,EAAE;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU;IANtB,OAAO,EAAE,EAAE,CAAC,WAAW,CAAA;IAE9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;gBAG3B,KAAK,EAAE,MAAM,EAAE,EACd,UAAU,EAAE,MAAM,EAAE;IAahC,sBAAsB,CAAC,CAAC,SAAS,MAAM,eAAe,EAC3D,IAAI,EAAE,MAAM;IAEZ;;;OAGG;IACH,IAAI,EAAE,CAAC,GACN,sBAAsB,CAAC,CAAC,CAAC,GAAG,SAAS;IA6CjC,oBAAoB,CAAC,SAAS,EAAE,EAAE,CAAC,oBAAoB,GAAG,EAAE,CAAC,IAAI;WAM1D,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM;IAW7C,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,MAAM;IAI3C,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,MAAM;IAW1C,+BAA+B,CACpC,IAAI,EAAE,EAAE,CAAC,oBAAoB,GAC5B,EAAE,CAAC,SAAS;IAWR,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS;IAI/C,mBAAmB,CACxB,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,eAAe,EAAE,gBAAgB,GAChC,OAAO;IAsBH,oBAAoB,CAAC,CAAC,EAC3B,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,eAAe,EAAE,gBAAgB,EACjC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,QAAQ,SAAI,GACX,CAAC,GAAG,SAAS;IA4BT,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYjD,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM;IAMvC,eAAe,CACpB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IAoDnC,OAAO,CAAC,yCAAyC;IAoB1C,4BAA4B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG;CAkDpE"}
|