@dagger.io/dagger 0.0.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +88 -0
- package/dist/src/api/client.gen.d.ts +6123 -0
- package/dist/src/api/client.gen.d.ts.map +1 -0
- package/dist/src/api/client.gen.js +8494 -0
- 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/src/common/errors/DaggerSDKError.d.ts +32 -0
- package/dist/src/common/errors/DaggerSDKError.d.ts.map +1 -0
- package/dist/src/common/errors/DaggerSDKError.js +26 -0
- package/dist/src/common/errors/DockerImageRefValidationError.d.ts +22 -0
- package/dist/src/common/errors/DockerImageRefValidationError.d.ts.map +1 -0
- package/dist/src/common/errors/DockerImageRefValidationError.js +21 -0
- package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts +21 -0
- package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionConnectParamsParseError.js +20 -0
- package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts +21 -0
- package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionConnectionTimeoutError.js +20 -0
- package/dist/src/common/errors/EngineSessionErrorOptions.d.ts +16 -0
- package/dist/src/common/errors/EngineSessionErrorOptions.d.ts.map +1 -0
- package/dist/src/common/errors/EngineSessionErrorOptions.js +16 -0
- package/dist/src/common/errors/ExecError.d.ts +42 -0
- package/dist/src/common/errors/ExecError.d.ts.map +1 -0
- package/dist/src/common/errors/ExecError.js +40 -0
- package/dist/src/common/errors/FunctionNotFound.d.ts +7 -0
- package/dist/src/common/errors/FunctionNotFound.d.ts.map +1 -0
- package/dist/src/common/errors/FunctionNotFound.js +9 -0
- package/dist/src/common/errors/GraphQLRequestError.d.ts +31 -0
- package/dist/src/common/errors/GraphQLRequestError.d.ts.map +1 -0
- package/dist/src/common/errors/GraphQLRequestError.js +30 -0
- package/dist/src/common/errors/InitEngineSessionBinaryError.d.ts +13 -0
- package/dist/src/common/errors/InitEngineSessionBinaryError.d.ts.map +1 -0
- package/dist/src/common/errors/InitEngineSessionBinaryError.js +15 -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 +13 -0
- package/dist/src/common/errors/NotAwaitedRequestError.d.ts.map +1 -0
- package/dist/src/common/errors/NotAwaitedRequestError.js +15 -0
- package/dist/src/common/errors/TooManyNestedObjectsError.d.ts +21 -0
- package/dist/src/common/errors/TooManyNestedObjectsError.d.ts.map +1 -0
- package/dist/src/common/errors/TooManyNestedObjectsError.js +20 -0
- package/dist/src/common/errors/UnknownDaggerError.d.ts +13 -0
- package/dist/src/common/errors/UnknownDaggerError.d.ts.map +1 -0
- package/dist/src/common/errors/UnknownDaggerError.js +15 -0
- package/dist/src/common/errors/errors-codes.d.ts +55 -0
- package/dist/src/common/errors/errors-codes.d.ts.map +1 -0
- package/dist/src/common/errors/errors-codes.js +47 -0
- package/dist/src/common/errors/index.d.ts +15 -0
- package/dist/src/common/errors/index.d.ts.map +1 -0
- package/dist/src/common/errors/index.js +14 -0
- package/dist/src/common/graphql/client.d.ts +3 -0
- package/dist/src/common/graphql/client.d.ts.map +1 -0
- package/dist/src/common/graphql/client.js +58 -0
- package/dist/src/common/graphql/compute_query.d.ts +37 -0
- package/dist/src/common/graphql/compute_query.d.ts.map +1 -0
- package/dist/src/common/graphql/compute_query.js +171 -0
- 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/src/common/utils.d.ts +70 -0
- package/dist/src/common/utils.d.ts.map +1 -0
- package/dist/src/common/utils.js +6 -0
- package/dist/src/connect.d.ts +28 -0
- package/dist/src/connect.d.ts.map +1 -0
- package/dist/src/connect.js +64 -0
- package/dist/src/connectOpts.d.ts +24 -0
- package/dist/src/connectOpts.d.ts.map +1 -0
- package/dist/src/connectOpts.js +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -0
- package/dist/src/module/decorators.d.ts +52 -0
- package/dist/src/module/decorators.d.ts.map +1 -0
- package/dist/src/module/decorators.js +55 -0
- package/dist/src/module/entrypoint/context.d.ts +8 -0
- package/dist/src/module/entrypoint/context.d.ts.map +1 -0
- package/dist/src/module/entrypoint/context.js +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/src/module/entrypoint/entrypoint.js +92 -0
- package/dist/src/module/entrypoint/introspection_entrypoint.d.ts +2 -0
- package/dist/src/module/entrypoint/introspection_entrypoint.d.ts.map +1 -0
- package/dist/src/module/entrypoint/introspection_entrypoint.js +52 -0
- package/dist/src/module/entrypoint/invoke.d.ts +14 -0
- package/dist/src/module/entrypoint/invoke.d.ts.map +1 -0
- package/dist/src/module/entrypoint/invoke.js +66 -0
- package/dist/src/module/entrypoint/load.d.ts +53 -0
- package/dist/src/module/entrypoint/load.d.ts.map +1 -0
- package/dist/src/module/entrypoint/load.js +237 -0
- package/dist/src/module/entrypoint/register.d.ts +33 -0
- package/dist/src/module/entrypoint/register.d.ts.map +1 -0
- package/dist/src/module/entrypoint/register.js +227 -0
- package/dist/src/module/executor.d.ts +28 -0
- package/dist/src/module/executor.d.ts.map +1 -0
- package/dist/src/module/executor.js +171 -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 +15 -0
- package/dist/src/module/introspector/dagger_module/argument.d.ts +50 -0
- package/dist/src/module/introspector/dagger_module/argument.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/argument.js +118 -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 +8 -0
- package/dist/src/module/introspector/dagger_module/decorator.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/decorator.js +7 -0
- package/dist/src/module/introspector/dagger_module/enum.d.ts +41 -0
- package/dist/src/module/introspector/dagger_module/enum.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enum.js +63 -0
- package/dist/src/module/introspector/dagger_module/enumBase.d.ts +19 -0
- package/dist/src/module/introspector/dagger_module/enumBase.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enumBase.js +1 -0
- package/dist/src/module/introspector/dagger_module/enumClass.d.ts +41 -0
- package/dist/src/module/introspector/dagger_module/enumClass.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/enumClass.js +69 -0
- package/dist/src/module/introspector/dagger_module/function.d.ts +39 -0
- package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/function.js +102 -0
- package/dist/src/module/introspector/dagger_module/index.d.ts +15 -0
- package/dist/src/module/introspector/dagger_module/index.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/index.js +14 -0
- package/dist/src/module/introspector/dagger_module/interface.d.ts +25 -0
- package/dist/src/module/introspector/dagger_module/interface.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/interface.js +56 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts +35 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/interfaceFunction.js +92 -0
- package/dist/src/module/introspector/dagger_module/locatable.d.ts +12 -0
- package/dist/src/module/introspector/dagger_module/locatable.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/locatable.js +14 -0
- package/dist/src/module/introspector/dagger_module/module.d.ts +118 -0
- package/dist/src/module/introspector/dagger_module/module.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/module.js +316 -0
- package/dist/src/module/introspector/dagger_module/object.d.ts +46 -0
- package/dist/src/module/introspector/dagger_module/object.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/object.js +113 -0
- package/dist/src/module/introspector/dagger_module/objectBase.d.ts +32 -0
- package/dist/src/module/introspector/dagger_module/objectBase.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/objectBase.js +1 -0
- package/dist/src/module/introspector/dagger_module/property.d.ts +36 -0
- package/dist/src/module/introspector/dagger_module/property.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/property.js +82 -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 +49 -0
- package/dist/src/module/introspector/dagger_module/typeObject.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/typeObject.js +87 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts +34 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.d.ts.map +1 -0
- package/dist/src/module/introspector/dagger_module/typeObjectProperty.js +60 -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 +19 -0
- package/dist/src/module/introspector/typedef.d.ts +52 -0
- package/dist/src/module/introspector/typedef.d.ts.map +1 -0
- package/dist/src/module/introspector/typedef.js +1 -0
- package/dist/src/module/introspector/typescript_module/ast.d.ts +64 -0
- package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/ast.js +476 -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/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/location.d.ts +6 -0
- package/dist/src/module/introspector/typescript_module/location.d.ts.map +1 -0
- package/dist/src/module/introspector/typescript_module/location.js +1 -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 +5 -0
- package/dist/src/module/introspector/utils/files.d.ts.map +1 -0
- package/dist/src/module/introspector/utils/files.js +28 -0
- package/dist/src/module/registry.d.ts +109 -0
- package/dist/src/module/registry.d.ts.map +1 -0
- package/dist/src/module/registry.js +123 -0
- package/dist/src/provisioning/bin.d.ts +77 -0
- package/dist/src/provisioning/bin.d.ts.map +1 -0
- package/dist/src/provisioning/bin.js +353 -0
- package/dist/src/provisioning/default.d.ts +2 -0
- package/dist/src/provisioning/default.d.ts.map +1 -0
- package/dist/src/provisioning/default.js +2 -0
- 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 +3 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +2 -0
- package/dist/src/telemetry/init.d.ts +21 -0
- package/dist/src/telemetry/init.d.ts.map +1 -0
- package/dist/src/telemetry/init.js +86 -0
- package/dist/src/telemetry/live_processor.d.ts +12 -0
- package/dist/src/telemetry/live_processor.d.ts.map +1 -0
- package/dist/src/telemetry/live_processor.js +13 -0
- package/dist/src/telemetry/telemetry.d.ts +16 -0
- package/dist/src/telemetry/telemetry.d.ts.map +1 -0
- package/dist/src/telemetry/telemetry.js +38 -0
- package/dist/src/telemetry/tracer.d.ts +32 -0
- package/dist/src/telemetry/tracer.d.ts.map +1 -0
- package/dist/src/telemetry/tracer.js +54 -0
- package/package.json +74 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { dag, TypeDefKind } from "../api/client.gen.js";
|
|
2
|
+
import { Context } from "../common/context.js";
|
|
3
|
+
import { FunctionNotFound } from "../common/errors/index.js";
|
|
4
|
+
import { Connection } from "../common/graphql/connection.js";
|
|
5
|
+
export class Executor {
|
|
6
|
+
modules;
|
|
7
|
+
daggerModule;
|
|
8
|
+
constructor(modules, daggerModule) {
|
|
9
|
+
this.modules = modules;
|
|
10
|
+
this.daggerModule = daggerModule;
|
|
11
|
+
}
|
|
12
|
+
getExportedObject(object) {
|
|
13
|
+
const key = object;
|
|
14
|
+
const module = this.modules.find((m) => m[key] !== undefined);
|
|
15
|
+
if (!module) {
|
|
16
|
+
throw new FunctionNotFound(`Object ${object} not found`);
|
|
17
|
+
}
|
|
18
|
+
return module[key];
|
|
19
|
+
}
|
|
20
|
+
buildClass(object, state) {
|
|
21
|
+
const daggerObject = this.daggerModule.objects[object];
|
|
22
|
+
if (!daggerObject) {
|
|
23
|
+
throw new FunctionNotFound(`Object ${object} not found in the module`);
|
|
24
|
+
}
|
|
25
|
+
switch (daggerObject.kind()) {
|
|
26
|
+
case "class": {
|
|
27
|
+
const obj = this.getExportedObject(object);
|
|
28
|
+
const instanciatedClass = Object.create(obj.prototype);
|
|
29
|
+
Object.assign(instanciatedClass, state);
|
|
30
|
+
return instanciatedClass;
|
|
31
|
+
}
|
|
32
|
+
case "object": {
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Transform a Dagger interface identifier into an implementation of this
|
|
39
|
+
* interface serves as module call binding to reach the true implementation.
|
|
40
|
+
*/
|
|
41
|
+
buildInterface(iface, id) {
|
|
42
|
+
const interfaceObject = this.daggerModule.interfaces[iface];
|
|
43
|
+
if (!interfaceObject) {
|
|
44
|
+
throw new Error(`Interface ${iface} not found in the module`);
|
|
45
|
+
}
|
|
46
|
+
const ifaceImpl = new InterfaceWrapper(this, this.daggerModule, `${this.daggerModule.name}${iface}`, id, interfaceObject.functions);
|
|
47
|
+
return ifaceImpl;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Transfer a Dagger enum member name into its implemented value.
|
|
51
|
+
* An enum value A = "a" will be received as "A" by the entrypoint
|
|
52
|
+
* but should be transformed into "a" to be sent to the function.
|
|
53
|
+
* If the enum isn't found in the module, it may be a core enum so we keep the value
|
|
54
|
+
* as is.
|
|
55
|
+
*/
|
|
56
|
+
buildEnum(enumName, value) {
|
|
57
|
+
const enumObject = this.daggerModule.enums[enumName];
|
|
58
|
+
if (!enumObject) {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
if (!enumObject.values[value]) {
|
|
62
|
+
throw new Error(`Enum ${enumName} does not have member ${value}`);
|
|
63
|
+
}
|
|
64
|
+
return enumObject.values[value].value;
|
|
65
|
+
}
|
|
66
|
+
async getResult(object, method, state, inputs) {
|
|
67
|
+
const obj = this.getExportedObject(object);
|
|
68
|
+
if (method === "") {
|
|
69
|
+
return new obj(...Object.values(inputs));
|
|
70
|
+
}
|
|
71
|
+
const builtObj = this.buildClass(object, state);
|
|
72
|
+
if (!builtObj[method]) {
|
|
73
|
+
throw new FunctionNotFound(`Method ${method} not found`);
|
|
74
|
+
}
|
|
75
|
+
return await builtObj[method](...Object.values(inputs));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Interface Wrapper serves as dynaminc module binding so the module can
|
|
80
|
+
* call function of this interface.
|
|
81
|
+
* Because the actual interface implementation can come from any external modules,
|
|
82
|
+
* all resolution are done by API Call.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* interface Example {
|
|
87
|
+
* foo: () => Promise<string>
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* class Test {
|
|
91
|
+
* @func()
|
|
92
|
+
* async callFoo(example: Example): Promise<string> {
|
|
93
|
+
* // <- This example argument here is actually the Interface Wrapper, and `foo` will,
|
|
94
|
+
* // directly execute the API call to reach the given implementation.
|
|
95
|
+
* return example.foo()
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
class InterfaceWrapper {
|
|
101
|
+
executor;
|
|
102
|
+
module;
|
|
103
|
+
ifaceName;
|
|
104
|
+
ifaceId;
|
|
105
|
+
fcts;
|
|
106
|
+
_ctx;
|
|
107
|
+
constructor(executor, module, ifaceName, ifaceId, fcts) {
|
|
108
|
+
this.executor = executor;
|
|
109
|
+
this.module = module;
|
|
110
|
+
this.ifaceName = ifaceName;
|
|
111
|
+
this.ifaceId = ifaceId;
|
|
112
|
+
this.fcts = fcts;
|
|
113
|
+
this._ctx = new Context([], new Connection(dag.getGQLClient()));
|
|
114
|
+
// Load the interface by its identifier
|
|
115
|
+
this._ctx = this._ctx.select(`load${ifaceName}FromID`, { id: ifaceId });
|
|
116
|
+
Object.entries(fcts).forEach(([name, fct]) => {
|
|
117
|
+
const argKeys = Object.keys(fct.arguments);
|
|
118
|
+
// Dynamically adding functions of the interface and it's resolvers.
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
this[name] = async (...args) => {
|
|
121
|
+
// Fill up arguments of that function.
|
|
122
|
+
const argsPayload = {};
|
|
123
|
+
for (let i = 0; i < argKeys.length; i++) {
|
|
124
|
+
if (args[i] !== undefined) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
argsPayload[argKeys[i]] = args[i];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
this._ctx = this._ctx.select(name, argsPayload);
|
|
130
|
+
// If the function is returning an IDable, we don't need to execute it
|
|
131
|
+
// since it will be resolved later.
|
|
132
|
+
if (fct.returnType.kind === TypeDefKind.InterfaceKind ||
|
|
133
|
+
fct.returnType.kind === TypeDefKind.ObjectKind) {
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
// If the function is returning a list, we may need to load the sub-objects
|
|
137
|
+
if (fct.returnType.kind === TypeDefKind.ListKind) {
|
|
138
|
+
const listTypeDef = fct.returnType
|
|
139
|
+
.typeDef;
|
|
140
|
+
// If the list is an object or an interface, then we need to load the sub-objects.
|
|
141
|
+
if (listTypeDef.kind === TypeDefKind.ObjectKind ||
|
|
142
|
+
listTypeDef.kind === TypeDefKind.InterfaceKind) {
|
|
143
|
+
const typedef = listTypeDef;
|
|
144
|
+
// Resolves the call to get the list of IDs to load
|
|
145
|
+
const ids = await this._ctx
|
|
146
|
+
.select("id")
|
|
147
|
+
.execute();
|
|
148
|
+
// If the return type is an interface defined by that module, we need to load it through
|
|
149
|
+
// the interface wrapper
|
|
150
|
+
if (this.module.interfaces[typedef.name]) {
|
|
151
|
+
return await Promise.all(ids.map(({ id }) => new InterfaceWrapper(this.executor, module, `${this.module.name}${typedef.name}`, id, this.module.interfaces[typedef.name].functions)));
|
|
152
|
+
}
|
|
153
|
+
// Otherwise, we can just load the objects from the API
|
|
154
|
+
return await Promise.all(
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
ids.map(({ id }) => dag[`load${listTypeDef.name}FromID`](id)));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return await this._ctx.execute();
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* ID function to make the interface IDeable when serialized as return value to the
|
|
165
|
+
* Dagger API.
|
|
166
|
+
*/
|
|
167
|
+
async id() {
|
|
168
|
+
const ctx = this._ctx.select("id");
|
|
169
|
+
return await ctx.execute();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"case_convertor.d.ts","sourceRoot":"","sources":["../../../../src/module/introspector/case_convertor.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBzD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function convertToPascalCase(input) {
|
|
2
|
+
// Handle empty string case
|
|
3
|
+
if (!input) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
// Split on word boundaries before uppercase letters, numbers, and special characters
|
|
7
|
+
const words = input
|
|
8
|
+
.split(/(?=[A-Z0-9])|[^a-zA-Z0-9]|(?<=[a-zA-Z])(?=\d)|(?<=\d)(?=[a-zA-Z])/g)
|
|
9
|
+
.filter((word) => word.length > 0);
|
|
10
|
+
// Convert each word to proper case
|
|
11
|
+
const pascalCase = words
|
|
12
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
13
|
+
.join("");
|
|
14
|
+
return pascalCase;
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { Locatable } from "./locatable.js";
|
|
6
|
+
import { References } from "./reference.js";
|
|
7
|
+
export type DaggerArguments = {
|
|
8
|
+
[name: string]: DaggerArgument;
|
|
9
|
+
};
|
|
10
|
+
export declare class DaggerArgument extends Locatable {
|
|
11
|
+
private readonly node;
|
|
12
|
+
private readonly ast;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
deprecated?: string;
|
|
16
|
+
private _typeRef?;
|
|
17
|
+
type?: TypeDef<TypeDefKind>;
|
|
18
|
+
isVariadic: boolean;
|
|
19
|
+
isNullable: boolean;
|
|
20
|
+
isOptional: boolean;
|
|
21
|
+
defaultPath?: string;
|
|
22
|
+
ignore?: string[];
|
|
23
|
+
defaultValue?: any;
|
|
24
|
+
private symbol;
|
|
25
|
+
constructor(node: ts.ParameterDeclaration, ast: AST);
|
|
26
|
+
/**
|
|
27
|
+
* Get the type of the parameter.
|
|
28
|
+
*
|
|
29
|
+
* If for it's a complex type that cannot be
|
|
30
|
+
* resolve yet, we save its string representation for further reference.
|
|
31
|
+
*/
|
|
32
|
+
private getType;
|
|
33
|
+
private getIsNullable;
|
|
34
|
+
private getDefaultValue;
|
|
35
|
+
getReference(): string | undefined;
|
|
36
|
+
propagateReferences(references: References): void;
|
|
37
|
+
toJSON(): {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
deprecated: string | undefined;
|
|
41
|
+
type: TypeDef<TypeDefKind> | undefined;
|
|
42
|
+
isVariadic: boolean;
|
|
43
|
+
isNullable: boolean;
|
|
44
|
+
isOptional: boolean;
|
|
45
|
+
defaultValue: any;
|
|
46
|
+
defaultPath: string | undefined;
|
|
47
|
+
ignore: string[] | undefined;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=argument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/argument.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,GAAG,EAGJ,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,CAAA;AAEhE,qBAAa,cAAe,SAAQ,SAAS;IAgBzC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAhBf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAQ;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3B,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,CAAC,EAAE,GAAG,CAAA;IAEzB,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,oBAAoB,EAC7B,GAAG,EAAE,GAAG;IAuC3B;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,eAAe;IAShB,YAAY,IAAI,MAAM,GAAG,SAAS;IAWlC,mBAAmB,CAAC,UAAU,EAAE,UAAU;IAmBjD,MAAM;;;;;;;;;;;;CAcP"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
4
|
+
import { AST, isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
|
|
5
|
+
import { ARGUMENT_DECORATOR } from "./decorator.js";
|
|
6
|
+
import { Locatable } from "./locatable.js";
|
|
7
|
+
export class DaggerArgument extends Locatable {
|
|
8
|
+
node;
|
|
9
|
+
ast;
|
|
10
|
+
name;
|
|
11
|
+
description;
|
|
12
|
+
deprecated;
|
|
13
|
+
_typeRef;
|
|
14
|
+
type;
|
|
15
|
+
isVariadic;
|
|
16
|
+
isNullable;
|
|
17
|
+
isOptional;
|
|
18
|
+
defaultPath;
|
|
19
|
+
ignore;
|
|
20
|
+
defaultValue;
|
|
21
|
+
symbol;
|
|
22
|
+
constructor(node, ast) {
|
|
23
|
+
super(node);
|
|
24
|
+
this.node = node;
|
|
25
|
+
this.ast = ast;
|
|
26
|
+
this.symbol = this.ast.getSymbolOrThrow(node.name);
|
|
27
|
+
this.name = this.node.name.getText();
|
|
28
|
+
const { description, deprecated } = this.ast.getSymbolDoc(this.symbol);
|
|
29
|
+
this.description = description;
|
|
30
|
+
this.deprecated = deprecated;
|
|
31
|
+
this.defaultValue = this.getDefaultValue();
|
|
32
|
+
this.isVariadic = this.node.dotDotDotToken !== undefined;
|
|
33
|
+
this.isNullable = this.getIsNullable();
|
|
34
|
+
this.isOptional =
|
|
35
|
+
this.isVariadic || // if argument has ...
|
|
36
|
+
(this.defaultValue === undefined && // if argument has a default value that couldn't be resolved.
|
|
37
|
+
this.node.initializer !== undefined) ||
|
|
38
|
+
this.isNullable || // if argument is nullable
|
|
39
|
+
this.node.questionToken !== undefined; // if argument has ?
|
|
40
|
+
if (this.deprecated !== undefined && !this.isOptional) {
|
|
41
|
+
throw new IntrospectionError(`argument ${this.name} is required and cannot be deprecated at ${AST.getNodePosition(this.node)}.`);
|
|
42
|
+
}
|
|
43
|
+
const decoratorArguments = this.ast.getDecoratorArgument(this.node, ARGUMENT_DECORATOR, "object");
|
|
44
|
+
if (decoratorArguments) {
|
|
45
|
+
this.ignore = decoratorArguments.ignore;
|
|
46
|
+
this.defaultPath = decoratorArguments.defaultPath;
|
|
47
|
+
}
|
|
48
|
+
this.type = this.getType();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the type of the parameter.
|
|
52
|
+
*
|
|
53
|
+
* If for it's a complex type that cannot be
|
|
54
|
+
* resolve yet, we save its string representation for further reference.
|
|
55
|
+
*/
|
|
56
|
+
getType() {
|
|
57
|
+
const type = this.ast.checker.getTypeAtLocation(this.node);
|
|
58
|
+
const typedef = this.ast.tsTypeToTypeDef(this.node, type);
|
|
59
|
+
if (typedef === undefined || !isTypeDefResolved(typedef)) {
|
|
60
|
+
this._typeRef = this.ast.typeToStringType(type);
|
|
61
|
+
}
|
|
62
|
+
return typedef;
|
|
63
|
+
}
|
|
64
|
+
getIsNullable() {
|
|
65
|
+
if (!this.node.type) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (ts.isUnionTypeNode(this.node.type)) {
|
|
69
|
+
for (const _type of this.node.type.types) {
|
|
70
|
+
if (_type.getText() === "null") {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
getDefaultValue() {
|
|
78
|
+
const initializer = this.node.initializer;
|
|
79
|
+
if (!initializer) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
return this.ast.resolveParameterDefaultValue(initializer);
|
|
83
|
+
}
|
|
84
|
+
getReference() {
|
|
85
|
+
if (this._typeRef &&
|
|
86
|
+
(this.type === undefined || !isTypeDefResolved(this.type))) {
|
|
87
|
+
return this._typeRef;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
propagateReferences(references) {
|
|
92
|
+
if (!this._typeRef) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (this.type && isTypeDefResolved(this.type)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const typeDef = references[this._typeRef];
|
|
99
|
+
if (!typeDef) {
|
|
100
|
+
throw new IntrospectionError(`could not find type reference for ${this._typeRef} at ${AST.getNodePosition(this.node)}.`);
|
|
101
|
+
}
|
|
102
|
+
this.type = resolveTypeDef(this.type, typeDef);
|
|
103
|
+
}
|
|
104
|
+
toJSON() {
|
|
105
|
+
return {
|
|
106
|
+
name: this.name,
|
|
107
|
+
description: this.description,
|
|
108
|
+
deprecated: this.deprecated,
|
|
109
|
+
type: this.type,
|
|
110
|
+
isVariadic: this.isVariadic,
|
|
111
|
+
isNullable: this.isNullable,
|
|
112
|
+
isOptional: this.isOptional,
|
|
113
|
+
defaultValue: this.defaultValue,
|
|
114
|
+
defaultPath: this.defaultPath,
|
|
115
|
+
ignore: this.ignore,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { AST } from "../typescript_module/index.js";
|
|
3
|
+
import { DaggerArguments } from "./argument.js";
|
|
4
|
+
import { References } from "./reference.js";
|
|
5
|
+
export declare class DaggerConstructor {
|
|
6
|
+
private readonly node;
|
|
7
|
+
private readonly ast;
|
|
8
|
+
name: string;
|
|
9
|
+
arguments: DaggerArguments;
|
|
10
|
+
constructor(node: ts.ConstructorDeclaration, ast: AST);
|
|
11
|
+
getArgsOrder(): string[];
|
|
12
|
+
getReferences(): string[];
|
|
13
|
+
propagateReferences(references: References): void;
|
|
14
|
+
toJSON(): {
|
|
15
|
+
arguments: DaggerArguments;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=constructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAkB,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,qBAAa,iBAAiB;IAK1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALf,IAAI,EAAE,MAAM,CAAK;IACjB,SAAS,EAAE,eAAe,CAAK;gBAGnB,IAAI,EAAE,EAAE,CAAC,sBAAsB,EAC/B,GAAG,EAAE,GAAG;IAYpB,YAAY,IAAI,MAAM,EAAE;IAIxB,aAAa,IAAI,MAAM,EAAE;IAazB,mBAAmB,CAAC,UAAU,EAAE,UAAU;IAMjD,MAAM;;;CAKP"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DaggerArgument } from "./argument.js";
|
|
2
|
+
export class DaggerConstructor {
|
|
3
|
+
node;
|
|
4
|
+
ast;
|
|
5
|
+
name = "";
|
|
6
|
+
arguments = {};
|
|
7
|
+
constructor(node, ast) {
|
|
8
|
+
this.node = node;
|
|
9
|
+
this.ast = ast;
|
|
10
|
+
const parameters = this.node.parameters;
|
|
11
|
+
for (const parameter of parameters) {
|
|
12
|
+
this.arguments[parameter.name.getText()] = new DaggerArgument(parameter, this.ast);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
getArgsOrder() {
|
|
16
|
+
return Object.keys(this.arguments);
|
|
17
|
+
}
|
|
18
|
+
getReferences() {
|
|
19
|
+
const references = [];
|
|
20
|
+
for (const argument of Object.values(this.arguments)) {
|
|
21
|
+
const ref = argument.getReference();
|
|
22
|
+
if (ref) {
|
|
23
|
+
references.push(ref);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return references;
|
|
27
|
+
}
|
|
28
|
+
propagateReferences(references) {
|
|
29
|
+
for (const argument of Object.values(this.arguments)) {
|
|
30
|
+
argument.propagateReferences(references);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
arguments: this.arguments,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type DaggerDecorators = "object" | "func" | "check" | "argument" | "enumType" | "field";
|
|
2
|
+
export declare const OBJECT_DECORATOR: DaggerDecorators;
|
|
3
|
+
export declare const FUNCTION_DECORATOR: DaggerDecorators;
|
|
4
|
+
export declare const CHECK_DECORATOR: DaggerDecorators;
|
|
5
|
+
export declare const FIELD_DECORATOR: DaggerDecorators;
|
|
6
|
+
export declare const ARGUMENT_DECORATOR: DaggerDecorators;
|
|
7
|
+
export declare const ENUM_DECORATOR: DaggerDecorators;
|
|
8
|
+
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/decorator.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,UAAU,GACV,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAkB,gBAAgB,CAAA;AAC/D,eAAO,MAAM,kBAAkB,EAAgB,gBAAgB,CAAA;AAC/D,eAAO,MAAM,eAAe,EAAiB,gBAAgB,CAAA;AAC7D,eAAO,MAAM,eAAe,EAAiB,gBAAgB,CAAA;AAC7D,eAAO,MAAM,kBAAkB,EAAoB,gBAAgB,CAAA;AACnE,eAAO,MAAM,cAAc,EAAoB,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { argument, func, object, enumType, field, check, } from "../../decorators.js";
|
|
2
|
+
export const OBJECT_DECORATOR = object.name;
|
|
3
|
+
export const FUNCTION_DECORATOR = func.name;
|
|
4
|
+
export const CHECK_DECORATOR = check.name;
|
|
5
|
+
export const FIELD_DECORATOR = field.name;
|
|
6
|
+
export const ARGUMENT_DECORATOR = argument.name;
|
|
7
|
+
export const ENUM_DECORATOR = enumType.name;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { AST } from "../typescript_module/index.js";
|
|
3
|
+
import { DaggerEnumBase, DaggerEnumBaseValue } from "./enumBase.js";
|
|
4
|
+
import { Locatable } from "./locatable.js";
|
|
5
|
+
export type DaggerEnums = {
|
|
6
|
+
[name: string]: DaggerEnum;
|
|
7
|
+
};
|
|
8
|
+
export type DaggerEnumValues = {
|
|
9
|
+
[name: string]: DaggerEnumValue;
|
|
10
|
+
};
|
|
11
|
+
export declare class DaggerEnumValue extends Locatable implements DaggerEnumBaseValue {
|
|
12
|
+
private readonly node;
|
|
13
|
+
private readonly ast;
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
description: string;
|
|
17
|
+
deprecated?: string;
|
|
18
|
+
private symbol;
|
|
19
|
+
constructor(node: ts.EnumMember, ast: AST);
|
|
20
|
+
toJSON(): {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
description: string;
|
|
24
|
+
deprecated: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare class DaggerEnum extends Locatable implements DaggerEnumBase {
|
|
28
|
+
private readonly node;
|
|
29
|
+
private readonly ast;
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
values: DaggerEnumValues;
|
|
33
|
+
private symbol;
|
|
34
|
+
constructor(node: ts.EnumDeclaration, ast: AST);
|
|
35
|
+
toJSON(): {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
values: DaggerEnumValues;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAA;AACxD,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAA;AAElE,qBAAa,eAAgB,SAAQ,SAAU,YAAW,mBAAmB;IASzE,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IAE1B,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,GAAG;IAmB3B,MAAM;;;;;;CAQP;AAED,qBAAa,UAAW,SAAQ,SAAU,YAAW,cAAc;IAQ/D,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IARf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,gBAAgB,CAAK;IAEpC,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,eAAe,EACxB,GAAG,EAAE,GAAG;IAgB3B,MAAM;;;;;CAOP"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
2
|
+
import { AST } from "../typescript_module/index.js";
|
|
3
|
+
import { Locatable } from "./locatable.js";
|
|
4
|
+
export class DaggerEnumValue extends Locatable {
|
|
5
|
+
node;
|
|
6
|
+
ast;
|
|
7
|
+
name;
|
|
8
|
+
value;
|
|
9
|
+
description;
|
|
10
|
+
deprecated;
|
|
11
|
+
symbol;
|
|
12
|
+
constructor(node, ast) {
|
|
13
|
+
super(node);
|
|
14
|
+
this.node = node;
|
|
15
|
+
this.ast = ast;
|
|
16
|
+
this.symbol = this.ast.getSymbolOrThrow(this.node.name);
|
|
17
|
+
this.name = this.node.name.getText();
|
|
18
|
+
const { description, deprecated } = this.ast.getSymbolDoc(this.symbol);
|
|
19
|
+
this.description = description;
|
|
20
|
+
this.deprecated = deprecated;
|
|
21
|
+
const initializer = this.node.initializer;
|
|
22
|
+
if (!initializer) {
|
|
23
|
+
throw new IntrospectionError(`enum ${this.name} at ${AST.getNodePosition(this.node)} has no value set to its member.`);
|
|
24
|
+
}
|
|
25
|
+
this.value = this.ast.resolveParameterDefaultValue(initializer);
|
|
26
|
+
}
|
|
27
|
+
toJSON() {
|
|
28
|
+
return {
|
|
29
|
+
name: this.name,
|
|
30
|
+
value: this.value,
|
|
31
|
+
description: this.description,
|
|
32
|
+
deprecated: this.deprecated,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class DaggerEnum extends Locatable {
|
|
37
|
+
node;
|
|
38
|
+
ast;
|
|
39
|
+
name;
|
|
40
|
+
description;
|
|
41
|
+
values = {};
|
|
42
|
+
symbol;
|
|
43
|
+
constructor(node, ast) {
|
|
44
|
+
super(node);
|
|
45
|
+
this.node = node;
|
|
46
|
+
this.ast = ast;
|
|
47
|
+
this.name = this.node.name.getText();
|
|
48
|
+
this.symbol = this.ast.getSymbolOrThrow(this.node.name);
|
|
49
|
+
this.description = this.ast.getDocFromSymbol(this.symbol);
|
|
50
|
+
const members = this.node.members;
|
|
51
|
+
for (const member of members) {
|
|
52
|
+
const value = new DaggerEnumValue(member, this.ast);
|
|
53
|
+
this.values[value.name] = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
toJSON() {
|
|
57
|
+
return {
|
|
58
|
+
name: this.name,
|
|
59
|
+
description: this.description,
|
|
60
|
+
values: this.values,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Locatable } from "./locatable.js";
|
|
2
|
+
export interface DaggerEnumBaseValue extends Locatable {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
description: string;
|
|
6
|
+
deprecated?: string;
|
|
7
|
+
}
|
|
8
|
+
export type DaggerEnumBaseValues = {
|
|
9
|
+
[name: string]: DaggerEnumBaseValue;
|
|
10
|
+
};
|
|
11
|
+
export interface DaggerEnumBase extends Locatable {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
values: DaggerEnumBaseValues;
|
|
15
|
+
}
|
|
16
|
+
export type DaggerEnumsBase = {
|
|
17
|
+
[name: string]: DaggerEnumBase;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=enumBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumBase.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/enumBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAAE,CAAA;AAE1E,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { AST } from "../typescript_module/index.js";
|
|
3
|
+
import { DaggerEnumBase, DaggerEnumBaseValue } from "./enumBase.js";
|
|
4
|
+
import { Locatable } from "./locatable.js";
|
|
5
|
+
export type DaggerEnumClasses = {
|
|
6
|
+
[name: string]: DaggerEnumClass;
|
|
7
|
+
};
|
|
8
|
+
export type DaggerEnumClassValues = {
|
|
9
|
+
[name: string]: DaggerEnumClassValue;
|
|
10
|
+
};
|
|
11
|
+
export declare class DaggerEnumClassValue extends Locatable implements DaggerEnumBaseValue {
|
|
12
|
+
private readonly node;
|
|
13
|
+
private readonly ast;
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
description: string;
|
|
17
|
+
deprecated?: string;
|
|
18
|
+
private symbol;
|
|
19
|
+
constructor(node: ts.PropertyDeclaration, ast: AST);
|
|
20
|
+
toJSON(): {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
description: string;
|
|
24
|
+
deprecated: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare class DaggerEnumClass extends Locatable implements DaggerEnumBase {
|
|
28
|
+
private readonly node;
|
|
29
|
+
private readonly ast;
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
values: DaggerEnumClassValues;
|
|
33
|
+
private symbol;
|
|
34
|
+
constructor(node: ts.ClassDeclaration, ast: AST);
|
|
35
|
+
toJSON(): {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
values: DaggerEnumClassValues;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=enumClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumClass.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/enumClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,iBAAiB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAA;AAEnE,MAAM,MAAM,qBAAqB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAA;CAAE,CAAA;AAE5E,qBAAa,oBACX,SAAQ,SACR,YAAW,mBAAmB;IAU5B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IAE1B,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,mBAAmB,EAC5B,GAAG,EAAE,GAAG;IAiB3B,MAAM;;;;;;CAQP;AAED,qBAAa,eAAgB,SAAQ,SAAU,YAAW,cAAc;IAQpE,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IARf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,qBAAqB,CAAK;IAEzC,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,gBAAgB,EACzB,GAAG,EAAE,GAAG;IAuB3B,MAAM;;;;;CAOP"}
|