@dagger.io/dagger 0.14.0 → 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 +145 -201
- package/dist/src/api/client.gen.d.ts.map +1 -0
- package/dist/{api → src/api}/client.gen.js +1114 -3520
- 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,254 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
3
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
4
|
+
import { isDeclarationOf } from "./declarations.js";
|
|
5
|
+
import { getValueByExportedName } from "./explorer.js";
|
|
6
|
+
export const CLIENT_GEN_FILE = "client.gen.ts";
|
|
7
|
+
export class AST {
|
|
8
|
+
files;
|
|
9
|
+
userModule;
|
|
10
|
+
checker;
|
|
11
|
+
sourceFiles;
|
|
12
|
+
constructor(files, userModule) {
|
|
13
|
+
this.files = files;
|
|
14
|
+
this.userModule = userModule;
|
|
15
|
+
const program = ts.createProgram(files, {
|
|
16
|
+
experimentalDecorators: true,
|
|
17
|
+
moduleResolution: ts.ModuleResolutionKind.Node10,
|
|
18
|
+
target: ts.ScriptTarget.ES2022,
|
|
19
|
+
});
|
|
20
|
+
this.checker = program.getTypeChecker();
|
|
21
|
+
this.sourceFiles = program
|
|
22
|
+
.getSourceFiles()
|
|
23
|
+
.filter((file) => !file.isDeclarationFile);
|
|
24
|
+
}
|
|
25
|
+
findResolvedNodeByName(name,
|
|
26
|
+
/**
|
|
27
|
+
* Optionally look for a specific node kind if we already know
|
|
28
|
+
* what we're looking for.
|
|
29
|
+
*/
|
|
30
|
+
kind) {
|
|
31
|
+
let result;
|
|
32
|
+
for (const sourceFile of this.sourceFiles) {
|
|
33
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
34
|
+
if (result !== undefined)
|
|
35
|
+
return;
|
|
36
|
+
// Skip if it's not from the client gen nor the user module
|
|
37
|
+
if (!sourceFile.fileName.endsWith(CLIENT_GEN_FILE) &&
|
|
38
|
+
!this.files.includes(sourceFile.fileName)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (kind !== undefined && node.kind === kind) {
|
|
42
|
+
const isDeclarationValid = isDeclarationOf[kind](node);
|
|
43
|
+
if (!isDeclarationValid)
|
|
44
|
+
return;
|
|
45
|
+
const convertedNode = node;
|
|
46
|
+
if (!convertedNode.name || convertedNode.name.getText() !== name) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const symbol = this.checker.getSymbolAtLocation(convertedNode.name);
|
|
50
|
+
if (!symbol) {
|
|
51
|
+
console.debug(`missing symbol for ${name} at ${sourceFile.fileName}:${node.pos}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
result = {
|
|
55
|
+
type: kind,
|
|
56
|
+
node: convertedNode,
|
|
57
|
+
symbol: symbol,
|
|
58
|
+
file: sourceFile,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
getTypeFromTypeAlias(typeAlias) {
|
|
66
|
+
const symbol = this.getSymbolOrThrow(typeAlias.name);
|
|
67
|
+
return this.checker.getDeclaredTypeOfSymbol(symbol);
|
|
68
|
+
}
|
|
69
|
+
static getNodePosition(node) {
|
|
70
|
+
const sourceFile = node.getSourceFile();
|
|
71
|
+
const position = ts.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
72
|
+
return `${sourceFile.fileName}:${position.line}:${position.character}`;
|
|
73
|
+
}
|
|
74
|
+
getDocFromSymbol(symbol) {
|
|
75
|
+
return ts.displayPartsToString(symbol.getDocumentationComment(this.checker));
|
|
76
|
+
}
|
|
77
|
+
getSymbolOrThrow(node) {
|
|
78
|
+
const symbol = this.getSymbol(node);
|
|
79
|
+
if (!symbol) {
|
|
80
|
+
throw new IntrospectionError(`could not find symbol at ${AST.getNodePosition(node)}`);
|
|
81
|
+
}
|
|
82
|
+
return symbol;
|
|
83
|
+
}
|
|
84
|
+
getSignatureFromFunctionOrThrow(node) {
|
|
85
|
+
const signature = this.checker.getSignatureFromDeclaration(node);
|
|
86
|
+
if (!signature) {
|
|
87
|
+
throw new IntrospectionError(`could not find signature at ${AST.getNodePosition(node)}`);
|
|
88
|
+
}
|
|
89
|
+
return signature;
|
|
90
|
+
}
|
|
91
|
+
getSymbol(node) {
|
|
92
|
+
return this.checker.getSymbolAtLocation(node);
|
|
93
|
+
}
|
|
94
|
+
isNodeDecoratedWith(node, daggerDecorator) {
|
|
95
|
+
const decorators = ts.getDecorators(node);
|
|
96
|
+
if (!decorators) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const decorator = decorators.find((d) => d.expression.getText().startsWith(daggerDecorator));
|
|
100
|
+
if (!decorator) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!ts.isCallExpression(decorator.expression)) {
|
|
104
|
+
throw new IntrospectionError(`decorator at ${AST.getNodePosition(node)} should be a call expression, please use ${daggerDecorator}() instead.`);
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
getDecoratorArgument(node, daggerDecorator, type, position = 0) {
|
|
109
|
+
const decorators = ts.getDecorators(node);
|
|
110
|
+
if (!decorators) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
const decorator = decorators.find((d) => d.expression.getText().startsWith(daggerDecorator));
|
|
114
|
+
if (!decorator) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const argument = decorator.expression.arguments[position];
|
|
118
|
+
if (!argument) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
switch (type) {
|
|
122
|
+
case "string":
|
|
123
|
+
return argument.getText();
|
|
124
|
+
case "object":
|
|
125
|
+
return eval(`(${argument.getText()})`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
unwrapTypeStringFromPromise(type) {
|
|
129
|
+
if (type.startsWith("Promise<")) {
|
|
130
|
+
return type.slice("Promise<".length, -">".length);
|
|
131
|
+
}
|
|
132
|
+
if (type.startsWith("Awaited<")) {
|
|
133
|
+
return type.slice("Awaited<".length, -">".length);
|
|
134
|
+
}
|
|
135
|
+
return type;
|
|
136
|
+
}
|
|
137
|
+
unwrapTypeStringFromArray(type) {
|
|
138
|
+
if (type.endsWith("[]")) {
|
|
139
|
+
return type.replace("[]", "");
|
|
140
|
+
}
|
|
141
|
+
if (type.startsWith("Array<")) {
|
|
142
|
+
return type.slice("Array<".length, -">".length);
|
|
143
|
+
}
|
|
144
|
+
return type;
|
|
145
|
+
}
|
|
146
|
+
stringTypeToUnwrappedType(type) {
|
|
147
|
+
type = this.unwrapTypeStringFromPromise(type);
|
|
148
|
+
// If they are difference, that means we upwrapped the array.
|
|
149
|
+
const extractedTypeFromArray = this.unwrapTypeStringFromArray(type);
|
|
150
|
+
if (extractedTypeFromArray !== type) {
|
|
151
|
+
return this.stringTypeToUnwrappedType(extractedTypeFromArray);
|
|
152
|
+
}
|
|
153
|
+
return type;
|
|
154
|
+
}
|
|
155
|
+
typeToStringType(type) {
|
|
156
|
+
const stringType = this.checker.typeToString(type);
|
|
157
|
+
return this.stringTypeToUnwrappedType(stringType);
|
|
158
|
+
}
|
|
159
|
+
tsTypeToTypeDef(node, type) {
|
|
160
|
+
if (type.flags & ts.TypeFlags.String)
|
|
161
|
+
return { kind: TypeDefKind.StringKind };
|
|
162
|
+
if (type.flags & ts.TypeFlags.Number)
|
|
163
|
+
return { kind: TypeDefKind.IntegerKind };
|
|
164
|
+
if (type.flags & ts.TypeFlags.Boolean)
|
|
165
|
+
return { kind: TypeDefKind.BooleanKind };
|
|
166
|
+
if (type.flags & ts.TypeFlags.Void)
|
|
167
|
+
return { kind: TypeDefKind.VoidKind };
|
|
168
|
+
// If a type has a flag Object, is can basically be anything.
|
|
169
|
+
// We firstly wants to see if it's a promise or an array so we can unwrap the
|
|
170
|
+
// actual type.
|
|
171
|
+
if (type.flags & ts.TypeFlags.Object) {
|
|
172
|
+
const objectType = type;
|
|
173
|
+
// If it's a reference, that means it's a generic type like
|
|
174
|
+
// `Promise<T>` or `number[]` or `Array<T>`.
|
|
175
|
+
if (objectType.objectFlags & ts.ObjectFlags.Reference) {
|
|
176
|
+
const typeArguments = this.checker.getTypeArguments(type);
|
|
177
|
+
switch (typeArguments.length) {
|
|
178
|
+
case 0:
|
|
179
|
+
// Might change after to support more complex type
|
|
180
|
+
break;
|
|
181
|
+
case 1: {
|
|
182
|
+
const typeArgument = typeArguments[0];
|
|
183
|
+
if (type.symbol.getName() === "Promise") {
|
|
184
|
+
return this.tsTypeToTypeDef(node, typeArgument);
|
|
185
|
+
}
|
|
186
|
+
if (type.symbol.getName() === "Array") {
|
|
187
|
+
return {
|
|
188
|
+
kind: TypeDefKind.ListKind,
|
|
189
|
+
typeDef: this.tsTypeToTypeDef(node, typeArgument),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
default: {
|
|
195
|
+
throw new IntrospectionError(`could not resolve type ${type.symbol.getName()} at ${AST.getNodePosition(node)}, dagger does not support generics with argument yet.`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
resolveParameterDefaultValueTypeReference(expression, value) {
|
|
202
|
+
const type = typeof value;
|
|
203
|
+
switch (type) {
|
|
204
|
+
case "string":
|
|
205
|
+
case "number":
|
|
206
|
+
case "bigint":
|
|
207
|
+
case "boolean":
|
|
208
|
+
case "object":
|
|
209
|
+
// Value will be jsonified on registration.
|
|
210
|
+
return value;
|
|
211
|
+
default:
|
|
212
|
+
// If we cannot resolve the value, we skip it and let the value be resolved automatically by the runtime
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
resolveParameterDefaultValue(expression) {
|
|
217
|
+
const kind = expression.kind;
|
|
218
|
+
switch (kind) {
|
|
219
|
+
case ts.SyntaxKind.StringLiteral:
|
|
220
|
+
return `${eval(expression.getText())}`;
|
|
221
|
+
case ts.SyntaxKind.NumericLiteral:
|
|
222
|
+
return parseInt(expression.getText());
|
|
223
|
+
case ts.SyntaxKind.TrueKeyword:
|
|
224
|
+
return true;
|
|
225
|
+
case ts.SyntaxKind.FalseKeyword:
|
|
226
|
+
return false;
|
|
227
|
+
case ts.SyntaxKind.NullKeyword:
|
|
228
|
+
return null;
|
|
229
|
+
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
230
|
+
return eval(expression.getText());
|
|
231
|
+
case ts.SyntaxKind.Identifier: {
|
|
232
|
+
// If the parameter is a reference to a variable, we try to resolve it using
|
|
233
|
+
// exported modules value.
|
|
234
|
+
const value = getValueByExportedName(expression.getText(), this.userModule);
|
|
235
|
+
if (value === undefined) {
|
|
236
|
+
throw new IntrospectionError(`could not resolve default value reference to the variable: '${expression.getText()}' from ${AST.getNodePosition(expression)}. Is it exported by the module?`);
|
|
237
|
+
}
|
|
238
|
+
return this.resolveParameterDefaultValueTypeReference(expression, value);
|
|
239
|
+
}
|
|
240
|
+
case ts.SyntaxKind.PropertyAccessExpression: {
|
|
241
|
+
const accessors = expression.getText().split(".");
|
|
242
|
+
let value = getValueByExportedName(accessors[0], this.userModule);
|
|
243
|
+
for (let i = 1; i < accessors.length; i++) {
|
|
244
|
+
value = value[accessors[i]];
|
|
245
|
+
}
|
|
246
|
+
return this.resolveParameterDefaultValueTypeReference(expression, value);
|
|
247
|
+
}
|
|
248
|
+
default: {
|
|
249
|
+
console.warn(`default value '${expression.getText()}' at ${AST.getNodePosition(expression)} cannot be resolved, dagger does not support object or function as default value.
|
|
250
|
+
The value will be ignored by the introspection and resolve at the runtime.`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export type DeclarationsMap = {
|
|
3
|
+
[ts.SyntaxKind.ClassDeclaration]: ts.ClassDeclaration;
|
|
4
|
+
[ts.SyntaxKind.MethodDeclaration]: ts.MethodDeclaration;
|
|
5
|
+
[ts.SyntaxKind.PropertyDeclaration]: ts.PropertyDeclaration;
|
|
6
|
+
[ts.SyntaxKind.FunctionDeclaration]: ts.FunctionDeclaration;
|
|
7
|
+
[ts.SyntaxKind.EnumDeclaration]: ts.EnumDeclaration;
|
|
8
|
+
[ts.SyntaxKind.InterfaceDeclaration]: ts.InterfaceDeclaration;
|
|
9
|
+
[ts.SyntaxKind.TypeAliasDeclaration]: ts.TypeAliasDeclaration;
|
|
10
|
+
};
|
|
11
|
+
export type Declarations<T extends ts.SyntaxKind> = T extends keyof DeclarationsMap ? DeclarationsMap[T] : ts.Node;
|
|
12
|
+
export declare const isDeclarationOf: {
|
|
13
|
+
[K in keyof DeclarationsMap]: (node: ts.Node) => node is DeclarationsMap[K];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAA;IACrD,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAA;IACvD,CAAC,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAA;IAC3D,CAAC,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAA;IAC3D,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,eAAe,CAAA;IACnD,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAA;IAC7D,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAA;CAC9D,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC,UAAU,IAC9C,CAAC,SAAS,MAAM,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA;AAEhE,eAAO,MAAM,eAAe,EAAE;KAC3B,CAAC,IAAI,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,eAAe,CAAC,CAAC,CAAC;CAS5E,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export const isDeclarationOf = {
|
|
3
|
+
[ts.SyntaxKind.ClassDeclaration]: ts.isClassDeclaration,
|
|
4
|
+
[ts.SyntaxKind.MethodDeclaration]: ts.isMethodDeclaration,
|
|
5
|
+
[ts.SyntaxKind.PropertyDeclaration]: ts.isPropertyDeclaration,
|
|
6
|
+
[ts.SyntaxKind.FunctionDeclaration]: ts.isFunctionDeclaration,
|
|
7
|
+
[ts.SyntaxKind.EnumDeclaration]: ts.isEnumDeclaration,
|
|
8
|
+
[ts.SyntaxKind.InterfaceDeclaration]: ts.isInterfaceDeclaration,
|
|
9
|
+
[ts.SyntaxKind.TypeAliasDeclaration]: ts.isTypeAliasDeclaration,
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,GAAG,SAAS,CAMpB;AAGD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAQ3E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function findModuleByExportedName(name, modules) {
|
|
2
|
+
for (const module of modules) {
|
|
3
|
+
if (module[name]) {
|
|
4
|
+
return module;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
export function getValueByExportedName(name, modules) {
|
|
10
|
+
for (const module of modules) {
|
|
11
|
+
if (module[name]) {
|
|
12
|
+
return module[name];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
2
|
+
import { TypeDef } from "../typedef.js";
|
|
3
|
+
export declare function isTypeDefResolved(typeDef: TypeDef<TypeDefKind>): boolean;
|
|
4
|
+
export declare function resolveTypeDef(typeDef: TypeDef<TypeDefKind> | undefined, reference: TypeDef<TypeDefKind>): TypeDef<TypeDefKind>;
|
|
5
|
+
//# sourceMappingURL=typedef_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedef_utils.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/typedef_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAgBxE;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,EACzC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAC9B,OAAO,CAAC,WAAW,CAAC,CAetB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
2
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
3
|
+
export function isTypeDefResolved(typeDef) {
|
|
4
|
+
if (typeDef.kind !== TypeDefKind.ListKind) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
const arrayTypeDef = typeDef;
|
|
8
|
+
if (arrayTypeDef.typeDef === undefined) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (arrayTypeDef.typeDef.kind === TypeDefKind.ListKind) {
|
|
12
|
+
return isTypeDefResolved(arrayTypeDef.typeDef);
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
export function resolveTypeDef(typeDef, reference) {
|
|
17
|
+
if (typeDef === undefined) {
|
|
18
|
+
return reference;
|
|
19
|
+
}
|
|
20
|
+
if (typeDef.kind === TypeDefKind.ListKind) {
|
|
21
|
+
const listTypeDef = typeDef;
|
|
22
|
+
listTypeDef.typeDef = resolveTypeDef(listTypeDef.typeDef, reference);
|
|
23
|
+
return listTypeDef;
|
|
24
|
+
}
|
|
25
|
+
throw new IntrospectionError(`type ${JSON.stringify(typeDef)} has already been resolved, it should not be overwritten ; reference: ${JSON.stringify(reference)}`);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/utils/files.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,SAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0B5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/module/registry.ts"],"names":[],"mappings":"AAKA,OAAO,kBAAkB,CAAA;AAIzB,MAAM,MAAM,KAAK,GAAG;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAE/C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAU1C,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;IACH,MAAM,QAAO,CAAC,CAAC,CAAe,SAAL,KAAK,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAMpD;IAED;;;OAGG;IACH,QAAQ,QAAO,CAAC,CAAC,CAAe,SAAL,KAAK,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAItD;IAED;;;;;;OAMG;IACH,KAAK,WAAY,MAAM,KAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC,CAIxE;IAED;;;OAGG;IACH,IAAI,WACM,MAAM,KACb,CAAC,CACF,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,UAAU,CAAC,EAAE,kBAAkB,KAC5B,IAAI,CAAC,CAMT;IAED,QAAQ,UACC,eAAe,KACrB,CAAC,CACF,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,KACnB,IAAI,CAAC,CAET;IAED;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG;IAY7C;;;;;;;;;;OAUG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,GAAG,CAAC;CAiChB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAiB,CAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// @experimentalDecorators
|
|
4
4
|
// @emitDecoratorMetadata
|
|
5
5
|
import "reflect-metadata";
|
|
6
|
-
import { UnknownDaggerError } from "
|
|
6
|
+
import { UnknownDaggerError } from "../common/errors/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Registry stores class and method that have the @object decorator.
|
|
9
9
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/provisioning/bin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,aAAa,EAAE,MAAM,OAAO,CAAA;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAgB/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAA;AAMxE,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,IAAI,CAAA;IACZ,OAAO,EAAE,IAAI,CAAA;CACd,CAAC,CAAA;AAEF;;GAEG;AACH,qBAAa,GAAI,YAAW,UAAU;IACpC,OAAO,CAAC,WAAW,CAAC,CAAmB;IAEvC,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAE3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGxB;IAED,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAW;gBAErC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAKjD,IAAI,IAAI,MAAM;IAId,IAAI,UAAU,IAAI,iBAAiB,GAAG,SAAS,CAE9C;IAEK,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;YAgB1C,WAAW;IAkEzB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;OAGG;YACW,gBAAgB;YA2EhB,iBAAiB;IA6BzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAItB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;YAOR,WAAW;YAkBX,gBAAgB;YAWhB,cAAc;IA4C5B;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB;AAGD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEjD;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE1D"}
|
|
@@ -11,7 +11,7 @@ import readline from "readline";
|
|
|
11
11
|
import * as tar from "tar";
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
import { EngineSessionConnectionTimeoutError, EngineSessionConnectParamsParseError, EngineSessionError, InitEngineSessionBinaryError, } from "../common/errors/index.js";
|
|
14
|
-
import { createGQLClient } from "../graphql/client.js";
|
|
14
|
+
import { createGQLClient } from "../common/graphql/client.js";
|
|
15
15
|
const CLI_HOST = "dl.dagger.io";
|
|
16
16
|
let OVERRIDE_CLI_URL;
|
|
17
17
|
let OVERRIDE_CHECKSUMS_URL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/provisioning/default.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,WAAW,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Code generated by dagger. DO NOT EDIT.
|
|
2
|
-
export const CLI_VERSION = "0.
|
|
2
|
+
export const CLI_VERSION = "0.15.0";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GraphQLClient } from "graphql-request";
|
|
2
|
+
import { Writable } from "node:stream";
|
|
3
|
+
export interface ConnectOpts {
|
|
4
|
+
Workdir?: string;
|
|
5
|
+
Project?: string;
|
|
6
|
+
LogOutput?: Writable;
|
|
7
|
+
Timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ConnectParams {
|
|
10
|
+
port: number;
|
|
11
|
+
session_token: string;
|
|
12
|
+
}
|
|
13
|
+
export interface EngineConn {
|
|
14
|
+
/**
|
|
15
|
+
* Library connection provisioning, it returns a ready to use GraphQL client
|
|
16
|
+
* connected to the Dagger engine.
|
|
17
|
+
*
|
|
18
|
+
* This test multiple options to connect to the Dagger Engine.
|
|
19
|
+
* 1. Check for already running engine through `DAGGER_SESSION_PORT` & `DAGGER_SESSION_TOKEN`
|
|
20
|
+
* environment variable.
|
|
21
|
+
* 2. Auto provision the engine from the Dagger CLI (install it if it doesn't exist) and
|
|
22
|
+
* connect the client.
|
|
23
|
+
*/
|
|
24
|
+
Connect: (opts: ConnectOpts) => Promise<GraphQLClient>;
|
|
25
|
+
/**
|
|
26
|
+
* Close stops the current connection.
|
|
27
|
+
*/
|
|
28
|
+
Close: () => void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=engineconn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineconn.d.ts","sourceRoot":"","sources":["../../../src/provisioning/engineconn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,UAAU;IACzB;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,aAAa,CAAC,CAAA;IAEtD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/provisioning/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI/C,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3C,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Bin } from "./bin.js";
|
|
2
|
+
import { CLI_VERSION } from "./default.js";
|
|
3
|
+
export async function withEngineSession(connectOpts, cb) {
|
|
4
|
+
const cliBin = process.env["_EXPERIMENTAL_DAGGER_CLI_BIN"];
|
|
5
|
+
const engineConn = new Bin(cliBin, CLI_VERSION);
|
|
6
|
+
const gqlClient = await engineConn.Connect(connectOpts);
|
|
7
|
+
try {
|
|
8
|
+
const res = await cb(gqlClient);
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
await engineConn.Close();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/telemetry/init.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,aAAa,CAAQ;IAE7B,OAAO,CAAC,GAAG,CAAC,CAAS;IAErB;;OAEG;IACH,UAAU;IAQV,SAAS;IAoBT;;OAEG;IACG,KAAK;IAMX;;OAEG;IACH,QAAQ;CAeT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,wBAAgB,UAAU,SAEzB;AAED,wBAAsB,KAAK,kBAE1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAqB,GAAG,MAAM,CAG3D;AAED,wBAAgB,UAAU,0BAgBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../../src/telemetry/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAsB;gBAExB,IAAI,EAAE,MAAM;IAIjB,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,GACpC,aAAa,CAAC,IAAI;IAIrB;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,eAAe,CAAC,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAC5C,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU;CAoBxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dagger.io/dagger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"author": "hello@dagger.io",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"dist/"
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
|
-
".": "./dist/index.js",
|
|
13
|
-
"./telemetry": "./dist/telemetry/index.js"
|
|
12
|
+
".": "./dist/src/index.js",
|
|
13
|
+
"./telemetry": "./dist/src/telemetry/index.js"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=18"
|
|
17
17
|
},
|
|
18
|
-
"main": "dist/index.js",
|
|
18
|
+
"main": "dist/src/index.js",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@grpc/grpc-js": "^1.11.1",
|
|
21
21
|
"@lifeomic/axios-fetch": "^3.1.0",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"mocha": "^10.7.0",
|
|
64
64
|
"prettier": "^3.3.3",
|
|
65
65
|
"ts-node": "^10.9.2",
|
|
66
|
+
"tsx": "^4.19.2",
|
|
66
67
|
"typescript-eslint": "^8.0.1"
|
|
67
68
|
}
|
|
68
69
|
}
|